babylon.module.d.ts 5.3 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815
  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 Vector3
  1505. */
  1506. length(): number;
  1507. /**
  1508. * Gets the squared length of the Vector3
  1509. * @returns squared length of the Vector3
  1510. */
  1511. lengthSquared(): number;
  1512. /**
  1513. * Normalize the current Vector3.
  1514. * Please note that this is an in place operation.
  1515. * @returns the current updated Vector3
  1516. */
  1517. normalize(): Vector3;
  1518. /**
  1519. * Reorders the x y z properties of the vector in place
  1520. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1521. * @returns the current updated vector
  1522. */
  1523. reorderInPlace(order: string): this;
  1524. /**
  1525. * Rotates the vector around 0,0,0 by a quaternion
  1526. * @param quaternion the rotation quaternion
  1527. * @param result vector to store the result
  1528. * @returns the resulting vector
  1529. */
  1530. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1531. /**
  1532. * Rotates a vector around a given point
  1533. * @param quaternion the rotation quaternion
  1534. * @param point the point to rotate around
  1535. * @param result vector to store the result
  1536. * @returns the resulting vector
  1537. */
  1538. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1539. /**
  1540. * Normalize the current Vector3 with the given input length.
  1541. * Please note that this is an in place operation.
  1542. * @param len the length of the vector
  1543. * @returns the current updated Vector3
  1544. */
  1545. normalizeFromLength(len: number): Vector3;
  1546. /**
  1547. * Normalize the current Vector3 to a new vector
  1548. * @returns the new Vector3
  1549. */
  1550. normalizeToNew(): Vector3;
  1551. /**
  1552. * Normalize the current Vector3 to the reference
  1553. * @param reference define the Vector3 to update
  1554. * @returns the updated Vector3
  1555. */
  1556. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1557. /**
  1558. * Creates a new Vector3 copied from the current Vector3
  1559. * @returns the new Vector3
  1560. */
  1561. clone(): Vector3;
  1562. /**
  1563. * Copies the given vector coordinates to the current Vector3 ones
  1564. * @param source defines the source Vector3
  1565. * @returns the current updated Vector3
  1566. */
  1567. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1568. /**
  1569. * Copies the given floats to the current Vector3 coordinates
  1570. * @param x defines the x coordinate of the operand
  1571. * @param y defines the y coordinate of the operand
  1572. * @param z defines the z coordinate of the operand
  1573. * @returns the current updated Vector3
  1574. */
  1575. copyFromFloats(x: number, y: number, z: number): Vector3;
  1576. /**
  1577. * Copies the given floats to the current Vector3 coordinates
  1578. * @param x defines the x coordinate of the operand
  1579. * @param y defines the y coordinate of the operand
  1580. * @param z defines the z coordinate of the operand
  1581. * @returns the current updated Vector3
  1582. */
  1583. set(x: number, y: number, z: number): Vector3;
  1584. /**
  1585. * Copies the given float to the current Vector3 coordinates
  1586. * @param v defines the x, y and z coordinates of the operand
  1587. * @returns the current updated Vector3
  1588. */
  1589. setAll(v: number): Vector3;
  1590. /**
  1591. * Get the clip factor between two vectors
  1592. * @param vector0 defines the first operand
  1593. * @param vector1 defines the second operand
  1594. * @param axis defines the axis to use
  1595. * @param size defines the size along the axis
  1596. * @returns the clip factor
  1597. */
  1598. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1599. /**
  1600. * Get angle between two vectors
  1601. * @param vector0 angle between vector0 and vector1
  1602. * @param vector1 angle between vector0 and vector1
  1603. * @param normal direction of the normal
  1604. * @return the angle between vector0 and vector1
  1605. */
  1606. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1607. /**
  1608. * Returns a new Vector3 set from the index "offset" of the given array
  1609. * @param array defines the source array
  1610. * @param offset defines the offset in the source array
  1611. * @returns the new Vector3
  1612. */
  1613. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1614. /**
  1615. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1616. * This function is deprecated. Use FromArray instead
  1617. * @param array defines the source array
  1618. * @param offset defines the offset in the source array
  1619. * @returns the new Vector3
  1620. */
  1621. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1622. /**
  1623. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1624. * @param array defines the source array
  1625. * @param offset defines the offset in the source array
  1626. * @param result defines the Vector3 where to store the result
  1627. */
  1628. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1629. /**
  1630. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1631. * This function is deprecated. Use FromArrayToRef instead.
  1632. * @param array defines the source array
  1633. * @param offset defines the offset in the source array
  1634. * @param result defines the Vector3 where to store the result
  1635. */
  1636. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1637. /**
  1638. * Sets the given vector "result" with the given floats.
  1639. * @param x defines the x coordinate of the source
  1640. * @param y defines the y coordinate of the source
  1641. * @param z defines the z coordinate of the source
  1642. * @param result defines the Vector3 where to store the result
  1643. */
  1644. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1645. /**
  1646. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1647. * @returns a new empty Vector3
  1648. */
  1649. static Zero(): Vector3;
  1650. /**
  1651. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1652. * @returns a new unit Vector3
  1653. */
  1654. static One(): Vector3;
  1655. /**
  1656. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1657. * @returns a new up Vector3
  1658. */
  1659. static Up(): Vector3;
  1660. /**
  1661. * Gets a up Vector3 that must not be updated
  1662. */
  1663. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1664. /**
  1665. * Gets a zero Vector3 that must not be updated
  1666. */
  1667. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  1668. /**
  1669. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1670. * @returns a new down Vector3
  1671. */
  1672. static Down(): Vector3;
  1673. /**
  1674. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1675. * @returns a new forward Vector3
  1676. */
  1677. static Forward(): Vector3;
  1678. /**
  1679. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1680. * @returns a new forward Vector3
  1681. */
  1682. static Backward(): Vector3;
  1683. /**
  1684. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1685. * @returns a new right Vector3
  1686. */
  1687. static Right(): Vector3;
  1688. /**
  1689. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1690. * @returns a new left Vector3
  1691. */
  1692. static Left(): Vector3;
  1693. /**
  1694. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1695. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1696. * @param vector defines the Vector3 to transform
  1697. * @param transformation defines the transformation matrix
  1698. * @returns the transformed Vector3
  1699. */
  1700. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1701. /**
  1702. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1703. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1704. * @param vector defines the Vector3 to transform
  1705. * @param transformation defines the transformation matrix
  1706. * @param result defines the Vector3 where to store the result
  1707. */
  1708. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1709. /**
  1710. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1711. * This method computes tranformed coordinates only, not transformed direction vectors
  1712. * @param x define the x coordinate of the source vector
  1713. * @param y define the y coordinate of the source vector
  1714. * @param z define the z coordinate of the source vector
  1715. * @param transformation defines the transformation matrix
  1716. * @param result defines the Vector3 where to store the result
  1717. */
  1718. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1719. /**
  1720. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1721. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1722. * @param vector defines the Vector3 to transform
  1723. * @param transformation defines the transformation matrix
  1724. * @returns the new Vector3
  1725. */
  1726. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1727. /**
  1728. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1729. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1730. * @param vector defines the Vector3 to transform
  1731. * @param transformation defines the transformation matrix
  1732. * @param result defines the Vector3 where to store the result
  1733. */
  1734. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1735. /**
  1736. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1737. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1738. * @param x define the x coordinate of the source vector
  1739. * @param y define the y coordinate of the source vector
  1740. * @param z define the z coordinate of the source vector
  1741. * @param transformation defines the transformation matrix
  1742. * @param result defines the Vector3 where to store the result
  1743. */
  1744. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1745. /**
  1746. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1747. * @param value1 defines the first control point
  1748. * @param value2 defines the second control point
  1749. * @param value3 defines the third control point
  1750. * @param value4 defines the fourth control point
  1751. * @param amount defines the amount on the spline to use
  1752. * @returns the new Vector3
  1753. */
  1754. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1755. /**
  1756. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1757. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1758. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1759. * @param value defines the current value
  1760. * @param min defines the lower range value
  1761. * @param max defines the upper range value
  1762. * @returns the new Vector3
  1763. */
  1764. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1765. /**
  1766. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1767. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1768. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1769. * @param value defines the current value
  1770. * @param min defines the lower range value
  1771. * @param max defines the upper range value
  1772. * @param result defines the Vector3 where to store the result
  1773. */
  1774. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1775. /**
  1776. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1777. * @param value1 defines the first control point
  1778. * @param tangent1 defines the first tangent vector
  1779. * @param value2 defines the second control point
  1780. * @param tangent2 defines the second tangent vector
  1781. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1782. * @returns the new Vector3
  1783. */
  1784. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1785. /**
  1786. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1787. * @param start defines the start value
  1788. * @param end defines the end value
  1789. * @param amount max defines amount between both (between 0 and 1)
  1790. * @returns the new Vector3
  1791. */
  1792. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1793. /**
  1794. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1795. * @param start defines the start value
  1796. * @param end defines the end value
  1797. * @param amount max defines amount between both (between 0 and 1)
  1798. * @param result defines the Vector3 where to store the result
  1799. */
  1800. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1801. /**
  1802. * Returns the dot product (float) between the vectors "left" and "right"
  1803. * @param left defines the left operand
  1804. * @param right defines the right operand
  1805. * @returns the dot product
  1806. */
  1807. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1808. /**
  1809. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1810. * The cross product is then orthogonal to both "left" and "right"
  1811. * @param left defines the left operand
  1812. * @param right defines the right operand
  1813. * @returns the cross product
  1814. */
  1815. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1816. /**
  1817. * Sets the given vector "result" with the cross product of "left" and "right"
  1818. * The cross product is then orthogonal to both "left" and "right"
  1819. * @param left defines the left operand
  1820. * @param right defines the right operand
  1821. * @param result defines the Vector3 where to store the result
  1822. */
  1823. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1824. /**
  1825. * Returns a new Vector3 as the normalization of the given vector
  1826. * @param vector defines the Vector3 to normalize
  1827. * @returns the new Vector3
  1828. */
  1829. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1830. /**
  1831. * Sets the given vector "result" with the normalization of the given first vector
  1832. * @param vector defines the Vector3 to normalize
  1833. * @param result defines the Vector3 where to store the result
  1834. */
  1835. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1836. /**
  1837. * Project a Vector3 onto screen space
  1838. * @param vector defines the Vector3 to project
  1839. * @param world defines the world matrix to use
  1840. * @param transform defines the transform (view x projection) matrix to use
  1841. * @param viewport defines the screen viewport to use
  1842. * @returns the new Vector3
  1843. */
  1844. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1845. /** @hidden */
  1846. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1847. /**
  1848. * Unproject from screen space to object space
  1849. * @param source defines the screen space Vector3 to use
  1850. * @param viewportWidth defines the current width of the viewport
  1851. * @param viewportHeight defines the current height of the viewport
  1852. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1853. * @param transform defines the transform (view x projection) matrix to use
  1854. * @returns the new Vector3
  1855. */
  1856. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1857. /**
  1858. * Unproject from screen space to object space
  1859. * @param source defines the screen space Vector3 to use
  1860. * @param viewportWidth defines the current width of the viewport
  1861. * @param viewportHeight defines the current height of the viewport
  1862. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1863. * @param view defines the view matrix to use
  1864. * @param projection defines the projection matrix to use
  1865. * @returns the new Vector3
  1866. */
  1867. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1868. /**
  1869. * Unproject from screen space to object space
  1870. * @param source defines the screen space Vector3 to use
  1871. * @param viewportWidth defines the current width of the viewport
  1872. * @param viewportHeight defines the current height of the viewport
  1873. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1874. * @param view defines the view matrix to use
  1875. * @param projection defines the projection matrix to use
  1876. * @param result defines the Vector3 where to store the result
  1877. */
  1878. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1879. /**
  1880. * Unproject from screen space to object space
  1881. * @param sourceX defines the screen space x coordinate to use
  1882. * @param sourceY defines the screen space y coordinate to use
  1883. * @param sourceZ defines the screen space z coordinate to use
  1884. * @param viewportWidth defines the current width of the viewport
  1885. * @param viewportHeight defines the current height of the viewport
  1886. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1887. * @param view defines the view matrix to use
  1888. * @param projection defines the projection matrix to use
  1889. * @param result defines the Vector3 where to store the result
  1890. */
  1891. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1892. /**
  1893. * Gets the minimal coordinate values between two Vector3
  1894. * @param left defines the first operand
  1895. * @param right defines the second operand
  1896. * @returns the new Vector3
  1897. */
  1898. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1899. /**
  1900. * Gets the maximal coordinate values between two Vector3
  1901. * @param left defines the first operand
  1902. * @param right defines the second operand
  1903. * @returns the new Vector3
  1904. */
  1905. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1906. /**
  1907. * Returns the distance between the vectors "value1" and "value2"
  1908. * @param value1 defines the first operand
  1909. * @param value2 defines the second operand
  1910. * @returns the distance
  1911. */
  1912. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1913. /**
  1914. * Returns the squared distance between the vectors "value1" and "value2"
  1915. * @param value1 defines the first operand
  1916. * @param value2 defines the second operand
  1917. * @returns the squared distance
  1918. */
  1919. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1920. /**
  1921. * Returns a new Vector3 located at the center between "value1" and "value2"
  1922. * @param value1 defines the first operand
  1923. * @param value2 defines the second operand
  1924. * @returns the new Vector3
  1925. */
  1926. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1927. /**
  1928. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1929. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1930. * to something in order to rotate it from its local system to the given target system
  1931. * Note: axis1, axis2 and axis3 are normalized during this operation
  1932. * @param axis1 defines the first axis
  1933. * @param axis2 defines the second axis
  1934. * @param axis3 defines the third axis
  1935. * @returns a new Vector3
  1936. */
  1937. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1938. /**
  1939. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1940. * @param axis1 defines the first axis
  1941. * @param axis2 defines the second axis
  1942. * @param axis3 defines the third axis
  1943. * @param ref defines the Vector3 where to store the result
  1944. */
  1945. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1946. }
  1947. /**
  1948. * Vector4 class created for EulerAngle class conversion to Quaternion
  1949. */
  1950. export class Vector4 {
  1951. /** x value of the vector */
  1952. x: number;
  1953. /** y value of the vector */
  1954. y: number;
  1955. /** z value of the vector */
  1956. z: number;
  1957. /** w value of the vector */
  1958. w: number;
  1959. /**
  1960. * Creates a Vector4 object from the given floats.
  1961. * @param x x value of the vector
  1962. * @param y y value of the vector
  1963. * @param z z value of the vector
  1964. * @param w w value of the vector
  1965. */
  1966. constructor(
  1967. /** x value of the vector */
  1968. x: number,
  1969. /** y value of the vector */
  1970. y: number,
  1971. /** z value of the vector */
  1972. z: number,
  1973. /** w value of the vector */
  1974. w: number);
  1975. /**
  1976. * Returns the string with the Vector4 coordinates.
  1977. * @returns a string containing all the vector values
  1978. */
  1979. toString(): string;
  1980. /**
  1981. * Returns the string "Vector4".
  1982. * @returns "Vector4"
  1983. */
  1984. getClassName(): string;
  1985. /**
  1986. * Returns the Vector4 hash code.
  1987. * @returns a unique hash code
  1988. */
  1989. getHashCode(): number;
  1990. /**
  1991. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1992. * @returns the resulting array
  1993. */
  1994. asArray(): number[];
  1995. /**
  1996. * Populates the given array from the given index with the Vector4 coordinates.
  1997. * @param array array to populate
  1998. * @param index index of the array to start at (default: 0)
  1999. * @returns the Vector4.
  2000. */
  2001. toArray(array: FloatArray, index?: number): Vector4;
  2002. /**
  2003. * Adds the given vector to the current Vector4.
  2004. * @param otherVector the vector to add
  2005. * @returns the updated Vector4.
  2006. */
  2007. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2008. /**
  2009. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2010. * @param otherVector the vector to add
  2011. * @returns the resulting vector
  2012. */
  2013. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2014. /**
  2015. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2016. * @param otherVector the vector to add
  2017. * @param result the vector to store the result
  2018. * @returns the current Vector4.
  2019. */
  2020. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2021. /**
  2022. * Subtract in place the given vector from the current Vector4.
  2023. * @param otherVector the vector to subtract
  2024. * @returns the updated Vector4.
  2025. */
  2026. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2027. /**
  2028. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2029. * @param otherVector the vector to add
  2030. * @returns the new vector with the result
  2031. */
  2032. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2033. /**
  2034. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2035. * @param otherVector the vector to subtract
  2036. * @param result the vector to store the result
  2037. * @returns the current Vector4.
  2038. */
  2039. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2040. /**
  2041. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2042. */
  2043. /**
  2044. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2045. * @param x value to subtract
  2046. * @param y value to subtract
  2047. * @param z value to subtract
  2048. * @param w value to subtract
  2049. * @returns new vector containing the result
  2050. */
  2051. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2052. /**
  2053. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2054. * @param x value to subtract
  2055. * @param y value to subtract
  2056. * @param z value to subtract
  2057. * @param w value to subtract
  2058. * @param result the vector to store the result in
  2059. * @returns the current Vector4.
  2060. */
  2061. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2062. /**
  2063. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2064. * @returns a new vector with the negated values
  2065. */
  2066. negate(): Vector4;
  2067. /**
  2068. * Multiplies the current Vector4 coordinates by scale (float).
  2069. * @param scale the number to scale with
  2070. * @returns the updated Vector4.
  2071. */
  2072. scaleInPlace(scale: number): Vector4;
  2073. /**
  2074. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2075. * @param scale the number to scale with
  2076. * @returns a new vector with the result
  2077. */
  2078. scale(scale: number): Vector4;
  2079. /**
  2080. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2081. * @param scale the number to scale with
  2082. * @param result a vector to store the result in
  2083. * @returns the current Vector4.
  2084. */
  2085. scaleToRef(scale: number, result: Vector4): Vector4;
  2086. /**
  2087. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2088. * @param scale defines the scale factor
  2089. * @param result defines the Vector4 object where to store the result
  2090. * @returns the unmodified current Vector4
  2091. */
  2092. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2093. /**
  2094. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2095. * @param otherVector the vector to compare against
  2096. * @returns true if they are equal
  2097. */
  2098. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2099. /**
  2100. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2101. * @param otherVector vector to compare against
  2102. * @param epsilon (Default: very small number)
  2103. * @returns true if they are equal
  2104. */
  2105. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2106. /**
  2107. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2108. * @param x x value to compare against
  2109. * @param y y value to compare against
  2110. * @param z z value to compare against
  2111. * @param w w value to compare against
  2112. * @returns true if equal
  2113. */
  2114. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2115. /**
  2116. * Multiplies in place the current Vector4 by the given one.
  2117. * @param otherVector vector to multiple with
  2118. * @returns the updated Vector4.
  2119. */
  2120. multiplyInPlace(otherVector: Vector4): Vector4;
  2121. /**
  2122. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2123. * @param otherVector vector to multiple with
  2124. * @returns resulting new vector
  2125. */
  2126. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2127. /**
  2128. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2129. * @param otherVector vector to multiple with
  2130. * @param result vector to store the result
  2131. * @returns the current Vector4.
  2132. */
  2133. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2134. /**
  2135. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2136. * @param x x value multiply with
  2137. * @param y y value multiply with
  2138. * @param z z value multiply with
  2139. * @param w w value multiply with
  2140. * @returns resulting new vector
  2141. */
  2142. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2143. /**
  2144. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2145. * @param otherVector vector to devide with
  2146. * @returns resulting new vector
  2147. */
  2148. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2149. /**
  2150. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2151. * @param otherVector vector to devide with
  2152. * @param result vector to store the result
  2153. * @returns the current Vector4.
  2154. */
  2155. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2156. /**
  2157. * Divides the current Vector3 coordinates by the given ones.
  2158. * @param otherVector vector to devide with
  2159. * @returns the updated Vector3.
  2160. */
  2161. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2162. /**
  2163. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2164. * @param other defines the second operand
  2165. * @returns the current updated Vector4
  2166. */
  2167. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2168. /**
  2169. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2170. * @param other defines the second operand
  2171. * @returns the current updated Vector4
  2172. */
  2173. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2174. /**
  2175. * Gets a new Vector4 from current Vector4 floored values
  2176. * @returns a new Vector4
  2177. */
  2178. floor(): Vector4;
  2179. /**
  2180. * Gets a new Vector4 from current Vector3 floored values
  2181. * @returns a new Vector4
  2182. */
  2183. fract(): Vector4;
  2184. /**
  2185. * Returns the Vector4 length (float).
  2186. * @returns the length
  2187. */
  2188. length(): number;
  2189. /**
  2190. * Returns the Vector4 squared length (float).
  2191. * @returns the length squared
  2192. */
  2193. lengthSquared(): number;
  2194. /**
  2195. * Normalizes in place the Vector4.
  2196. * @returns the updated Vector4.
  2197. */
  2198. normalize(): Vector4;
  2199. /**
  2200. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2201. * @returns this converted to a new vector3
  2202. */
  2203. toVector3(): Vector3;
  2204. /**
  2205. * Returns a new Vector4 copied from the current one.
  2206. * @returns the new cloned vector
  2207. */
  2208. clone(): Vector4;
  2209. /**
  2210. * Updates the current Vector4 with the given one coordinates.
  2211. * @param source the source vector to copy from
  2212. * @returns the updated Vector4.
  2213. */
  2214. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2215. /**
  2216. * Updates the current Vector4 coordinates with the given floats.
  2217. * @param x float to copy from
  2218. * @param y float to copy from
  2219. * @param z float to copy from
  2220. * @param w float to copy from
  2221. * @returns the updated Vector4.
  2222. */
  2223. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2224. /**
  2225. * Updates the current Vector4 coordinates with the given floats.
  2226. * @param x float to set from
  2227. * @param y float to set from
  2228. * @param z float to set from
  2229. * @param w float to set from
  2230. * @returns the updated Vector4.
  2231. */
  2232. set(x: number, y: number, z: number, w: number): Vector4;
  2233. /**
  2234. * Copies the given float to the current Vector3 coordinates
  2235. * @param v defines the x, y, z and w coordinates of the operand
  2236. * @returns the current updated Vector3
  2237. */
  2238. setAll(v: number): Vector4;
  2239. /**
  2240. * Returns a new Vector4 set from the starting index of the given array.
  2241. * @param array the array to pull values from
  2242. * @param offset the offset into the array to start at
  2243. * @returns the new vector
  2244. */
  2245. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2246. /**
  2247. * Updates the given vector "result" from the starting index of the given array.
  2248. * @param array the array to pull values from
  2249. * @param offset the offset into the array to start at
  2250. * @param result the vector to store the result in
  2251. */
  2252. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2253. /**
  2254. * Updates the given vector "result" from the starting index of the given Float32Array.
  2255. * @param array the array to pull values from
  2256. * @param offset the offset into the array to start at
  2257. * @param result the vector to store the result in
  2258. */
  2259. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2260. /**
  2261. * Updates the given vector "result" coordinates from the given floats.
  2262. * @param x float to set from
  2263. * @param y float to set from
  2264. * @param z float to set from
  2265. * @param w float to set from
  2266. * @param result the vector to the floats in
  2267. */
  2268. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2269. /**
  2270. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2271. * @returns the new vector
  2272. */
  2273. static Zero(): Vector4;
  2274. /**
  2275. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2276. * @returns the new vector
  2277. */
  2278. static One(): Vector4;
  2279. /**
  2280. * Returns a new normalized Vector4 from the given one.
  2281. * @param vector the vector to normalize
  2282. * @returns the vector
  2283. */
  2284. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2285. /**
  2286. * Updates the given vector "result" from the normalization of the given one.
  2287. * @param vector the vector to normalize
  2288. * @param result the vector to store the result in
  2289. */
  2290. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2291. /**
  2292. * Returns a vector with the minimum values from the left and right vectors
  2293. * @param left left vector to minimize
  2294. * @param right right vector to minimize
  2295. * @returns a new vector with the minimum of the left and right vector values
  2296. */
  2297. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2298. /**
  2299. * Returns a vector with the maximum values from the left and right vectors
  2300. * @param left left vector to maximize
  2301. * @param right right vector to maximize
  2302. * @returns a new vector with the maximum of the left and right vector values
  2303. */
  2304. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2305. /**
  2306. * Returns the distance (float) between the vectors "value1" and "value2".
  2307. * @param value1 value to calulate the distance between
  2308. * @param value2 value to calulate the distance between
  2309. * @return the distance between the two vectors
  2310. */
  2311. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2312. /**
  2313. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2314. * @param value1 value to calulate the distance between
  2315. * @param value2 value to calulate the distance between
  2316. * @return the distance between the two vectors squared
  2317. */
  2318. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2319. /**
  2320. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2321. * @param value1 value to calulate the center between
  2322. * @param value2 value to calulate the center between
  2323. * @return the center between the two vectors
  2324. */
  2325. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2326. /**
  2327. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2328. * This methods computes transformed normalized direction vectors only.
  2329. * @param vector the vector to transform
  2330. * @param transformation the transformation matrix to apply
  2331. * @returns the new vector
  2332. */
  2333. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2334. /**
  2335. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2336. * This methods computes transformed normalized direction vectors only.
  2337. * @param vector the vector to transform
  2338. * @param transformation the transformation matrix to apply
  2339. * @param result the vector to store the result in
  2340. */
  2341. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2342. /**
  2343. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2344. * This methods computes transformed normalized direction vectors only.
  2345. * @param x value to transform
  2346. * @param y value to transform
  2347. * @param z value to transform
  2348. * @param w value to transform
  2349. * @param transformation the transformation matrix to apply
  2350. * @param result the vector to store the results in
  2351. */
  2352. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2353. /**
  2354. * Creates a new Vector4 from a Vector3
  2355. * @param source defines the source data
  2356. * @param w defines the 4th component (default is 0)
  2357. * @returns a new Vector4
  2358. */
  2359. static FromVector3(source: Vector3, w?: number): Vector4;
  2360. }
  2361. /**
  2362. * Interface for the size containing width and height
  2363. */
  2364. export interface ISize {
  2365. /**
  2366. * Width
  2367. */
  2368. width: number;
  2369. /**
  2370. * Heighht
  2371. */
  2372. height: number;
  2373. }
  2374. /**
  2375. * Size containing widht and height
  2376. */
  2377. export class Size implements ISize {
  2378. /**
  2379. * Width
  2380. */
  2381. width: number;
  2382. /**
  2383. * Height
  2384. */
  2385. height: number;
  2386. /**
  2387. * Creates a Size object from the given width and height (floats).
  2388. * @param width width of the new size
  2389. * @param height height of the new size
  2390. */
  2391. constructor(width: number, height: number);
  2392. /**
  2393. * Returns a string with the Size width and height
  2394. * @returns a string with the Size width and height
  2395. */
  2396. toString(): string;
  2397. /**
  2398. * "Size"
  2399. * @returns the string "Size"
  2400. */
  2401. getClassName(): string;
  2402. /**
  2403. * Returns the Size hash code.
  2404. * @returns a hash code for a unique width and height
  2405. */
  2406. getHashCode(): number;
  2407. /**
  2408. * Updates the current size from the given one.
  2409. * @param src the given size
  2410. */
  2411. copyFrom(src: Size): void;
  2412. /**
  2413. * Updates in place the current Size from the given floats.
  2414. * @param width width of the new size
  2415. * @param height height of the new size
  2416. * @returns the updated Size.
  2417. */
  2418. copyFromFloats(width: number, height: number): Size;
  2419. /**
  2420. * Updates in place the current Size from the given floats.
  2421. * @param width width to set
  2422. * @param height height to set
  2423. * @returns the updated Size.
  2424. */
  2425. set(width: number, height: number): Size;
  2426. /**
  2427. * Multiplies the width and height by numbers
  2428. * @param w factor to multiple the width by
  2429. * @param h factor to multiple the height by
  2430. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  2431. */
  2432. multiplyByFloats(w: number, h: number): Size;
  2433. /**
  2434. * Clones the size
  2435. * @returns a new Size copied from the given one.
  2436. */
  2437. clone(): Size;
  2438. /**
  2439. * True if the current Size and the given one width and height are strictly equal.
  2440. * @param other the other size to compare against
  2441. * @returns True if the current Size and the given one width and height are strictly equal.
  2442. */
  2443. equals(other: Size): boolean;
  2444. /**
  2445. * The surface of the Size : width * height (float).
  2446. */
  2447. readonly surface: number;
  2448. /**
  2449. * Create a new size of zero
  2450. * @returns a new Size set to (0.0, 0.0)
  2451. */
  2452. static Zero(): Size;
  2453. /**
  2454. * Sums the width and height of two sizes
  2455. * @param otherSize size to add to this size
  2456. * @returns a new Size set as the addition result of the current Size and the given one.
  2457. */
  2458. add(otherSize: Size): Size;
  2459. /**
  2460. * Subtracts the width and height of two
  2461. * @param otherSize size to subtract to this size
  2462. * @returns a new Size set as the subtraction result of the given one from the current Size.
  2463. */
  2464. subtract(otherSize: Size): Size;
  2465. /**
  2466. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  2467. * @param start starting size to lerp between
  2468. * @param end end size to lerp between
  2469. * @param amount amount to lerp between the start and end values
  2470. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  2471. */
  2472. static Lerp(start: Size, end: Size, amount: number): Size;
  2473. }
  2474. /**
  2475. * Class used to store quaternion data
  2476. * @see https://en.wikipedia.org/wiki/Quaternion
  2477. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2478. */
  2479. export class Quaternion {
  2480. /** defines the first component (0 by default) */
  2481. x: number;
  2482. /** defines the second component (0 by default) */
  2483. y: number;
  2484. /** defines the third component (0 by default) */
  2485. z: number;
  2486. /** defines the fourth component (1.0 by default) */
  2487. w: number;
  2488. /**
  2489. * Creates a new Quaternion from the given floats
  2490. * @param x defines the first component (0 by default)
  2491. * @param y defines the second component (0 by default)
  2492. * @param z defines the third component (0 by default)
  2493. * @param w defines the fourth component (1.0 by default)
  2494. */
  2495. constructor(
  2496. /** defines the first component (0 by default) */
  2497. x?: number,
  2498. /** defines the second component (0 by default) */
  2499. y?: number,
  2500. /** defines the third component (0 by default) */
  2501. z?: number,
  2502. /** defines the fourth component (1.0 by default) */
  2503. w?: number);
  2504. /**
  2505. * Gets a string representation for the current quaternion
  2506. * @returns a string with the Quaternion coordinates
  2507. */
  2508. toString(): string;
  2509. /**
  2510. * Gets the class name of the quaternion
  2511. * @returns the string "Quaternion"
  2512. */
  2513. getClassName(): string;
  2514. /**
  2515. * Gets a hash code for this quaternion
  2516. * @returns the quaternion hash code
  2517. */
  2518. getHashCode(): number;
  2519. /**
  2520. * Copy the quaternion to an array
  2521. * @returns a new array populated with 4 elements from the quaternion coordinates
  2522. */
  2523. asArray(): number[];
  2524. /**
  2525. * Check if two quaternions are equals
  2526. * @param otherQuaternion defines the second operand
  2527. * @return true if the current quaternion and the given one coordinates are strictly equals
  2528. */
  2529. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2530. /**
  2531. * Clone the current quaternion
  2532. * @returns a new quaternion copied from the current one
  2533. */
  2534. clone(): Quaternion;
  2535. /**
  2536. * Copy a quaternion to the current one
  2537. * @param other defines the other quaternion
  2538. * @returns the updated current quaternion
  2539. */
  2540. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2541. /**
  2542. * Updates the current quaternion with the given float coordinates
  2543. * @param x defines the x coordinate
  2544. * @param y defines the y coordinate
  2545. * @param z defines the z coordinate
  2546. * @param w defines the w coordinate
  2547. * @returns the updated current quaternion
  2548. */
  2549. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2550. /**
  2551. * Updates the current quaternion from the given float coordinates
  2552. * @param x defines the x coordinate
  2553. * @param y defines the y coordinate
  2554. * @param z defines the z coordinate
  2555. * @param w defines the w coordinate
  2556. * @returns the updated current quaternion
  2557. */
  2558. set(x: number, y: number, z: number, w: number): Quaternion;
  2559. /**
  2560. * Adds two quaternions
  2561. * @param other defines the second operand
  2562. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2563. */
  2564. add(other: DeepImmutable<Quaternion>): Quaternion;
  2565. /**
  2566. * Add a quaternion to the current one
  2567. * @param other defines the quaternion to add
  2568. * @returns the current quaternion
  2569. */
  2570. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2571. /**
  2572. * Subtract two quaternions
  2573. * @param other defines the second operand
  2574. * @returns a new quaternion as the subtraction result of the given one from the current one
  2575. */
  2576. subtract(other: Quaternion): Quaternion;
  2577. /**
  2578. * Multiplies the current quaternion by a scale factor
  2579. * @param value defines the scale factor
  2580. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2581. */
  2582. scale(value: number): Quaternion;
  2583. /**
  2584. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2585. * @param scale defines the scale factor
  2586. * @param result defines the Quaternion object where to store the result
  2587. * @returns the unmodified current quaternion
  2588. */
  2589. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2590. /**
  2591. * Multiplies in place the current quaternion by a scale factor
  2592. * @param value defines the scale factor
  2593. * @returns the current modified quaternion
  2594. */
  2595. scaleInPlace(value: number): Quaternion;
  2596. /**
  2597. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2598. * @param scale defines the scale factor
  2599. * @param result defines the Quaternion object where to store the result
  2600. * @returns the unmodified current quaternion
  2601. */
  2602. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2603. /**
  2604. * Multiplies two quaternions
  2605. * @param q1 defines the second operand
  2606. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2607. */
  2608. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2609. /**
  2610. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2611. * @param q1 defines the second operand
  2612. * @param result defines the target quaternion
  2613. * @returns the current quaternion
  2614. */
  2615. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2616. /**
  2617. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2618. * @param q1 defines the second operand
  2619. * @returns the currentupdated quaternion
  2620. */
  2621. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2622. /**
  2623. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2624. * @param ref defines the target quaternion
  2625. * @returns the current quaternion
  2626. */
  2627. conjugateToRef(ref: Quaternion): Quaternion;
  2628. /**
  2629. * Conjugates in place (1-q) the current quaternion
  2630. * @returns the current updated quaternion
  2631. */
  2632. conjugateInPlace(): Quaternion;
  2633. /**
  2634. * Conjugates in place (1-q) the current quaternion
  2635. * @returns a new quaternion
  2636. */
  2637. conjugate(): Quaternion;
  2638. /**
  2639. * Gets length of current quaternion
  2640. * @returns the quaternion length (float)
  2641. */
  2642. length(): number;
  2643. /**
  2644. * Normalize in place the current quaternion
  2645. * @returns the current updated quaternion
  2646. */
  2647. normalize(): Quaternion;
  2648. /**
  2649. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2650. * @param order is a reserved parameter and is ignore for now
  2651. * @returns a new Vector3 containing the Euler angles
  2652. */
  2653. toEulerAngles(order?: string): Vector3;
  2654. /**
  2655. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2656. * @param result defines the vector which will be filled with the Euler angles
  2657. * @param order is a reserved parameter and is ignore for now
  2658. * @returns the current unchanged quaternion
  2659. */
  2660. toEulerAnglesToRef(result: Vector3): Quaternion;
  2661. /**
  2662. * Updates the given rotation matrix with the current quaternion values
  2663. * @param result defines the target matrix
  2664. * @returns the current unchanged quaternion
  2665. */
  2666. toRotationMatrix(result: Matrix): Quaternion;
  2667. /**
  2668. * Updates the current quaternion from the given rotation matrix values
  2669. * @param matrix defines the source matrix
  2670. * @returns the current updated quaternion
  2671. */
  2672. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2673. /**
  2674. * Creates a new quaternion from a rotation matrix
  2675. * @param matrix defines the source matrix
  2676. * @returns a new quaternion created from the given rotation matrix values
  2677. */
  2678. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2679. /**
  2680. * Updates the given quaternion with the given rotation matrix values
  2681. * @param matrix defines the source matrix
  2682. * @param result defines the target quaternion
  2683. */
  2684. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2685. /**
  2686. * Returns the dot product (float) between the quaternions "left" and "right"
  2687. * @param left defines the left operand
  2688. * @param right defines the right operand
  2689. * @returns the dot product
  2690. */
  2691. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2692. /**
  2693. * Checks if the two quaternions are close to each other
  2694. * @param quat0 defines the first quaternion to check
  2695. * @param quat1 defines the second quaternion to check
  2696. * @returns true if the two quaternions are close to each other
  2697. */
  2698. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2699. /**
  2700. * Creates an empty quaternion
  2701. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2702. */
  2703. static Zero(): Quaternion;
  2704. /**
  2705. * Inverse a given quaternion
  2706. * @param q defines the source quaternion
  2707. * @returns a new quaternion as the inverted current quaternion
  2708. */
  2709. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2710. /**
  2711. * Inverse a given quaternion
  2712. * @param q defines the source quaternion
  2713. * @param result the quaternion the result will be stored in
  2714. * @returns the result quaternion
  2715. */
  2716. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2717. /**
  2718. * Creates an identity quaternion
  2719. * @returns the identity quaternion
  2720. */
  2721. static Identity(): Quaternion;
  2722. /**
  2723. * Gets a boolean indicating if the given quaternion is identity
  2724. * @param quaternion defines the quaternion to check
  2725. * @returns true if the quaternion is identity
  2726. */
  2727. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2728. /**
  2729. * Creates a quaternion from a rotation around an axis
  2730. * @param axis defines the axis to use
  2731. * @param angle defines the angle to use
  2732. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2733. */
  2734. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2735. /**
  2736. * Creates a rotation around an axis and stores it into the given quaternion
  2737. * @param axis defines the axis to use
  2738. * @param angle defines the angle to use
  2739. * @param result defines the target quaternion
  2740. * @returns the target quaternion
  2741. */
  2742. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2743. /**
  2744. * Creates a new quaternion from data stored into an array
  2745. * @param array defines the data source
  2746. * @param offset defines the offset in the source array where the data starts
  2747. * @returns a new quaternion
  2748. */
  2749. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2750. /**
  2751. * Create a quaternion from Euler rotation angles
  2752. * @param x Pitch
  2753. * @param y Yaw
  2754. * @param z Roll
  2755. * @returns the new Quaternion
  2756. */
  2757. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2758. /**
  2759. * Updates a quaternion from Euler rotation angles
  2760. * @param x Pitch
  2761. * @param y Yaw
  2762. * @param z Roll
  2763. * @param result the quaternion to store the result
  2764. * @returns the updated quaternion
  2765. */
  2766. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2767. /**
  2768. * Create a quaternion from Euler rotation vector
  2769. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2770. * @returns the new Quaternion
  2771. */
  2772. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2773. /**
  2774. * Updates a quaternion from Euler rotation vector
  2775. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2776. * @param result the quaternion to store the result
  2777. * @returns the updated quaternion
  2778. */
  2779. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2780. /**
  2781. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2782. * @param yaw defines the rotation around Y axis
  2783. * @param pitch defines the rotation around X axis
  2784. * @param roll defines the rotation around Z axis
  2785. * @returns the new quaternion
  2786. */
  2787. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2788. /**
  2789. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2790. * @param yaw defines the rotation around Y axis
  2791. * @param pitch defines the rotation around X axis
  2792. * @param roll defines the rotation around Z axis
  2793. * @param result defines the target quaternion
  2794. */
  2795. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2796. /**
  2797. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2798. * @param alpha defines the rotation around first axis
  2799. * @param beta defines the rotation around second axis
  2800. * @param gamma defines the rotation around third axis
  2801. * @returns the new quaternion
  2802. */
  2803. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2804. /**
  2805. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2806. * @param alpha defines the rotation around first axis
  2807. * @param beta defines the rotation around second axis
  2808. * @param gamma defines the rotation around third axis
  2809. * @param result defines the target quaternion
  2810. */
  2811. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2812. /**
  2813. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  2814. * @param axis1 defines the first axis
  2815. * @param axis2 defines the second axis
  2816. * @param axis3 defines the third axis
  2817. * @returns the new quaternion
  2818. */
  2819. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2820. /**
  2821. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  2822. * @param axis1 defines the first axis
  2823. * @param axis2 defines the second axis
  2824. * @param axis3 defines the third axis
  2825. * @param ref defines the target quaternion
  2826. */
  2827. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2828. /**
  2829. * Interpolates between two quaternions
  2830. * @param left defines first quaternion
  2831. * @param right defines second quaternion
  2832. * @param amount defines the gradient to use
  2833. * @returns the new interpolated quaternion
  2834. */
  2835. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2836. /**
  2837. * Interpolates between two quaternions and stores it into a target quaternion
  2838. * @param left defines first quaternion
  2839. * @param right defines second quaternion
  2840. * @param amount defines the gradient to use
  2841. * @param result defines the target quaternion
  2842. */
  2843. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2844. /**
  2845. * Interpolate between two quaternions using Hermite interpolation
  2846. * @param value1 defines first quaternion
  2847. * @param tangent1 defines the incoming tangent
  2848. * @param value2 defines second quaternion
  2849. * @param tangent2 defines the outgoing tangent
  2850. * @param amount defines the target quaternion
  2851. * @returns the new interpolated quaternion
  2852. */
  2853. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2854. }
  2855. /**
  2856. * Class used to store matrix data (4x4)
  2857. */
  2858. export class Matrix {
  2859. private static _updateFlagSeed;
  2860. private static _identityReadOnly;
  2861. private _isIdentity;
  2862. private _isIdentityDirty;
  2863. private _isIdentity3x2;
  2864. private _isIdentity3x2Dirty;
  2865. /**
  2866. * Gets the update flag of the matrix which is an unique number for the matrix.
  2867. * It will be incremented every time the matrix data change.
  2868. * You can use it to speed the comparison between two versions of the same matrix.
  2869. */
  2870. updateFlag: number;
  2871. private readonly _m;
  2872. /**
  2873. * Gets the internal data of the matrix
  2874. */
  2875. readonly m: DeepImmutable<Float32Array>;
  2876. /** @hidden */
  2877. _markAsUpdated(): void;
  2878. /** @hidden */
  2879. private _updateIdentityStatus;
  2880. /**
  2881. * Creates an empty matrix (filled with zeros)
  2882. */
  2883. constructor();
  2884. /**
  2885. * Check if the current matrix is identity
  2886. * @returns true is the matrix is the identity matrix
  2887. */
  2888. isIdentity(): boolean;
  2889. /**
  2890. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2891. * @returns true is the matrix is the identity matrix
  2892. */
  2893. isIdentityAs3x2(): boolean;
  2894. /**
  2895. * Gets the determinant of the matrix
  2896. * @returns the matrix determinant
  2897. */
  2898. determinant(): number;
  2899. /**
  2900. * Returns the matrix as a Float32Array
  2901. * @returns the matrix underlying array
  2902. */
  2903. toArray(): DeepImmutable<Float32Array>;
  2904. /**
  2905. * Returns the matrix as a Float32Array
  2906. * @returns the matrix underlying array.
  2907. */
  2908. asArray(): DeepImmutable<Float32Array>;
  2909. /**
  2910. * Inverts the current matrix in place
  2911. * @returns the current inverted matrix
  2912. */
  2913. invert(): Matrix;
  2914. /**
  2915. * Sets all the matrix elements to zero
  2916. * @returns the current matrix
  2917. */
  2918. reset(): Matrix;
  2919. /**
  2920. * Adds the current matrix with a second one
  2921. * @param other defines the matrix to add
  2922. * @returns a new matrix as the addition of the current matrix and the given one
  2923. */
  2924. add(other: DeepImmutable<Matrix>): Matrix;
  2925. /**
  2926. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2927. * @param other defines the matrix to add
  2928. * @param result defines the target matrix
  2929. * @returns the current matrix
  2930. */
  2931. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2932. /**
  2933. * Adds in place the given matrix to the current matrix
  2934. * @param other defines the second operand
  2935. * @returns the current updated matrix
  2936. */
  2937. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2938. /**
  2939. * Sets the given matrix to the current inverted Matrix
  2940. * @param other defines the target matrix
  2941. * @returns the unmodified current matrix
  2942. */
  2943. invertToRef(other: Matrix): Matrix;
  2944. /**
  2945. * add a value at the specified position in the current Matrix
  2946. * @param index the index of the value within the matrix. between 0 and 15.
  2947. * @param value the value to be added
  2948. * @returns the current updated matrix
  2949. */
  2950. addAtIndex(index: number, value: number): Matrix;
  2951. /**
  2952. * mutiply the specified position in the current Matrix by a value
  2953. * @param index the index of the value within the matrix. between 0 and 15.
  2954. * @param value the value to be added
  2955. * @returns the current updated matrix
  2956. */
  2957. multiplyAtIndex(index: number, value: number): Matrix;
  2958. /**
  2959. * Inserts the translation vector (using 3 floats) in the current matrix
  2960. * @param x defines the 1st component of the translation
  2961. * @param y defines the 2nd component of the translation
  2962. * @param z defines the 3rd component of the translation
  2963. * @returns the current updated matrix
  2964. */
  2965. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2966. /**
  2967. * Adds the translation vector (using 3 floats) in the current matrix
  2968. * @param x defines the 1st component of the translation
  2969. * @param y defines the 2nd component of the translation
  2970. * @param z defines the 3rd component of the translation
  2971. * @returns the current updated matrix
  2972. */
  2973. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2974. /**
  2975. * Inserts the translation vector in the current matrix
  2976. * @param vector3 defines the translation to insert
  2977. * @returns the current updated matrix
  2978. */
  2979. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2980. /**
  2981. * Gets the translation value of the current matrix
  2982. * @returns a new Vector3 as the extracted translation from the matrix
  2983. */
  2984. getTranslation(): Vector3;
  2985. /**
  2986. * Fill a Vector3 with the extracted translation from the matrix
  2987. * @param result defines the Vector3 where to store the translation
  2988. * @returns the current matrix
  2989. */
  2990. getTranslationToRef(result: Vector3): Matrix;
  2991. /**
  2992. * Remove rotation and scaling part from the matrix
  2993. * @returns the updated matrix
  2994. */
  2995. removeRotationAndScaling(): Matrix;
  2996. /**
  2997. * Multiply two matrices
  2998. * @param other defines the second operand
  2999. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3000. */
  3001. multiply(other: DeepImmutable<Matrix>): Matrix;
  3002. /**
  3003. * Copy the current matrix from the given one
  3004. * @param other defines the source matrix
  3005. * @returns the current updated matrix
  3006. */
  3007. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3008. /**
  3009. * Populates the given array from the starting index with the current matrix values
  3010. * @param array defines the target array
  3011. * @param offset defines the offset in the target array where to start storing values
  3012. * @returns the current matrix
  3013. */
  3014. copyToArray(array: Float32Array, offset?: number): Matrix;
  3015. /**
  3016. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3017. * @param other defines the second operand
  3018. * @param result defines the matrix where to store the multiplication
  3019. * @returns the current matrix
  3020. */
  3021. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3022. /**
  3023. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3024. * @param other defines the second operand
  3025. * @param result defines the array where to store the multiplication
  3026. * @param offset defines the offset in the target array where to start storing values
  3027. * @returns the current matrix
  3028. */
  3029. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3030. /**
  3031. * Check equality between this matrix and a second one
  3032. * @param value defines the second matrix to compare
  3033. * @returns true is the current matrix and the given one values are strictly equal
  3034. */
  3035. equals(value: DeepImmutable<Matrix>): boolean;
  3036. /**
  3037. * Clone the current matrix
  3038. * @returns a new matrix from the current matrix
  3039. */
  3040. clone(): Matrix;
  3041. /**
  3042. * Returns the name of the current matrix class
  3043. * @returns the string "Matrix"
  3044. */
  3045. getClassName(): string;
  3046. /**
  3047. * Gets the hash code of the current matrix
  3048. * @returns the hash code
  3049. */
  3050. getHashCode(): number;
  3051. /**
  3052. * Decomposes the current Matrix into a translation, rotation and scaling components
  3053. * @param scale defines the scale vector3 given as a reference to update
  3054. * @param rotation defines the rotation quaternion given as a reference to update
  3055. * @param translation defines the translation vector3 given as a reference to update
  3056. * @returns true if operation was successful
  3057. */
  3058. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3059. /**
  3060. * Gets specific row of the matrix
  3061. * @param index defines the number of the row to get
  3062. * @returns the index-th row of the current matrix as a new Vector4
  3063. */
  3064. getRow(index: number): Nullable<Vector4>;
  3065. /**
  3066. * Sets the index-th row of the current matrix to the vector4 values
  3067. * @param index defines the number of the row to set
  3068. * @param row defines the target vector4
  3069. * @returns the updated current matrix
  3070. */
  3071. setRow(index: number, row: Vector4): Matrix;
  3072. /**
  3073. * Compute the transpose of the matrix
  3074. * @returns the new transposed matrix
  3075. */
  3076. transpose(): Matrix;
  3077. /**
  3078. * Compute the transpose of the matrix and store it in a given matrix
  3079. * @param result defines the target matrix
  3080. * @returns the current matrix
  3081. */
  3082. transposeToRef(result: Matrix): Matrix;
  3083. /**
  3084. * Sets the index-th row of the current matrix with the given 4 x float values
  3085. * @param index defines the row index
  3086. * @param x defines the x component to set
  3087. * @param y defines the y component to set
  3088. * @param z defines the z component to set
  3089. * @param w defines the w component to set
  3090. * @returns the updated current matrix
  3091. */
  3092. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3093. /**
  3094. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3095. * @param scale defines the scale factor
  3096. * @returns a new matrix
  3097. */
  3098. scale(scale: number): Matrix;
  3099. /**
  3100. * Scale the current matrix values by a factor to a given result matrix
  3101. * @param scale defines the scale factor
  3102. * @param result defines the matrix to store the result
  3103. * @returns the current matrix
  3104. */
  3105. scaleToRef(scale: number, result: Matrix): Matrix;
  3106. /**
  3107. * Scale the current matrix values by a factor and add the result to a given matrix
  3108. * @param scale defines the scale factor
  3109. * @param result defines the Matrix to store the result
  3110. * @returns the current matrix
  3111. */
  3112. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3113. /**
  3114. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3115. * @param ref matrix to store the result
  3116. */
  3117. toNormalMatrix(ref: Matrix): void;
  3118. /**
  3119. * Gets only rotation part of the current matrix
  3120. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3121. */
  3122. getRotationMatrix(): Matrix;
  3123. /**
  3124. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3125. * @param result defines the target matrix to store data to
  3126. * @returns the current matrix
  3127. */
  3128. getRotationMatrixToRef(result: Matrix): Matrix;
  3129. /**
  3130. * Toggles model matrix from being right handed to left handed in place and vice versa
  3131. */
  3132. toggleModelMatrixHandInPlace(): void;
  3133. /**
  3134. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3135. */
  3136. toggleProjectionMatrixHandInPlace(): void;
  3137. /**
  3138. * Creates a matrix from an array
  3139. * @param array defines the source array
  3140. * @param offset defines an offset in the source array
  3141. * @returns a new Matrix set from the starting index of the given array
  3142. */
  3143. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3144. /**
  3145. * Copy the content of an array into a given matrix
  3146. * @param array defines the source array
  3147. * @param offset defines an offset in the source array
  3148. * @param result defines the target matrix
  3149. */
  3150. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3151. /**
  3152. * Stores an array into a matrix after having multiplied each component by a given factor
  3153. * @param array defines the source array
  3154. * @param offset defines the offset in the source array
  3155. * @param scale defines the scaling factor
  3156. * @param result defines the target matrix
  3157. */
  3158. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3159. /**
  3160. * Gets an identity matrix that must not be updated
  3161. */
  3162. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3163. /**
  3164. * Stores a list of values (16) inside a given matrix
  3165. * @param initialM11 defines 1st value of 1st row
  3166. * @param initialM12 defines 2nd value of 1st row
  3167. * @param initialM13 defines 3rd value of 1st row
  3168. * @param initialM14 defines 4th value of 1st row
  3169. * @param initialM21 defines 1st value of 2nd row
  3170. * @param initialM22 defines 2nd value of 2nd row
  3171. * @param initialM23 defines 3rd value of 2nd row
  3172. * @param initialM24 defines 4th value of 2nd row
  3173. * @param initialM31 defines 1st value of 3rd row
  3174. * @param initialM32 defines 2nd value of 3rd row
  3175. * @param initialM33 defines 3rd value of 3rd row
  3176. * @param initialM34 defines 4th value of 3rd row
  3177. * @param initialM41 defines 1st value of 4th row
  3178. * @param initialM42 defines 2nd value of 4th row
  3179. * @param initialM43 defines 3rd value of 4th row
  3180. * @param initialM44 defines 4th value of 4th row
  3181. * @param result defines the target matrix
  3182. */
  3183. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  3184. /**
  3185. * Creates new matrix from a list of values (16)
  3186. * @param initialM11 defines 1st value of 1st row
  3187. * @param initialM12 defines 2nd value of 1st row
  3188. * @param initialM13 defines 3rd value of 1st row
  3189. * @param initialM14 defines 4th value of 1st row
  3190. * @param initialM21 defines 1st value of 2nd row
  3191. * @param initialM22 defines 2nd value of 2nd row
  3192. * @param initialM23 defines 3rd value of 2nd row
  3193. * @param initialM24 defines 4th value of 2nd row
  3194. * @param initialM31 defines 1st value of 3rd row
  3195. * @param initialM32 defines 2nd value of 3rd row
  3196. * @param initialM33 defines 3rd value of 3rd row
  3197. * @param initialM34 defines 4th value of 3rd row
  3198. * @param initialM41 defines 1st value of 4th row
  3199. * @param initialM42 defines 2nd value of 4th row
  3200. * @param initialM43 defines 3rd value of 4th row
  3201. * @param initialM44 defines 4th value of 4th row
  3202. * @returns the new matrix
  3203. */
  3204. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  3205. /**
  3206. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3207. * @param scale defines the scale vector3
  3208. * @param rotation defines the rotation quaternion
  3209. * @param translation defines the translation vector3
  3210. * @returns a new matrix
  3211. */
  3212. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3213. /**
  3214. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3215. * @param scale defines the scale vector3
  3216. * @param rotation defines the rotation quaternion
  3217. * @param translation defines the translation vector3
  3218. * @param result defines the target matrix
  3219. */
  3220. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3221. /**
  3222. * Creates a new identity matrix
  3223. * @returns a new identity matrix
  3224. */
  3225. static Identity(): Matrix;
  3226. /**
  3227. * Creates a new identity matrix and stores the result in a given matrix
  3228. * @param result defines the target matrix
  3229. */
  3230. static IdentityToRef(result: Matrix): void;
  3231. /**
  3232. * Creates a new zero matrix
  3233. * @returns a new zero matrix
  3234. */
  3235. static Zero(): Matrix;
  3236. /**
  3237. * Creates a new rotation matrix for "angle" radians around the X axis
  3238. * @param angle defines the angle (in radians) to use
  3239. * @return the new matrix
  3240. */
  3241. static RotationX(angle: number): Matrix;
  3242. /**
  3243. * Creates a new matrix as the invert of a given matrix
  3244. * @param source defines the source matrix
  3245. * @returns the new matrix
  3246. */
  3247. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3248. /**
  3249. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3250. * @param angle defines the angle (in radians) to use
  3251. * @param result defines the target matrix
  3252. */
  3253. static RotationXToRef(angle: number, result: Matrix): void;
  3254. /**
  3255. * Creates a new rotation matrix for "angle" radians around the Y axis
  3256. * @param angle defines the angle (in radians) to use
  3257. * @return the new matrix
  3258. */
  3259. static RotationY(angle: number): Matrix;
  3260. /**
  3261. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3262. * @param angle defines the angle (in radians) to use
  3263. * @param result defines the target matrix
  3264. */
  3265. static RotationYToRef(angle: number, result: Matrix): void;
  3266. /**
  3267. * Creates a new rotation matrix for "angle" radians around the Z axis
  3268. * @param angle defines the angle (in radians) to use
  3269. * @return the new matrix
  3270. */
  3271. static RotationZ(angle: number): Matrix;
  3272. /**
  3273. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3274. * @param angle defines the angle (in radians) to use
  3275. * @param result defines the target matrix
  3276. */
  3277. static RotationZToRef(angle: number, result: Matrix): void;
  3278. /**
  3279. * Creates a new rotation matrix for "angle" radians around the given axis
  3280. * @param axis defines the axis to use
  3281. * @param angle defines the angle (in radians) to use
  3282. * @return the new matrix
  3283. */
  3284. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3285. /**
  3286. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3287. * @param axis defines the axis to use
  3288. * @param angle defines the angle (in radians) to use
  3289. * @param result defines the target matrix
  3290. */
  3291. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3292. /**
  3293. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3294. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3295. * @param from defines the vector to align
  3296. * @param to defines the vector to align to
  3297. * @param result defines the target matrix
  3298. */
  3299. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3300. /**
  3301. * Creates a rotation matrix
  3302. * @param yaw defines the yaw angle in radians (Y axis)
  3303. * @param pitch defines the pitch angle in radians (X axis)
  3304. * @param roll defines the roll angle in radians (X axis)
  3305. * @returns the new rotation matrix
  3306. */
  3307. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3308. /**
  3309. * Creates a rotation matrix and stores it in a given matrix
  3310. * @param yaw defines the yaw angle in radians (Y axis)
  3311. * @param pitch defines the pitch angle in radians (X axis)
  3312. * @param roll defines the roll angle in radians (X axis)
  3313. * @param result defines the target matrix
  3314. */
  3315. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3316. /**
  3317. * Creates a scaling matrix
  3318. * @param x defines the scale factor on X axis
  3319. * @param y defines the scale factor on Y axis
  3320. * @param z defines the scale factor on Z axis
  3321. * @returns the new matrix
  3322. */
  3323. static Scaling(x: number, y: number, z: number): Matrix;
  3324. /**
  3325. * Creates a scaling matrix and stores it in a given matrix
  3326. * @param x defines the scale factor on X axis
  3327. * @param y defines the scale factor on Y axis
  3328. * @param z defines the scale factor on Z axis
  3329. * @param result defines the target matrix
  3330. */
  3331. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3332. /**
  3333. * Creates a translation matrix
  3334. * @param x defines the translation on X axis
  3335. * @param y defines the translation on Y axis
  3336. * @param z defines the translationon Z axis
  3337. * @returns the new matrix
  3338. */
  3339. static Translation(x: number, y: number, z: number): Matrix;
  3340. /**
  3341. * Creates a translation matrix and stores it in a given matrix
  3342. * @param x defines the translation on X axis
  3343. * @param y defines the translation on Y axis
  3344. * @param z defines the translationon Z axis
  3345. * @param result defines the target matrix
  3346. */
  3347. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3348. /**
  3349. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3350. * @param startValue defines the start value
  3351. * @param endValue defines the end value
  3352. * @param gradient defines the gradient factor
  3353. * @returns the new matrix
  3354. */
  3355. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3356. /**
  3357. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3358. * @param startValue defines the start value
  3359. * @param endValue defines the end value
  3360. * @param gradient defines the gradient factor
  3361. * @param result defines the Matrix object where to store data
  3362. */
  3363. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3364. /**
  3365. * Builds a new matrix whose values are computed by:
  3366. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3367. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3368. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3369. * @param startValue defines the first matrix
  3370. * @param endValue defines the second matrix
  3371. * @param gradient defines the gradient between the two matrices
  3372. * @returns the new matrix
  3373. */
  3374. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3375. /**
  3376. * Update a matrix to values which are computed by:
  3377. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3378. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3379. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3380. * @param startValue defines the first matrix
  3381. * @param endValue defines the second matrix
  3382. * @param gradient defines the gradient between the two matrices
  3383. * @param result defines the target matrix
  3384. */
  3385. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3386. /**
  3387. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3388. * This function works in left handed mode
  3389. * @param eye defines the final position of the entity
  3390. * @param target defines where the entity should look at
  3391. * @param up defines the up vector for the entity
  3392. * @returns the new matrix
  3393. */
  3394. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3395. /**
  3396. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3397. * This function works in left handed mode
  3398. * @param eye defines the final position of the entity
  3399. * @param target defines where the entity should look at
  3400. * @param up defines the up vector for the entity
  3401. * @param result defines the target matrix
  3402. */
  3403. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3404. /**
  3405. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3406. * This function works in right handed mode
  3407. * @param eye defines the final position of the entity
  3408. * @param target defines where the entity should look at
  3409. * @param up defines the up vector for the entity
  3410. * @returns the new matrix
  3411. */
  3412. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3413. /**
  3414. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3415. * This function works in right handed mode
  3416. * @param eye defines the final position of the entity
  3417. * @param target defines where the entity should look at
  3418. * @param up defines the up vector for the entity
  3419. * @param result defines the target matrix
  3420. */
  3421. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3422. /**
  3423. * Create a left-handed orthographic projection matrix
  3424. * @param width defines the viewport width
  3425. * @param height defines the viewport height
  3426. * @param znear defines the near clip plane
  3427. * @param zfar defines the far clip plane
  3428. * @returns a new matrix as a left-handed orthographic projection matrix
  3429. */
  3430. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3431. /**
  3432. * Store a left-handed orthographic projection to a given matrix
  3433. * @param width defines the viewport width
  3434. * @param height defines the viewport height
  3435. * @param znear defines the near clip plane
  3436. * @param zfar defines the far clip plane
  3437. * @param result defines the target matrix
  3438. */
  3439. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3440. /**
  3441. * Create a left-handed orthographic projection matrix
  3442. * @param left defines the viewport left coordinate
  3443. * @param right defines the viewport right coordinate
  3444. * @param bottom defines the viewport bottom coordinate
  3445. * @param top defines the viewport top coordinate
  3446. * @param znear defines the near clip plane
  3447. * @param zfar defines the far clip plane
  3448. * @returns a new matrix as a left-handed orthographic projection matrix
  3449. */
  3450. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3451. /**
  3452. * Stores a left-handed orthographic projection into a given matrix
  3453. * @param left defines the viewport left coordinate
  3454. * @param right defines the viewport right coordinate
  3455. * @param bottom defines the viewport bottom coordinate
  3456. * @param top defines the viewport top coordinate
  3457. * @param znear defines the near clip plane
  3458. * @param zfar defines the far clip plane
  3459. * @param result defines the target matrix
  3460. */
  3461. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3462. /**
  3463. * Creates a right-handed orthographic projection matrix
  3464. * @param left defines the viewport left coordinate
  3465. * @param right defines the viewport right coordinate
  3466. * @param bottom defines the viewport bottom coordinate
  3467. * @param top defines the viewport top coordinate
  3468. * @param znear defines the near clip plane
  3469. * @param zfar defines the far clip plane
  3470. * @returns a new matrix as a right-handed orthographic projection matrix
  3471. */
  3472. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3473. /**
  3474. * Stores a right-handed orthographic projection into a given matrix
  3475. * @param left defines the viewport left coordinate
  3476. * @param right defines the viewport right coordinate
  3477. * @param bottom defines the viewport bottom coordinate
  3478. * @param top defines the viewport top coordinate
  3479. * @param znear defines the near clip plane
  3480. * @param zfar defines the far clip plane
  3481. * @param result defines the target matrix
  3482. */
  3483. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3484. /**
  3485. * Creates a left-handed perspective projection matrix
  3486. * @param width defines the viewport width
  3487. * @param height defines the viewport height
  3488. * @param znear defines the near clip plane
  3489. * @param zfar defines the far clip plane
  3490. * @returns a new matrix as a left-handed perspective projection matrix
  3491. */
  3492. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3493. /**
  3494. * Creates a left-handed perspective projection matrix
  3495. * @param fov defines the horizontal field of view
  3496. * @param aspect defines the aspect ratio
  3497. * @param znear defines the near clip plane
  3498. * @param zfar defines the far clip plane
  3499. * @returns a new matrix as a left-handed perspective projection matrix
  3500. */
  3501. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3502. /**
  3503. * Stores a left-handed perspective projection into a given matrix
  3504. * @param fov defines the horizontal field of view
  3505. * @param aspect defines the aspect ratio
  3506. * @param znear defines the near clip plane
  3507. * @param zfar defines the far clip plane
  3508. * @param result defines the target matrix
  3509. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3510. */
  3511. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3512. /**
  3513. * Creates a right-handed perspective projection matrix
  3514. * @param fov defines the horizontal field of view
  3515. * @param aspect defines the aspect ratio
  3516. * @param znear defines the near clip plane
  3517. * @param zfar defines the far clip plane
  3518. * @returns a new matrix as a right-handed perspective projection matrix
  3519. */
  3520. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3521. /**
  3522. * Stores a right-handed perspective projection into a given matrix
  3523. * @param fov defines the horizontal field of view
  3524. * @param aspect defines the aspect ratio
  3525. * @param znear defines the near clip plane
  3526. * @param zfar defines the far clip plane
  3527. * @param result defines the target matrix
  3528. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3529. */
  3530. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3531. /**
  3532. * Stores a perspective projection for WebVR info a given matrix
  3533. * @param fov defines the field of view
  3534. * @param znear defines the near clip plane
  3535. * @param zfar defines the far clip plane
  3536. * @param result defines the target matrix
  3537. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3538. */
  3539. static PerspectiveFovWebVRToRef(fov: {
  3540. upDegrees: number;
  3541. downDegrees: number;
  3542. leftDegrees: number;
  3543. rightDegrees: number;
  3544. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3545. /**
  3546. * Computes a complete transformation matrix
  3547. * @param viewport defines the viewport to use
  3548. * @param world defines the world matrix
  3549. * @param view defines the view matrix
  3550. * @param projection defines the projection matrix
  3551. * @param zmin defines the near clip plane
  3552. * @param zmax defines the far clip plane
  3553. * @returns the transformation matrix
  3554. */
  3555. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3556. /**
  3557. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3558. * @param matrix defines the matrix to use
  3559. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3560. */
  3561. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3562. /**
  3563. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3564. * @param matrix defines the matrix to use
  3565. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3566. */
  3567. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3568. /**
  3569. * Compute the transpose of a given matrix
  3570. * @param matrix defines the matrix to transpose
  3571. * @returns the new matrix
  3572. */
  3573. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3574. /**
  3575. * Compute the transpose of a matrix and store it in a target matrix
  3576. * @param matrix defines the matrix to transpose
  3577. * @param result defines the target matrix
  3578. */
  3579. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3580. /**
  3581. * Computes a reflection matrix from a plane
  3582. * @param plane defines the reflection plane
  3583. * @returns a new matrix
  3584. */
  3585. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  3586. /**
  3587. * Computes a reflection matrix from a plane
  3588. * @param plane defines the reflection plane
  3589. * @param result defines the target matrix
  3590. */
  3591. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  3592. /**
  3593. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3594. * @param xaxis defines the value of the 1st axis
  3595. * @param yaxis defines the value of the 2nd axis
  3596. * @param zaxis defines the value of the 3rd axis
  3597. * @param result defines the target matrix
  3598. */
  3599. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3600. /**
  3601. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3602. * @param quat defines the quaternion to use
  3603. * @param result defines the target matrix
  3604. */
  3605. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3606. }
  3607. /**
  3608. * Represens a plane by the equation ax + by + cz + d = 0
  3609. */
  3610. export class Plane {
  3611. /**
  3612. * Normal of the plane (a,b,c)
  3613. */
  3614. normal: Vector3;
  3615. /**
  3616. * d component of the plane
  3617. */
  3618. d: number;
  3619. /**
  3620. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  3621. * @param a a component of the plane
  3622. * @param b b component of the plane
  3623. * @param c c component of the plane
  3624. * @param d d component of the plane
  3625. */
  3626. constructor(a: number, b: number, c: number, d: number);
  3627. /**
  3628. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  3629. */
  3630. asArray(): number[];
  3631. /**
  3632. * @returns a new plane copied from the current Plane.
  3633. */
  3634. clone(): Plane;
  3635. /**
  3636. * @returns the string "Plane".
  3637. */
  3638. getClassName(): string;
  3639. /**
  3640. * @returns the Plane hash code.
  3641. */
  3642. getHashCode(): number;
  3643. /**
  3644. * Normalize the current Plane in place.
  3645. * @returns the updated Plane.
  3646. */
  3647. normalize(): Plane;
  3648. /**
  3649. * Applies a transformation the plane and returns the result
  3650. * @param transformation the transformation matrix to be applied to the plane
  3651. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  3652. */
  3653. transform(transformation: DeepImmutable<Matrix>): Plane;
  3654. /**
  3655. * Calcualtte the dot product between the point and the plane normal
  3656. * @param point point to calculate the dot product with
  3657. * @returns the dot product (float) of the point coordinates and the plane normal.
  3658. */
  3659. dotCoordinate(point: DeepImmutable<Vector3>): number;
  3660. /**
  3661. * Updates the current Plane from the plane defined by the three given points.
  3662. * @param point1 one of the points used to contruct the plane
  3663. * @param point2 one of the points used to contruct the plane
  3664. * @param point3 one of the points used to contruct the plane
  3665. * @returns the updated Plane.
  3666. */
  3667. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3668. /**
  3669. * Checks if the plane is facing a given direction
  3670. * @param direction the direction to check if the plane is facing
  3671. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  3672. * @returns True is the vector "direction" is the same side than the plane normal.
  3673. */
  3674. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  3675. /**
  3676. * Calculates the distance to a point
  3677. * @param point point to calculate distance to
  3678. * @returns the signed distance (float) from the given point to the Plane.
  3679. */
  3680. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  3681. /**
  3682. * Creates a plane from an array
  3683. * @param array the array to create a plane from
  3684. * @returns a new Plane from the given array.
  3685. */
  3686. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  3687. /**
  3688. * Creates a plane from three points
  3689. * @param point1 point used to create the plane
  3690. * @param point2 point used to create the plane
  3691. * @param point3 point used to create the plane
  3692. * @returns a new Plane defined by the three given points.
  3693. */
  3694. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3695. /**
  3696. * Creates a plane from an origin point and a normal
  3697. * @param origin origin of the plane to be constructed
  3698. * @param normal normal of the plane to be constructed
  3699. * @returns a new Plane the normal vector to this plane at the given origin point.
  3700. * Note : the vector "normal" is updated because normalized.
  3701. */
  3702. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  3703. /**
  3704. * Calculates the distance from a plane and a point
  3705. * @param origin origin of the plane to be constructed
  3706. * @param normal normal of the plane to be constructed
  3707. * @param point point to calculate distance to
  3708. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  3709. */
  3710. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  3711. }
  3712. /**
  3713. * Class used to represent a viewport on screen
  3714. */
  3715. export class Viewport {
  3716. /** viewport left coordinate */
  3717. x: number;
  3718. /** viewport top coordinate */
  3719. y: number;
  3720. /**viewport width */
  3721. width: number;
  3722. /** viewport height */
  3723. height: number;
  3724. /**
  3725. * Creates a Viewport object located at (x, y) and sized (width, height)
  3726. * @param x defines viewport left coordinate
  3727. * @param y defines viewport top coordinate
  3728. * @param width defines the viewport width
  3729. * @param height defines the viewport height
  3730. */
  3731. constructor(
  3732. /** viewport left coordinate */
  3733. x: number,
  3734. /** viewport top coordinate */
  3735. y: number,
  3736. /**viewport width */
  3737. width: number,
  3738. /** viewport height */
  3739. height: number);
  3740. /**
  3741. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  3742. * @param renderWidth defines the rendering width
  3743. * @param renderHeight defines the rendering height
  3744. * @returns a new Viewport
  3745. */
  3746. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  3747. /**
  3748. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  3749. * @param renderWidth defines the rendering width
  3750. * @param renderHeight defines the rendering height
  3751. * @param ref defines the target viewport
  3752. * @returns the current viewport
  3753. */
  3754. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  3755. /**
  3756. * Returns a new Viewport copied from the current one
  3757. * @returns a new Viewport
  3758. */
  3759. clone(): Viewport;
  3760. }
  3761. /**
  3762. * Reprasents a camera frustum
  3763. */
  3764. export class Frustum {
  3765. /**
  3766. * Gets the planes representing the frustum
  3767. * @param transform matrix to be applied to the returned planes
  3768. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  3769. */
  3770. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  3771. /**
  3772. * Gets the near frustum plane transformed by the transform matrix
  3773. * @param transform transformation matrix to be applied to the resulting frustum plane
  3774. * @param frustumPlane the resuling frustum plane
  3775. */
  3776. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3777. /**
  3778. * Gets the far frustum plane transformed by the transform matrix
  3779. * @param transform transformation matrix to be applied to the resulting frustum plane
  3780. * @param frustumPlane the resuling frustum plane
  3781. */
  3782. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3783. /**
  3784. * Gets the left frustum plane transformed by the transform matrix
  3785. * @param transform transformation matrix to be applied to the resulting frustum plane
  3786. * @param frustumPlane the resuling frustum plane
  3787. */
  3788. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3789. /**
  3790. * Gets the right frustum plane transformed by the transform matrix
  3791. * @param transform transformation matrix to be applied to the resulting frustum plane
  3792. * @param frustumPlane the resuling frustum plane
  3793. */
  3794. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3795. /**
  3796. * Gets the top frustum plane transformed by the transform matrix
  3797. * @param transform transformation matrix to be applied to the resulting frustum plane
  3798. * @param frustumPlane the resuling frustum plane
  3799. */
  3800. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3801. /**
  3802. * Gets the bottom frustum plane transformed by the transform matrix
  3803. * @param transform transformation matrix to be applied to the resulting frustum plane
  3804. * @param frustumPlane the resuling frustum plane
  3805. */
  3806. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3807. /**
  3808. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  3809. * @param transform transformation matrix to be applied to the resulting frustum planes
  3810. * @param frustumPlanes the resuling frustum planes
  3811. */
  3812. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  3813. }
  3814. /** Defines supported spaces */
  3815. export enum Space {
  3816. /** Local (object) space */
  3817. LOCAL = 0,
  3818. /** World space */
  3819. WORLD = 1,
  3820. /** Bone space */
  3821. BONE = 2
  3822. }
  3823. /** Defines the 3 main axes */
  3824. export class Axis {
  3825. /** X axis */
  3826. static X: Vector3;
  3827. /** Y axis */
  3828. static Y: Vector3;
  3829. /** Z axis */
  3830. static Z: Vector3;
  3831. }
  3832. /** Class used to represent a Bezier curve */
  3833. export class BezierCurve {
  3834. /**
  3835. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  3836. * @param t defines the time
  3837. * @param x1 defines the left coordinate on X axis
  3838. * @param y1 defines the left coordinate on Y axis
  3839. * @param x2 defines the right coordinate on X axis
  3840. * @param y2 defines the right coordinate on Y axis
  3841. * @returns the interpolated value
  3842. */
  3843. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  3844. }
  3845. /**
  3846. * Defines potential orientation for back face culling
  3847. */
  3848. export enum Orientation {
  3849. /**
  3850. * Clockwise
  3851. */
  3852. CW = 0,
  3853. /** Counter clockwise */
  3854. CCW = 1
  3855. }
  3856. /**
  3857. * Defines angle representation
  3858. */
  3859. export class Angle {
  3860. private _radians;
  3861. /**
  3862. * Creates an Angle object of "radians" radians (float).
  3863. * @param radians the angle in radians
  3864. */
  3865. constructor(radians: number);
  3866. /**
  3867. * Get value in degrees
  3868. * @returns the Angle value in degrees (float)
  3869. */
  3870. degrees(): number;
  3871. /**
  3872. * Get value in radians
  3873. * @returns the Angle value in radians (float)
  3874. */
  3875. radians(): number;
  3876. /**
  3877. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  3878. * @param a defines first vector
  3879. * @param b defines second vector
  3880. * @returns a new Angle
  3881. */
  3882. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  3883. /**
  3884. * Gets a new Angle object from the given float in radians
  3885. * @param radians defines the angle value in radians
  3886. * @returns a new Angle
  3887. */
  3888. static FromRadians(radians: number): Angle;
  3889. /**
  3890. * Gets a new Angle object from the given float in degrees
  3891. * @param degrees defines the angle value in degrees
  3892. * @returns a new Angle
  3893. */
  3894. static FromDegrees(degrees: number): Angle;
  3895. }
  3896. /**
  3897. * This represents an arc in a 2d space.
  3898. */
  3899. export class Arc2 {
  3900. /** Defines the start point of the arc */
  3901. startPoint: Vector2;
  3902. /** Defines the mid point of the arc */
  3903. midPoint: Vector2;
  3904. /** Defines the end point of the arc */
  3905. endPoint: Vector2;
  3906. /**
  3907. * Defines the center point of the arc.
  3908. */
  3909. centerPoint: Vector2;
  3910. /**
  3911. * Defines the radius of the arc.
  3912. */
  3913. radius: number;
  3914. /**
  3915. * Defines the angle of the arc (from mid point to end point).
  3916. */
  3917. angle: Angle;
  3918. /**
  3919. * Defines the start angle of the arc (from start point to middle point).
  3920. */
  3921. startAngle: Angle;
  3922. /**
  3923. * Defines the orientation of the arc (clock wise/counter clock wise).
  3924. */
  3925. orientation: Orientation;
  3926. /**
  3927. * Creates an Arc object from the three given points : start, middle and end.
  3928. * @param startPoint Defines the start point of the arc
  3929. * @param midPoint Defines the midlle point of the arc
  3930. * @param endPoint Defines the end point of the arc
  3931. */
  3932. constructor(
  3933. /** Defines the start point of the arc */
  3934. startPoint: Vector2,
  3935. /** Defines the mid point of the arc */
  3936. midPoint: Vector2,
  3937. /** Defines the end point of the arc */
  3938. endPoint: Vector2);
  3939. }
  3940. /**
  3941. * Represents a 2D path made up of multiple 2D points
  3942. */
  3943. export class Path2 {
  3944. private _points;
  3945. private _length;
  3946. /**
  3947. * If the path start and end point are the same
  3948. */
  3949. closed: boolean;
  3950. /**
  3951. * Creates a Path2 object from the starting 2D coordinates x and y.
  3952. * @param x the starting points x value
  3953. * @param y the starting points y value
  3954. */
  3955. constructor(x: number, y: number);
  3956. /**
  3957. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  3958. * @param x the added points x value
  3959. * @param y the added points y value
  3960. * @returns the updated Path2.
  3961. */
  3962. addLineTo(x: number, y: number): Path2;
  3963. /**
  3964. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  3965. * @param midX middle point x value
  3966. * @param midY middle point y value
  3967. * @param endX end point x value
  3968. * @param endY end point y value
  3969. * @param numberOfSegments (default: 36)
  3970. * @returns the updated Path2.
  3971. */
  3972. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3973. /**
  3974. * Closes the Path2.
  3975. * @returns the Path2.
  3976. */
  3977. close(): Path2;
  3978. /**
  3979. * Gets the sum of the distance between each sequential point in the path
  3980. * @returns the Path2 total length (float).
  3981. */
  3982. length(): number;
  3983. /**
  3984. * Gets the points which construct the path
  3985. * @returns the Path2 internal array of points.
  3986. */
  3987. getPoints(): Vector2[];
  3988. /**
  3989. * Retreives the point at the distance aways from the starting point
  3990. * @param normalizedLengthPosition the length along the path to retreive the point from
  3991. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  3992. */
  3993. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3994. /**
  3995. * Creates a new path starting from an x and y position
  3996. * @param x starting x value
  3997. * @param y starting y value
  3998. * @returns a new Path2 starting at the coordinates (x, y).
  3999. */
  4000. static StartingAt(x: number, y: number): Path2;
  4001. }
  4002. /**
  4003. * Represents a 3D path made up of multiple 3D points
  4004. */
  4005. export class Path3D {
  4006. /**
  4007. * an array of Vector3, the curve axis of the Path3D
  4008. */
  4009. path: Vector3[];
  4010. private _curve;
  4011. private _distances;
  4012. private _tangents;
  4013. private _normals;
  4014. private _binormals;
  4015. private _raw;
  4016. /**
  4017. * new Path3D(path, normal, raw)
  4018. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4019. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4020. * @param path an array of Vector3, the curve axis of the Path3D
  4021. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4022. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4023. */
  4024. constructor(
  4025. /**
  4026. * an array of Vector3, the curve axis of the Path3D
  4027. */
  4028. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  4029. /**
  4030. * Returns the Path3D array of successive Vector3 designing its curve.
  4031. * @returns the Path3D array of successive Vector3 designing its curve.
  4032. */
  4033. getCurve(): Vector3[];
  4034. /**
  4035. * Returns an array populated with tangent vectors on each Path3D curve point.
  4036. * @returns an array populated with tangent vectors on each Path3D curve point.
  4037. */
  4038. getTangents(): Vector3[];
  4039. /**
  4040. * Returns an array populated with normal vectors on each Path3D curve point.
  4041. * @returns an array populated with normal vectors on each Path3D curve point.
  4042. */
  4043. getNormals(): Vector3[];
  4044. /**
  4045. * Returns an array populated with binormal vectors on each Path3D curve point.
  4046. * @returns an array populated with binormal vectors on each Path3D curve point.
  4047. */
  4048. getBinormals(): Vector3[];
  4049. /**
  4050. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4051. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4052. */
  4053. getDistances(): number[];
  4054. /**
  4055. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4056. * @param path path which all values are copied into the curves points
  4057. * @param firstNormal which should be projected onto the curve
  4058. * @returns the same object updated.
  4059. */
  4060. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4061. private _compute;
  4062. private _getFirstNonNullVector;
  4063. private _getLastNonNullVector;
  4064. private _normalVector;
  4065. }
  4066. /**
  4067. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4068. * A Curve3 is designed from a series of successive Vector3.
  4069. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4070. */
  4071. export class Curve3 {
  4072. private _points;
  4073. private _length;
  4074. /**
  4075. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4076. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4077. * @param v1 (Vector3) the control point
  4078. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4079. * @param nbPoints (integer) the wanted number of points in the curve
  4080. * @returns the created Curve3
  4081. */
  4082. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4083. /**
  4084. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4085. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4086. * @param v1 (Vector3) the first control point
  4087. * @param v2 (Vector3) the second control point
  4088. * @param v3 (Vector3) the end point of the Cubic Bezier
  4089. * @param nbPoints (integer) the wanted number of points in the curve
  4090. * @returns the created Curve3
  4091. */
  4092. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4093. /**
  4094. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4095. * @param p1 (Vector3) the origin point of the Hermite Spline
  4096. * @param t1 (Vector3) the tangent vector at the origin point
  4097. * @param p2 (Vector3) the end point of the Hermite Spline
  4098. * @param t2 (Vector3) the tangent vector at the end point
  4099. * @param nbPoints (integer) the wanted number of points in the curve
  4100. * @returns the created Curve3
  4101. */
  4102. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4103. /**
  4104. * Returns a Curve3 object along a CatmullRom Spline curve :
  4105. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4106. * @param nbPoints (integer) the wanted number of points between each curve control points
  4107. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4108. * @returns the created Curve3
  4109. */
  4110. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4111. /**
  4112. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4113. * A Curve3 is designed from a series of successive Vector3.
  4114. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4115. * @param points points which make up the curve
  4116. */
  4117. constructor(points: Vector3[]);
  4118. /**
  4119. * @returns the Curve3 stored array of successive Vector3
  4120. */
  4121. getPoints(): Vector3[];
  4122. /**
  4123. * @returns the computed length (float) of the curve.
  4124. */
  4125. length(): number;
  4126. /**
  4127. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4128. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4129. * curveA and curveB keep unchanged.
  4130. * @param curve the curve to continue from this curve
  4131. * @returns the newly constructed curve
  4132. */
  4133. continue(curve: DeepImmutable<Curve3>): Curve3;
  4134. private _computeLength;
  4135. }
  4136. /**
  4137. * Contains position and normal vectors for a vertex
  4138. */
  4139. export class PositionNormalVertex {
  4140. /** the position of the vertex (defaut: 0,0,0) */
  4141. position: Vector3;
  4142. /** the normal of the vertex (defaut: 0,1,0) */
  4143. normal: Vector3;
  4144. /**
  4145. * Creates a PositionNormalVertex
  4146. * @param position the position of the vertex (defaut: 0,0,0)
  4147. * @param normal the normal of the vertex (defaut: 0,1,0)
  4148. */
  4149. constructor(
  4150. /** the position of the vertex (defaut: 0,0,0) */
  4151. position?: Vector3,
  4152. /** the normal of the vertex (defaut: 0,1,0) */
  4153. normal?: Vector3);
  4154. /**
  4155. * Clones the PositionNormalVertex
  4156. * @returns the cloned PositionNormalVertex
  4157. */
  4158. clone(): PositionNormalVertex;
  4159. }
  4160. /**
  4161. * Contains position, normal and uv vectors for a vertex
  4162. */
  4163. export class PositionNormalTextureVertex {
  4164. /** the position of the vertex (defaut: 0,0,0) */
  4165. position: Vector3;
  4166. /** the normal of the vertex (defaut: 0,1,0) */
  4167. normal: Vector3;
  4168. /** the uv of the vertex (default: 0,0) */
  4169. uv: Vector2;
  4170. /**
  4171. * Creates a PositionNormalTextureVertex
  4172. * @param position the position of the vertex (defaut: 0,0,0)
  4173. * @param normal the normal of the vertex (defaut: 0,1,0)
  4174. * @param uv the uv of the vertex (default: 0,0)
  4175. */
  4176. constructor(
  4177. /** the position of the vertex (defaut: 0,0,0) */
  4178. position?: Vector3,
  4179. /** the normal of the vertex (defaut: 0,1,0) */
  4180. normal?: Vector3,
  4181. /** the uv of the vertex (default: 0,0) */
  4182. uv?: Vector2);
  4183. /**
  4184. * Clones the PositionNormalTextureVertex
  4185. * @returns the cloned PositionNormalTextureVertex
  4186. */
  4187. clone(): PositionNormalTextureVertex;
  4188. }
  4189. /**
  4190. * @hidden
  4191. */
  4192. export class Tmp {
  4193. static Color3: Color3[];
  4194. static Color4: Color4[];
  4195. static Vector2: Vector2[];
  4196. static Vector3: Vector3[];
  4197. static Vector4: Vector4[];
  4198. static Quaternion: Quaternion[];
  4199. static Matrix: Matrix[];
  4200. }
  4201. }
  4202. declare module "babylonjs/Offline/IOfflineProvider" {
  4203. /**
  4204. * Class used to enable access to offline support
  4205. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4206. */
  4207. export interface IOfflineProvider {
  4208. /**
  4209. * Gets a boolean indicating if scene must be saved in the database
  4210. */
  4211. enableSceneOffline: boolean;
  4212. /**
  4213. * Gets a boolean indicating if textures must be saved in the database
  4214. */
  4215. enableTexturesOffline: boolean;
  4216. /**
  4217. * Open the offline support and make it available
  4218. * @param successCallback defines the callback to call on success
  4219. * @param errorCallback defines the callback to call on error
  4220. */
  4221. open(successCallback: () => void, errorCallback: () => void): void;
  4222. /**
  4223. * Loads an image from the offline support
  4224. * @param url defines the url to load from
  4225. * @param image defines the target DOM image
  4226. */
  4227. loadImage(url: string, image: HTMLImageElement): void;
  4228. /**
  4229. * Loads a file from offline support
  4230. * @param url defines the URL to load from
  4231. * @param sceneLoaded defines a callback to call on success
  4232. * @param progressCallBack defines a callback to call when progress changed
  4233. * @param errorCallback defines a callback to call on error
  4234. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4235. */
  4236. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4237. }
  4238. }
  4239. declare module "babylonjs/Misc/observable" {
  4240. import { Nullable } from "babylonjs/types";
  4241. /**
  4242. * A class serves as a medium between the observable and its observers
  4243. */
  4244. export class EventState {
  4245. /**
  4246. * Create a new EventState
  4247. * @param mask defines the mask associated with this state
  4248. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4249. * @param target defines the original target of the state
  4250. * @param currentTarget defines the current target of the state
  4251. */
  4252. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  4253. /**
  4254. * Initialize the current event state
  4255. * @param mask defines the mask associated with this state
  4256. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4257. * @param target defines the original target of the state
  4258. * @param currentTarget defines the current target of the state
  4259. * @returns the current event state
  4260. */
  4261. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  4262. /**
  4263. * An Observer can set this property to true to prevent subsequent observers of being notified
  4264. */
  4265. skipNextObservers: boolean;
  4266. /**
  4267. * Get the mask value that were used to trigger the event corresponding to this EventState object
  4268. */
  4269. mask: number;
  4270. /**
  4271. * The object that originally notified the event
  4272. */
  4273. target?: any;
  4274. /**
  4275. * The current object in the bubbling phase
  4276. */
  4277. currentTarget?: any;
  4278. /**
  4279. * This will be populated with the return value of the last function that was executed.
  4280. * If it is the first function in the callback chain it will be the event data.
  4281. */
  4282. lastReturnValue?: any;
  4283. }
  4284. /**
  4285. * Represent an Observer registered to a given Observable object.
  4286. */
  4287. export class Observer<T> {
  4288. /**
  4289. * Defines the callback to call when the observer is notified
  4290. */
  4291. callback: (eventData: T, eventState: EventState) => void;
  4292. /**
  4293. * Defines the mask of the observer (used to filter notifications)
  4294. */
  4295. mask: number;
  4296. /**
  4297. * Defines the current scope used to restore the JS context
  4298. */
  4299. scope: any;
  4300. /** @hidden */
  4301. _willBeUnregistered: boolean;
  4302. /**
  4303. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  4304. */
  4305. unregisterOnNextCall: boolean;
  4306. /**
  4307. * Creates a new observer
  4308. * @param callback defines the callback to call when the observer is notified
  4309. * @param mask defines the mask of the observer (used to filter notifications)
  4310. * @param scope defines the current scope used to restore the JS context
  4311. */
  4312. constructor(
  4313. /**
  4314. * Defines the callback to call when the observer is notified
  4315. */
  4316. callback: (eventData: T, eventState: EventState) => void,
  4317. /**
  4318. * Defines the mask of the observer (used to filter notifications)
  4319. */
  4320. mask: number,
  4321. /**
  4322. * Defines the current scope used to restore the JS context
  4323. */
  4324. scope?: any);
  4325. }
  4326. /**
  4327. * Represent a list of observers registered to multiple Observables object.
  4328. */
  4329. export class MultiObserver<T> {
  4330. private _observers;
  4331. private _observables;
  4332. /**
  4333. * Release associated resources
  4334. */
  4335. dispose(): void;
  4336. /**
  4337. * Raise a callback when one of the observable will notify
  4338. * @param observables defines a list of observables to watch
  4339. * @param callback defines the callback to call on notification
  4340. * @param mask defines the mask used to filter notifications
  4341. * @param scope defines the current scope used to restore the JS context
  4342. * @returns the new MultiObserver
  4343. */
  4344. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  4345. }
  4346. /**
  4347. * The Observable class is a simple implementation of the Observable pattern.
  4348. *
  4349. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  4350. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  4351. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  4352. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  4353. */
  4354. export class Observable<T> {
  4355. private _observers;
  4356. private _eventState;
  4357. private _onObserverAdded;
  4358. /**
  4359. * Creates a new observable
  4360. * @param onObserverAdded defines a callback to call when a new observer is added
  4361. */
  4362. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4363. /**
  4364. * Create a new Observer with the specified callback
  4365. * @param callback the callback that will be executed for that Observer
  4366. * @param mask the mask used to filter observers
  4367. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  4368. * @param scope optional scope for the callback to be called from
  4369. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4370. * @returns the new observer created for the callback
  4371. */
  4372. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4373. /**
  4374. * Create a new Observer with the specified callback and unregisters after the next notification
  4375. * @param callback the callback that will be executed for that Observer
  4376. * @returns the new observer created for the callback
  4377. */
  4378. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4379. /**
  4380. * Remove an Observer from the Observable object
  4381. * @param observer the instance of the Observer to remove
  4382. * @returns false if it doesn't belong to this Observable
  4383. */
  4384. remove(observer: Nullable<Observer<T>>): boolean;
  4385. /**
  4386. * Remove a callback from the Observable object
  4387. * @param callback the callback to remove
  4388. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4389. * @returns false if it doesn't belong to this Observable
  4390. */
  4391. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4392. private _deferUnregister;
  4393. private _remove;
  4394. /**
  4395. * Moves the observable to the top of the observer list making it get called first when notified
  4396. * @param observer the observer to move
  4397. */
  4398. makeObserverTopPriority(observer: Observer<T>): void;
  4399. /**
  4400. * Moves the observable to the bottom of the observer list making it get called last when notified
  4401. * @param observer the observer to move
  4402. */
  4403. makeObserverBottomPriority(observer: Observer<T>): void;
  4404. /**
  4405. * Notify all Observers by calling their respective callback with the given data
  4406. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4407. * @param eventData defines the data to send to all observers
  4408. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4409. * @param target defines the original target of the state
  4410. * @param currentTarget defines the current target of the state
  4411. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4412. */
  4413. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4414. /**
  4415. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4416. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4417. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4418. * and it is crucial that all callbacks will be executed.
  4419. * The order of the callbacks is kept, callbacks are not executed parallel.
  4420. *
  4421. * @param eventData The data to be sent to each callback
  4422. * @param mask is used to filter observers defaults to -1
  4423. * @param target defines the callback target (see EventState)
  4424. * @param currentTarget defines he current object in the bubbling phase
  4425. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4426. */
  4427. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4428. /**
  4429. * Notify a specific observer
  4430. * @param observer defines the observer to notify
  4431. * @param eventData defines the data to be sent to each callback
  4432. * @param mask is used to filter observers defaults to -1
  4433. */
  4434. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4435. /**
  4436. * Gets a boolean indicating if the observable has at least one observer
  4437. * @returns true is the Observable has at least one Observer registered
  4438. */
  4439. hasObservers(): boolean;
  4440. /**
  4441. * Clear the list of observers
  4442. */
  4443. clear(): void;
  4444. /**
  4445. * Clone the current observable
  4446. * @returns a new observable
  4447. */
  4448. clone(): Observable<T>;
  4449. /**
  4450. * Does this observable handles observer registered with a given mask
  4451. * @param mask defines the mask to be tested
  4452. * @return whether or not one observer registered with the given mask is handeled
  4453. **/
  4454. hasSpecificMask(mask?: number): boolean;
  4455. }
  4456. }
  4457. declare module "babylonjs/Misc/filesInputStore" {
  4458. /**
  4459. * Class used to help managing file picking and drag'n'drop
  4460. * File Storage
  4461. */
  4462. export class FilesInputStore {
  4463. /**
  4464. * List of files ready to be loaded
  4465. */
  4466. static FilesToLoad: {
  4467. [key: string]: File;
  4468. };
  4469. }
  4470. }
  4471. declare module "babylonjs/Engines/constants" {
  4472. /** Defines the cross module used constants to avoid circular dependncies */
  4473. export class Constants {
  4474. /** Defines that alpha blending is disabled */
  4475. static readonly ALPHA_DISABLE: number;
  4476. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4477. static readonly ALPHA_ADD: number;
  4478. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4479. static readonly ALPHA_COMBINE: number;
  4480. /** Defines that alpha blending to DEST - SRC * DEST */
  4481. static readonly ALPHA_SUBTRACT: number;
  4482. /** Defines that alpha blending to SRC * DEST */
  4483. static readonly ALPHA_MULTIPLY: number;
  4484. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4485. static readonly ALPHA_MAXIMIZED: number;
  4486. /** Defines that alpha blending to SRC + DEST */
  4487. static readonly ALPHA_ONEONE: number;
  4488. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4489. static readonly ALPHA_PREMULTIPLIED: number;
  4490. /**
  4491. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4492. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4493. */
  4494. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4495. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4496. static readonly ALPHA_INTERPOLATE: number;
  4497. /**
  4498. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4499. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4500. */
  4501. static readonly ALPHA_SCREENMODE: number;
  4502. /** Defines that the ressource is not delayed*/
  4503. static readonly DELAYLOADSTATE_NONE: number;
  4504. /** Defines that the ressource was successfully delay loaded */
  4505. static readonly DELAYLOADSTATE_LOADED: number;
  4506. /** Defines that the ressource is currently delay loading */
  4507. static readonly DELAYLOADSTATE_LOADING: number;
  4508. /** Defines that the ressource is delayed and has not started loading */
  4509. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4510. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4511. static readonly NEVER: number;
  4512. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  4513. static readonly ALWAYS: number;
  4514. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4515. static readonly LESS: number;
  4516. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4517. static readonly EQUAL: number;
  4518. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  4519. static readonly LEQUAL: number;
  4520. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4521. static readonly GREATER: number;
  4522. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  4523. static readonly GEQUAL: number;
  4524. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  4525. static readonly NOTEQUAL: number;
  4526. /** Passed to stencilOperation to specify that stencil value must be kept */
  4527. static readonly KEEP: number;
  4528. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4529. static readonly REPLACE: number;
  4530. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4531. static readonly INCR: number;
  4532. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4533. static readonly DECR: number;
  4534. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4535. static readonly INVERT: number;
  4536. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4537. static readonly INCR_WRAP: number;
  4538. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4539. static readonly DECR_WRAP: number;
  4540. /** Texture is not repeating outside of 0..1 UVs */
  4541. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4542. /** Texture is repeating outside of 0..1 UVs */
  4543. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4544. /** Texture is repeating and mirrored */
  4545. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4546. /** ALPHA */
  4547. static readonly TEXTUREFORMAT_ALPHA: number;
  4548. /** LUMINANCE */
  4549. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4550. /** LUMINANCE_ALPHA */
  4551. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4552. /** RGB */
  4553. static readonly TEXTUREFORMAT_RGB: number;
  4554. /** RGBA */
  4555. static readonly TEXTUREFORMAT_RGBA: number;
  4556. /** RED */
  4557. static readonly TEXTUREFORMAT_RED: number;
  4558. /** RED (2nd reference) */
  4559. static readonly TEXTUREFORMAT_R: number;
  4560. /** RG */
  4561. static readonly TEXTUREFORMAT_RG: number;
  4562. /** RED_INTEGER */
  4563. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4564. /** RED_INTEGER (2nd reference) */
  4565. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4566. /** RG_INTEGER */
  4567. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4568. /** RGB_INTEGER */
  4569. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4570. /** RGBA_INTEGER */
  4571. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4572. /** UNSIGNED_BYTE */
  4573. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4574. /** UNSIGNED_BYTE (2nd reference) */
  4575. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4576. /** FLOAT */
  4577. static readonly TEXTURETYPE_FLOAT: number;
  4578. /** HALF_FLOAT */
  4579. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4580. /** BYTE */
  4581. static readonly TEXTURETYPE_BYTE: number;
  4582. /** SHORT */
  4583. static readonly TEXTURETYPE_SHORT: number;
  4584. /** UNSIGNED_SHORT */
  4585. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4586. /** INT */
  4587. static readonly TEXTURETYPE_INT: number;
  4588. /** UNSIGNED_INT */
  4589. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4590. /** UNSIGNED_SHORT_4_4_4_4 */
  4591. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4592. /** UNSIGNED_SHORT_5_5_5_1 */
  4593. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4594. /** UNSIGNED_SHORT_5_6_5 */
  4595. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4596. /** UNSIGNED_INT_2_10_10_10_REV */
  4597. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4598. /** UNSIGNED_INT_24_8 */
  4599. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4600. /** UNSIGNED_INT_10F_11F_11F_REV */
  4601. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4602. /** UNSIGNED_INT_5_9_9_9_REV */
  4603. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4604. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4605. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4606. /** nearest is mag = nearest and min = nearest and mip = linear */
  4607. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4608. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4609. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4610. /** Trilinear is mag = linear and min = linear and mip = linear */
  4611. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4612. /** nearest is mag = nearest and min = nearest and mip = linear */
  4613. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4614. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4615. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4616. /** Trilinear is mag = linear and min = linear and mip = linear */
  4617. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4618. /** mag = nearest and min = nearest and mip = nearest */
  4619. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4620. /** mag = nearest and min = linear and mip = nearest */
  4621. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4622. /** mag = nearest and min = linear and mip = linear */
  4623. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4624. /** mag = nearest and min = linear and mip = none */
  4625. static readonly TEXTURE_NEAREST_LINEAR: number;
  4626. /** mag = nearest and min = nearest and mip = none */
  4627. static readonly TEXTURE_NEAREST_NEAREST: number;
  4628. /** mag = linear and min = nearest and mip = nearest */
  4629. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4630. /** mag = linear and min = nearest and mip = linear */
  4631. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4632. /** mag = linear and min = linear and mip = none */
  4633. static readonly TEXTURE_LINEAR_LINEAR: number;
  4634. /** mag = linear and min = nearest and mip = none */
  4635. static readonly TEXTURE_LINEAR_NEAREST: number;
  4636. /** Explicit coordinates mode */
  4637. static readonly TEXTURE_EXPLICIT_MODE: number;
  4638. /** Spherical coordinates mode */
  4639. static readonly TEXTURE_SPHERICAL_MODE: number;
  4640. /** Planar coordinates mode */
  4641. static readonly TEXTURE_PLANAR_MODE: number;
  4642. /** Cubic coordinates mode */
  4643. static readonly TEXTURE_CUBIC_MODE: number;
  4644. /** Projection coordinates mode */
  4645. static readonly TEXTURE_PROJECTION_MODE: number;
  4646. /** Skybox coordinates mode */
  4647. static readonly TEXTURE_SKYBOX_MODE: number;
  4648. /** Inverse Cubic coordinates mode */
  4649. static readonly TEXTURE_INVCUBIC_MODE: number;
  4650. /** Equirectangular coordinates mode */
  4651. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4652. /** Equirectangular Fixed coordinates mode */
  4653. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4654. /** Equirectangular Fixed Mirrored coordinates mode */
  4655. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4656. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4657. static readonly SCALEMODE_FLOOR: number;
  4658. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4659. static readonly SCALEMODE_NEAREST: number;
  4660. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4661. static readonly SCALEMODE_CEILING: number;
  4662. /**
  4663. * The dirty texture flag value
  4664. */
  4665. static readonly MATERIAL_TextureDirtyFlag: number;
  4666. /**
  4667. * The dirty light flag value
  4668. */
  4669. static readonly MATERIAL_LightDirtyFlag: number;
  4670. /**
  4671. * The dirty fresnel flag value
  4672. */
  4673. static readonly MATERIAL_FresnelDirtyFlag: number;
  4674. /**
  4675. * The dirty attribute flag value
  4676. */
  4677. static readonly MATERIAL_AttributesDirtyFlag: number;
  4678. /**
  4679. * The dirty misc flag value
  4680. */
  4681. static readonly MATERIAL_MiscDirtyFlag: number;
  4682. /**
  4683. * The all dirty flag value
  4684. */
  4685. static readonly MATERIAL_AllDirtyFlag: number;
  4686. /**
  4687. * Returns the triangle fill mode
  4688. */
  4689. static readonly MATERIAL_TriangleFillMode: number;
  4690. /**
  4691. * Returns the wireframe mode
  4692. */
  4693. static readonly MATERIAL_WireFrameFillMode: number;
  4694. /**
  4695. * Returns the point fill mode
  4696. */
  4697. static readonly MATERIAL_PointFillMode: number;
  4698. /**
  4699. * Returns the point list draw mode
  4700. */
  4701. static readonly MATERIAL_PointListDrawMode: number;
  4702. /**
  4703. * Returns the line list draw mode
  4704. */
  4705. static readonly MATERIAL_LineListDrawMode: number;
  4706. /**
  4707. * Returns the line loop draw mode
  4708. */
  4709. static readonly MATERIAL_LineLoopDrawMode: number;
  4710. /**
  4711. * Returns the line strip draw mode
  4712. */
  4713. static readonly MATERIAL_LineStripDrawMode: number;
  4714. /**
  4715. * Returns the triangle strip draw mode
  4716. */
  4717. static readonly MATERIAL_TriangleStripDrawMode: number;
  4718. /**
  4719. * Returns the triangle fan draw mode
  4720. */
  4721. static readonly MATERIAL_TriangleFanDrawMode: number;
  4722. /**
  4723. * Stores the clock-wise side orientation
  4724. */
  4725. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4726. /**
  4727. * Stores the counter clock-wise side orientation
  4728. */
  4729. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4730. /**
  4731. * Nothing
  4732. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4733. */
  4734. static readonly ACTION_NothingTrigger: number;
  4735. /**
  4736. * On pick
  4737. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4738. */
  4739. static readonly ACTION_OnPickTrigger: number;
  4740. /**
  4741. * On left pick
  4742. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4743. */
  4744. static readonly ACTION_OnLeftPickTrigger: number;
  4745. /**
  4746. * On right pick
  4747. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4748. */
  4749. static readonly ACTION_OnRightPickTrigger: number;
  4750. /**
  4751. * On center pick
  4752. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4753. */
  4754. static readonly ACTION_OnCenterPickTrigger: number;
  4755. /**
  4756. * On pick down
  4757. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4758. */
  4759. static readonly ACTION_OnPickDownTrigger: number;
  4760. /**
  4761. * On double pick
  4762. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4763. */
  4764. static readonly ACTION_OnDoublePickTrigger: number;
  4765. /**
  4766. * On pick up
  4767. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4768. */
  4769. static readonly ACTION_OnPickUpTrigger: number;
  4770. /**
  4771. * On pick out.
  4772. * This trigger will only be raised if you also declared a OnPickDown
  4773. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4774. */
  4775. static readonly ACTION_OnPickOutTrigger: number;
  4776. /**
  4777. * On long press
  4778. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4779. */
  4780. static readonly ACTION_OnLongPressTrigger: number;
  4781. /**
  4782. * On pointer over
  4783. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4784. */
  4785. static readonly ACTION_OnPointerOverTrigger: number;
  4786. /**
  4787. * On pointer out
  4788. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4789. */
  4790. static readonly ACTION_OnPointerOutTrigger: number;
  4791. /**
  4792. * On every frame
  4793. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4794. */
  4795. static readonly ACTION_OnEveryFrameTrigger: number;
  4796. /**
  4797. * On intersection enter
  4798. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4799. */
  4800. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4801. /**
  4802. * On intersection exit
  4803. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4804. */
  4805. static readonly ACTION_OnIntersectionExitTrigger: number;
  4806. /**
  4807. * On key down
  4808. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4809. */
  4810. static readonly ACTION_OnKeyDownTrigger: number;
  4811. /**
  4812. * On key up
  4813. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4814. */
  4815. static readonly ACTION_OnKeyUpTrigger: number;
  4816. /**
  4817. * Billboard mode will only apply to Y axis
  4818. */
  4819. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4820. /**
  4821. * Billboard mode will apply to all axes
  4822. */
  4823. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4824. /**
  4825. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4826. */
  4827. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4828. /**
  4829. * Gets or sets base Assets URL
  4830. */
  4831. static PARTICLES_BaseAssetsUrl: string;
  4832. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4833. * Test order :
  4834. * Is the bounding sphere outside the frustum ?
  4835. * If not, are the bounding box vertices outside the frustum ?
  4836. * It not, then the cullable object is in the frustum.
  4837. */
  4838. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4839. /** Culling strategy : Bounding Sphere Only.
  4840. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4841. * It's also less accurate than the standard because some not visible objects can still be selected.
  4842. * Test : is the bounding sphere outside the frustum ?
  4843. * If not, then the cullable object is in the frustum.
  4844. */
  4845. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4846. /** Culling strategy : Optimistic Inclusion.
  4847. * This in an inclusion test first, then the standard exclusion test.
  4848. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4849. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  4850. * Anyway, it's as accurate as the standard strategy.
  4851. * Test :
  4852. * Is the cullable object bounding sphere center in the frustum ?
  4853. * If not, apply the default culling strategy.
  4854. */
  4855. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4856. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4857. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4858. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4859. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  4860. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4861. * Test :
  4862. * Is the cullable object bounding sphere center in the frustum ?
  4863. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4864. */
  4865. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4866. /**
  4867. * No logging while loading
  4868. */
  4869. static readonly SCENELOADER_NO_LOGGING: number;
  4870. /**
  4871. * Minimal logging while loading
  4872. */
  4873. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4874. /**
  4875. * Summary logging while loading
  4876. */
  4877. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4878. /**
  4879. * Detailled logging while loading
  4880. */
  4881. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4882. }
  4883. }
  4884. declare module "babylonjs/Misc/domManagement" {
  4885. /**
  4886. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4887. * Babylon.js
  4888. */
  4889. export class DomManagement {
  4890. /**
  4891. * Checks if the window object exists
  4892. * @returns true if the window object exists
  4893. */
  4894. static IsWindowObjectExist(): boolean;
  4895. /**
  4896. * Extracts text content from a DOM element hierarchy
  4897. * @param element defines the root element
  4898. * @returns a string
  4899. */
  4900. static GetDOMTextContent(element: HTMLElement): string;
  4901. }
  4902. }
  4903. declare module "babylonjs/Misc/logger" {
  4904. /**
  4905. * Logger used througouht the application to allow configuration of
  4906. * the log level required for the messages.
  4907. */
  4908. export class Logger {
  4909. /**
  4910. * No log
  4911. */
  4912. static readonly NoneLogLevel: number;
  4913. /**
  4914. * Only message logs
  4915. */
  4916. static readonly MessageLogLevel: number;
  4917. /**
  4918. * Only warning logs
  4919. */
  4920. static readonly WarningLogLevel: number;
  4921. /**
  4922. * Only error logs
  4923. */
  4924. static readonly ErrorLogLevel: number;
  4925. /**
  4926. * All logs
  4927. */
  4928. static readonly AllLogLevel: number;
  4929. private static _LogCache;
  4930. /**
  4931. * Gets a value indicating the number of loading errors
  4932. * @ignorenaming
  4933. */
  4934. static errorsCount: number;
  4935. /**
  4936. * Callback called when a new log is added
  4937. */
  4938. static OnNewCacheEntry: (entry: string) => void;
  4939. private static _AddLogEntry;
  4940. private static _FormatMessage;
  4941. private static _LogDisabled;
  4942. private static _LogEnabled;
  4943. private static _WarnDisabled;
  4944. private static _WarnEnabled;
  4945. private static _ErrorDisabled;
  4946. private static _ErrorEnabled;
  4947. /**
  4948. * Log a message to the console
  4949. */
  4950. static Log: (message: string) => void;
  4951. /**
  4952. * Write a warning message to the console
  4953. */
  4954. static Warn: (message: string) => void;
  4955. /**
  4956. * Write an error message to the console
  4957. */
  4958. static Error: (message: string) => void;
  4959. /**
  4960. * Gets current log cache (list of logs)
  4961. */
  4962. static readonly LogCache: string;
  4963. /**
  4964. * Clears the log cache
  4965. */
  4966. static ClearLogCache(): void;
  4967. /**
  4968. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4969. */
  4970. static LogLevels: number;
  4971. }
  4972. }
  4973. declare module "babylonjs/Misc/typeStore" {
  4974. /** @hidden */
  4975. export class _TypeStore {
  4976. /** @hidden */
  4977. static RegisteredTypes: {
  4978. [key: string]: Object;
  4979. };
  4980. /** @hidden */
  4981. static GetClass(fqdn: string): any;
  4982. }
  4983. }
  4984. declare module "babylonjs/Misc/deepCopier" {
  4985. /**
  4986. * Class containing a set of static utilities functions for deep copy.
  4987. */
  4988. export class DeepCopier {
  4989. /**
  4990. * Tries to copy an object by duplicating every property
  4991. * @param source defines the source object
  4992. * @param destination defines the target object
  4993. * @param doNotCopyList defines a list of properties to avoid
  4994. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4995. */
  4996. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4997. }
  4998. }
  4999. declare module "babylonjs/Misc/precisionDate" {
  5000. /**
  5001. * Class containing a set of static utilities functions for precision date
  5002. */
  5003. export class PrecisionDate {
  5004. /**
  5005. * Gets either window.performance.now() if supported or Date.now() else
  5006. */
  5007. static readonly Now: number;
  5008. }
  5009. }
  5010. declare module "babylonjs/Misc/devTools" {
  5011. /** @hidden */
  5012. export class _DevTools {
  5013. static WarnImport(name: string): string;
  5014. }
  5015. }
  5016. declare module "babylonjs/Misc/webRequest" {
  5017. /**
  5018. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  5019. */
  5020. export class WebRequest {
  5021. private _xhr;
  5022. /**
  5023. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  5024. * i.e. when loading files, where the server/service expects an Authorization header
  5025. */
  5026. static CustomRequestHeaders: {
  5027. [key: string]: string;
  5028. };
  5029. /**
  5030. * Add callback functions in this array to update all the requests before they get sent to the network
  5031. */
  5032. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  5033. private _injectCustomRequestHeaders;
  5034. /**
  5035. * Gets or sets a function to be called when loading progress changes
  5036. */
  5037. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  5038. /**
  5039. * Returns client's state
  5040. */
  5041. readonly readyState: number;
  5042. /**
  5043. * Returns client's status
  5044. */
  5045. readonly status: number;
  5046. /**
  5047. * Returns client's status as a text
  5048. */
  5049. readonly statusText: string;
  5050. /**
  5051. * Returns client's response
  5052. */
  5053. readonly response: any;
  5054. /**
  5055. * Returns client's response url
  5056. */
  5057. readonly responseURL: string;
  5058. /**
  5059. * Returns client's response as text
  5060. */
  5061. readonly responseText: string;
  5062. /**
  5063. * Gets or sets the expected response type
  5064. */
  5065. responseType: XMLHttpRequestResponseType;
  5066. /** @hidden */
  5067. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  5068. /** @hidden */
  5069. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  5070. /**
  5071. * Cancels any network activity
  5072. */
  5073. abort(): void;
  5074. /**
  5075. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  5076. * @param body defines an optional request body
  5077. */
  5078. send(body?: Document | BodyInit | null): void;
  5079. /**
  5080. * Sets the request method, request URL
  5081. * @param method defines the method to use (GET, POST, etc..)
  5082. * @param url defines the url to connect with
  5083. */
  5084. open(method: string, url: string): void;
  5085. }
  5086. }
  5087. declare module "babylonjs/Misc/andOrNotEvaluator" {
  5088. /**
  5089. * Class used to evalaute queries containing `and` and `or` operators
  5090. */
  5091. export class AndOrNotEvaluator {
  5092. /**
  5093. * Evaluate a query
  5094. * @param query defines the query to evaluate
  5095. * @param evaluateCallback defines the callback used to filter result
  5096. * @returns true if the query matches
  5097. */
  5098. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5099. private static _HandleParenthesisContent;
  5100. private static _SimplifyNegation;
  5101. }
  5102. }
  5103. declare module "babylonjs/Misc/tags" {
  5104. /**
  5105. * Class used to store custom tags
  5106. */
  5107. export class Tags {
  5108. /**
  5109. * Adds support for tags on the given object
  5110. * @param obj defines the object to use
  5111. */
  5112. static EnableFor(obj: any): void;
  5113. /**
  5114. * Removes tags support
  5115. * @param obj defines the object to use
  5116. */
  5117. static DisableFor(obj: any): void;
  5118. /**
  5119. * Gets a boolean indicating if the given object has tags
  5120. * @param obj defines the object to use
  5121. * @returns a boolean
  5122. */
  5123. static HasTags(obj: any): boolean;
  5124. /**
  5125. * Gets the tags available on a given object
  5126. * @param obj defines the object to use
  5127. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5128. * @returns the tags
  5129. */
  5130. static GetTags(obj: any, asString?: boolean): any;
  5131. /**
  5132. * Adds tags to an object
  5133. * @param obj defines the object to use
  5134. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5135. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5136. */
  5137. static AddTagsTo(obj: any, tagsString: string): void;
  5138. /**
  5139. * @hidden
  5140. */
  5141. static _AddTagTo(obj: any, tag: string): void;
  5142. /**
  5143. * Removes specific tags from a specific object
  5144. * @param obj defines the object to use
  5145. * @param tagsString defines the tags to remove
  5146. */
  5147. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5148. /**
  5149. * @hidden
  5150. */
  5151. static _RemoveTagFrom(obj: any, tag: string): void;
  5152. /**
  5153. * Defines if tags hosted on an object match a given query
  5154. * @param obj defines the object to use
  5155. * @param tagsQuery defines the tag query
  5156. * @returns a boolean
  5157. */
  5158. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5159. }
  5160. }
  5161. declare module "babylonjs/Materials/materialDefines" {
  5162. /**
  5163. * Manages the defines for the Material
  5164. */
  5165. export class MaterialDefines {
  5166. /** @hidden */
  5167. protected _keys: string[];
  5168. private _isDirty;
  5169. /** @hidden */
  5170. _renderId: number;
  5171. /** @hidden */
  5172. _areLightsDirty: boolean;
  5173. /** @hidden */
  5174. _areAttributesDirty: boolean;
  5175. /** @hidden */
  5176. _areTexturesDirty: boolean;
  5177. /** @hidden */
  5178. _areFresnelDirty: boolean;
  5179. /** @hidden */
  5180. _areMiscDirty: boolean;
  5181. /** @hidden */
  5182. _areImageProcessingDirty: boolean;
  5183. /** @hidden */
  5184. _normals: boolean;
  5185. /** @hidden */
  5186. _uvs: boolean;
  5187. /** @hidden */
  5188. _needNormals: boolean;
  5189. /** @hidden */
  5190. _needUVs: boolean;
  5191. [id: string]: any;
  5192. /**
  5193. * Specifies if the material needs to be re-calculated
  5194. */
  5195. readonly isDirty: boolean;
  5196. /**
  5197. * Marks the material to indicate that it has been re-calculated
  5198. */
  5199. markAsProcessed(): void;
  5200. /**
  5201. * Marks the material to indicate that it needs to be re-calculated
  5202. */
  5203. markAsUnprocessed(): void;
  5204. /**
  5205. * Marks the material to indicate all of its defines need to be re-calculated
  5206. */
  5207. markAllAsDirty(): void;
  5208. /**
  5209. * Marks the material to indicate that image processing needs to be re-calculated
  5210. */
  5211. markAsImageProcessingDirty(): void;
  5212. /**
  5213. * Marks the material to indicate the lights need to be re-calculated
  5214. */
  5215. markAsLightDirty(): void;
  5216. /**
  5217. * Marks the attribute state as changed
  5218. */
  5219. markAsAttributesDirty(): void;
  5220. /**
  5221. * Marks the texture state as changed
  5222. */
  5223. markAsTexturesDirty(): void;
  5224. /**
  5225. * Marks the fresnel state as changed
  5226. */
  5227. markAsFresnelDirty(): void;
  5228. /**
  5229. * Marks the misc state as changed
  5230. */
  5231. markAsMiscDirty(): void;
  5232. /**
  5233. * Rebuilds the material defines
  5234. */
  5235. rebuild(): void;
  5236. /**
  5237. * Specifies if two material defines are equal
  5238. * @param other - A material define instance to compare to
  5239. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5240. */
  5241. isEqual(other: MaterialDefines): boolean;
  5242. /**
  5243. * Clones this instance's defines to another instance
  5244. * @param other - material defines to clone values to
  5245. */
  5246. cloneTo(other: MaterialDefines): void;
  5247. /**
  5248. * Resets the material define values
  5249. */
  5250. reset(): void;
  5251. /**
  5252. * Converts the material define values to a string
  5253. * @returns - String of material define information
  5254. */
  5255. toString(): string;
  5256. }
  5257. }
  5258. declare module "babylonjs/Engines/IPipelineContext" {
  5259. /**
  5260. * Class used to store and describe the pipeline context associated with an effect
  5261. */
  5262. export interface IPipelineContext {
  5263. /**
  5264. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  5265. */
  5266. isAsync: boolean;
  5267. /**
  5268. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  5269. */
  5270. isReady: boolean;
  5271. /** @hidden */
  5272. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  5273. }
  5274. }
  5275. declare module "babylonjs/Meshes/dataBuffer" {
  5276. /**
  5277. * Class used to store gfx data (like WebGLBuffer)
  5278. */
  5279. export class DataBuffer {
  5280. /**
  5281. * Gets or sets the number of objects referencing this buffer
  5282. */
  5283. references: number;
  5284. /** Gets or sets the size of the underlying buffer */
  5285. capacity: number;
  5286. /**
  5287. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  5288. */
  5289. is32Bits: boolean;
  5290. /**
  5291. * Gets the underlying buffer
  5292. */
  5293. readonly underlyingResource: any;
  5294. }
  5295. }
  5296. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  5297. /** @hidden */
  5298. export interface IShaderProcessor {
  5299. attributeProcessor?: (attribute: string) => string;
  5300. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  5301. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  5302. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  5303. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  5304. lineProcessor?: (line: string, isFragment: boolean) => string;
  5305. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  5306. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  5307. }
  5308. }
  5309. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  5310. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  5311. /** @hidden */
  5312. export interface ProcessingOptions {
  5313. defines: string[];
  5314. indexParameters: any;
  5315. isFragment: boolean;
  5316. shouldUseHighPrecisionShader: boolean;
  5317. supportsUniformBuffers: boolean;
  5318. shadersRepository: string;
  5319. includesShadersStore: {
  5320. [key: string]: string;
  5321. };
  5322. processor?: IShaderProcessor;
  5323. version: string;
  5324. platformName: string;
  5325. lookForClosingBracketForUniformBuffer?: boolean;
  5326. }
  5327. }
  5328. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  5329. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  5330. /** @hidden */
  5331. export class ShaderCodeNode {
  5332. line: string;
  5333. children: ShaderCodeNode[];
  5334. additionalDefineKey?: string;
  5335. additionalDefineValue?: string;
  5336. isValid(preprocessors: {
  5337. [key: string]: string;
  5338. }): boolean;
  5339. process(preprocessors: {
  5340. [key: string]: string;
  5341. }, options: ProcessingOptions): string;
  5342. }
  5343. }
  5344. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  5345. /** @hidden */
  5346. export class ShaderCodeCursor {
  5347. private _lines;
  5348. lineIndex: number;
  5349. readonly currentLine: string;
  5350. readonly canRead: boolean;
  5351. lines: string[];
  5352. }
  5353. }
  5354. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  5355. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  5356. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  5357. /** @hidden */
  5358. export class ShaderCodeConditionNode extends ShaderCodeNode {
  5359. process(preprocessors: {
  5360. [key: string]: string;
  5361. }, options: ProcessingOptions): string;
  5362. }
  5363. }
  5364. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  5365. /** @hidden */
  5366. export class ShaderDefineExpression {
  5367. isTrue(preprocessors: {
  5368. [key: string]: string;
  5369. }): boolean;
  5370. }
  5371. }
  5372. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  5373. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  5374. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  5375. /** @hidden */
  5376. export class ShaderCodeTestNode extends ShaderCodeNode {
  5377. testExpression: ShaderDefineExpression;
  5378. isValid(preprocessors: {
  5379. [key: string]: string;
  5380. }): boolean;
  5381. }
  5382. }
  5383. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  5384. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  5385. /** @hidden */
  5386. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  5387. define: string;
  5388. not: boolean;
  5389. constructor(define: string, not?: boolean);
  5390. isTrue(preprocessors: {
  5391. [key: string]: string;
  5392. }): boolean;
  5393. }
  5394. }
  5395. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  5396. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  5397. /** @hidden */
  5398. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  5399. leftOperand: ShaderDefineExpression;
  5400. rightOperand: ShaderDefineExpression;
  5401. isTrue(preprocessors: {
  5402. [key: string]: string;
  5403. }): boolean;
  5404. }
  5405. }
  5406. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  5407. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  5408. /** @hidden */
  5409. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  5410. leftOperand: ShaderDefineExpression;
  5411. rightOperand: ShaderDefineExpression;
  5412. isTrue(preprocessors: {
  5413. [key: string]: string;
  5414. }): boolean;
  5415. }
  5416. }
  5417. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  5418. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  5419. /** @hidden */
  5420. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  5421. define: string;
  5422. operand: string;
  5423. testValue: string;
  5424. constructor(define: string, operand: string, testValue: string);
  5425. isTrue(preprocessors: {
  5426. [key: string]: string;
  5427. }): boolean;
  5428. }
  5429. }
  5430. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  5431. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  5432. /** @hidden */
  5433. export class ShaderProcessor {
  5434. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  5435. private static _ProcessPrecision;
  5436. private static _ExtractOperation;
  5437. private static _BuildSubExpression;
  5438. private static _BuildExpression;
  5439. private static _MoveCursorWithinIf;
  5440. private static _MoveCursor;
  5441. private static _EvaluatePreProcessors;
  5442. private static _PreparePreProcessors;
  5443. private static _ProcessShaderConversion;
  5444. private static _ProcessIncludes;
  5445. }
  5446. }
  5447. declare module "babylonjs/Misc/performanceMonitor" {
  5448. /**
  5449. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5450. */
  5451. export class PerformanceMonitor {
  5452. private _enabled;
  5453. private _rollingFrameTime;
  5454. private _lastFrameTimeMs;
  5455. /**
  5456. * constructor
  5457. * @param frameSampleSize The number of samples required to saturate the sliding window
  5458. */
  5459. constructor(frameSampleSize?: number);
  5460. /**
  5461. * Samples current frame
  5462. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5463. */
  5464. sampleFrame(timeMs?: number): void;
  5465. /**
  5466. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5467. */
  5468. readonly averageFrameTime: number;
  5469. /**
  5470. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5471. */
  5472. readonly averageFrameTimeVariance: number;
  5473. /**
  5474. * Returns the frame time of the most recent frame
  5475. */
  5476. readonly instantaneousFrameTime: number;
  5477. /**
  5478. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5479. */
  5480. readonly averageFPS: number;
  5481. /**
  5482. * Returns the average framerate in frames per second using the most recent frame time
  5483. */
  5484. readonly instantaneousFPS: number;
  5485. /**
  5486. * Returns true if enough samples have been taken to completely fill the sliding window
  5487. */
  5488. readonly isSaturated: boolean;
  5489. /**
  5490. * Enables contributions to the sliding window sample set
  5491. */
  5492. enable(): void;
  5493. /**
  5494. * Disables contributions to the sliding window sample set
  5495. * Samples will not be interpolated over the disabled period
  5496. */
  5497. disable(): void;
  5498. /**
  5499. * Returns true if sampling is enabled
  5500. */
  5501. readonly isEnabled: boolean;
  5502. /**
  5503. * Resets performance monitor
  5504. */
  5505. reset(): void;
  5506. }
  5507. /**
  5508. * RollingAverage
  5509. *
  5510. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5511. */
  5512. export class RollingAverage {
  5513. /**
  5514. * Current average
  5515. */
  5516. average: number;
  5517. /**
  5518. * Current variance
  5519. */
  5520. variance: number;
  5521. protected _samples: Array<number>;
  5522. protected _sampleCount: number;
  5523. protected _pos: number;
  5524. protected _m2: number;
  5525. /**
  5526. * constructor
  5527. * @param length The number of samples required to saturate the sliding window
  5528. */
  5529. constructor(length: number);
  5530. /**
  5531. * Adds a sample to the sample set
  5532. * @param v The sample value
  5533. */
  5534. add(v: number): void;
  5535. /**
  5536. * Returns previously added values or null if outside of history or outside the sliding window domain
  5537. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5538. * @return Value previously recorded with add() or null if outside of range
  5539. */
  5540. history(i: number): number;
  5541. /**
  5542. * Returns true if enough samples have been taken to completely fill the sliding window
  5543. * @return true if sample-set saturated
  5544. */
  5545. isSaturated(): boolean;
  5546. /**
  5547. * Resets the rolling average (equivalent to 0 samples taken so far)
  5548. */
  5549. reset(): void;
  5550. /**
  5551. * Wraps a value around the sample range boundaries
  5552. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5553. * @return Wrapped position in sample range
  5554. */
  5555. protected _wrapPosition(i: number): number;
  5556. }
  5557. }
  5558. declare module "babylonjs/Misc/stringDictionary" {
  5559. import { Nullable } from "babylonjs/types";
  5560. /**
  5561. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5562. * The underlying implementation relies on an associative array to ensure the best performances.
  5563. * The value can be anything including 'null' but except 'undefined'
  5564. */
  5565. export class StringDictionary<T> {
  5566. /**
  5567. * This will clear this dictionary and copy the content from the 'source' one.
  5568. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5569. * @param source the dictionary to take the content from and copy to this dictionary
  5570. */
  5571. copyFrom(source: StringDictionary<T>): void;
  5572. /**
  5573. * Get a value based from its key
  5574. * @param key the given key to get the matching value from
  5575. * @return the value if found, otherwise undefined is returned
  5576. */
  5577. get(key: string): T | undefined;
  5578. /**
  5579. * Get a value from its key or add it if it doesn't exist.
  5580. * This method will ensure you that a given key/data will be present in the dictionary.
  5581. * @param key the given key to get the matching value from
  5582. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5583. * The factory will only be invoked if there's no data for the given key.
  5584. * @return the value corresponding to the key.
  5585. */
  5586. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5587. /**
  5588. * Get a value from its key if present in the dictionary otherwise add it
  5589. * @param key the key to get the value from
  5590. * @param val if there's no such key/value pair in the dictionary add it with this value
  5591. * @return the value corresponding to the key
  5592. */
  5593. getOrAdd(key: string, val: T): T;
  5594. /**
  5595. * Check if there's a given key in the dictionary
  5596. * @param key the key to check for
  5597. * @return true if the key is present, false otherwise
  5598. */
  5599. contains(key: string): boolean;
  5600. /**
  5601. * Add a new key and its corresponding value
  5602. * @param key the key to add
  5603. * @param value the value corresponding to the key
  5604. * @return true if the operation completed successfully, false if we couldn't insert the key/value because there was already this key in the dictionary
  5605. */
  5606. add(key: string, value: T): boolean;
  5607. /**
  5608. * Update a specific value associated to a key
  5609. * @param key defines the key to use
  5610. * @param value defines the value to store
  5611. * @returns true if the value was updated (or false if the key was not found)
  5612. */
  5613. set(key: string, value: T): boolean;
  5614. /**
  5615. * Get the element of the given key and remove it from the dictionary
  5616. * @param key defines the key to search
  5617. * @returns the value associated with the key or null if not found
  5618. */
  5619. getAndRemove(key: string): Nullable<T>;
  5620. /**
  5621. * Remove a key/value from the dictionary.
  5622. * @param key the key to remove
  5623. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5624. */
  5625. remove(key: string): boolean;
  5626. /**
  5627. * Clear the whole content of the dictionary
  5628. */
  5629. clear(): void;
  5630. /**
  5631. * Gets the current count
  5632. */
  5633. readonly count: number;
  5634. /**
  5635. * Execute a callback on each key/val of the dictionary.
  5636. * Note that you can remove any element in this dictionary in the callback implementation
  5637. * @param callback the callback to execute on a given key/value pair
  5638. */
  5639. forEach(callback: (key: string, val: T) => void): void;
  5640. /**
  5641. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5642. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5643. * Note that you can remove any element in this dictionary in the callback implementation
  5644. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5645. * @returns the first item
  5646. */
  5647. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5648. private _count;
  5649. private _data;
  5650. }
  5651. }
  5652. declare module "babylonjs/Misc/promise" {
  5653. /**
  5654. * Helper class that provides a small promise polyfill
  5655. */
  5656. export class PromisePolyfill {
  5657. /**
  5658. * Static function used to check if the polyfill is required
  5659. * If this is the case then the function will inject the polyfill to window.Promise
  5660. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5661. */
  5662. static Apply(force?: boolean): void;
  5663. }
  5664. }
  5665. declare module "babylonjs/Meshes/buffer" {
  5666. import { Nullable, DataArray } from "babylonjs/types";
  5667. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  5668. /**
  5669. * Class used to store data that will be store in GPU memory
  5670. */
  5671. export class Buffer {
  5672. private _engine;
  5673. private _buffer;
  5674. /** @hidden */
  5675. _data: Nullable<DataArray>;
  5676. private _updatable;
  5677. private _instanced;
  5678. /**
  5679. * Gets the byte stride.
  5680. */
  5681. readonly byteStride: number;
  5682. /**
  5683. * Constructor
  5684. * @param engine the engine
  5685. * @param data the data to use for this buffer
  5686. * @param updatable whether the data is updatable
  5687. * @param stride the stride (optional)
  5688. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5689. * @param instanced whether the buffer is instanced (optional)
  5690. * @param useBytes set to true if the stride in in bytes (optional)
  5691. */
  5692. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5693. /**
  5694. * Create a new VertexBuffer based on the current buffer
  5695. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5696. * @param offset defines offset in the buffer (0 by default)
  5697. * @param size defines the size in floats of attributes (position is 3 for instance)
  5698. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5699. * @param instanced defines if the vertex buffer contains indexed data
  5700. * @param useBytes defines if the offset and stride are in bytes
  5701. * @returns the new vertex buffer
  5702. */
  5703. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5704. /**
  5705. * Gets a boolean indicating if the Buffer is updatable?
  5706. * @returns true if the buffer is updatable
  5707. */
  5708. isUpdatable(): boolean;
  5709. /**
  5710. * Gets current buffer's data
  5711. * @returns a DataArray or null
  5712. */
  5713. getData(): Nullable<DataArray>;
  5714. /**
  5715. * Gets underlying native buffer
  5716. * @returns underlying native buffer
  5717. */
  5718. getBuffer(): Nullable<DataBuffer>;
  5719. /**
  5720. * Gets the stride in float32 units (i.e. byte stride / 4).
  5721. * May not be an integer if the byte stride is not divisible by 4.
  5722. * DEPRECATED. Use byteStride instead.
  5723. * @returns the stride in float32 units
  5724. */
  5725. getStrideSize(): number;
  5726. /**
  5727. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5728. * @param data defines the data to store
  5729. */
  5730. create(data?: Nullable<DataArray>): void;
  5731. /** @hidden */
  5732. _rebuild(): void;
  5733. /**
  5734. * Update current buffer data
  5735. * @param data defines the data to store
  5736. */
  5737. update(data: DataArray): void;
  5738. /**
  5739. * Updates the data directly.
  5740. * @param data the new data
  5741. * @param offset the new offset
  5742. * @param vertexCount the vertex count (optional)
  5743. * @param useBytes set to true if the offset is in bytes
  5744. */
  5745. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5746. /**
  5747. * Release all resources
  5748. */
  5749. dispose(): void;
  5750. }
  5751. /**
  5752. * Specialized buffer used to store vertex data
  5753. */
  5754. export class VertexBuffer {
  5755. /** @hidden */
  5756. _buffer: Buffer;
  5757. private _kind;
  5758. private _size;
  5759. private _ownsBuffer;
  5760. private _instanced;
  5761. private _instanceDivisor;
  5762. /**
  5763. * The byte type.
  5764. */
  5765. static readonly BYTE: number;
  5766. /**
  5767. * The unsigned byte type.
  5768. */
  5769. static readonly UNSIGNED_BYTE: number;
  5770. /**
  5771. * The short type.
  5772. */
  5773. static readonly SHORT: number;
  5774. /**
  5775. * The unsigned short type.
  5776. */
  5777. static readonly UNSIGNED_SHORT: number;
  5778. /**
  5779. * The integer type.
  5780. */
  5781. static readonly INT: number;
  5782. /**
  5783. * The unsigned integer type.
  5784. */
  5785. static readonly UNSIGNED_INT: number;
  5786. /**
  5787. * The float type.
  5788. */
  5789. static readonly FLOAT: number;
  5790. /**
  5791. * Gets or sets the instance divisor when in instanced mode
  5792. */
  5793. instanceDivisor: number;
  5794. /**
  5795. * Gets the byte stride.
  5796. */
  5797. readonly byteStride: number;
  5798. /**
  5799. * Gets the byte offset.
  5800. */
  5801. readonly byteOffset: number;
  5802. /**
  5803. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5804. */
  5805. readonly normalized: boolean;
  5806. /**
  5807. * Gets the data type of each component in the array.
  5808. */
  5809. readonly type: number;
  5810. /**
  5811. * Constructor
  5812. * @param engine the engine
  5813. * @param data the data to use for this vertex buffer
  5814. * @param kind the vertex buffer kind
  5815. * @param updatable whether the data is updatable
  5816. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5817. * @param stride the stride (optional)
  5818. * @param instanced whether the buffer is instanced (optional)
  5819. * @param offset the offset of the data (optional)
  5820. * @param size the number of components (optional)
  5821. * @param type the type of the component (optional)
  5822. * @param normalized whether the data contains normalized data (optional)
  5823. * @param useBytes set to true if stride and offset are in bytes (optional)
  5824. */
  5825. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean);
  5826. /** @hidden */
  5827. _rebuild(): void;
  5828. /**
  5829. * Returns the kind of the VertexBuffer (string)
  5830. * @returns a string
  5831. */
  5832. getKind(): string;
  5833. /**
  5834. * Gets a boolean indicating if the VertexBuffer is updatable?
  5835. * @returns true if the buffer is updatable
  5836. */
  5837. isUpdatable(): boolean;
  5838. /**
  5839. * Gets current buffer's data
  5840. * @returns a DataArray or null
  5841. */
  5842. getData(): Nullable<DataArray>;
  5843. /**
  5844. * Gets underlying native buffer
  5845. * @returns underlying native buffer
  5846. */
  5847. getBuffer(): Nullable<DataBuffer>;
  5848. /**
  5849. * Gets the stride in float32 units (i.e. byte stride / 4).
  5850. * May not be an integer if the byte stride is not divisible by 4.
  5851. * DEPRECATED. Use byteStride instead.
  5852. * @returns the stride in float32 units
  5853. */
  5854. getStrideSize(): number;
  5855. /**
  5856. * Returns the offset as a multiple of the type byte length.
  5857. * DEPRECATED. Use byteOffset instead.
  5858. * @returns the offset in bytes
  5859. */
  5860. getOffset(): number;
  5861. /**
  5862. * Returns the number of components per vertex attribute (integer)
  5863. * @returns the size in float
  5864. */
  5865. getSize(): number;
  5866. /**
  5867. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5868. * @returns true if this buffer is instanced
  5869. */
  5870. getIsInstanced(): boolean;
  5871. /**
  5872. * Returns the instancing divisor, zero for non-instanced (integer).
  5873. * @returns a number
  5874. */
  5875. getInstanceDivisor(): number;
  5876. /**
  5877. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5878. * @param data defines the data to store
  5879. */
  5880. create(data?: DataArray): void;
  5881. /**
  5882. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5883. * This function will create a new buffer if the current one is not updatable
  5884. * @param data defines the data to store
  5885. */
  5886. update(data: DataArray): void;
  5887. /**
  5888. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5889. * Returns the directly updated WebGLBuffer.
  5890. * @param data the new data
  5891. * @param offset the new offset
  5892. * @param useBytes set to true if the offset is in bytes
  5893. */
  5894. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5895. /**
  5896. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5897. */
  5898. dispose(): void;
  5899. /**
  5900. * Enumerates each value of this vertex buffer as numbers.
  5901. * @param count the number of values to enumerate
  5902. * @param callback the callback function called for each value
  5903. */
  5904. forEach(count: number, callback: (value: number, index: number) => void): void;
  5905. /**
  5906. * Positions
  5907. */
  5908. static readonly PositionKind: string;
  5909. /**
  5910. * Normals
  5911. */
  5912. static readonly NormalKind: string;
  5913. /**
  5914. * Tangents
  5915. */
  5916. static readonly TangentKind: string;
  5917. /**
  5918. * Texture coordinates
  5919. */
  5920. static readonly UVKind: string;
  5921. /**
  5922. * Texture coordinates 2
  5923. */
  5924. static readonly UV2Kind: string;
  5925. /**
  5926. * Texture coordinates 3
  5927. */
  5928. static readonly UV3Kind: string;
  5929. /**
  5930. * Texture coordinates 4
  5931. */
  5932. static readonly UV4Kind: string;
  5933. /**
  5934. * Texture coordinates 5
  5935. */
  5936. static readonly UV5Kind: string;
  5937. /**
  5938. * Texture coordinates 6
  5939. */
  5940. static readonly UV6Kind: string;
  5941. /**
  5942. * Colors
  5943. */
  5944. static readonly ColorKind: string;
  5945. /**
  5946. * Matrix indices (for bones)
  5947. */
  5948. static readonly MatricesIndicesKind: string;
  5949. /**
  5950. * Matrix weights (for bones)
  5951. */
  5952. static readonly MatricesWeightsKind: string;
  5953. /**
  5954. * Additional matrix indices (for bones)
  5955. */
  5956. static readonly MatricesIndicesExtraKind: string;
  5957. /**
  5958. * Additional matrix weights (for bones)
  5959. */
  5960. static readonly MatricesWeightsExtraKind: string;
  5961. /**
  5962. * Deduces the stride given a kind.
  5963. * @param kind The kind string to deduce
  5964. * @returns The deduced stride
  5965. */
  5966. static DeduceStride(kind: string): number;
  5967. /**
  5968. * Gets the byte length of the given type.
  5969. * @param type the type
  5970. * @returns the number of bytes
  5971. */
  5972. static GetTypeByteLength(type: number): number;
  5973. /**
  5974. * Enumerates each value of the given parameters as numbers.
  5975. * @param data the data to enumerate
  5976. * @param byteOffset the byte offset of the data
  5977. * @param byteStride the byte stride of the data
  5978. * @param componentCount the number of components per element
  5979. * @param componentType the type of the component
  5980. * @param count the number of values to enumerate
  5981. * @param normalized whether the data is normalized
  5982. * @param callback the callback function called for each value
  5983. */
  5984. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5985. private static _GetFloatValue;
  5986. }
  5987. }
  5988. declare module "babylonjs/Maths/sphericalPolynomial" {
  5989. import { Vector3, Color3 } from "babylonjs/Maths/math";
  5990. /**
  5991. * Class representing spherical harmonics coefficients to the 3rd degree
  5992. */
  5993. export class SphericalHarmonics {
  5994. /**
  5995. * Defines whether or not the harmonics have been prescaled for rendering.
  5996. */
  5997. preScaled: boolean;
  5998. /**
  5999. * The l0,0 coefficients of the spherical harmonics
  6000. */
  6001. l00: Vector3;
  6002. /**
  6003. * The l1,-1 coefficients of the spherical harmonics
  6004. */
  6005. l1_1: Vector3;
  6006. /**
  6007. * The l1,0 coefficients of the spherical harmonics
  6008. */
  6009. l10: Vector3;
  6010. /**
  6011. * The l1,1 coefficients of the spherical harmonics
  6012. */
  6013. l11: Vector3;
  6014. /**
  6015. * The l2,-2 coefficients of the spherical harmonics
  6016. */
  6017. l2_2: Vector3;
  6018. /**
  6019. * The l2,-1 coefficients of the spherical harmonics
  6020. */
  6021. l2_1: Vector3;
  6022. /**
  6023. * The l2,0 coefficients of the spherical harmonics
  6024. */
  6025. l20: Vector3;
  6026. /**
  6027. * The l2,1 coefficients of the spherical harmonics
  6028. */
  6029. l21: Vector3;
  6030. /**
  6031. * The l2,2 coefficients of the spherical harmonics
  6032. */
  6033. l22: Vector3;
  6034. /**
  6035. * Adds a light to the spherical harmonics
  6036. * @param direction the direction of the light
  6037. * @param color the color of the light
  6038. * @param deltaSolidAngle the delta solid angle of the light
  6039. */
  6040. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  6041. /**
  6042. * Scales the spherical harmonics by the given amount
  6043. * @param scale the amount to scale
  6044. */
  6045. scaleInPlace(scale: number): void;
  6046. /**
  6047. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  6048. *
  6049. * ```
  6050. * E_lm = A_l * L_lm
  6051. * ```
  6052. *
  6053. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  6054. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  6055. * the scaling factors are given in equation 9.
  6056. */
  6057. convertIncidentRadianceToIrradiance(): void;
  6058. /**
  6059. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  6060. *
  6061. * ```
  6062. * L = (1/pi) * E * rho
  6063. * ```
  6064. *
  6065. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  6066. */
  6067. convertIrradianceToLambertianRadiance(): void;
  6068. /**
  6069. * Integrates the reconstruction coefficients directly in to the SH preventing further
  6070. * required operations at run time.
  6071. *
  6072. * This is simply done by scaling back the SH with Ylm constants parameter.
  6073. * The trigonometric part being applied by the shader at run time.
  6074. */
  6075. preScaleForRendering(): void;
  6076. /**
  6077. * Constructs a spherical harmonics from an array.
  6078. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  6079. * @returns the spherical harmonics
  6080. */
  6081. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  6082. /**
  6083. * Gets the spherical harmonics from polynomial
  6084. * @param polynomial the spherical polynomial
  6085. * @returns the spherical harmonics
  6086. */
  6087. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  6088. }
  6089. /**
  6090. * Class representing spherical polynomial coefficients to the 3rd degree
  6091. */
  6092. export class SphericalPolynomial {
  6093. private _harmonics;
  6094. /**
  6095. * The spherical harmonics used to create the polynomials.
  6096. */
  6097. readonly preScaledHarmonics: SphericalHarmonics;
  6098. /**
  6099. * The x coefficients of the spherical polynomial
  6100. */
  6101. x: Vector3;
  6102. /**
  6103. * The y coefficients of the spherical polynomial
  6104. */
  6105. y: Vector3;
  6106. /**
  6107. * The z coefficients of the spherical polynomial
  6108. */
  6109. z: Vector3;
  6110. /**
  6111. * The xx coefficients of the spherical polynomial
  6112. */
  6113. xx: Vector3;
  6114. /**
  6115. * The yy coefficients of the spherical polynomial
  6116. */
  6117. yy: Vector3;
  6118. /**
  6119. * The zz coefficients of the spherical polynomial
  6120. */
  6121. zz: Vector3;
  6122. /**
  6123. * The xy coefficients of the spherical polynomial
  6124. */
  6125. xy: Vector3;
  6126. /**
  6127. * The yz coefficients of the spherical polynomial
  6128. */
  6129. yz: Vector3;
  6130. /**
  6131. * The zx coefficients of the spherical polynomial
  6132. */
  6133. zx: Vector3;
  6134. /**
  6135. * Adds an ambient color to the spherical polynomial
  6136. * @param color the color to add
  6137. */
  6138. addAmbient(color: Color3): void;
  6139. /**
  6140. * Scales the spherical polynomial by the given amount
  6141. * @param scale the amount to scale
  6142. */
  6143. scaleInPlace(scale: number): void;
  6144. /**
  6145. * Gets the spherical polynomial from harmonics
  6146. * @param harmonics the spherical harmonics
  6147. * @returns the spherical polynomial
  6148. */
  6149. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  6150. /**
  6151. * Constructs a spherical polynomial from an array.
  6152. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  6153. * @returns the spherical polynomial
  6154. */
  6155. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  6156. }
  6157. }
  6158. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  6159. import { Nullable } from "babylonjs/types";
  6160. /**
  6161. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  6162. */
  6163. export interface CubeMapInfo {
  6164. /**
  6165. * The pixel array for the front face.
  6166. * This is stored in format, left to right, up to down format.
  6167. */
  6168. front: Nullable<ArrayBufferView>;
  6169. /**
  6170. * The pixel array for the back face.
  6171. * This is stored in format, left to right, up to down format.
  6172. */
  6173. back: Nullable<ArrayBufferView>;
  6174. /**
  6175. * The pixel array for the left face.
  6176. * This is stored in format, left to right, up to down format.
  6177. */
  6178. left: Nullable<ArrayBufferView>;
  6179. /**
  6180. * The pixel array for the right face.
  6181. * This is stored in format, left to right, up to down format.
  6182. */
  6183. right: Nullable<ArrayBufferView>;
  6184. /**
  6185. * The pixel array for the up face.
  6186. * This is stored in format, left to right, up to down format.
  6187. */
  6188. up: Nullable<ArrayBufferView>;
  6189. /**
  6190. * The pixel array for the down face.
  6191. * This is stored in format, left to right, up to down format.
  6192. */
  6193. down: Nullable<ArrayBufferView>;
  6194. /**
  6195. * The size of the cubemap stored.
  6196. *
  6197. * Each faces will be size * size pixels.
  6198. */
  6199. size: number;
  6200. /**
  6201. * The format of the texture.
  6202. *
  6203. * RGBA, RGB.
  6204. */
  6205. format: number;
  6206. /**
  6207. * The type of the texture data.
  6208. *
  6209. * UNSIGNED_INT, FLOAT.
  6210. */
  6211. type: number;
  6212. /**
  6213. * Specifies whether the texture is in gamma space.
  6214. */
  6215. gammaSpace: boolean;
  6216. }
  6217. /**
  6218. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  6219. */
  6220. export class PanoramaToCubeMapTools {
  6221. private static FACE_FRONT;
  6222. private static FACE_BACK;
  6223. private static FACE_RIGHT;
  6224. private static FACE_LEFT;
  6225. private static FACE_DOWN;
  6226. private static FACE_UP;
  6227. /**
  6228. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  6229. *
  6230. * @param float32Array The source data.
  6231. * @param inputWidth The width of the input panorama.
  6232. * @param inputHeight The height of the input panorama.
  6233. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  6234. * @return The cubemap data
  6235. */
  6236. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  6237. private static CreateCubemapTexture;
  6238. private static CalcProjectionSpherical;
  6239. }
  6240. }
  6241. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  6242. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6243. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6244. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  6245. /**
  6246. * Helper class dealing with the extraction of spherical polynomial dataArray
  6247. * from a cube map.
  6248. */
  6249. export class CubeMapToSphericalPolynomialTools {
  6250. private static FileFaces;
  6251. /**
  6252. * Converts a texture to the according Spherical Polynomial data.
  6253. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6254. *
  6255. * @param texture The texture to extract the information from.
  6256. * @return The Spherical Polynomial data.
  6257. */
  6258. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  6259. /**
  6260. * Converts a cubemap to the according Spherical Polynomial data.
  6261. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6262. *
  6263. * @param cubeInfo The Cube map to extract the information from.
  6264. * @return The Spherical Polynomial data.
  6265. */
  6266. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  6267. }
  6268. }
  6269. declare module "babylonjs/Engines/engineStore" {
  6270. import { Nullable } from "babylonjs/types";
  6271. import { Engine } from "babylonjs/Engines/engine";
  6272. import { Scene } from "babylonjs/scene";
  6273. /**
  6274. * The engine store class is responsible to hold all the instances of Engine and Scene created
  6275. * during the life time of the application.
  6276. */
  6277. export class EngineStore {
  6278. /** Gets the list of created engines */
  6279. static Instances: import("babylonjs/Engines/engine").Engine[];
  6280. /** @hidden */
  6281. static _LastCreatedScene: Nullable<Scene>;
  6282. /**
  6283. * Gets the latest created engine
  6284. */
  6285. static readonly LastCreatedEngine: Nullable<Engine>;
  6286. /**
  6287. * Gets the latest created scene
  6288. */
  6289. static readonly LastCreatedScene: Nullable<Scene>;
  6290. }
  6291. }
  6292. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  6293. /**
  6294. * Define options used to create a render target texture
  6295. */
  6296. export class RenderTargetCreationOptions {
  6297. /**
  6298. * Specifies is mipmaps must be generated
  6299. */
  6300. generateMipMaps?: boolean;
  6301. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6302. generateDepthBuffer?: boolean;
  6303. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6304. generateStencilBuffer?: boolean;
  6305. /** Defines texture type (int by default) */
  6306. type?: number;
  6307. /** Defines sampling mode (trilinear by default) */
  6308. samplingMode?: number;
  6309. /** Defines format (RGBA by default) */
  6310. format?: number;
  6311. }
  6312. }
  6313. declare module "babylonjs/States/alphaCullingState" {
  6314. /**
  6315. * @hidden
  6316. **/
  6317. export class _AlphaState {
  6318. private _isAlphaBlendDirty;
  6319. private _isBlendFunctionParametersDirty;
  6320. private _isBlendEquationParametersDirty;
  6321. private _isBlendConstantsDirty;
  6322. private _alphaBlend;
  6323. private _blendFunctionParameters;
  6324. private _blendEquationParameters;
  6325. private _blendConstants;
  6326. /**
  6327. * Initializes the state.
  6328. */
  6329. constructor();
  6330. readonly isDirty: boolean;
  6331. alphaBlend: boolean;
  6332. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6333. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6334. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6335. reset(): void;
  6336. apply(gl: WebGLRenderingContext): void;
  6337. }
  6338. }
  6339. declare module "babylonjs/States/depthCullingState" {
  6340. import { Nullable } from "babylonjs/types";
  6341. /**
  6342. * @hidden
  6343. **/
  6344. export class _DepthCullingState {
  6345. private _isDepthTestDirty;
  6346. private _isDepthMaskDirty;
  6347. private _isDepthFuncDirty;
  6348. private _isCullFaceDirty;
  6349. private _isCullDirty;
  6350. private _isZOffsetDirty;
  6351. private _isFrontFaceDirty;
  6352. private _depthTest;
  6353. private _depthMask;
  6354. private _depthFunc;
  6355. private _cull;
  6356. private _cullFace;
  6357. private _zOffset;
  6358. private _frontFace;
  6359. /**
  6360. * Initializes the state.
  6361. */
  6362. constructor();
  6363. readonly isDirty: boolean;
  6364. zOffset: number;
  6365. cullFace: Nullable<number>;
  6366. cull: Nullable<boolean>;
  6367. depthFunc: Nullable<number>;
  6368. depthMask: boolean;
  6369. depthTest: boolean;
  6370. frontFace: Nullable<number>;
  6371. reset(): void;
  6372. apply(gl: WebGLRenderingContext): void;
  6373. }
  6374. }
  6375. declare module "babylonjs/States/stencilState" {
  6376. /**
  6377. * @hidden
  6378. **/
  6379. export class _StencilState {
  6380. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  6381. static readonly ALWAYS: number;
  6382. /** Passed to stencilOperation to specify that stencil value must be kept */
  6383. static readonly KEEP: number;
  6384. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6385. static readonly REPLACE: number;
  6386. private _isStencilTestDirty;
  6387. private _isStencilMaskDirty;
  6388. private _isStencilFuncDirty;
  6389. private _isStencilOpDirty;
  6390. private _stencilTest;
  6391. private _stencilMask;
  6392. private _stencilFunc;
  6393. private _stencilFuncRef;
  6394. private _stencilFuncMask;
  6395. private _stencilOpStencilFail;
  6396. private _stencilOpDepthFail;
  6397. private _stencilOpStencilDepthPass;
  6398. readonly isDirty: boolean;
  6399. stencilFunc: number;
  6400. stencilFuncRef: number;
  6401. stencilFuncMask: number;
  6402. stencilOpStencilFail: number;
  6403. stencilOpDepthFail: number;
  6404. stencilOpStencilDepthPass: number;
  6405. stencilMask: number;
  6406. stencilTest: boolean;
  6407. constructor();
  6408. reset(): void;
  6409. apply(gl: WebGLRenderingContext): void;
  6410. }
  6411. }
  6412. declare module "babylonjs/States/index" {
  6413. export * from "babylonjs/States/alphaCullingState";
  6414. export * from "babylonjs/States/depthCullingState";
  6415. export * from "babylonjs/States/stencilState";
  6416. }
  6417. declare module "babylonjs/Instrumentation/timeToken" {
  6418. import { Nullable } from "babylonjs/types";
  6419. /**
  6420. * @hidden
  6421. **/
  6422. export class _TimeToken {
  6423. _startTimeQuery: Nullable<WebGLQuery>;
  6424. _endTimeQuery: Nullable<WebGLQuery>;
  6425. _timeElapsedQuery: Nullable<WebGLQuery>;
  6426. _timeElapsedQueryEnded: boolean;
  6427. }
  6428. }
  6429. declare module "babylonjs/Materials/Textures/internalTexture" {
  6430. import { Observable } from "babylonjs/Misc/observable";
  6431. import { Nullable, int } from "babylonjs/types";
  6432. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6433. import { Engine } from "babylonjs/Engines/engine";
  6434. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6435. /**
  6436. * Class used to store data associated with WebGL texture data for the engine
  6437. * This class should not be used directly
  6438. */
  6439. export class InternalTexture {
  6440. /** @hidden */
  6441. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6442. /**
  6443. * The source of the texture data is unknown
  6444. */
  6445. static DATASOURCE_UNKNOWN: number;
  6446. /**
  6447. * Texture data comes from an URL
  6448. */
  6449. static DATASOURCE_URL: number;
  6450. /**
  6451. * Texture data is only used for temporary storage
  6452. */
  6453. static DATASOURCE_TEMP: number;
  6454. /**
  6455. * Texture data comes from raw data (ArrayBuffer)
  6456. */
  6457. static DATASOURCE_RAW: number;
  6458. /**
  6459. * Texture content is dynamic (video or dynamic texture)
  6460. */
  6461. static DATASOURCE_DYNAMIC: number;
  6462. /**
  6463. * Texture content is generated by rendering to it
  6464. */
  6465. static DATASOURCE_RENDERTARGET: number;
  6466. /**
  6467. * Texture content is part of a multi render target process
  6468. */
  6469. static DATASOURCE_MULTIRENDERTARGET: number;
  6470. /**
  6471. * Texture data comes from a cube data file
  6472. */
  6473. static DATASOURCE_CUBE: number;
  6474. /**
  6475. * Texture data comes from a raw cube data
  6476. */
  6477. static DATASOURCE_CUBERAW: number;
  6478. /**
  6479. * Texture data come from a prefiltered cube data file
  6480. */
  6481. static DATASOURCE_CUBEPREFILTERED: number;
  6482. /**
  6483. * Texture content is raw 3D data
  6484. */
  6485. static DATASOURCE_RAW3D: number;
  6486. /**
  6487. * Texture content is a depth texture
  6488. */
  6489. static DATASOURCE_DEPTHTEXTURE: number;
  6490. /**
  6491. * Texture data comes from a raw cube data encoded with RGBD
  6492. */
  6493. static DATASOURCE_CUBERAW_RGBD: number;
  6494. /**
  6495. * Defines if the texture is ready
  6496. */
  6497. isReady: boolean;
  6498. /**
  6499. * Defines if the texture is a cube texture
  6500. */
  6501. isCube: boolean;
  6502. /**
  6503. * Defines if the texture contains 3D data
  6504. */
  6505. is3D: boolean;
  6506. /**
  6507. * Defines if the texture contains multiview data
  6508. */
  6509. isMultiview: boolean;
  6510. /**
  6511. * Gets the URL used to load this texture
  6512. */
  6513. url: string;
  6514. /**
  6515. * Gets the sampling mode of the texture
  6516. */
  6517. samplingMode: number;
  6518. /**
  6519. * Gets a boolean indicating if the texture needs mipmaps generation
  6520. */
  6521. generateMipMaps: boolean;
  6522. /**
  6523. * Gets the number of samples used by the texture (WebGL2+ only)
  6524. */
  6525. samples: number;
  6526. /**
  6527. * Gets the type of the texture (int, float...)
  6528. */
  6529. type: number;
  6530. /**
  6531. * Gets the format of the texture (RGB, RGBA...)
  6532. */
  6533. format: number;
  6534. /**
  6535. * Observable called when the texture is loaded
  6536. */
  6537. onLoadedObservable: Observable<InternalTexture>;
  6538. /**
  6539. * Gets the width of the texture
  6540. */
  6541. width: number;
  6542. /**
  6543. * Gets the height of the texture
  6544. */
  6545. height: number;
  6546. /**
  6547. * Gets the depth of the texture
  6548. */
  6549. depth: number;
  6550. /**
  6551. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6552. */
  6553. baseWidth: number;
  6554. /**
  6555. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6556. */
  6557. baseHeight: number;
  6558. /**
  6559. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6560. */
  6561. baseDepth: number;
  6562. /**
  6563. * Gets a boolean indicating if the texture is inverted on Y axis
  6564. */
  6565. invertY: boolean;
  6566. /** @hidden */
  6567. _invertVScale: boolean;
  6568. /** @hidden */
  6569. _associatedChannel: number;
  6570. /** @hidden */
  6571. _dataSource: number;
  6572. /** @hidden */
  6573. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6574. /** @hidden */
  6575. _bufferView: Nullable<ArrayBufferView>;
  6576. /** @hidden */
  6577. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6578. /** @hidden */
  6579. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6580. /** @hidden */
  6581. _size: number;
  6582. /** @hidden */
  6583. _extension: string;
  6584. /** @hidden */
  6585. _files: Nullable<string[]>;
  6586. /** @hidden */
  6587. _workingCanvas: Nullable<HTMLCanvasElement>;
  6588. /** @hidden */
  6589. _workingContext: Nullable<CanvasRenderingContext2D>;
  6590. /** @hidden */
  6591. _framebuffer: Nullable<WebGLFramebuffer>;
  6592. /** @hidden */
  6593. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6594. /** @hidden */
  6595. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6596. /** @hidden */
  6597. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6598. /** @hidden */
  6599. _attachments: Nullable<number[]>;
  6600. /** @hidden */
  6601. _cachedCoordinatesMode: Nullable<number>;
  6602. /** @hidden */
  6603. _cachedWrapU: Nullable<number>;
  6604. /** @hidden */
  6605. _cachedWrapV: Nullable<number>;
  6606. /** @hidden */
  6607. _cachedWrapR: Nullable<number>;
  6608. /** @hidden */
  6609. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6610. /** @hidden */
  6611. _isDisabled: boolean;
  6612. /** @hidden */
  6613. _compression: Nullable<string>;
  6614. /** @hidden */
  6615. _generateStencilBuffer: boolean;
  6616. /** @hidden */
  6617. _generateDepthBuffer: boolean;
  6618. /** @hidden */
  6619. _comparisonFunction: number;
  6620. /** @hidden */
  6621. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6622. /** @hidden */
  6623. _lodGenerationScale: number;
  6624. /** @hidden */
  6625. _lodGenerationOffset: number;
  6626. /** @hidden */
  6627. _colorTextureArray: Nullable<WebGLTexture>;
  6628. /** @hidden */
  6629. _depthStencilTextureArray: Nullable<WebGLTexture>;
  6630. /** @hidden */
  6631. _lodTextureHigh: Nullable<BaseTexture>;
  6632. /** @hidden */
  6633. _lodTextureMid: Nullable<BaseTexture>;
  6634. /** @hidden */
  6635. _lodTextureLow: Nullable<BaseTexture>;
  6636. /** @hidden */
  6637. _isRGBD: boolean;
  6638. /** @hidden */
  6639. _linearSpecularLOD: boolean;
  6640. /** @hidden */
  6641. _irradianceTexture: Nullable<BaseTexture>;
  6642. /** @hidden */
  6643. _webGLTexture: Nullable<WebGLTexture>;
  6644. /** @hidden */
  6645. _references: number;
  6646. private _engine;
  6647. /**
  6648. * Gets the Engine the texture belongs to.
  6649. * @returns The babylon engine
  6650. */
  6651. getEngine(): Engine;
  6652. /**
  6653. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6654. */
  6655. readonly dataSource: number;
  6656. /**
  6657. * Creates a new InternalTexture
  6658. * @param engine defines the engine to use
  6659. * @param dataSource defines the type of data that will be used
  6660. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6661. */
  6662. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6663. /**
  6664. * Increments the number of references (ie. the number of Texture that point to it)
  6665. */
  6666. incrementReferences(): void;
  6667. /**
  6668. * Change the size of the texture (not the size of the content)
  6669. * @param width defines the new width
  6670. * @param height defines the new height
  6671. * @param depth defines the new depth (1 by default)
  6672. */
  6673. updateSize(width: int, height: int, depth?: int): void;
  6674. /** @hidden */
  6675. _rebuild(): void;
  6676. /** @hidden */
  6677. _swapAndDie(target: InternalTexture): void;
  6678. /**
  6679. * Dispose the current allocated resources
  6680. */
  6681. dispose(): void;
  6682. }
  6683. }
  6684. declare module "babylonjs/Animations/easing" {
  6685. /**
  6686. * This represents the main contract an easing function should follow.
  6687. * Easing functions are used throughout the animation system.
  6688. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6689. */
  6690. export interface IEasingFunction {
  6691. /**
  6692. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6693. * of the easing function.
  6694. * The link below provides some of the most common examples of easing functions.
  6695. * @see https://easings.net/
  6696. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6697. * @returns the corresponding value on the curve defined by the easing function
  6698. */
  6699. ease(gradient: number): number;
  6700. }
  6701. /**
  6702. * Base class used for every default easing function.
  6703. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6704. */
  6705. export class EasingFunction implements IEasingFunction {
  6706. /**
  6707. * Interpolation follows the mathematical formula associated with the easing function.
  6708. */
  6709. static readonly EASINGMODE_EASEIN: number;
  6710. /**
  6711. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6712. */
  6713. static readonly EASINGMODE_EASEOUT: number;
  6714. /**
  6715. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6716. */
  6717. static readonly EASINGMODE_EASEINOUT: number;
  6718. private _easingMode;
  6719. /**
  6720. * Sets the easing mode of the current function.
  6721. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6722. */
  6723. setEasingMode(easingMode: number): void;
  6724. /**
  6725. * Gets the current easing mode.
  6726. * @returns the easing mode
  6727. */
  6728. getEasingMode(): number;
  6729. /**
  6730. * @hidden
  6731. */
  6732. easeInCore(gradient: number): number;
  6733. /**
  6734. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6735. * of the easing function.
  6736. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6737. * @returns the corresponding value on the curve defined by the easing function
  6738. */
  6739. ease(gradient: number): number;
  6740. }
  6741. /**
  6742. * Easing function with a circle shape (see link below).
  6743. * @see https://easings.net/#easeInCirc
  6744. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6745. */
  6746. export class CircleEase extends EasingFunction implements IEasingFunction {
  6747. /** @hidden */
  6748. easeInCore(gradient: number): number;
  6749. }
  6750. /**
  6751. * Easing function with a ease back shape (see link below).
  6752. * @see https://easings.net/#easeInBack
  6753. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6754. */
  6755. export class BackEase extends EasingFunction implements IEasingFunction {
  6756. /** Defines the amplitude of the function */
  6757. amplitude: number;
  6758. /**
  6759. * Instantiates a back ease easing
  6760. * @see https://easings.net/#easeInBack
  6761. * @param amplitude Defines the amplitude of the function
  6762. */
  6763. constructor(
  6764. /** Defines the amplitude of the function */
  6765. amplitude?: number);
  6766. /** @hidden */
  6767. easeInCore(gradient: number): number;
  6768. }
  6769. /**
  6770. * Easing function with a bouncing shape (see link below).
  6771. * @see https://easings.net/#easeInBounce
  6772. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6773. */
  6774. export class BounceEase extends EasingFunction implements IEasingFunction {
  6775. /** Defines the number of bounces */
  6776. bounces: number;
  6777. /** Defines the amplitude of the bounce */
  6778. bounciness: number;
  6779. /**
  6780. * Instantiates a bounce easing
  6781. * @see https://easings.net/#easeInBounce
  6782. * @param bounces Defines the number of bounces
  6783. * @param bounciness Defines the amplitude of the bounce
  6784. */
  6785. constructor(
  6786. /** Defines the number of bounces */
  6787. bounces?: number,
  6788. /** Defines the amplitude of the bounce */
  6789. bounciness?: number);
  6790. /** @hidden */
  6791. easeInCore(gradient: number): number;
  6792. }
  6793. /**
  6794. * Easing function with a power of 3 shape (see link below).
  6795. * @see https://easings.net/#easeInCubic
  6796. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6797. */
  6798. export class CubicEase extends EasingFunction implements IEasingFunction {
  6799. /** @hidden */
  6800. easeInCore(gradient: number): number;
  6801. }
  6802. /**
  6803. * Easing function with an elastic shape (see link below).
  6804. * @see https://easings.net/#easeInElastic
  6805. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6806. */
  6807. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6808. /** Defines the number of oscillations*/
  6809. oscillations: number;
  6810. /** Defines the amplitude of the oscillations*/
  6811. springiness: number;
  6812. /**
  6813. * Instantiates an elastic easing function
  6814. * @see https://easings.net/#easeInElastic
  6815. * @param oscillations Defines the number of oscillations
  6816. * @param springiness Defines the amplitude of the oscillations
  6817. */
  6818. constructor(
  6819. /** Defines the number of oscillations*/
  6820. oscillations?: number,
  6821. /** Defines the amplitude of the oscillations*/
  6822. springiness?: number);
  6823. /** @hidden */
  6824. easeInCore(gradient: number): number;
  6825. }
  6826. /**
  6827. * Easing function with an exponential shape (see link below).
  6828. * @see https://easings.net/#easeInExpo
  6829. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6830. */
  6831. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6832. /** Defines the exponent of the function */
  6833. exponent: number;
  6834. /**
  6835. * Instantiates an exponential easing function
  6836. * @see https://easings.net/#easeInExpo
  6837. * @param exponent Defines the exponent of the function
  6838. */
  6839. constructor(
  6840. /** Defines the exponent of the function */
  6841. exponent?: number);
  6842. /** @hidden */
  6843. easeInCore(gradient: number): number;
  6844. }
  6845. /**
  6846. * Easing function with a power shape (see link below).
  6847. * @see https://easings.net/#easeInQuad
  6848. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6849. */
  6850. export class PowerEase extends EasingFunction implements IEasingFunction {
  6851. /** Defines the power of the function */
  6852. power: number;
  6853. /**
  6854. * Instantiates an power base easing function
  6855. * @see https://easings.net/#easeInQuad
  6856. * @param power Defines the power of the function
  6857. */
  6858. constructor(
  6859. /** Defines the power of the function */
  6860. power?: number);
  6861. /** @hidden */
  6862. easeInCore(gradient: number): number;
  6863. }
  6864. /**
  6865. * Easing function with a power of 2 shape (see link below).
  6866. * @see https://easings.net/#easeInQuad
  6867. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6868. */
  6869. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6870. /** @hidden */
  6871. easeInCore(gradient: number): number;
  6872. }
  6873. /**
  6874. * Easing function with a power of 4 shape (see link below).
  6875. * @see https://easings.net/#easeInQuart
  6876. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6877. */
  6878. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6879. /** @hidden */
  6880. easeInCore(gradient: number): number;
  6881. }
  6882. /**
  6883. * Easing function with a power of 5 shape (see link below).
  6884. * @see https://easings.net/#easeInQuint
  6885. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6886. */
  6887. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6888. /** @hidden */
  6889. easeInCore(gradient: number): number;
  6890. }
  6891. /**
  6892. * Easing function with a sin shape (see link below).
  6893. * @see https://easings.net/#easeInSine
  6894. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6895. */
  6896. export class SineEase extends EasingFunction implements IEasingFunction {
  6897. /** @hidden */
  6898. easeInCore(gradient: number): number;
  6899. }
  6900. /**
  6901. * Easing function with a bezier shape (see link below).
  6902. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6903. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6904. */
  6905. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6906. /** Defines the x component of the start tangent in the bezier curve */
  6907. x1: number;
  6908. /** Defines the y component of the start tangent in the bezier curve */
  6909. y1: number;
  6910. /** Defines the x component of the end tangent in the bezier curve */
  6911. x2: number;
  6912. /** Defines the y component of the end tangent in the bezier curve */
  6913. y2: number;
  6914. /**
  6915. * Instantiates a bezier function
  6916. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6917. * @param x1 Defines the x component of the start tangent in the bezier curve
  6918. * @param y1 Defines the y component of the start tangent in the bezier curve
  6919. * @param x2 Defines the x component of the end tangent in the bezier curve
  6920. * @param y2 Defines the y component of the end tangent in the bezier curve
  6921. */
  6922. constructor(
  6923. /** Defines the x component of the start tangent in the bezier curve */
  6924. x1?: number,
  6925. /** Defines the y component of the start tangent in the bezier curve */
  6926. y1?: number,
  6927. /** Defines the x component of the end tangent in the bezier curve */
  6928. x2?: number,
  6929. /** Defines the y component of the end tangent in the bezier curve */
  6930. y2?: number);
  6931. /** @hidden */
  6932. easeInCore(gradient: number): number;
  6933. }
  6934. }
  6935. declare module "babylonjs/Animations/animationKey" {
  6936. /**
  6937. * Defines an interface which represents an animation key frame
  6938. */
  6939. export interface IAnimationKey {
  6940. /**
  6941. * Frame of the key frame
  6942. */
  6943. frame: number;
  6944. /**
  6945. * Value at the specifies key frame
  6946. */
  6947. value: any;
  6948. /**
  6949. * The input tangent for the cubic hermite spline
  6950. */
  6951. inTangent?: any;
  6952. /**
  6953. * The output tangent for the cubic hermite spline
  6954. */
  6955. outTangent?: any;
  6956. /**
  6957. * The animation interpolation type
  6958. */
  6959. interpolation?: AnimationKeyInterpolation;
  6960. }
  6961. /**
  6962. * Enum for the animation key frame interpolation type
  6963. */
  6964. export enum AnimationKeyInterpolation {
  6965. /**
  6966. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6967. */
  6968. STEP = 1
  6969. }
  6970. }
  6971. declare module "babylonjs/Animations/animationRange" {
  6972. /**
  6973. * Represents the range of an animation
  6974. */
  6975. export class AnimationRange {
  6976. /**The name of the animation range**/
  6977. name: string;
  6978. /**The starting frame of the animation */
  6979. from: number;
  6980. /**The ending frame of the animation*/
  6981. to: number;
  6982. /**
  6983. * Initializes the range of an animation
  6984. * @param name The name of the animation range
  6985. * @param from The starting frame of the animation
  6986. * @param to The ending frame of the animation
  6987. */
  6988. constructor(
  6989. /**The name of the animation range**/
  6990. name: string,
  6991. /**The starting frame of the animation */
  6992. from: number,
  6993. /**The ending frame of the animation*/
  6994. to: number);
  6995. /**
  6996. * Makes a copy of the animation range
  6997. * @returns A copy of the animation range
  6998. */
  6999. clone(): AnimationRange;
  7000. }
  7001. }
  7002. declare module "babylonjs/Animations/animationEvent" {
  7003. /**
  7004. * Composed of a frame, and an action function
  7005. */
  7006. export class AnimationEvent {
  7007. /** The frame for which the event is triggered **/
  7008. frame: number;
  7009. /** The event to perform when triggered **/
  7010. action: (currentFrame: number) => void;
  7011. /** Specifies if the event should be triggered only once**/
  7012. onlyOnce?: boolean | undefined;
  7013. /**
  7014. * Specifies if the animation event is done
  7015. */
  7016. isDone: boolean;
  7017. /**
  7018. * Initializes the animation event
  7019. * @param frame The frame for which the event is triggered
  7020. * @param action The event to perform when triggered
  7021. * @param onlyOnce Specifies if the event should be triggered only once
  7022. */
  7023. constructor(
  7024. /** The frame for which the event is triggered **/
  7025. frame: number,
  7026. /** The event to perform when triggered **/
  7027. action: (currentFrame: number) => void,
  7028. /** Specifies if the event should be triggered only once**/
  7029. onlyOnce?: boolean | undefined);
  7030. /** @hidden */
  7031. _clone(): AnimationEvent;
  7032. }
  7033. }
  7034. declare module "babylonjs/Behaviors/behavior" {
  7035. import { Nullable } from "babylonjs/types";
  7036. /**
  7037. * Interface used to define a behavior
  7038. */
  7039. export interface Behavior<T> {
  7040. /** gets or sets behavior's name */
  7041. name: string;
  7042. /**
  7043. * Function called when the behavior needs to be initialized (after attaching it to a target)
  7044. */
  7045. init(): void;
  7046. /**
  7047. * Called when the behavior is attached to a target
  7048. * @param target defines the target where the behavior is attached to
  7049. */
  7050. attach(target: T): void;
  7051. /**
  7052. * Called when the behavior is detached from its target
  7053. */
  7054. detach(): void;
  7055. }
  7056. /**
  7057. * Interface implemented by classes supporting behaviors
  7058. */
  7059. export interface IBehaviorAware<T> {
  7060. /**
  7061. * Attach a behavior
  7062. * @param behavior defines the behavior to attach
  7063. * @returns the current host
  7064. */
  7065. addBehavior(behavior: Behavior<T>): T;
  7066. /**
  7067. * Remove a behavior from the current object
  7068. * @param behavior defines the behavior to detach
  7069. * @returns the current host
  7070. */
  7071. removeBehavior(behavior: Behavior<T>): T;
  7072. /**
  7073. * Gets a behavior using its name to search
  7074. * @param name defines the name to search
  7075. * @returns the behavior or null if not found
  7076. */
  7077. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  7078. }
  7079. }
  7080. declare module "babylonjs/Collisions/intersectionInfo" {
  7081. import { Nullable } from "babylonjs/types";
  7082. /**
  7083. * @hidden
  7084. */
  7085. export class IntersectionInfo {
  7086. bu: Nullable<number>;
  7087. bv: Nullable<number>;
  7088. distance: number;
  7089. faceId: number;
  7090. subMeshId: number;
  7091. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  7092. }
  7093. }
  7094. declare module "babylonjs/Culling/boundingSphere" {
  7095. import { DeepImmutable } from "babylonjs/types";
  7096. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7097. /**
  7098. * Class used to store bounding sphere information
  7099. */
  7100. export class BoundingSphere {
  7101. /**
  7102. * Gets the center of the bounding sphere in local space
  7103. */
  7104. readonly center: Vector3;
  7105. /**
  7106. * Radius of the bounding sphere in local space
  7107. */
  7108. radius: number;
  7109. /**
  7110. * Gets the center of the bounding sphere in world space
  7111. */
  7112. readonly centerWorld: Vector3;
  7113. /**
  7114. * Radius of the bounding sphere in world space
  7115. */
  7116. radiusWorld: number;
  7117. /**
  7118. * Gets the minimum vector in local space
  7119. */
  7120. readonly minimum: Vector3;
  7121. /**
  7122. * Gets the maximum vector in local space
  7123. */
  7124. readonly maximum: Vector3;
  7125. private _worldMatrix;
  7126. private static readonly TmpVector3;
  7127. /**
  7128. * Creates a new bounding sphere
  7129. * @param min defines the minimum vector (in local space)
  7130. * @param max defines the maximum vector (in local space)
  7131. * @param worldMatrix defines the new world matrix
  7132. */
  7133. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7134. /**
  7135. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7136. * @param min defines the new minimum vector (in local space)
  7137. * @param max defines the new maximum vector (in local space)
  7138. * @param worldMatrix defines the new world matrix
  7139. */
  7140. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7141. /**
  7142. * Scale the current bounding sphere by applying a scale factor
  7143. * @param factor defines the scale factor to apply
  7144. * @returns the current bounding box
  7145. */
  7146. scale(factor: number): BoundingSphere;
  7147. /**
  7148. * Gets the world matrix of the bounding box
  7149. * @returns a matrix
  7150. */
  7151. getWorldMatrix(): DeepImmutable<Matrix>;
  7152. /** @hidden */
  7153. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7154. /**
  7155. * Tests if the bounding sphere is intersecting the frustum planes
  7156. * @param frustumPlanes defines the frustum planes to test
  7157. * @returns true if there is an intersection
  7158. */
  7159. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7160. /**
  7161. * Tests if the bounding sphere center is in between the frustum planes.
  7162. * Used for optimistic fast inclusion.
  7163. * @param frustumPlanes defines the frustum planes to test
  7164. * @returns true if the sphere center is in between the frustum planes
  7165. */
  7166. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7167. /**
  7168. * Tests if a point is inside the bounding sphere
  7169. * @param point defines the point to test
  7170. * @returns true if the point is inside the bounding sphere
  7171. */
  7172. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7173. /**
  7174. * Checks if two sphere intersct
  7175. * @param sphere0 sphere 0
  7176. * @param sphere1 sphere 1
  7177. * @returns true if the speres intersect
  7178. */
  7179. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7180. }
  7181. }
  7182. declare module "babylonjs/Culling/boundingBox" {
  7183. import { DeepImmutable } from "babylonjs/types";
  7184. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7185. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7186. import { ICullable } from "babylonjs/Culling/boundingInfo";
  7187. /**
  7188. * Class used to store bounding box information
  7189. */
  7190. export class BoundingBox implements ICullable {
  7191. /**
  7192. * Gets the 8 vectors representing the bounding box in local space
  7193. */
  7194. readonly vectors: Vector3[];
  7195. /**
  7196. * Gets the center of the bounding box in local space
  7197. */
  7198. readonly center: Vector3;
  7199. /**
  7200. * Gets the center of the bounding box in world space
  7201. */
  7202. readonly centerWorld: Vector3;
  7203. /**
  7204. * Gets the extend size in local space
  7205. */
  7206. readonly extendSize: Vector3;
  7207. /**
  7208. * Gets the extend size in world space
  7209. */
  7210. readonly extendSizeWorld: Vector3;
  7211. /**
  7212. * Gets the OBB (object bounding box) directions
  7213. */
  7214. readonly directions: Vector3[];
  7215. /**
  7216. * Gets the 8 vectors representing the bounding box in world space
  7217. */
  7218. readonly vectorsWorld: Vector3[];
  7219. /**
  7220. * Gets the minimum vector in world space
  7221. */
  7222. readonly minimumWorld: Vector3;
  7223. /**
  7224. * Gets the maximum vector in world space
  7225. */
  7226. readonly maximumWorld: Vector3;
  7227. /**
  7228. * Gets the minimum vector in local space
  7229. */
  7230. readonly minimum: Vector3;
  7231. /**
  7232. * Gets the maximum vector in local space
  7233. */
  7234. readonly maximum: Vector3;
  7235. private _worldMatrix;
  7236. private static readonly TmpVector3;
  7237. /**
  7238. * @hidden
  7239. */
  7240. _tag: number;
  7241. /**
  7242. * Creates a new bounding box
  7243. * @param min defines the minimum vector (in local space)
  7244. * @param max defines the maximum vector (in local space)
  7245. * @param worldMatrix defines the new world matrix
  7246. */
  7247. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7248. /**
  7249. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7250. * @param min defines the new minimum vector (in local space)
  7251. * @param max defines the new maximum vector (in local space)
  7252. * @param worldMatrix defines the new world matrix
  7253. */
  7254. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7255. /**
  7256. * Scale the current bounding box by applying a scale factor
  7257. * @param factor defines the scale factor to apply
  7258. * @returns the current bounding box
  7259. */
  7260. scale(factor: number): BoundingBox;
  7261. /**
  7262. * Gets the world matrix of the bounding box
  7263. * @returns a matrix
  7264. */
  7265. getWorldMatrix(): DeepImmutable<Matrix>;
  7266. /** @hidden */
  7267. _update(world: DeepImmutable<Matrix>): void;
  7268. /**
  7269. * Tests if the bounding box is intersecting the frustum planes
  7270. * @param frustumPlanes defines the frustum planes to test
  7271. * @returns true if there is an intersection
  7272. */
  7273. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7274. /**
  7275. * Tests if the bounding box is entirely inside the frustum planes
  7276. * @param frustumPlanes defines the frustum planes to test
  7277. * @returns true if there is an inclusion
  7278. */
  7279. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7280. /**
  7281. * Tests if a point is inside the bounding box
  7282. * @param point defines the point to test
  7283. * @returns true if the point is inside the bounding box
  7284. */
  7285. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7286. /**
  7287. * Tests if the bounding box intersects with a bounding sphere
  7288. * @param sphere defines the sphere to test
  7289. * @returns true if there is an intersection
  7290. */
  7291. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7292. /**
  7293. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7294. * @param min defines the min vector to use
  7295. * @param max defines the max vector to use
  7296. * @returns true if there is an intersection
  7297. */
  7298. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7299. /**
  7300. * Tests if two bounding boxes are intersections
  7301. * @param box0 defines the first box to test
  7302. * @param box1 defines the second box to test
  7303. * @returns true if there is an intersection
  7304. */
  7305. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7306. /**
  7307. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7308. * @param minPoint defines the minimum vector of the bounding box
  7309. * @param maxPoint defines the maximum vector of the bounding box
  7310. * @param sphereCenter defines the sphere center
  7311. * @param sphereRadius defines the sphere radius
  7312. * @returns true if there is an intersection
  7313. */
  7314. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7315. /**
  7316. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7317. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7318. * @param frustumPlanes defines the frustum planes to test
  7319. * @return true if there is an inclusion
  7320. */
  7321. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7322. /**
  7323. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7324. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7325. * @param frustumPlanes defines the frustum planes to test
  7326. * @return true if there is an intersection
  7327. */
  7328. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7329. }
  7330. }
  7331. declare module "babylonjs/Collisions/collider" {
  7332. import { Nullable, IndicesArray } from "babylonjs/types";
  7333. import { Vector3, Plane } from "babylonjs/Maths/math";
  7334. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7335. /** @hidden */
  7336. export class Collider {
  7337. /** Define if a collision was found */
  7338. collisionFound: boolean;
  7339. /**
  7340. * Define last intersection point in local space
  7341. */
  7342. intersectionPoint: Vector3;
  7343. /**
  7344. * Define last collided mesh
  7345. */
  7346. collidedMesh: Nullable<AbstractMesh>;
  7347. private _collisionPoint;
  7348. private _planeIntersectionPoint;
  7349. private _tempVector;
  7350. private _tempVector2;
  7351. private _tempVector3;
  7352. private _tempVector4;
  7353. private _edge;
  7354. private _baseToVertex;
  7355. private _destinationPoint;
  7356. private _slidePlaneNormal;
  7357. private _displacementVector;
  7358. /** @hidden */
  7359. _radius: Vector3;
  7360. /** @hidden */
  7361. _retry: number;
  7362. private _velocity;
  7363. private _basePoint;
  7364. private _epsilon;
  7365. /** @hidden */
  7366. _velocityWorldLength: number;
  7367. /** @hidden */
  7368. _basePointWorld: Vector3;
  7369. private _velocityWorld;
  7370. private _normalizedVelocity;
  7371. /** @hidden */
  7372. _initialVelocity: Vector3;
  7373. /** @hidden */
  7374. _initialPosition: Vector3;
  7375. private _nearestDistance;
  7376. private _collisionMask;
  7377. collisionMask: number;
  7378. /**
  7379. * Gets the plane normal used to compute the sliding response (in local space)
  7380. */
  7381. readonly slidePlaneNormal: Vector3;
  7382. /** @hidden */
  7383. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7384. /** @hidden */
  7385. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7386. /** @hidden */
  7387. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7388. /** @hidden */
  7389. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7390. /** @hidden */
  7391. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7392. /** @hidden */
  7393. _getResponse(pos: Vector3, vel: Vector3): void;
  7394. }
  7395. }
  7396. declare module "babylonjs/Culling/boundingInfo" {
  7397. import { DeepImmutable } from "babylonjs/types";
  7398. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7399. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7400. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7401. import { Collider } from "babylonjs/Collisions/collider";
  7402. /**
  7403. * Interface for cullable objects
  7404. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7405. */
  7406. export interface ICullable {
  7407. /**
  7408. * Checks if the object or part of the object is in the frustum
  7409. * @param frustumPlanes Camera near/planes
  7410. * @returns true if the object is in frustum otherwise false
  7411. */
  7412. isInFrustum(frustumPlanes: Plane[]): boolean;
  7413. /**
  7414. * Checks if a cullable object (mesh...) is in the camera frustum
  7415. * Unlike isInFrustum this cheks the full bounding box
  7416. * @param frustumPlanes Camera near/planes
  7417. * @returns true if the object is in frustum otherwise false
  7418. */
  7419. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7420. }
  7421. /**
  7422. * Info for a bounding data of a mesh
  7423. */
  7424. export class BoundingInfo implements ICullable {
  7425. /**
  7426. * Bounding box for the mesh
  7427. */
  7428. readonly boundingBox: BoundingBox;
  7429. /**
  7430. * Bounding sphere for the mesh
  7431. */
  7432. readonly boundingSphere: BoundingSphere;
  7433. private _isLocked;
  7434. private static readonly TmpVector3;
  7435. /**
  7436. * Constructs bounding info
  7437. * @param minimum min vector of the bounding box/sphere
  7438. * @param maximum max vector of the bounding box/sphere
  7439. * @param worldMatrix defines the new world matrix
  7440. */
  7441. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7442. /**
  7443. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7444. * @param min defines the new minimum vector (in local space)
  7445. * @param max defines the new maximum vector (in local space)
  7446. * @param worldMatrix defines the new world matrix
  7447. */
  7448. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7449. /**
  7450. * min vector of the bounding box/sphere
  7451. */
  7452. readonly minimum: Vector3;
  7453. /**
  7454. * max vector of the bounding box/sphere
  7455. */
  7456. readonly maximum: Vector3;
  7457. /**
  7458. * If the info is locked and won't be updated to avoid perf overhead
  7459. */
  7460. isLocked: boolean;
  7461. /**
  7462. * Updates the bounding sphere and box
  7463. * @param world world matrix to be used to update
  7464. */
  7465. update(world: DeepImmutable<Matrix>): void;
  7466. /**
  7467. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7468. * @param center New center of the bounding info
  7469. * @param extend New extend of the bounding info
  7470. * @returns the current bounding info
  7471. */
  7472. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7473. /**
  7474. * Scale the current bounding info by applying a scale factor
  7475. * @param factor defines the scale factor to apply
  7476. * @returns the current bounding info
  7477. */
  7478. scale(factor: number): BoundingInfo;
  7479. /**
  7480. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7481. * @param frustumPlanes defines the frustum to test
  7482. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7483. * @returns true if the bounding info is in the frustum planes
  7484. */
  7485. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7486. /**
  7487. * Gets the world distance between the min and max points of the bounding box
  7488. */
  7489. readonly diagonalLength: number;
  7490. /**
  7491. * Checks if a cullable object (mesh...) is in the camera frustum
  7492. * Unlike isInFrustum this cheks the full bounding box
  7493. * @param frustumPlanes Camera near/planes
  7494. * @returns true if the object is in frustum otherwise false
  7495. */
  7496. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7497. /** @hidden */
  7498. _checkCollision(collider: Collider): boolean;
  7499. /**
  7500. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7501. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7502. * @param point the point to check intersection with
  7503. * @returns if the point intersects
  7504. */
  7505. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7506. /**
  7507. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7508. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7509. * @param boundingInfo the bounding info to check intersection with
  7510. * @param precise if the intersection should be done using OBB
  7511. * @returns if the bounding info intersects
  7512. */
  7513. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7514. }
  7515. }
  7516. declare module "babylonjs/Misc/smartArray" {
  7517. /**
  7518. * Defines an array and its length.
  7519. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7520. */
  7521. export interface ISmartArrayLike<T> {
  7522. /**
  7523. * The data of the array.
  7524. */
  7525. data: Array<T>;
  7526. /**
  7527. * The active length of the array.
  7528. */
  7529. length: number;
  7530. }
  7531. /**
  7532. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7533. */
  7534. export class SmartArray<T> implements ISmartArrayLike<T> {
  7535. /**
  7536. * The full set of data from the array.
  7537. */
  7538. data: Array<T>;
  7539. /**
  7540. * The active length of the array.
  7541. */
  7542. length: number;
  7543. protected _id: number;
  7544. /**
  7545. * Instantiates a Smart Array.
  7546. * @param capacity defines the default capacity of the array.
  7547. */
  7548. constructor(capacity: number);
  7549. /**
  7550. * Pushes a value at the end of the active data.
  7551. * @param value defines the object to push in the array.
  7552. */
  7553. push(value: T): void;
  7554. /**
  7555. * Iterates over the active data and apply the lambda to them.
  7556. * @param func defines the action to apply on each value.
  7557. */
  7558. forEach(func: (content: T) => void): void;
  7559. /**
  7560. * Sorts the full sets of data.
  7561. * @param compareFn defines the comparison function to apply.
  7562. */
  7563. sort(compareFn: (a: T, b: T) => number): void;
  7564. /**
  7565. * Resets the active data to an empty array.
  7566. */
  7567. reset(): void;
  7568. /**
  7569. * Releases all the data from the array as well as the array.
  7570. */
  7571. dispose(): void;
  7572. /**
  7573. * Concats the active data with a given array.
  7574. * @param array defines the data to concatenate with.
  7575. */
  7576. concat(array: any): void;
  7577. /**
  7578. * Returns the position of a value in the active data.
  7579. * @param value defines the value to find the index for
  7580. * @returns the index if found in the active data otherwise -1
  7581. */
  7582. indexOf(value: T): number;
  7583. /**
  7584. * Returns whether an element is part of the active data.
  7585. * @param value defines the value to look for
  7586. * @returns true if found in the active data otherwise false
  7587. */
  7588. contains(value: T): boolean;
  7589. private static _GlobalId;
  7590. }
  7591. /**
  7592. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7593. * The data in this array can only be present once
  7594. */
  7595. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7596. private _duplicateId;
  7597. /**
  7598. * Pushes a value at the end of the active data.
  7599. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7600. * @param value defines the object to push in the array.
  7601. */
  7602. push(value: T): void;
  7603. /**
  7604. * Pushes a value at the end of the active data.
  7605. * If the data is already present, it won t be added again
  7606. * @param value defines the object to push in the array.
  7607. * @returns true if added false if it was already present
  7608. */
  7609. pushNoDuplicate(value: T): boolean;
  7610. /**
  7611. * Resets the active data to an empty array.
  7612. */
  7613. reset(): void;
  7614. /**
  7615. * Concats the active data with a given array.
  7616. * This ensures no dupplicate will be present in the result.
  7617. * @param array defines the data to concatenate with.
  7618. */
  7619. concatWithNoDuplicate(array: any): void;
  7620. }
  7621. }
  7622. declare module "babylonjs/Misc/iInspectable" {
  7623. /**
  7624. * Enum that determines the text-wrapping mode to use.
  7625. */
  7626. export enum InspectableType {
  7627. /**
  7628. * Checkbox for booleans
  7629. */
  7630. Checkbox = 0,
  7631. /**
  7632. * Sliders for numbers
  7633. */
  7634. Slider = 1,
  7635. /**
  7636. * Vector3
  7637. */
  7638. Vector3 = 2,
  7639. /**
  7640. * Quaternions
  7641. */
  7642. Quaternion = 3,
  7643. /**
  7644. * Color3
  7645. */
  7646. Color3 = 4
  7647. }
  7648. /**
  7649. * Interface used to define custom inspectable properties.
  7650. * This interface is used by the inspector to display custom property grids
  7651. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7652. */
  7653. export interface IInspectable {
  7654. /**
  7655. * Gets the label to display
  7656. */
  7657. label: string;
  7658. /**
  7659. * Gets the name of the property to edit
  7660. */
  7661. propertyName: string;
  7662. /**
  7663. * Gets the type of the editor to use
  7664. */
  7665. type: InspectableType;
  7666. /**
  7667. * Gets the minimum value of the property when using in "slider" mode
  7668. */
  7669. min?: number;
  7670. /**
  7671. * Gets the maximum value of the property when using in "slider" mode
  7672. */
  7673. max?: number;
  7674. /**
  7675. * Gets the setp to use when using in "slider" mode
  7676. */
  7677. step?: number;
  7678. }
  7679. }
  7680. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  7681. import { Nullable } from "babylonjs/types";
  7682. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7683. /**
  7684. * This represents the required contract to create a new type of texture loader.
  7685. */
  7686. export interface IInternalTextureLoader {
  7687. /**
  7688. * Defines wether the loader supports cascade loading the different faces.
  7689. */
  7690. supportCascades: boolean;
  7691. /**
  7692. * This returns if the loader support the current file information.
  7693. * @param extension defines the file extension of the file being loaded
  7694. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7695. * @param fallback defines the fallback internal texture if any
  7696. * @param isBase64 defines whether the texture is encoded as a base64
  7697. * @param isBuffer defines whether the texture data are stored as a buffer
  7698. * @returns true if the loader can load the specified file
  7699. */
  7700. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  7701. /**
  7702. * Transform the url before loading if required.
  7703. * @param rootUrl the url of the texture
  7704. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7705. * @returns the transformed texture
  7706. */
  7707. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  7708. /**
  7709. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  7710. * @param rootUrl the url of the texture
  7711. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7712. * @returns the fallback texture
  7713. */
  7714. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  7715. /**
  7716. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  7717. * @param data contains the texture data
  7718. * @param texture defines the BabylonJS internal texture
  7719. * @param createPolynomials will be true if polynomials have been requested
  7720. * @param onLoad defines the callback to trigger once the texture is ready
  7721. * @param onError defines the callback to trigger in case of error
  7722. */
  7723. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  7724. /**
  7725. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  7726. * @param data contains the texture data
  7727. * @param texture defines the BabylonJS internal texture
  7728. * @param callback defines the method to call once ready to upload
  7729. */
  7730. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  7731. }
  7732. }
  7733. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7734. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7735. import { Nullable } from "babylonjs/types";
  7736. import { Scene } from "babylonjs/scene";
  7737. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7738. module "babylonjs/Engines/engine" {
  7739. interface Engine {
  7740. /**
  7741. * Creates a depth stencil cube texture.
  7742. * This is only available in WebGL 2.
  7743. * @param size The size of face edge in the cube texture.
  7744. * @param options The options defining the cube texture.
  7745. * @returns The cube texture
  7746. */
  7747. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7748. /**
  7749. * Creates a cube texture
  7750. * @param rootUrl defines the url where the files to load is located
  7751. * @param scene defines the current scene
  7752. * @param files defines the list of files to load (1 per face)
  7753. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7754. * @param onLoad defines an optional callback raised when the texture is loaded
  7755. * @param onError defines an optional callback raised if there is an issue to load the texture
  7756. * @param format defines the format of the data
  7757. * @param forcedExtension defines the extension to use to pick the right loader
  7758. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7759. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7760. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7761. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7762. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7763. * @returns the cube texture as an InternalTexture
  7764. */
  7765. 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;
  7766. /**
  7767. * Creates a cube texture
  7768. * @param rootUrl defines the url where the files to load is located
  7769. * @param scene defines the current scene
  7770. * @param files defines the list of files to load (1 per face)
  7771. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7772. * @param onLoad defines an optional callback raised when the texture is loaded
  7773. * @param onError defines an optional callback raised if there is an issue to load the texture
  7774. * @param format defines the format of the data
  7775. * @param forcedExtension defines the extension to use to pick the right loader
  7776. * @returns the cube texture as an InternalTexture
  7777. */
  7778. 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;
  7779. /**
  7780. * Creates a cube texture
  7781. * @param rootUrl defines the url where the files to load is located
  7782. * @param scene defines the current scene
  7783. * @param files defines the list of files to load (1 per face)
  7784. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7785. * @param onLoad defines an optional callback raised when the texture is loaded
  7786. * @param onError defines an optional callback raised if there is an issue to load the texture
  7787. * @param format defines the format of the data
  7788. * @param forcedExtension defines the extension to use to pick the right loader
  7789. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7790. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7791. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7792. * @returns the cube texture as an InternalTexture
  7793. */
  7794. 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;
  7795. /** @hidden */
  7796. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7797. /** @hidden */
  7798. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7799. /** @hidden */
  7800. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7801. /** @hidden */
  7802. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7803. }
  7804. }
  7805. }
  7806. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7807. import { Nullable } from "babylonjs/types";
  7808. import { Scene } from "babylonjs/scene";
  7809. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  7810. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7811. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7812. /**
  7813. * Class for creating a cube texture
  7814. */
  7815. export class CubeTexture extends BaseTexture {
  7816. private _delayedOnLoad;
  7817. /**
  7818. * The url of the texture
  7819. */
  7820. url: string;
  7821. /**
  7822. * Gets or sets the center of the bounding box associated with the cube texture.
  7823. * It must define where the camera used to render the texture was set
  7824. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7825. */
  7826. boundingBoxPosition: Vector3;
  7827. private _boundingBoxSize;
  7828. /**
  7829. * Gets or sets the size of the bounding box associated with the cube texture
  7830. * When defined, the cubemap will switch to local mode
  7831. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7832. * @example https://www.babylonjs-playground.com/#RNASML
  7833. */
  7834. /**
  7835. * Returns the bounding box size
  7836. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7837. */
  7838. boundingBoxSize: Vector3;
  7839. protected _rotationY: number;
  7840. /**
  7841. * Sets texture matrix rotation angle around Y axis in radians.
  7842. */
  7843. /**
  7844. * Gets texture matrix rotation angle around Y axis radians.
  7845. */
  7846. rotationY: number;
  7847. /**
  7848. * Are mip maps generated for this texture or not.
  7849. */
  7850. readonly noMipmap: boolean;
  7851. private _noMipmap;
  7852. private _files;
  7853. private _extensions;
  7854. private _textureMatrix;
  7855. private _format;
  7856. private _createPolynomials;
  7857. /** @hidden */
  7858. _prefiltered: boolean;
  7859. /**
  7860. * Creates a cube texture from an array of image urls
  7861. * @param files defines an array of image urls
  7862. * @param scene defines the hosting scene
  7863. * @param noMipmap specifies if mip maps are not used
  7864. * @returns a cube texture
  7865. */
  7866. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7867. /**
  7868. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7869. * @param url defines the url of the prefiltered texture
  7870. * @param scene defines the scene the texture is attached to
  7871. * @param forcedExtension defines the extension of the file if different from the url
  7872. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7873. * @return the prefiltered texture
  7874. */
  7875. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7876. /**
  7877. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7878. * as prefiltered data.
  7879. * @param rootUrl defines the url of the texture or the root name of the six images
  7880. * @param scene defines the scene the texture is attached to
  7881. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7882. * @param noMipmap defines if mipmaps should be created or not
  7883. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7884. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7885. * @param onError defines a callback triggered in case of error during load
  7886. * @param format defines the internal format to use for the texture once loaded
  7887. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7888. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7889. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7890. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7891. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7892. * @return the cube texture
  7893. */
  7894. 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);
  7895. /**
  7896. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7897. */
  7898. readonly isPrefiltered: boolean;
  7899. /**
  7900. * Get the current class name of the texture useful for serialization or dynamic coding.
  7901. * @returns "CubeTexture"
  7902. */
  7903. getClassName(): string;
  7904. /**
  7905. * Update the url (and optional buffer) of this texture if url was null during construction.
  7906. * @param url the url of the texture
  7907. * @param forcedExtension defines the extension to use
  7908. * @param onLoad callback called when the texture is loaded (defaults to null)
  7909. */
  7910. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7911. /**
  7912. * Delays loading of the cube texture
  7913. * @param forcedExtension defines the extension to use
  7914. */
  7915. delayLoad(forcedExtension?: string): void;
  7916. /**
  7917. * Returns the reflection texture matrix
  7918. * @returns the reflection texture matrix
  7919. */
  7920. getReflectionTextureMatrix(): Matrix;
  7921. /**
  7922. * Sets the reflection texture matrix
  7923. * @param value Reflection texture matrix
  7924. */
  7925. setReflectionTextureMatrix(value: Matrix): void;
  7926. /**
  7927. * Parses text to create a cube texture
  7928. * @param parsedTexture define the serialized text to read from
  7929. * @param scene defines the hosting scene
  7930. * @param rootUrl defines the root url of the cube texture
  7931. * @returns a cube texture
  7932. */
  7933. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7934. /**
  7935. * Makes a clone, or deep copy, of the cube texture
  7936. * @returns a new cube texture
  7937. */
  7938. clone(): CubeTexture;
  7939. }
  7940. }
  7941. declare module "babylonjs/Shaders/postprocess.vertex" {
  7942. /** @hidden */
  7943. export var postprocessVertexShader: {
  7944. name: string;
  7945. shader: string;
  7946. };
  7947. }
  7948. declare module "babylonjs/Cameras/targetCamera" {
  7949. import { Nullable } from "babylonjs/types";
  7950. import { Camera } from "babylonjs/Cameras/camera";
  7951. import { Scene } from "babylonjs/scene";
  7952. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  7953. /**
  7954. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  7955. * This is the base of the follow, arc rotate cameras and Free camera
  7956. * @see http://doc.babylonjs.com/features/cameras
  7957. */
  7958. export class TargetCamera extends Camera {
  7959. private static _RigCamTransformMatrix;
  7960. private static _TargetTransformMatrix;
  7961. private static _TargetFocalPoint;
  7962. /**
  7963. * Define the current direction the camera is moving to
  7964. */
  7965. cameraDirection: Vector3;
  7966. /**
  7967. * Define the current rotation the camera is rotating to
  7968. */
  7969. cameraRotation: Vector2;
  7970. /**
  7971. * When set, the up vector of the camera will be updated by the rotation of the camera
  7972. */
  7973. updateUpVectorFromRotation: boolean;
  7974. private _tmpQuaternion;
  7975. /**
  7976. * Define the current rotation of the camera
  7977. */
  7978. rotation: Vector3;
  7979. /**
  7980. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  7981. */
  7982. rotationQuaternion: Quaternion;
  7983. /**
  7984. * Define the current speed of the camera
  7985. */
  7986. speed: number;
  7987. /**
  7988. * Add cconstraint to the camera to prevent it to move freely in all directions and
  7989. * around all axis.
  7990. */
  7991. noRotationConstraint: boolean;
  7992. /**
  7993. * Define the current target of the camera as an object or a position.
  7994. */
  7995. lockedTarget: any;
  7996. /** @hidden */
  7997. _currentTarget: Vector3;
  7998. /** @hidden */
  7999. _initialFocalDistance: number;
  8000. /** @hidden */
  8001. _viewMatrix: Matrix;
  8002. /** @hidden */
  8003. _camMatrix: Matrix;
  8004. /** @hidden */
  8005. _cameraTransformMatrix: Matrix;
  8006. /** @hidden */
  8007. _cameraRotationMatrix: Matrix;
  8008. /** @hidden */
  8009. _referencePoint: Vector3;
  8010. /** @hidden */
  8011. _transformedReferencePoint: Vector3;
  8012. protected _globalCurrentTarget: Vector3;
  8013. protected _globalCurrentUpVector: Vector3;
  8014. /** @hidden */
  8015. _reset: () => void;
  8016. private _defaultUp;
  8017. /**
  8018. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8019. * This is the base of the follow, arc rotate cameras and Free camera
  8020. * @see http://doc.babylonjs.com/features/cameras
  8021. * @param name Defines the name of the camera in the scene
  8022. * @param position Defines the start position of the camera in the scene
  8023. * @param scene Defines the scene the camera belongs to
  8024. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8025. */
  8026. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8027. /**
  8028. * Gets the position in front of the camera at a given distance.
  8029. * @param distance The distance from the camera we want the position to be
  8030. * @returns the position
  8031. */
  8032. getFrontPosition(distance: number): Vector3;
  8033. /** @hidden */
  8034. _getLockedTargetPosition(): Nullable<Vector3>;
  8035. private _storedPosition;
  8036. private _storedRotation;
  8037. private _storedRotationQuaternion;
  8038. /**
  8039. * Store current camera state of the camera (fov, position, rotation, etc..)
  8040. * @returns the camera
  8041. */
  8042. storeState(): Camera;
  8043. /**
  8044. * Restored camera state. You must call storeState() first
  8045. * @returns whether it was successful or not
  8046. * @hidden
  8047. */
  8048. _restoreStateValues(): boolean;
  8049. /** @hidden */
  8050. _initCache(): void;
  8051. /** @hidden */
  8052. _updateCache(ignoreParentClass?: boolean): void;
  8053. /** @hidden */
  8054. _isSynchronizedViewMatrix(): boolean;
  8055. /** @hidden */
  8056. _computeLocalCameraSpeed(): number;
  8057. /**
  8058. * Defines the target the camera should look at.
  8059. * This will automatically adapt alpha beta and radius to fit within the new target.
  8060. * @param target Defines the new target as a Vector or a mesh
  8061. */
  8062. setTarget(target: Vector3): void;
  8063. /**
  8064. * Return the current target position of the camera. This value is expressed in local space.
  8065. * @returns the target position
  8066. */
  8067. getTarget(): Vector3;
  8068. /** @hidden */
  8069. _decideIfNeedsToMove(): boolean;
  8070. /** @hidden */
  8071. _updatePosition(): void;
  8072. /** @hidden */
  8073. _checkInputs(): void;
  8074. protected _updateCameraRotationMatrix(): void;
  8075. /**
  8076. * 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)
  8077. * @returns the current camera
  8078. */
  8079. private _rotateUpVectorWithCameraRotationMatrix;
  8080. private _cachedRotationZ;
  8081. private _cachedQuaternionRotationZ;
  8082. /** @hidden */
  8083. _getViewMatrix(): Matrix;
  8084. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8085. /**
  8086. * @hidden
  8087. */
  8088. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8089. /**
  8090. * @hidden
  8091. */
  8092. _updateRigCameras(): void;
  8093. private _getRigCamPositionAndTarget;
  8094. /**
  8095. * Gets the current object class name.
  8096. * @return the class name
  8097. */
  8098. getClassName(): string;
  8099. }
  8100. }
  8101. declare module "babylonjs/Cameras/cameraInputsManager" {
  8102. import { Nullable } from "babylonjs/types";
  8103. import { Camera } from "babylonjs/Cameras/camera";
  8104. /**
  8105. * @ignore
  8106. * This is a list of all the different input types that are available in the application.
  8107. * Fo instance: ArcRotateCameraGamepadInput...
  8108. */
  8109. export var CameraInputTypes: {};
  8110. /**
  8111. * This is the contract to implement in order to create a new input class.
  8112. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8113. */
  8114. export interface ICameraInput<TCamera extends Camera> {
  8115. /**
  8116. * Defines the camera the input is attached to.
  8117. */
  8118. camera: Nullable<TCamera>;
  8119. /**
  8120. * Gets the class name of the current intput.
  8121. * @returns the class name
  8122. */
  8123. getClassName(): string;
  8124. /**
  8125. * Get the friendly name associated with the input class.
  8126. * @returns the input friendly name
  8127. */
  8128. getSimpleName(): string;
  8129. /**
  8130. * Attach the input controls to a specific dom element to get the input from.
  8131. * @param element Defines the element the controls should be listened from
  8132. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8133. */
  8134. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8135. /**
  8136. * Detach the current controls from the specified dom element.
  8137. * @param element Defines the element to stop listening the inputs from
  8138. */
  8139. detachControl(element: Nullable<HTMLElement>): void;
  8140. /**
  8141. * Update the current camera state depending on the inputs that have been used this frame.
  8142. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8143. */
  8144. checkInputs?: () => void;
  8145. }
  8146. /**
  8147. * Represents a map of input types to input instance or input index to input instance.
  8148. */
  8149. export interface CameraInputsMap<TCamera extends Camera> {
  8150. /**
  8151. * Accessor to the input by input type.
  8152. */
  8153. [name: string]: ICameraInput<TCamera>;
  8154. /**
  8155. * Accessor to the input by input index.
  8156. */
  8157. [idx: number]: ICameraInput<TCamera>;
  8158. }
  8159. /**
  8160. * This represents the input manager used within a camera.
  8161. * It helps dealing with all the different kind of input attached to a camera.
  8162. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8163. */
  8164. export class CameraInputsManager<TCamera extends Camera> {
  8165. /**
  8166. * Defines the list of inputs attahed to the camera.
  8167. */
  8168. attached: CameraInputsMap<TCamera>;
  8169. /**
  8170. * Defines the dom element the camera is collecting inputs from.
  8171. * This is null if the controls have not been attached.
  8172. */
  8173. attachedElement: Nullable<HTMLElement>;
  8174. /**
  8175. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8176. */
  8177. noPreventDefault: boolean;
  8178. /**
  8179. * Defined the camera the input manager belongs to.
  8180. */
  8181. camera: TCamera;
  8182. /**
  8183. * Update the current camera state depending on the inputs that have been used this frame.
  8184. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8185. */
  8186. checkInputs: () => void;
  8187. /**
  8188. * Instantiate a new Camera Input Manager.
  8189. * @param camera Defines the camera the input manager blongs to
  8190. */
  8191. constructor(camera: TCamera);
  8192. /**
  8193. * Add an input method to a camera
  8194. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8195. * @param input camera input method
  8196. */
  8197. add(input: ICameraInput<TCamera>): void;
  8198. /**
  8199. * Remove a specific input method from a camera
  8200. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8201. * @param inputToRemove camera input method
  8202. */
  8203. remove(inputToRemove: ICameraInput<TCamera>): void;
  8204. /**
  8205. * Remove a specific input type from a camera
  8206. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8207. * @param inputType the type of the input to remove
  8208. */
  8209. removeByType(inputType: string): void;
  8210. private _addCheckInputs;
  8211. /**
  8212. * Attach the input controls to the currently attached dom element to listen the events from.
  8213. * @param input Defines the input to attach
  8214. */
  8215. attachInput(input: ICameraInput<TCamera>): void;
  8216. /**
  8217. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8218. * @param element Defines the dom element to collect the events from
  8219. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8220. */
  8221. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8222. /**
  8223. * Detach the current manager inputs controls from a specific dom element.
  8224. * @param element Defines the dom element to collect the events from
  8225. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8226. */
  8227. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8228. /**
  8229. * Rebuild the dynamic inputCheck function from the current list of
  8230. * defined inputs in the manager.
  8231. */
  8232. rebuildInputCheck(): void;
  8233. /**
  8234. * Remove all attached input methods from a camera
  8235. */
  8236. clear(): void;
  8237. /**
  8238. * Serialize the current input manager attached to a camera.
  8239. * This ensures than once parsed,
  8240. * the input associated to the camera will be identical to the current ones
  8241. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8242. */
  8243. serialize(serializedCamera: any): void;
  8244. /**
  8245. * Parses an input manager serialized JSON to restore the previous list of inputs
  8246. * and states associated to a camera.
  8247. * @param parsedCamera Defines the JSON to parse
  8248. */
  8249. parse(parsedCamera: any): void;
  8250. }
  8251. }
  8252. declare module "babylonjs/Events/keyboardEvents" {
  8253. /**
  8254. * Gather the list of keyboard event types as constants.
  8255. */
  8256. export class KeyboardEventTypes {
  8257. /**
  8258. * The keydown event is fired when a key becomes active (pressed).
  8259. */
  8260. static readonly KEYDOWN: number;
  8261. /**
  8262. * The keyup event is fired when a key has been released.
  8263. */
  8264. static readonly KEYUP: number;
  8265. }
  8266. /**
  8267. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8268. */
  8269. export class KeyboardInfo {
  8270. /**
  8271. * Defines the type of event (KeyboardEventTypes)
  8272. */
  8273. type: number;
  8274. /**
  8275. * Defines the related dom event
  8276. */
  8277. event: KeyboardEvent;
  8278. /**
  8279. * Instantiates a new keyboard info.
  8280. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8281. * @param type Defines the type of event (KeyboardEventTypes)
  8282. * @param event Defines the related dom event
  8283. */
  8284. constructor(
  8285. /**
  8286. * Defines the type of event (KeyboardEventTypes)
  8287. */
  8288. type: number,
  8289. /**
  8290. * Defines the related dom event
  8291. */
  8292. event: KeyboardEvent);
  8293. }
  8294. /**
  8295. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8296. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8297. */
  8298. export class KeyboardInfoPre extends KeyboardInfo {
  8299. /**
  8300. * Defines the type of event (KeyboardEventTypes)
  8301. */
  8302. type: number;
  8303. /**
  8304. * Defines the related dom event
  8305. */
  8306. event: KeyboardEvent;
  8307. /**
  8308. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8309. */
  8310. skipOnPointerObservable: boolean;
  8311. /**
  8312. * Instantiates a new keyboard pre info.
  8313. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8314. * @param type Defines the type of event (KeyboardEventTypes)
  8315. * @param event Defines the related dom event
  8316. */
  8317. constructor(
  8318. /**
  8319. * Defines the type of event (KeyboardEventTypes)
  8320. */
  8321. type: number,
  8322. /**
  8323. * Defines the related dom event
  8324. */
  8325. event: KeyboardEvent);
  8326. }
  8327. }
  8328. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8329. import { Nullable } from "babylonjs/types";
  8330. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8331. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8332. /**
  8333. * Manage the keyboard inputs to control the movement of a free camera.
  8334. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8335. */
  8336. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8337. /**
  8338. * Defines the camera the input is attached to.
  8339. */
  8340. camera: FreeCamera;
  8341. /**
  8342. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8343. */
  8344. keysUp: number[];
  8345. /**
  8346. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8347. */
  8348. keysDown: number[];
  8349. /**
  8350. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8351. */
  8352. keysLeft: number[];
  8353. /**
  8354. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8355. */
  8356. keysRight: number[];
  8357. private _keys;
  8358. private _onCanvasBlurObserver;
  8359. private _onKeyboardObserver;
  8360. private _engine;
  8361. private _scene;
  8362. /**
  8363. * Attach the input controls to a specific dom element to get the input from.
  8364. * @param element Defines the element the controls should be listened from
  8365. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8366. */
  8367. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8368. /**
  8369. * Detach the current controls from the specified dom element.
  8370. * @param element Defines the element to stop listening the inputs from
  8371. */
  8372. detachControl(element: Nullable<HTMLElement>): void;
  8373. /**
  8374. * Update the current camera state depending on the inputs that have been used this frame.
  8375. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8376. */
  8377. checkInputs(): void;
  8378. /**
  8379. * Gets the class name of the current intput.
  8380. * @returns the class name
  8381. */
  8382. getClassName(): string;
  8383. /** @hidden */
  8384. _onLostFocus(): void;
  8385. /**
  8386. * Get the friendly name associated with the input class.
  8387. * @returns the input friendly name
  8388. */
  8389. getSimpleName(): string;
  8390. }
  8391. }
  8392. declare module "babylonjs/Materials/multiMaterial" {
  8393. import { Nullable } from "babylonjs/types";
  8394. import { Scene } from "babylonjs/scene";
  8395. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8396. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  8397. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8398. import { Material } from "babylonjs/Materials/material";
  8399. /**
  8400. * A multi-material is used to apply different materials to different parts of the same object without the need of
  8401. * separate meshes. This can be use to improve performances.
  8402. * @see http://doc.babylonjs.com/how_to/multi_materials
  8403. */
  8404. export class MultiMaterial extends Material {
  8405. private _subMaterials;
  8406. /**
  8407. * Gets or Sets the list of Materials used within the multi material.
  8408. * They need to be ordered according to the submeshes order in the associated mesh
  8409. */
  8410. subMaterials: Nullable<Material>[];
  8411. /**
  8412. * Function used to align with Node.getChildren()
  8413. * @returns the list of Materials used within the multi material
  8414. */
  8415. getChildren(): Nullable<Material>[];
  8416. /**
  8417. * Instantiates a new Multi Material
  8418. * A multi-material is used to apply different materials to different parts of the same object without the need of
  8419. * separate meshes. This can be use to improve performances.
  8420. * @see http://doc.babylonjs.com/how_to/multi_materials
  8421. * @param name Define the name in the scene
  8422. * @param scene Define the scene the material belongs to
  8423. */
  8424. constructor(name: string, scene: Scene);
  8425. private _hookArray;
  8426. /**
  8427. * Get one of the submaterial by its index in the submaterials array
  8428. * @param index The index to look the sub material at
  8429. * @returns The Material if the index has been defined
  8430. */
  8431. getSubMaterial(index: number): Nullable<Material>;
  8432. /**
  8433. * Get the list of active textures for the whole sub materials list.
  8434. * @returns All the textures that will be used during the rendering
  8435. */
  8436. getActiveTextures(): BaseTexture[];
  8437. /**
  8438. * Gets the current class name of the material e.g. "MultiMaterial"
  8439. * Mainly use in serialization.
  8440. * @returns the class name
  8441. */
  8442. getClassName(): string;
  8443. /**
  8444. * Checks if the material is ready to render the requested sub mesh
  8445. * @param mesh Define the mesh the submesh belongs to
  8446. * @param subMesh Define the sub mesh to look readyness for
  8447. * @param useInstances Define whether or not the material is used with instances
  8448. * @returns true if ready, otherwise false
  8449. */
  8450. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  8451. /**
  8452. * Clones the current material and its related sub materials
  8453. * @param name Define the name of the newly cloned material
  8454. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  8455. * @returns the cloned material
  8456. */
  8457. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  8458. /**
  8459. * Serializes the materials into a JSON representation.
  8460. * @returns the JSON representation
  8461. */
  8462. serialize(): any;
  8463. /**
  8464. * Dispose the material and release its associated resources
  8465. * @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)
  8466. * @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)
  8467. * @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)
  8468. */
  8469. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  8470. /**
  8471. * Creates a MultiMaterial from parsed MultiMaterial data.
  8472. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  8473. * @param scene defines the hosting scene
  8474. * @returns a new MultiMaterial
  8475. */
  8476. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  8477. }
  8478. }
  8479. declare module "babylonjs/Loading/sceneLoaderFlags" {
  8480. /**
  8481. * Class used to represent data loading progression
  8482. */
  8483. export class SceneLoaderFlags {
  8484. private static _ForceFullSceneLoadingForIncremental;
  8485. private static _ShowLoadingScreen;
  8486. private static _CleanBoneMatrixWeights;
  8487. private static _loggingLevel;
  8488. /**
  8489. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  8490. */
  8491. static ForceFullSceneLoadingForIncremental: boolean;
  8492. /**
  8493. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  8494. */
  8495. static ShowLoadingScreen: boolean;
  8496. /**
  8497. * Defines the current logging level (while loading the scene)
  8498. * @ignorenaming
  8499. */
  8500. static loggingLevel: number;
  8501. /**
  8502. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  8503. */
  8504. static CleanBoneMatrixWeights: boolean;
  8505. }
  8506. }
  8507. declare module "babylonjs/Meshes/transformNode" {
  8508. import { DeepImmutable } from "babylonjs/types";
  8509. import { Observable } from "babylonjs/Misc/observable";
  8510. import { Nullable } from "babylonjs/types";
  8511. import { Camera } from "babylonjs/Cameras/camera";
  8512. import { Scene } from "babylonjs/scene";
  8513. import { Quaternion, Matrix, Vector3, Space } from "babylonjs/Maths/math";
  8514. import { Node } from "babylonjs/node";
  8515. import { Bone } from "babylonjs/Bones/bone";
  8516. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8517. /**
  8518. * 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.
  8519. * @see https://doc.babylonjs.com/how_to/transformnode
  8520. */
  8521. export class TransformNode extends Node {
  8522. /**
  8523. * Object will not rotate to face the camera
  8524. */
  8525. static BILLBOARDMODE_NONE: number;
  8526. /**
  8527. * Object will rotate to face the camera but only on the x axis
  8528. */
  8529. static BILLBOARDMODE_X: number;
  8530. /**
  8531. * Object will rotate to face the camera but only on the y axis
  8532. */
  8533. static BILLBOARDMODE_Y: number;
  8534. /**
  8535. * Object will rotate to face the camera but only on the z axis
  8536. */
  8537. static BILLBOARDMODE_Z: number;
  8538. /**
  8539. * Object will rotate to face the camera
  8540. */
  8541. static BILLBOARDMODE_ALL: number;
  8542. private _forward;
  8543. private _forwardInverted;
  8544. private _up;
  8545. private _right;
  8546. private _rightInverted;
  8547. private _position;
  8548. private _rotation;
  8549. private _rotationQuaternion;
  8550. protected _scaling: Vector3;
  8551. protected _isDirty: boolean;
  8552. private _transformToBoneReferal;
  8553. private _billboardMode;
  8554. /**
  8555. * Gets or sets the billboard mode. Default is 0.
  8556. *
  8557. * | Value | Type | Description |
  8558. * | --- | --- | --- |
  8559. * | 0 | BILLBOARDMODE_NONE | |
  8560. * | 1 | BILLBOARDMODE_X | |
  8561. * | 2 | BILLBOARDMODE_Y | |
  8562. * | 4 | BILLBOARDMODE_Z | |
  8563. * | 7 | BILLBOARDMODE_ALL | |
  8564. *
  8565. */
  8566. billboardMode: number;
  8567. private _preserveParentRotationForBillboard;
  8568. /**
  8569. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  8570. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  8571. */
  8572. preserveParentRotationForBillboard: boolean;
  8573. /**
  8574. * 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
  8575. */
  8576. scalingDeterminant: number;
  8577. private _infiniteDistance;
  8578. /**
  8579. * Gets or sets the distance of the object to max, often used by skybox
  8580. */
  8581. infiniteDistance: boolean;
  8582. /**
  8583. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  8584. * By default the system will update normals to compensate
  8585. */
  8586. ignoreNonUniformScaling: boolean;
  8587. /**
  8588. * 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
  8589. */
  8590. reIntegrateRotationIntoRotationQuaternion: boolean;
  8591. /** @hidden */
  8592. _poseMatrix: Nullable<Matrix>;
  8593. /** @hidden */
  8594. _localMatrix: Matrix;
  8595. private _usePivotMatrix;
  8596. private _absolutePosition;
  8597. private _pivotMatrix;
  8598. private _pivotMatrixInverse;
  8599. protected _postMultiplyPivotMatrix: boolean;
  8600. protected _isWorldMatrixFrozen: boolean;
  8601. /** @hidden */
  8602. _indexInSceneTransformNodesArray: number;
  8603. /**
  8604. * An event triggered after the world matrix is updated
  8605. */
  8606. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  8607. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  8608. /**
  8609. * Gets a string identifying the name of the class
  8610. * @returns "TransformNode" string
  8611. */
  8612. getClassName(): string;
  8613. /**
  8614. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  8615. */
  8616. position: Vector3;
  8617. /**
  8618. * 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)).
  8619. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  8620. */
  8621. rotation: Vector3;
  8622. /**
  8623. * 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)).
  8624. */
  8625. scaling: Vector3;
  8626. /**
  8627. * 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).
  8628. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  8629. */
  8630. rotationQuaternion: Nullable<Quaternion>;
  8631. /**
  8632. * The forward direction of that transform in world space.
  8633. */
  8634. readonly forward: Vector3;
  8635. /**
  8636. * The up direction of that transform in world space.
  8637. */
  8638. readonly up: Vector3;
  8639. /**
  8640. * The right direction of that transform in world space.
  8641. */
  8642. readonly right: Vector3;
  8643. /**
  8644. * Copies the parameter passed Matrix into the mesh Pose matrix.
  8645. * @param matrix the matrix to copy the pose from
  8646. * @returns this TransformNode.
  8647. */
  8648. updatePoseMatrix(matrix: Matrix): TransformNode;
  8649. /**
  8650. * Returns the mesh Pose matrix.
  8651. * @returns the pose matrix
  8652. */
  8653. getPoseMatrix(): Matrix;
  8654. /** @hidden */
  8655. _isSynchronized(): boolean;
  8656. /** @hidden */
  8657. _initCache(): void;
  8658. /**
  8659. * Flag the transform node as dirty (Forcing it to update everything)
  8660. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  8661. * @returns this transform node
  8662. */
  8663. markAsDirty(property: string): TransformNode;
  8664. /**
  8665. * Returns the current mesh absolute position.
  8666. * Returns a Vector3.
  8667. */
  8668. readonly absolutePosition: Vector3;
  8669. /**
  8670. * Sets a new matrix to apply before all other transformation
  8671. * @param matrix defines the transform matrix
  8672. * @returns the current TransformNode
  8673. */
  8674. setPreTransformMatrix(matrix: Matrix): TransformNode;
  8675. /**
  8676. * Sets a new pivot matrix to the current node
  8677. * @param matrix defines the new pivot matrix to use
  8678. * @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
  8679. * @returns the current TransformNode
  8680. */
  8681. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  8682. /**
  8683. * Returns the mesh pivot matrix.
  8684. * Default : Identity.
  8685. * @returns the matrix
  8686. */
  8687. getPivotMatrix(): Matrix;
  8688. /**
  8689. * Prevents the World matrix to be computed any longer.
  8690. * @returns the TransformNode.
  8691. */
  8692. freezeWorldMatrix(): TransformNode;
  8693. /**
  8694. * Allows back the World matrix computation.
  8695. * @returns the TransformNode.
  8696. */
  8697. unfreezeWorldMatrix(): this;
  8698. /**
  8699. * True if the World matrix has been frozen.
  8700. */
  8701. readonly isWorldMatrixFrozen: boolean;
  8702. /**
  8703. * Retuns the mesh absolute position in the World.
  8704. * @returns a Vector3.
  8705. */
  8706. getAbsolutePosition(): Vector3;
  8707. /**
  8708. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  8709. * @param absolutePosition the absolute position to set
  8710. * @returns the TransformNode.
  8711. */
  8712. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  8713. /**
  8714. * Sets the mesh position in its local space.
  8715. * @param vector3 the position to set in localspace
  8716. * @returns the TransformNode.
  8717. */
  8718. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  8719. /**
  8720. * Returns the mesh position in the local space from the current World matrix values.
  8721. * @returns a new Vector3.
  8722. */
  8723. getPositionExpressedInLocalSpace(): Vector3;
  8724. /**
  8725. * Translates the mesh along the passed Vector3 in its local space.
  8726. * @param vector3 the distance to translate in localspace
  8727. * @returns the TransformNode.
  8728. */
  8729. locallyTranslate(vector3: Vector3): TransformNode;
  8730. private static _lookAtVectorCache;
  8731. /**
  8732. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  8733. * @param targetPoint the position (must be in same space as current mesh) to look at
  8734. * @param yawCor optional yaw (y-axis) correction in radians
  8735. * @param pitchCor optional pitch (x-axis) correction in radians
  8736. * @param rollCor optional roll (z-axis) correction in radians
  8737. * @param space the choosen space of the target
  8738. * @returns the TransformNode.
  8739. */
  8740. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  8741. /**
  8742. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  8743. * This Vector3 is expressed in the World space.
  8744. * @param localAxis axis to rotate
  8745. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  8746. */
  8747. getDirection(localAxis: Vector3): Vector3;
  8748. /**
  8749. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  8750. * localAxis is expressed in the mesh local space.
  8751. * result is computed in the Wordl space from the mesh World matrix.
  8752. * @param localAxis axis to rotate
  8753. * @param result the resulting transformnode
  8754. * @returns this TransformNode.
  8755. */
  8756. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  8757. /**
  8758. * Sets this transform node rotation to the given local axis.
  8759. * @param localAxis the axis in local space
  8760. * @param yawCor optional yaw (y-axis) correction in radians
  8761. * @param pitchCor optional pitch (x-axis) correction in radians
  8762. * @param rollCor optional roll (z-axis) correction in radians
  8763. * @returns this TransformNode
  8764. */
  8765. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  8766. /**
  8767. * Sets a new pivot point to the current node
  8768. * @param point defines the new pivot point to use
  8769. * @param space defines if the point is in world or local space (local by default)
  8770. * @returns the current TransformNode
  8771. */
  8772. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  8773. /**
  8774. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  8775. * @returns the pivot point
  8776. */
  8777. getPivotPoint(): Vector3;
  8778. /**
  8779. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  8780. * @param result the vector3 to store the result
  8781. * @returns this TransformNode.
  8782. */
  8783. getPivotPointToRef(result: Vector3): TransformNode;
  8784. /**
  8785. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  8786. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  8787. */
  8788. getAbsolutePivotPoint(): Vector3;
  8789. /**
  8790. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  8791. * @param result vector3 to store the result
  8792. * @returns this TransformNode.
  8793. */
  8794. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  8795. /**
  8796. * Defines the passed node as the parent of the current node.
  8797. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  8798. * @see https://doc.babylonjs.com/how_to/parenting
  8799. * @param node the node ot set as the parent
  8800. * @returns this TransformNode.
  8801. */
  8802. setParent(node: Nullable<Node>): TransformNode;
  8803. private _nonUniformScaling;
  8804. /**
  8805. * True if the scaling property of this object is non uniform eg. (1,2,1)
  8806. */
  8807. readonly nonUniformScaling: boolean;
  8808. /** @hidden */
  8809. _updateNonUniformScalingState(value: boolean): boolean;
  8810. /**
  8811. * Attach the current TransformNode to another TransformNode associated with a bone
  8812. * @param bone Bone affecting the TransformNode
  8813. * @param affectedTransformNode TransformNode associated with the bone
  8814. * @returns this object
  8815. */
  8816. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  8817. /**
  8818. * Detach the transform node if its associated with a bone
  8819. * @returns this object
  8820. */
  8821. detachFromBone(): TransformNode;
  8822. private static _rotationAxisCache;
  8823. /**
  8824. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  8825. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  8826. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  8827. * The passed axis is also normalized.
  8828. * @param axis the axis to rotate around
  8829. * @param amount the amount to rotate in radians
  8830. * @param space Space to rotate in (Default: local)
  8831. * @returns the TransformNode.
  8832. */
  8833. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  8834. /**
  8835. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  8836. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  8837. * The passed axis is also normalized. .
  8838. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  8839. * @param point the point to rotate around
  8840. * @param axis the axis to rotate around
  8841. * @param amount the amount to rotate in radians
  8842. * @returns the TransformNode
  8843. */
  8844. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  8845. /**
  8846. * Translates the mesh along the axis vector for the passed distance in the given space.
  8847. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  8848. * @param axis the axis to translate in
  8849. * @param distance the distance to translate
  8850. * @param space Space to rotate in (Default: local)
  8851. * @returns the TransformNode.
  8852. */
  8853. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  8854. /**
  8855. * Adds a rotation step to the mesh current rotation.
  8856. * x, y, z are Euler angles expressed in radians.
  8857. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  8858. * This means this rotation is made in the mesh local space only.
  8859. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  8860. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  8861. * ```javascript
  8862. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  8863. * ```
  8864. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  8865. * 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.
  8866. * @param x Rotation to add
  8867. * @param y Rotation to add
  8868. * @param z Rotation to add
  8869. * @returns the TransformNode.
  8870. */
  8871. addRotation(x: number, y: number, z: number): TransformNode;
  8872. /**
  8873. * @hidden
  8874. */
  8875. protected _getEffectiveParent(): Nullable<Node>;
  8876. /**
  8877. * Computes the world matrix of the node
  8878. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8879. * @returns the world matrix
  8880. */
  8881. computeWorldMatrix(force?: boolean): Matrix;
  8882. protected _afterComputeWorldMatrix(): void;
  8883. /**
  8884. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  8885. * @param func callback function to add
  8886. *
  8887. * @returns the TransformNode.
  8888. */
  8889. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  8890. /**
  8891. * Removes a registered callback function.
  8892. * @param func callback function to remove
  8893. * @returns the TransformNode.
  8894. */
  8895. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  8896. /**
  8897. * Gets the position of the current mesh in camera space
  8898. * @param camera defines the camera to use
  8899. * @returns a position
  8900. */
  8901. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  8902. /**
  8903. * Returns the distance from the mesh to the active camera
  8904. * @param camera defines the camera to use
  8905. * @returns the distance
  8906. */
  8907. getDistanceToCamera(camera?: Nullable<Camera>): number;
  8908. /**
  8909. * Clone the current transform node
  8910. * @param name Name of the new clone
  8911. * @param newParent New parent for the clone
  8912. * @param doNotCloneChildren Do not clone children hierarchy
  8913. * @returns the new transform node
  8914. */
  8915. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  8916. /**
  8917. * Serializes the objects information.
  8918. * @param currentSerializationObject defines the object to serialize in
  8919. * @returns the serialized object
  8920. */
  8921. serialize(currentSerializationObject?: any): any;
  8922. /**
  8923. * Returns a new TransformNode object parsed from the source provided.
  8924. * @param parsedTransformNode is the source.
  8925. * @param scene the scne the object belongs to
  8926. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  8927. * @returns a new TransformNode object parsed from the source provided.
  8928. */
  8929. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  8930. /**
  8931. * Get all child-transformNodes of this node
  8932. * @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
  8933. * @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
  8934. * @returns an array of TransformNode
  8935. */
  8936. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  8937. /**
  8938. * Releases resources associated with this transform node.
  8939. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  8940. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  8941. */
  8942. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  8943. /**
  8944. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  8945. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  8946. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  8947. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  8948. * @returns the current mesh
  8949. */
  8950. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  8951. }
  8952. }
  8953. declare module "babylonjs/Animations/animationPropertiesOverride" {
  8954. /**
  8955. * Class used to override all child animations of a given target
  8956. */
  8957. export class AnimationPropertiesOverride {
  8958. /**
  8959. * Gets or sets a value indicating if animation blending must be used
  8960. */
  8961. enableBlending: boolean;
  8962. /**
  8963. * Gets or sets the blending speed to use when enableBlending is true
  8964. */
  8965. blendingSpeed: number;
  8966. /**
  8967. * Gets or sets the default loop mode to use
  8968. */
  8969. loopMode: number;
  8970. }
  8971. }
  8972. declare module "babylonjs/Bones/bone" {
  8973. import { Skeleton } from "babylonjs/Bones/skeleton";
  8974. import { Vector3, Quaternion, Matrix, Space } from "babylonjs/Maths/math";
  8975. import { Nullable } from "babylonjs/types";
  8976. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8977. import { TransformNode } from "babylonjs/Meshes/transformNode";
  8978. import { Node } from "babylonjs/node";
  8979. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  8980. /**
  8981. * Class used to store bone information
  8982. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  8983. */
  8984. export class Bone extends Node {
  8985. /**
  8986. * defines the bone name
  8987. */
  8988. name: string;
  8989. private static _tmpVecs;
  8990. private static _tmpQuat;
  8991. private static _tmpMats;
  8992. /**
  8993. * Gets the list of child bones
  8994. */
  8995. children: Bone[];
  8996. /** Gets the animations associated with this bone */
  8997. animations: import("babylonjs/Animations/animation").Animation[];
  8998. /**
  8999. * Gets or sets bone length
  9000. */
  9001. length: number;
  9002. /**
  9003. * @hidden Internal only
  9004. * Set this value to map this bone to a different index in the transform matrices
  9005. * Set this value to -1 to exclude the bone from the transform matrices
  9006. */
  9007. _index: Nullable<number>;
  9008. private _skeleton;
  9009. private _localMatrix;
  9010. private _restPose;
  9011. private _baseMatrix;
  9012. private _absoluteTransform;
  9013. private _invertedAbsoluteTransform;
  9014. private _parent;
  9015. private _scalingDeterminant;
  9016. private _worldTransform;
  9017. private _localScaling;
  9018. private _localRotation;
  9019. private _localPosition;
  9020. private _needToDecompose;
  9021. private _needToCompose;
  9022. /** @hidden */
  9023. _linkedTransformNode: Nullable<TransformNode>;
  9024. /** @hidden */
  9025. _waitingTransformNodeId: Nullable<string>;
  9026. /** @hidden */
  9027. /** @hidden */
  9028. _matrix: Matrix;
  9029. /**
  9030. * Create a new bone
  9031. * @param name defines the bone name
  9032. * @param skeleton defines the parent skeleton
  9033. * @param parentBone defines the parent (can be null if the bone is the root)
  9034. * @param localMatrix defines the local matrix
  9035. * @param restPose defines the rest pose matrix
  9036. * @param baseMatrix defines the base matrix
  9037. * @param index defines index of the bone in the hiearchy
  9038. */
  9039. constructor(
  9040. /**
  9041. * defines the bone name
  9042. */
  9043. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  9044. /**
  9045. * Gets the current object class name.
  9046. * @return the class name
  9047. */
  9048. getClassName(): string;
  9049. /**
  9050. * Gets the parent skeleton
  9051. * @returns a skeleton
  9052. */
  9053. getSkeleton(): Skeleton;
  9054. /**
  9055. * Gets parent bone
  9056. * @returns a bone or null if the bone is the root of the bone hierarchy
  9057. */
  9058. getParent(): Nullable<Bone>;
  9059. /**
  9060. * Returns an array containing the root bones
  9061. * @returns an array containing the root bones
  9062. */
  9063. getChildren(): Array<Bone>;
  9064. /**
  9065. * Sets the parent bone
  9066. * @param parent defines the parent (can be null if the bone is the root)
  9067. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  9068. */
  9069. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  9070. /**
  9071. * Gets the local matrix
  9072. * @returns a matrix
  9073. */
  9074. getLocalMatrix(): Matrix;
  9075. /**
  9076. * Gets the base matrix (initial matrix which remains unchanged)
  9077. * @returns a matrix
  9078. */
  9079. getBaseMatrix(): Matrix;
  9080. /**
  9081. * Gets the rest pose matrix
  9082. * @returns a matrix
  9083. */
  9084. getRestPose(): Matrix;
  9085. /**
  9086. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  9087. */
  9088. getWorldMatrix(): Matrix;
  9089. /**
  9090. * Sets the local matrix to rest pose matrix
  9091. */
  9092. returnToRest(): void;
  9093. /**
  9094. * Gets the inverse of the absolute transform matrix.
  9095. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  9096. * @returns a matrix
  9097. */
  9098. getInvertedAbsoluteTransform(): Matrix;
  9099. /**
  9100. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  9101. * @returns a matrix
  9102. */
  9103. getAbsoluteTransform(): Matrix;
  9104. /**
  9105. * Links with the given transform node.
  9106. * The local matrix of this bone is copied from the transform node every frame.
  9107. * @param transformNode defines the transform node to link to
  9108. */
  9109. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  9110. /** Gets or sets current position (in local space) */
  9111. position: Vector3;
  9112. /** Gets or sets current rotation (in local space) */
  9113. rotation: Vector3;
  9114. /** Gets or sets current rotation quaternion (in local space) */
  9115. rotationQuaternion: Quaternion;
  9116. /** Gets or sets current scaling (in local space) */
  9117. scaling: Vector3;
  9118. /**
  9119. * Gets the animation properties override
  9120. */
  9121. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  9122. private _decompose;
  9123. private _compose;
  9124. /**
  9125. * Update the base and local matrices
  9126. * @param matrix defines the new base or local matrix
  9127. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  9128. * @param updateLocalMatrix defines if the local matrix should be updated
  9129. */
  9130. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  9131. /** @hidden */
  9132. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  9133. /**
  9134. * Flag the bone as dirty (Forcing it to update everything)
  9135. */
  9136. markAsDirty(): void;
  9137. /** @hidden */
  9138. _markAsDirtyAndCompose(): void;
  9139. private _markAsDirtyAndDecompose;
  9140. /**
  9141. * Translate the bone in local or world space
  9142. * @param vec The amount to translate the bone
  9143. * @param space The space that the translation is in
  9144. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9145. */
  9146. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  9147. /**
  9148. * Set the postion of the bone in local or world space
  9149. * @param position The position to set the bone
  9150. * @param space The space that the position is in
  9151. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9152. */
  9153. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  9154. /**
  9155. * Set the absolute position of the bone (world space)
  9156. * @param position The position to set the bone
  9157. * @param mesh The mesh that this bone is attached to
  9158. */
  9159. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  9160. /**
  9161. * Scale the bone on the x, y and z axes (in local space)
  9162. * @param x The amount to scale the bone on the x axis
  9163. * @param y The amount to scale the bone on the y axis
  9164. * @param z The amount to scale the bone on the z axis
  9165. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  9166. */
  9167. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  9168. /**
  9169. * Set the bone scaling in local space
  9170. * @param scale defines the scaling vector
  9171. */
  9172. setScale(scale: Vector3): void;
  9173. /**
  9174. * Gets the current scaling in local space
  9175. * @returns the current scaling vector
  9176. */
  9177. getScale(): Vector3;
  9178. /**
  9179. * Gets the current scaling in local space and stores it in a target vector
  9180. * @param result defines the target vector
  9181. */
  9182. getScaleToRef(result: Vector3): void;
  9183. /**
  9184. * Set the yaw, pitch, and roll of the bone in local or world space
  9185. * @param yaw The rotation of the bone on the y axis
  9186. * @param pitch The rotation of the bone on the x axis
  9187. * @param roll The rotation of the bone on the z axis
  9188. * @param space The space that the axes of rotation are in
  9189. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9190. */
  9191. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  9192. /**
  9193. * Add a rotation to the bone on an axis in local or world space
  9194. * @param axis The axis to rotate the bone on
  9195. * @param amount The amount to rotate the bone
  9196. * @param space The space that the axis is in
  9197. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9198. */
  9199. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  9200. /**
  9201. * Set the rotation of the bone to a particular axis angle in local or world space
  9202. * @param axis The axis to rotate the bone on
  9203. * @param angle The angle that the bone should be rotated to
  9204. * @param space The space that the axis is in
  9205. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9206. */
  9207. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  9208. /**
  9209. * Set the euler rotation of the bone in local of world space
  9210. * @param rotation The euler rotation that the bone should be set to
  9211. * @param space The space that the rotation is in
  9212. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9213. */
  9214. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  9215. /**
  9216. * Set the quaternion rotation of the bone in local of world space
  9217. * @param quat The quaternion rotation that the bone should be set to
  9218. * @param space The space that the rotation is in
  9219. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9220. */
  9221. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  9222. /**
  9223. * Set the rotation matrix of the bone in local of world space
  9224. * @param rotMat The rotation matrix that the bone should be set to
  9225. * @param space The space that the rotation is in
  9226. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9227. */
  9228. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  9229. private _rotateWithMatrix;
  9230. private _getNegativeRotationToRef;
  9231. /**
  9232. * Get the position of the bone in local or world space
  9233. * @param space The space that the returned position is in
  9234. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9235. * @returns The position of the bone
  9236. */
  9237. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  9238. /**
  9239. * Copy the position of the bone to a vector3 in local or world space
  9240. * @param space The space that the returned position is in
  9241. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9242. * @param result The vector3 to copy the position to
  9243. */
  9244. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  9245. /**
  9246. * Get the absolute position of the bone (world space)
  9247. * @param mesh The mesh that this bone is attached to
  9248. * @returns The absolute position of the bone
  9249. */
  9250. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  9251. /**
  9252. * Copy the absolute position of the bone (world space) to the result param
  9253. * @param mesh The mesh that this bone is attached to
  9254. * @param result The vector3 to copy the absolute position to
  9255. */
  9256. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  9257. /**
  9258. * Compute the absolute transforms of this bone and its children
  9259. */
  9260. computeAbsoluteTransforms(): void;
  9261. /**
  9262. * Get the world direction from an axis that is in the local space of the bone
  9263. * @param localAxis The local direction that is used to compute the world direction
  9264. * @param mesh The mesh that this bone is attached to
  9265. * @returns The world direction
  9266. */
  9267. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9268. /**
  9269. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  9270. * @param localAxis The local direction that is used to compute the world direction
  9271. * @param mesh The mesh that this bone is attached to
  9272. * @param result The vector3 that the world direction will be copied to
  9273. */
  9274. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9275. /**
  9276. * Get the euler rotation of the bone in local or world space
  9277. * @param space The space that the rotation should be in
  9278. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9279. * @returns The euler rotation
  9280. */
  9281. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  9282. /**
  9283. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  9284. * @param space The space that the rotation should be in
  9285. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9286. * @param result The vector3 that the rotation should be copied to
  9287. */
  9288. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9289. /**
  9290. * Get the quaternion rotation of the bone in either local or world space
  9291. * @param space The space that the rotation should be in
  9292. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9293. * @returns The quaternion rotation
  9294. */
  9295. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  9296. /**
  9297. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  9298. * @param space The space that the rotation should be in
  9299. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9300. * @param result The quaternion that the rotation should be copied to
  9301. */
  9302. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  9303. /**
  9304. * Get the rotation matrix of the bone in local or world space
  9305. * @param space The space that the rotation should be in
  9306. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9307. * @returns The rotation matrix
  9308. */
  9309. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  9310. /**
  9311. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  9312. * @param space The space that the rotation should be in
  9313. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9314. * @param result The quaternion that the rotation should be copied to
  9315. */
  9316. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  9317. /**
  9318. * Get the world position of a point that is in the local space of the bone
  9319. * @param position The local position
  9320. * @param mesh The mesh that this bone is attached to
  9321. * @returns The world position
  9322. */
  9323. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9324. /**
  9325. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  9326. * @param position The local position
  9327. * @param mesh The mesh that this bone is attached to
  9328. * @param result The vector3 that the world position should be copied to
  9329. */
  9330. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9331. /**
  9332. * Get the local position of a point that is in world space
  9333. * @param position The world position
  9334. * @param mesh The mesh that this bone is attached to
  9335. * @returns The local position
  9336. */
  9337. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9338. /**
  9339. * Get the local position of a point that is in world space and copy it to the result param
  9340. * @param position The world position
  9341. * @param mesh The mesh that this bone is attached to
  9342. * @param result The vector3 that the local position should be copied to
  9343. */
  9344. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9345. }
  9346. }
  9347. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  9348. import { Nullable } from "babylonjs/types";
  9349. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  9350. import { Scene } from "babylonjs/scene";
  9351. module "babylonjs/Engines/engine" {
  9352. interface Engine {
  9353. /**
  9354. * Creates a raw texture
  9355. * @param data defines the data to store in the texture
  9356. * @param width defines the width of the texture
  9357. * @param height defines the height of the texture
  9358. * @param format defines the format of the data
  9359. * @param generateMipMaps defines if the engine should generate the mip levels
  9360. * @param invertY defines if data must be stored with Y axis inverted
  9361. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  9362. * @param compression defines the compression used (null by default)
  9363. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9364. * @returns the raw texture inside an InternalTexture
  9365. */
  9366. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  9367. /**
  9368. * Update a raw texture
  9369. * @param texture defines the texture to update
  9370. * @param data defines the data to store in the texture
  9371. * @param format defines the format of the data
  9372. * @param invertY defines if data must be stored with Y axis inverted
  9373. */
  9374. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  9375. /**
  9376. * Update a raw texture
  9377. * @param texture defines the texture to update
  9378. * @param data defines the data to store in the texture
  9379. * @param format defines the format of the data
  9380. * @param invertY defines if data must be stored with Y axis inverted
  9381. * @param compression defines the compression used (null by default)
  9382. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9383. */
  9384. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  9385. /**
  9386. * Creates a new raw cube texture
  9387. * @param data defines the array of data to use to create each face
  9388. * @param size defines the size of the textures
  9389. * @param format defines the format of the data
  9390. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  9391. * @param generateMipMaps defines if the engine should generate the mip levels
  9392. * @param invertY defines if data must be stored with Y axis inverted
  9393. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  9394. * @param compression defines the compression used (null by default)
  9395. * @returns the cube texture as an InternalTexture
  9396. */
  9397. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  9398. /**
  9399. * Update a raw cube texture
  9400. * @param texture defines the texture to udpdate
  9401. * @param data defines the data to store
  9402. * @param format defines the data format
  9403. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9404. * @param invertY defines if data must be stored with Y axis inverted
  9405. */
  9406. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  9407. /**
  9408. * Update a raw cube texture
  9409. * @param texture defines the texture to udpdate
  9410. * @param data defines the data to store
  9411. * @param format defines the data format
  9412. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9413. * @param invertY defines if data must be stored with Y axis inverted
  9414. * @param compression defines the compression used (null by default)
  9415. */
  9416. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  9417. /**
  9418. * Update a raw cube texture
  9419. * @param texture defines the texture to udpdate
  9420. * @param data defines the data to store
  9421. * @param format defines the data format
  9422. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9423. * @param invertY defines if data must be stored with Y axis inverted
  9424. * @param compression defines the compression used (null by default)
  9425. * @param level defines which level of the texture to update
  9426. */
  9427. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  9428. /**
  9429. * Creates a new raw cube texture from a specified url
  9430. * @param url defines the url where the data is located
  9431. * @param scene defines the current scene
  9432. * @param size defines the size of the textures
  9433. * @param format defines the format of the data
  9434. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  9435. * @param noMipmap defines if the engine should avoid generating the mip levels
  9436. * @param callback defines a callback used to extract texture data from loaded data
  9437. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  9438. * @param onLoad defines a callback called when texture is loaded
  9439. * @param onError defines a callback called if there is an error
  9440. * @returns the cube texture as an InternalTexture
  9441. */
  9442. 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;
  9443. /**
  9444. * Creates a new raw cube texture from a specified url
  9445. * @param url defines the url where the data is located
  9446. * @param scene defines the current scene
  9447. * @param size defines the size of the textures
  9448. * @param format defines the format of the data
  9449. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  9450. * @param noMipmap defines if the engine should avoid generating the mip levels
  9451. * @param callback defines a callback used to extract texture data from loaded data
  9452. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  9453. * @param onLoad defines a callback called when texture is loaded
  9454. * @param onError defines a callback called if there is an error
  9455. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  9456. * @param invertY defines if data must be stored with Y axis inverted
  9457. * @returns the cube texture as an InternalTexture
  9458. */
  9459. 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;
  9460. /**
  9461. * Creates a new raw 3D texture
  9462. * @param data defines the data used to create the texture
  9463. * @param width defines the width of the texture
  9464. * @param height defines the height of the texture
  9465. * @param depth defines the depth of the texture
  9466. * @param format defines the format of the texture
  9467. * @param generateMipMaps defines if the engine must generate mip levels
  9468. * @param invertY defines if data must be stored with Y axis inverted
  9469. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  9470. * @param compression defines the compressed used (can be null)
  9471. * @param textureType defines the compressed used (can be null)
  9472. * @returns a new raw 3D texture (stored in an InternalTexture)
  9473. */
  9474. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  9475. /**
  9476. * Update a raw 3D texture
  9477. * @param texture defines the texture to update
  9478. * @param data defines the data to store
  9479. * @param format defines the data format
  9480. * @param invertY defines if data must be stored with Y axis inverted
  9481. */
  9482. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  9483. /**
  9484. * Update a raw 3D texture
  9485. * @param texture defines the texture to update
  9486. * @param data defines the data to store
  9487. * @param format defines the data format
  9488. * @param invertY defines if data must be stored with Y axis inverted
  9489. * @param compression defines the used compression (can be null)
  9490. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  9491. */
  9492. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  9493. }
  9494. }
  9495. }
  9496. declare module "babylonjs/Materials/Textures/rawTexture" {
  9497. import { Scene } from "babylonjs/scene";
  9498. import { Texture } from "babylonjs/Materials/Textures/texture";
  9499. import "babylonjs/Engines/Extensions/engine.rawTexture";
  9500. /**
  9501. * Raw texture can help creating a texture directly from an array of data.
  9502. * This can be super useful if you either get the data from an uncompressed source or
  9503. * if you wish to create your texture pixel by pixel.
  9504. */
  9505. export class RawTexture extends Texture {
  9506. /**
  9507. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  9508. */
  9509. format: number;
  9510. private _engine;
  9511. /**
  9512. * Instantiates a new RawTexture.
  9513. * Raw texture can help creating a texture directly from an array of data.
  9514. * This can be super useful if you either get the data from an uncompressed source or
  9515. * if you wish to create your texture pixel by pixel.
  9516. * @param data define the array of data to use to create the texture
  9517. * @param width define the width of the texture
  9518. * @param height define the height of the texture
  9519. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  9520. * @param scene define the scene the texture belongs to
  9521. * @param generateMipMaps define whether mip maps should be generated or not
  9522. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9523. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9524. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9525. */
  9526. constructor(data: ArrayBufferView, width: number, height: number,
  9527. /**
  9528. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  9529. */
  9530. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  9531. /**
  9532. * Updates the texture underlying data.
  9533. * @param data Define the new data of the texture
  9534. */
  9535. update(data: ArrayBufferView): void;
  9536. /**
  9537. * Creates a luminance texture from some data.
  9538. * @param data Define the texture data
  9539. * @param width Define the width of the texture
  9540. * @param height Define the height of the texture
  9541. * @param scene Define the scene the texture belongs to
  9542. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9543. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9544. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9545. * @returns the luminance texture
  9546. */
  9547. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  9548. /**
  9549. * Creates a luminance alpha texture from some data.
  9550. * @param data Define the texture data
  9551. * @param width Define the width of the texture
  9552. * @param height Define the height of the texture
  9553. * @param scene Define the scene the texture belongs to
  9554. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9555. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9556. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9557. * @returns the luminance alpha texture
  9558. */
  9559. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  9560. /**
  9561. * Creates an alpha texture from some data.
  9562. * @param data Define the texture data
  9563. * @param width Define the width of the texture
  9564. * @param height Define the height of the texture
  9565. * @param scene Define the scene the texture belongs to
  9566. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9567. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9568. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9569. * @returns the alpha texture
  9570. */
  9571. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  9572. /**
  9573. * Creates a RGB texture from some data.
  9574. * @param data Define the texture data
  9575. * @param width Define the width of the texture
  9576. * @param height Define the height of the texture
  9577. * @param scene Define the scene the texture belongs to
  9578. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9579. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9580. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9581. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9582. * @returns the RGB alpha texture
  9583. */
  9584. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  9585. /**
  9586. * Creates a RGBA texture from some data.
  9587. * @param data Define the texture data
  9588. * @param width Define the width of the texture
  9589. * @param height Define the height of the texture
  9590. * @param scene Define the scene the texture belongs to
  9591. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9592. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9593. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9594. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9595. * @returns the RGBA texture
  9596. */
  9597. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  9598. /**
  9599. * Creates a R texture from some data.
  9600. * @param data Define the texture data
  9601. * @param width Define the width of the texture
  9602. * @param height Define the height of the texture
  9603. * @param scene Define the scene the texture belongs to
  9604. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9605. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9606. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9607. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9608. * @returns the R texture
  9609. */
  9610. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  9611. }
  9612. }
  9613. declare module "babylonjs/Animations/runtimeAnimation" {
  9614. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  9615. import { Animatable } from "babylonjs/Animations/animatable";
  9616. import { Scene } from "babylonjs/scene";
  9617. /**
  9618. * Defines a runtime animation
  9619. */
  9620. export class RuntimeAnimation {
  9621. private _events;
  9622. /**
  9623. * The current frame of the runtime animation
  9624. */
  9625. private _currentFrame;
  9626. /**
  9627. * The animation used by the runtime animation
  9628. */
  9629. private _animation;
  9630. /**
  9631. * The target of the runtime animation
  9632. */
  9633. private _target;
  9634. /**
  9635. * The initiating animatable
  9636. */
  9637. private _host;
  9638. /**
  9639. * The original value of the runtime animation
  9640. */
  9641. private _originalValue;
  9642. /**
  9643. * The original blend value of the runtime animation
  9644. */
  9645. private _originalBlendValue;
  9646. /**
  9647. * The offsets cache of the runtime animation
  9648. */
  9649. private _offsetsCache;
  9650. /**
  9651. * The high limits cache of the runtime animation
  9652. */
  9653. private _highLimitsCache;
  9654. /**
  9655. * Specifies if the runtime animation has been stopped
  9656. */
  9657. private _stopped;
  9658. /**
  9659. * The blending factor of the runtime animation
  9660. */
  9661. private _blendingFactor;
  9662. /**
  9663. * The BabylonJS scene
  9664. */
  9665. private _scene;
  9666. /**
  9667. * The current value of the runtime animation
  9668. */
  9669. private _currentValue;
  9670. /** @hidden */
  9671. _animationState: _IAnimationState;
  9672. /**
  9673. * The active target of the runtime animation
  9674. */
  9675. private _activeTargets;
  9676. private _currentActiveTarget;
  9677. private _directTarget;
  9678. /**
  9679. * The target path of the runtime animation
  9680. */
  9681. private _targetPath;
  9682. /**
  9683. * The weight of the runtime animation
  9684. */
  9685. private _weight;
  9686. /**
  9687. * The ratio offset of the runtime animation
  9688. */
  9689. private _ratioOffset;
  9690. /**
  9691. * The previous delay of the runtime animation
  9692. */
  9693. private _previousDelay;
  9694. /**
  9695. * The previous ratio of the runtime animation
  9696. */
  9697. private _previousRatio;
  9698. private _enableBlending;
  9699. private _keys;
  9700. private _minFrame;
  9701. private _maxFrame;
  9702. private _minValue;
  9703. private _maxValue;
  9704. private _targetIsArray;
  9705. /**
  9706. * Gets the current frame of the runtime animation
  9707. */
  9708. readonly currentFrame: number;
  9709. /**
  9710. * Gets the weight of the runtime animation
  9711. */
  9712. readonly weight: number;
  9713. /**
  9714. * Gets the current value of the runtime animation
  9715. */
  9716. readonly currentValue: any;
  9717. /**
  9718. * Gets the target path of the runtime animation
  9719. */
  9720. readonly targetPath: string;
  9721. /**
  9722. * Gets the actual target of the runtime animation
  9723. */
  9724. readonly target: any;
  9725. /** @hidden */
  9726. _onLoop: () => void;
  9727. /**
  9728. * Create a new RuntimeAnimation object
  9729. * @param target defines the target of the animation
  9730. * @param animation defines the source animation object
  9731. * @param scene defines the hosting scene
  9732. * @param host defines the initiating Animatable
  9733. */
  9734. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  9735. private _preparePath;
  9736. /**
  9737. * Gets the animation from the runtime animation
  9738. */
  9739. readonly animation: Animation;
  9740. /**
  9741. * Resets the runtime animation to the beginning
  9742. * @param restoreOriginal defines whether to restore the target property to the original value
  9743. */
  9744. reset(restoreOriginal?: boolean): void;
  9745. /**
  9746. * Specifies if the runtime animation is stopped
  9747. * @returns Boolean specifying if the runtime animation is stopped
  9748. */
  9749. isStopped(): boolean;
  9750. /**
  9751. * Disposes of the runtime animation
  9752. */
  9753. dispose(): void;
  9754. /**
  9755. * Apply the interpolated value to the target
  9756. * @param currentValue defines the value computed by the animation
  9757. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  9758. */
  9759. setValue(currentValue: any, weight: number): void;
  9760. private _getOriginalValues;
  9761. private _setValue;
  9762. /**
  9763. * Gets the loop pmode of the runtime animation
  9764. * @returns Loop Mode
  9765. */
  9766. private _getCorrectLoopMode;
  9767. /**
  9768. * Move the current animation to a given frame
  9769. * @param frame defines the frame to move to
  9770. */
  9771. goToFrame(frame: number): void;
  9772. /**
  9773. * @hidden Internal use only
  9774. */
  9775. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  9776. /**
  9777. * Execute the current animation
  9778. * @param delay defines the delay to add to the current frame
  9779. * @param from defines the lower bound of the animation range
  9780. * @param to defines the upper bound of the animation range
  9781. * @param loop defines if the current animation must loop
  9782. * @param speedRatio defines the current speed ratio
  9783. * @param weight defines the weight of the animation (default is -1 so no weight)
  9784. * @param onLoop optional callback called when animation loops
  9785. * @returns a boolean indicating if the animation is running
  9786. */
  9787. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  9788. }
  9789. }
  9790. declare module "babylonjs/Animations/animatable" {
  9791. import { Animation } from "babylonjs/Animations/animation";
  9792. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  9793. import { Nullable } from "babylonjs/types";
  9794. import { Observable } from "babylonjs/Misc/observable";
  9795. import { Scene } from "babylonjs/scene";
  9796. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math";
  9797. import { Node } from "babylonjs/node";
  9798. /**
  9799. * Class used to store an actual running animation
  9800. */
  9801. export class Animatable {
  9802. /** defines the target object */
  9803. target: any;
  9804. /** defines the starting frame number (default is 0) */
  9805. fromFrame: number;
  9806. /** defines the ending frame number (default is 100) */
  9807. toFrame: number;
  9808. /** defines if the animation must loop (default is false) */
  9809. loopAnimation: boolean;
  9810. /** defines a callback to call when animation ends if it is not looping */
  9811. onAnimationEnd?: (() => void) | null | undefined;
  9812. /** defines a callback to call when animation loops */
  9813. onAnimationLoop?: (() => void) | null | undefined;
  9814. private _localDelayOffset;
  9815. private _pausedDelay;
  9816. private _runtimeAnimations;
  9817. private _paused;
  9818. private _scene;
  9819. private _speedRatio;
  9820. private _weight;
  9821. private _syncRoot;
  9822. /**
  9823. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  9824. * This will only apply for non looping animation (default is true)
  9825. */
  9826. disposeOnEnd: boolean;
  9827. /**
  9828. * Gets a boolean indicating if the animation has started
  9829. */
  9830. animationStarted: boolean;
  9831. /**
  9832. * Observer raised when the animation ends
  9833. */
  9834. onAnimationEndObservable: Observable<Animatable>;
  9835. /**
  9836. * Observer raised when the animation loops
  9837. */
  9838. onAnimationLoopObservable: Observable<Animatable>;
  9839. /**
  9840. * Gets the root Animatable used to synchronize and normalize animations
  9841. */
  9842. readonly syncRoot: Nullable<Animatable>;
  9843. /**
  9844. * Gets the current frame of the first RuntimeAnimation
  9845. * Used to synchronize Animatables
  9846. */
  9847. readonly masterFrame: number;
  9848. /**
  9849. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  9850. */
  9851. weight: number;
  9852. /**
  9853. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  9854. */
  9855. speedRatio: number;
  9856. /**
  9857. * Creates a new Animatable
  9858. * @param scene defines the hosting scene
  9859. * @param target defines the target object
  9860. * @param fromFrame defines the starting frame number (default is 0)
  9861. * @param toFrame defines the ending frame number (default is 100)
  9862. * @param loopAnimation defines if the animation must loop (default is false)
  9863. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  9864. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  9865. * @param animations defines a group of animation to add to the new Animatable
  9866. * @param onAnimationLoop defines a callback to call when animation loops
  9867. */
  9868. constructor(scene: Scene,
  9869. /** defines the target object */
  9870. target: any,
  9871. /** defines the starting frame number (default is 0) */
  9872. fromFrame?: number,
  9873. /** defines the ending frame number (default is 100) */
  9874. toFrame?: number,
  9875. /** defines if the animation must loop (default is false) */
  9876. loopAnimation?: boolean, speedRatio?: number,
  9877. /** defines a callback to call when animation ends if it is not looping */
  9878. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  9879. /** defines a callback to call when animation loops */
  9880. onAnimationLoop?: (() => void) | null | undefined);
  9881. /**
  9882. * Synchronize and normalize current Animatable with a source Animatable
  9883. * This is useful when using animation weights and when animations are not of the same length
  9884. * @param root defines the root Animatable to synchronize with
  9885. * @returns the current Animatable
  9886. */
  9887. syncWith(root: Animatable): Animatable;
  9888. /**
  9889. * Gets the list of runtime animations
  9890. * @returns an array of RuntimeAnimation
  9891. */
  9892. getAnimations(): RuntimeAnimation[];
  9893. /**
  9894. * Adds more animations to the current animatable
  9895. * @param target defines the target of the animations
  9896. * @param animations defines the new animations to add
  9897. */
  9898. appendAnimations(target: any, animations: Animation[]): void;
  9899. /**
  9900. * Gets the source animation for a specific property
  9901. * @param property defines the propertyu to look for
  9902. * @returns null or the source animation for the given property
  9903. */
  9904. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  9905. /**
  9906. * Gets the runtime animation for a specific property
  9907. * @param property defines the propertyu to look for
  9908. * @returns null or the runtime animation for the given property
  9909. */
  9910. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  9911. /**
  9912. * Resets the animatable to its original state
  9913. */
  9914. reset(): void;
  9915. /**
  9916. * Allows the animatable to blend with current running animations
  9917. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  9918. * @param blendingSpeed defines the blending speed to use
  9919. */
  9920. enableBlending(blendingSpeed: number): void;
  9921. /**
  9922. * Disable animation blending
  9923. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  9924. */
  9925. disableBlending(): void;
  9926. /**
  9927. * Jump directly to a given frame
  9928. * @param frame defines the frame to jump to
  9929. */
  9930. goToFrame(frame: number): void;
  9931. /**
  9932. * Pause the animation
  9933. */
  9934. pause(): void;
  9935. /**
  9936. * Restart the animation
  9937. */
  9938. restart(): void;
  9939. private _raiseOnAnimationEnd;
  9940. /**
  9941. * Stop and delete the current animation
  9942. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  9943. * @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)
  9944. */
  9945. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  9946. /**
  9947. * Wait asynchronously for the animation to end
  9948. * @returns a promise which will be fullfilled when the animation ends
  9949. */
  9950. waitAsync(): Promise<Animatable>;
  9951. /** @hidden */
  9952. _animate(delay: number): boolean;
  9953. }
  9954. module "babylonjs/scene" {
  9955. interface Scene {
  9956. /** @hidden */
  9957. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  9958. /** @hidden */
  9959. _processLateAnimationBindingsForMatrices(holder: {
  9960. totalWeight: number;
  9961. animations: RuntimeAnimation[];
  9962. originalValue: Matrix;
  9963. }): any;
  9964. /** @hidden */
  9965. _processLateAnimationBindingsForQuaternions(holder: {
  9966. totalWeight: number;
  9967. animations: RuntimeAnimation[];
  9968. originalValue: Quaternion;
  9969. }, refQuaternion: Quaternion): Quaternion;
  9970. /** @hidden */
  9971. _processLateAnimationBindings(): void;
  9972. /**
  9973. * Will start the animation sequence of a given target
  9974. * @param target defines the target
  9975. * @param from defines from which frame should animation start
  9976. * @param to defines until which frame should animation run.
  9977. * @param weight defines the weight to apply to the animation (1.0 by default)
  9978. * @param loop defines if the animation loops
  9979. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  9980. * @param onAnimationEnd defines the function to be executed when the animation ends
  9981. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  9982. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  9983. * @param onAnimationLoop defines the callback to call when an animation loops
  9984. * @returns the animatable object created for this animation
  9985. */
  9986. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  9987. /**
  9988. * Will start the animation sequence of a given target
  9989. * @param target defines the target
  9990. * @param from defines from which frame should animation start
  9991. * @param to defines until which frame should animation run.
  9992. * @param loop defines if the animation loops
  9993. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  9994. * @param onAnimationEnd defines the function to be executed when the animation ends
  9995. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  9996. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  9997. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  9998. * @param onAnimationLoop defines the callback to call when an animation loops
  9999. * @returns the animatable object created for this animation
  10000. */
  10001. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  10002. /**
  10003. * Will start the animation sequence of a given target and its hierarchy
  10004. * @param target defines the target
  10005. * @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.
  10006. * @param from defines from which frame should animation start
  10007. * @param to defines until which frame should animation run.
  10008. * @param loop defines if the animation loops
  10009. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  10010. * @param onAnimationEnd defines the function to be executed when the animation ends
  10011. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  10012. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  10013. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  10014. * @param onAnimationLoop defines the callback to call when an animation loops
  10015. * @returns the list of created animatables
  10016. */
  10017. 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[];
  10018. /**
  10019. * Begin a new animation on a given node
  10020. * @param target defines the target where the animation will take place
  10021. * @param animations defines the list of animations to start
  10022. * @param from defines the initial value
  10023. * @param to defines the final value
  10024. * @param loop defines if you want animation to loop (off by default)
  10025. * @param speedRatio defines the speed ratio to apply to all animations
  10026. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  10027. * @param onAnimationLoop defines the callback to call when an animation loops
  10028. * @returns the list of created animatables
  10029. */
  10030. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  10031. /**
  10032. * Begin a new animation on a given node and its hierarchy
  10033. * @param target defines the root node where the animation will take place
  10034. * @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.
  10035. * @param animations defines the list of animations to start
  10036. * @param from defines the initial value
  10037. * @param to defines the final value
  10038. * @param loop defines if you want animation to loop (off by default)
  10039. * @param speedRatio defines the speed ratio to apply to all animations
  10040. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  10041. * @param onAnimationLoop defines the callback to call when an animation loops
  10042. * @returns the list of animatables created for all nodes
  10043. */
  10044. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  10045. /**
  10046. * Gets the animatable associated with a specific target
  10047. * @param target defines the target of the animatable
  10048. * @returns the required animatable if found
  10049. */
  10050. getAnimatableByTarget(target: any): Nullable<Animatable>;
  10051. /**
  10052. * Gets all animatables associated with a given target
  10053. * @param target defines the target to look animatables for
  10054. * @returns an array of Animatables
  10055. */
  10056. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  10057. /**
  10058. * Stops and removes all animations that have been applied to the scene
  10059. */
  10060. stopAllAnimations(): void;
  10061. }
  10062. }
  10063. module "babylonjs/Bones/bone" {
  10064. interface Bone {
  10065. /**
  10066. * Copy an animation range from another bone
  10067. * @param source defines the source bone
  10068. * @param rangeName defines the range name to copy
  10069. * @param frameOffset defines the frame offset
  10070. * @param rescaleAsRequired defines if rescaling must be applied if required
  10071. * @param skelDimensionsRatio defines the scaling ratio
  10072. * @returns true if operation was successful
  10073. */
  10074. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  10075. }
  10076. }
  10077. }
  10078. declare module "babylonjs/Bones/skeleton" {
  10079. import { Bone } from "babylonjs/Bones/bone";
  10080. import { IAnimatable } from "babylonjs/Misc/tools";
  10081. import { Observable } from "babylonjs/Misc/observable";
  10082. import { Vector3, Matrix } from "babylonjs/Maths/math";
  10083. import { Scene } from "babylonjs/scene";
  10084. import { Nullable } from "babylonjs/types";
  10085. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10086. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  10087. import { Animatable } from "babylonjs/Animations/animatable";
  10088. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  10089. import { Animation } from "babylonjs/Animations/animation";
  10090. import { AnimationRange } from "babylonjs/Animations/animationRange";
  10091. import { IInspectable } from "babylonjs/Misc/iInspectable";
  10092. /**
  10093. * Class used to handle skinning animations
  10094. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  10095. */
  10096. export class Skeleton implements IAnimatable {
  10097. /** defines the skeleton name */
  10098. name: string;
  10099. /** defines the skeleton Id */
  10100. id: string;
  10101. /**
  10102. * Defines the list of child bones
  10103. */
  10104. bones: Bone[];
  10105. /**
  10106. * Defines an estimate of the dimension of the skeleton at rest
  10107. */
  10108. dimensionsAtRest: Vector3;
  10109. /**
  10110. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  10111. */
  10112. needInitialSkinMatrix: boolean;
  10113. /**
  10114. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  10115. */
  10116. overrideMesh: Nullable<AbstractMesh>;
  10117. /**
  10118. * Gets the list of animations attached to this skeleton
  10119. */
  10120. animations: Array<Animation>;
  10121. private _scene;
  10122. private _isDirty;
  10123. private _transformMatrices;
  10124. private _transformMatrixTexture;
  10125. private _meshesWithPoseMatrix;
  10126. private _animatables;
  10127. private _identity;
  10128. private _synchronizedWithMesh;
  10129. private _ranges;
  10130. private _lastAbsoluteTransformsUpdateId;
  10131. private _canUseTextureForBones;
  10132. private _uniqueId;
  10133. /** @hidden */
  10134. _numBonesWithLinkedTransformNode: number;
  10135. /** @hidden */
  10136. _hasWaitingData: Nullable<boolean>;
  10137. /**
  10138. * Specifies if the skeleton should be serialized
  10139. */
  10140. doNotSerialize: boolean;
  10141. private _useTextureToStoreBoneMatrices;
  10142. /**
  10143. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  10144. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  10145. */
  10146. useTextureToStoreBoneMatrices: boolean;
  10147. private _animationPropertiesOverride;
  10148. /**
  10149. * Gets or sets the animation properties override
  10150. */
  10151. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  10152. /**
  10153. * List of inspectable custom properties (used by the Inspector)
  10154. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  10155. */
  10156. inspectableCustomProperties: IInspectable[];
  10157. /**
  10158. * An observable triggered before computing the skeleton's matrices
  10159. */
  10160. onBeforeComputeObservable: Observable<Skeleton>;
  10161. /**
  10162. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  10163. */
  10164. readonly isUsingTextureForMatrices: boolean;
  10165. /**
  10166. * Gets the unique ID of this skeleton
  10167. */
  10168. readonly uniqueId: number;
  10169. /**
  10170. * Creates a new skeleton
  10171. * @param name defines the skeleton name
  10172. * @param id defines the skeleton Id
  10173. * @param scene defines the hosting scene
  10174. */
  10175. constructor(
  10176. /** defines the skeleton name */
  10177. name: string,
  10178. /** defines the skeleton Id */
  10179. id: string, scene: Scene);
  10180. /**
  10181. * Gets the current object class name.
  10182. * @return the class name
  10183. */
  10184. getClassName(): string;
  10185. /**
  10186. * Returns an array containing the root bones
  10187. * @returns an array containing the root bones
  10188. */
  10189. getChildren(): Array<Bone>;
  10190. /**
  10191. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  10192. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  10193. * @returns a Float32Array containing matrices data
  10194. */
  10195. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  10196. /**
  10197. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  10198. * @returns a raw texture containing the data
  10199. */
  10200. getTransformMatrixTexture(): Nullable<RawTexture>;
  10201. /**
  10202. * Gets the current hosting scene
  10203. * @returns a scene object
  10204. */
  10205. getScene(): Scene;
  10206. /**
  10207. * Gets a string representing the current skeleton data
  10208. * @param fullDetails defines a boolean indicating if we want a verbose version
  10209. * @returns a string representing the current skeleton data
  10210. */
  10211. toString(fullDetails?: boolean): string;
  10212. /**
  10213. * Get bone's index searching by name
  10214. * @param name defines bone's name to search for
  10215. * @return the indice of the bone. Returns -1 if not found
  10216. */
  10217. getBoneIndexByName(name: string): number;
  10218. /**
  10219. * Creater a new animation range
  10220. * @param name defines the name of the range
  10221. * @param from defines the start key
  10222. * @param to defines the end key
  10223. */
  10224. createAnimationRange(name: string, from: number, to: number): void;
  10225. /**
  10226. * Delete a specific animation range
  10227. * @param name defines the name of the range
  10228. * @param deleteFrames defines if frames must be removed as well
  10229. */
  10230. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  10231. /**
  10232. * Gets a specific animation range
  10233. * @param name defines the name of the range to look for
  10234. * @returns the requested animation range or null if not found
  10235. */
  10236. getAnimationRange(name: string): Nullable<AnimationRange>;
  10237. /**
  10238. * Gets the list of all animation ranges defined on this skeleton
  10239. * @returns an array
  10240. */
  10241. getAnimationRanges(): Nullable<AnimationRange>[];
  10242. /**
  10243. * Copy animation range from a source skeleton.
  10244. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  10245. * @param source defines the source skeleton
  10246. * @param name defines the name of the range to copy
  10247. * @param rescaleAsRequired defines if rescaling must be applied if required
  10248. * @returns true if operation was successful
  10249. */
  10250. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  10251. /**
  10252. * Forces the skeleton to go to rest pose
  10253. */
  10254. returnToRest(): void;
  10255. private _getHighestAnimationFrame;
  10256. /**
  10257. * Begin a specific animation range
  10258. * @param name defines the name of the range to start
  10259. * @param loop defines if looping must be turned on (false by default)
  10260. * @param speedRatio defines the speed ratio to apply (1 by default)
  10261. * @param onAnimationEnd defines a callback which will be called when animation will end
  10262. * @returns a new animatable
  10263. */
  10264. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  10265. /** @hidden */
  10266. _markAsDirty(): void;
  10267. /** @hidden */
  10268. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  10269. /** @hidden */
  10270. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  10271. private _computeTransformMatrices;
  10272. /**
  10273. * Build all resources required to render a skeleton
  10274. */
  10275. prepare(): void;
  10276. /**
  10277. * Gets the list of animatables currently running for this skeleton
  10278. * @returns an array of animatables
  10279. */
  10280. getAnimatables(): IAnimatable[];
  10281. /**
  10282. * Clone the current skeleton
  10283. * @param name defines the name of the new skeleton
  10284. * @param id defines the id of the new skeleton
  10285. * @returns the new skeleton
  10286. */
  10287. clone(name: string, id: string): Skeleton;
  10288. /**
  10289. * Enable animation blending for this skeleton
  10290. * @param blendingSpeed defines the blending speed to apply
  10291. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  10292. */
  10293. enableBlending(blendingSpeed?: number): void;
  10294. /**
  10295. * Releases all resources associated with the current skeleton
  10296. */
  10297. dispose(): void;
  10298. /**
  10299. * Serialize the skeleton in a JSON object
  10300. * @returns a JSON object
  10301. */
  10302. serialize(): any;
  10303. /**
  10304. * Creates a new skeleton from serialized data
  10305. * @param parsedSkeleton defines the serialized data
  10306. * @param scene defines the hosting scene
  10307. * @returns a new skeleton
  10308. */
  10309. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  10310. /**
  10311. * Compute all node absolute transforms
  10312. * @param forceUpdate defines if computation must be done even if cache is up to date
  10313. */
  10314. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  10315. /**
  10316. * Gets the root pose matrix
  10317. * @returns a matrix
  10318. */
  10319. getPoseMatrix(): Nullable<Matrix>;
  10320. /**
  10321. * Sorts bones per internal index
  10322. */
  10323. sortBones(): void;
  10324. private _sortBones;
  10325. }
  10326. }
  10327. declare module "babylonjs/Morph/morphTarget" {
  10328. import { IAnimatable } from "babylonjs/Misc/tools";
  10329. import { Observable } from "babylonjs/Misc/observable";
  10330. import { Nullable, FloatArray } from "babylonjs/types";
  10331. import { Scene } from "babylonjs/scene";
  10332. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10333. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  10334. /**
  10335. * Defines a target to use with MorphTargetManager
  10336. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  10337. */
  10338. export class MorphTarget implements IAnimatable {
  10339. /** defines the name of the target */
  10340. name: string;
  10341. /**
  10342. * Gets or sets the list of animations
  10343. */
  10344. animations: import("babylonjs/Animations/animation").Animation[];
  10345. private _scene;
  10346. private _positions;
  10347. private _normals;
  10348. private _tangents;
  10349. private _uvs;
  10350. private _influence;
  10351. /**
  10352. * Observable raised when the influence changes
  10353. */
  10354. onInfluenceChanged: Observable<boolean>;
  10355. /** @hidden */
  10356. _onDataLayoutChanged: Observable<void>;
  10357. /**
  10358. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  10359. */
  10360. influence: number;
  10361. /**
  10362. * Gets or sets the id of the morph Target
  10363. */
  10364. id: string;
  10365. private _animationPropertiesOverride;
  10366. /**
  10367. * Gets or sets the animation properties override
  10368. */
  10369. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  10370. /**
  10371. * Creates a new MorphTarget
  10372. * @param name defines the name of the target
  10373. * @param influence defines the influence to use
  10374. * @param scene defines the scene the morphtarget belongs to
  10375. */
  10376. constructor(
  10377. /** defines the name of the target */
  10378. name: string, influence?: number, scene?: Nullable<Scene>);
  10379. /**
  10380. * Gets a boolean defining if the target contains position data
  10381. */
  10382. readonly hasPositions: boolean;
  10383. /**
  10384. * Gets a boolean defining if the target contains normal data
  10385. */
  10386. readonly hasNormals: boolean;
  10387. /**
  10388. * Gets a boolean defining if the target contains tangent data
  10389. */
  10390. readonly hasTangents: boolean;
  10391. /**
  10392. * Gets a boolean defining if the target contains texture coordinates data
  10393. */
  10394. readonly hasUVs: boolean;
  10395. /**
  10396. * Affects position data to this target
  10397. * @param data defines the position data to use
  10398. */
  10399. setPositions(data: Nullable<FloatArray>): void;
  10400. /**
  10401. * Gets the position data stored in this target
  10402. * @returns a FloatArray containing the position data (or null if not present)
  10403. */
  10404. getPositions(): Nullable<FloatArray>;
  10405. /**
  10406. * Affects normal data to this target
  10407. * @param data defines the normal data to use
  10408. */
  10409. setNormals(data: Nullable<FloatArray>): void;
  10410. /**
  10411. * Gets the normal data stored in this target
  10412. * @returns a FloatArray containing the normal data (or null if not present)
  10413. */
  10414. getNormals(): Nullable<FloatArray>;
  10415. /**
  10416. * Affects tangent data to this target
  10417. * @param data defines the tangent data to use
  10418. */
  10419. setTangents(data: Nullable<FloatArray>): void;
  10420. /**
  10421. * Gets the tangent data stored in this target
  10422. * @returns a FloatArray containing the tangent data (or null if not present)
  10423. */
  10424. getTangents(): Nullable<FloatArray>;
  10425. /**
  10426. * Affects texture coordinates data to this target
  10427. * @param data defines the texture coordinates data to use
  10428. */
  10429. setUVs(data: Nullable<FloatArray>): void;
  10430. /**
  10431. * Gets the texture coordinates data stored in this target
  10432. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  10433. */
  10434. getUVs(): Nullable<FloatArray>;
  10435. /**
  10436. * Serializes the current target into a Serialization object
  10437. * @returns the serialized object
  10438. */
  10439. serialize(): any;
  10440. /**
  10441. * Returns the string "MorphTarget"
  10442. * @returns "MorphTarget"
  10443. */
  10444. getClassName(): string;
  10445. /**
  10446. * Creates a new target from serialized data
  10447. * @param serializationObject defines the serialized data to use
  10448. * @returns a new MorphTarget
  10449. */
  10450. static Parse(serializationObject: any): MorphTarget;
  10451. /**
  10452. * Creates a MorphTarget from mesh data
  10453. * @param mesh defines the source mesh
  10454. * @param name defines the name to use for the new target
  10455. * @param influence defines the influence to attach to the target
  10456. * @returns a new MorphTarget
  10457. */
  10458. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  10459. }
  10460. }
  10461. declare module "babylonjs/Morph/morphTargetManager" {
  10462. import { Nullable } from "babylonjs/types";
  10463. import { Scene } from "babylonjs/scene";
  10464. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  10465. /**
  10466. * This class is used to deform meshes using morphing between different targets
  10467. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  10468. */
  10469. export class MorphTargetManager {
  10470. private _targets;
  10471. private _targetInfluenceChangedObservers;
  10472. private _targetDataLayoutChangedObservers;
  10473. private _activeTargets;
  10474. private _scene;
  10475. private _influences;
  10476. private _supportsNormals;
  10477. private _supportsTangents;
  10478. private _supportsUVs;
  10479. private _vertexCount;
  10480. private _uniqueId;
  10481. private _tempInfluences;
  10482. /**
  10483. * Creates a new MorphTargetManager
  10484. * @param scene defines the current scene
  10485. */
  10486. constructor(scene?: Nullable<Scene>);
  10487. /**
  10488. * Gets the unique ID of this manager
  10489. */
  10490. readonly uniqueId: number;
  10491. /**
  10492. * Gets the number of vertices handled by this manager
  10493. */
  10494. readonly vertexCount: number;
  10495. /**
  10496. * Gets a boolean indicating if this manager supports morphing of normals
  10497. */
  10498. readonly supportsNormals: boolean;
  10499. /**
  10500. * Gets a boolean indicating if this manager supports morphing of tangents
  10501. */
  10502. readonly supportsTangents: boolean;
  10503. /**
  10504. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  10505. */
  10506. readonly supportsUVs: boolean;
  10507. /**
  10508. * Gets the number of targets stored in this manager
  10509. */
  10510. readonly numTargets: number;
  10511. /**
  10512. * Gets the number of influencers (ie. the number of targets with influences > 0)
  10513. */
  10514. readonly numInfluencers: number;
  10515. /**
  10516. * Gets the list of influences (one per target)
  10517. */
  10518. readonly influences: Float32Array;
  10519. /**
  10520. * Gets the active target at specified index. An active target is a target with an influence > 0
  10521. * @param index defines the index to check
  10522. * @returns the requested target
  10523. */
  10524. getActiveTarget(index: number): MorphTarget;
  10525. /**
  10526. * Gets the target at specified index
  10527. * @param index defines the index to check
  10528. * @returns the requested target
  10529. */
  10530. getTarget(index: number): MorphTarget;
  10531. /**
  10532. * Add a new target to this manager
  10533. * @param target defines the target to add
  10534. */
  10535. addTarget(target: MorphTarget): void;
  10536. /**
  10537. * Removes a target from the manager
  10538. * @param target defines the target to remove
  10539. */
  10540. removeTarget(target: MorphTarget): void;
  10541. /**
  10542. * Serializes the current manager into a Serialization object
  10543. * @returns the serialized object
  10544. */
  10545. serialize(): any;
  10546. private _syncActiveTargets;
  10547. /**
  10548. * Syncrhonize the targets with all the meshes using this morph target manager
  10549. */
  10550. synchronize(): void;
  10551. /**
  10552. * Creates a new MorphTargetManager from serialized data
  10553. * @param serializationObject defines the serialized data
  10554. * @param scene defines the hosting scene
  10555. * @returns the new MorphTargetManager
  10556. */
  10557. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  10558. }
  10559. }
  10560. declare module "babylonjs/sceneComponent" {
  10561. import { Scene } from "babylonjs/scene";
  10562. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10563. import { SubMesh } from "babylonjs/Meshes/subMesh";
  10564. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  10565. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  10566. import { Nullable } from "babylonjs/types";
  10567. import { Camera } from "babylonjs/Cameras/camera";
  10568. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  10569. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10570. import { AbstractScene } from "babylonjs/abstractScene";
  10571. /**
  10572. * Groups all the scene component constants in one place to ease maintenance.
  10573. * @hidden
  10574. */
  10575. export class SceneComponentConstants {
  10576. static readonly NAME_EFFECTLAYER: string;
  10577. static readonly NAME_LAYER: string;
  10578. static readonly NAME_LENSFLARESYSTEM: string;
  10579. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10580. static readonly NAME_PARTICLESYSTEM: string;
  10581. static readonly NAME_GAMEPAD: string;
  10582. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10583. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10584. static readonly NAME_DEPTHRENDERER: string;
  10585. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10586. static readonly NAME_SPRITE: string;
  10587. static readonly NAME_OUTLINERENDERER: string;
  10588. static readonly NAME_PROCEDURALTEXTURE: string;
  10589. static readonly NAME_SHADOWGENERATOR: string;
  10590. static readonly NAME_OCTREE: string;
  10591. static readonly NAME_PHYSICSENGINE: string;
  10592. static readonly NAME_AUDIO: string;
  10593. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10594. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10595. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10596. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10597. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10598. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10599. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10600. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10601. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10602. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10603. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10604. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10605. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10606. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10607. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10608. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10609. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10610. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10611. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10612. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10613. static readonly STEP_AFTERRENDER_AUDIO: number;
  10614. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10615. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10616. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10617. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10618. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10619. static readonly STEP_POINTERMOVE_SPRITE: number;
  10620. static readonly STEP_POINTERDOWN_SPRITE: number;
  10621. static readonly STEP_POINTERUP_SPRITE: number;
  10622. }
  10623. /**
  10624. * This represents a scene component.
  10625. *
  10626. * This is used to decouple the dependency the scene is having on the different workloads like
  10627. * layers, post processes...
  10628. */
  10629. export interface ISceneComponent {
  10630. /**
  10631. * The name of the component. Each component must have a unique name.
  10632. */
  10633. name: string;
  10634. /**
  10635. * The scene the component belongs to.
  10636. */
  10637. scene: Scene;
  10638. /**
  10639. * Register the component to one instance of a scene.
  10640. */
  10641. register(): void;
  10642. /**
  10643. * Rebuilds the elements related to this component in case of
  10644. * context lost for instance.
  10645. */
  10646. rebuild(): void;
  10647. /**
  10648. * Disposes the component and the associated ressources.
  10649. */
  10650. dispose(): void;
  10651. }
  10652. /**
  10653. * This represents a SERIALIZABLE scene component.
  10654. *
  10655. * This extends Scene Component to add Serialization methods on top.
  10656. */
  10657. export interface ISceneSerializableComponent extends ISceneComponent {
  10658. /**
  10659. * Adds all the elements from the container to the scene
  10660. * @param container the container holding the elements
  10661. */
  10662. addFromContainer(container: AbstractScene): void;
  10663. /**
  10664. * Removes all the elements in the container from the scene
  10665. * @param container contains the elements to remove
  10666. * @param dispose if the removed element should be disposed (default: false)
  10667. */
  10668. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10669. /**
  10670. * Serializes the component data to the specified json object
  10671. * @param serializationObject The object to serialize to
  10672. */
  10673. serialize(serializationObject: any): void;
  10674. }
  10675. /**
  10676. * Strong typing of a Mesh related stage step action
  10677. */
  10678. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10679. /**
  10680. * Strong typing of a Evaluate Sub Mesh related stage step action
  10681. */
  10682. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10683. /**
  10684. * Strong typing of a Active Mesh related stage step action
  10685. */
  10686. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10687. /**
  10688. * Strong typing of a Camera related stage step action
  10689. */
  10690. export type CameraStageAction = (camera: Camera) => void;
  10691. /**
  10692. * Strong typing of a Camera Frame buffer related stage step action
  10693. */
  10694. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10695. /**
  10696. * Strong typing of a Render Target related stage step action
  10697. */
  10698. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10699. /**
  10700. * Strong typing of a RenderingGroup related stage step action
  10701. */
  10702. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10703. /**
  10704. * Strong typing of a Mesh Render related stage step action
  10705. */
  10706. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10707. /**
  10708. * Strong typing of a simple stage step action
  10709. */
  10710. export type SimpleStageAction = () => void;
  10711. /**
  10712. * Strong typing of a render target action.
  10713. */
  10714. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10715. /**
  10716. * Strong typing of a pointer move action.
  10717. */
  10718. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  10719. /**
  10720. * Strong typing of a pointer up/down action.
  10721. */
  10722. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10723. /**
  10724. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  10725. * @hidden
  10726. */
  10727. export class Stage<T extends Function> extends Array<{
  10728. index: number;
  10729. component: ISceneComponent;
  10730. action: T;
  10731. }> {
  10732. /**
  10733. * Hide ctor from the rest of the world.
  10734. * @param items The items to add.
  10735. */
  10736. private constructor();
  10737. /**
  10738. * Creates a new Stage.
  10739. * @returns A new instance of a Stage
  10740. */
  10741. static Create<T extends Function>(): Stage<T>;
  10742. /**
  10743. * Registers a step in an ordered way in the targeted stage.
  10744. * @param index Defines the position to register the step in
  10745. * @param component Defines the component attached to the step
  10746. * @param action Defines the action to launch during the step
  10747. */
  10748. registerStep(index: number, component: ISceneComponent, action: T): void;
  10749. /**
  10750. * Clears all the steps from the stage.
  10751. */
  10752. clear(): void;
  10753. }
  10754. }
  10755. declare module "babylonjs/Meshes/meshLODLevel" {
  10756. import { Mesh } from "babylonjs/Meshes/mesh";
  10757. import { Nullable } from "babylonjs/types";
  10758. /**
  10759. * Class used to represent a specific level of detail of a mesh
  10760. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  10761. */
  10762. export class MeshLODLevel {
  10763. /** Defines the distance where this level should star being displayed */
  10764. distance: number;
  10765. /** Defines the mesh to use to render this level */
  10766. mesh: Nullable<Mesh>;
  10767. /**
  10768. * Creates a new LOD level
  10769. * @param distance defines the distance where this level should star being displayed
  10770. * @param mesh defines the mesh to use to render this level
  10771. */
  10772. constructor(
  10773. /** Defines the distance where this level should star being displayed */
  10774. distance: number,
  10775. /** Defines the mesh to use to render this level */
  10776. mesh: Nullable<Mesh>);
  10777. }
  10778. }
  10779. declare module "babylonjs/Lights/shadowLight" {
  10780. import { Camera } from "babylonjs/Cameras/camera";
  10781. import { Scene } from "babylonjs/scene";
  10782. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  10783. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10784. import { Light } from "babylonjs/Lights/light";
  10785. /**
  10786. * Interface describing all the common properties and methods a shadow light needs to implement.
  10787. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  10788. * as well as binding the different shadow properties to the effects.
  10789. */
  10790. export interface IShadowLight extends Light {
  10791. /**
  10792. * The light id in the scene (used in scene.findLighById for instance)
  10793. */
  10794. id: string;
  10795. /**
  10796. * The position the shdow will be casted from.
  10797. */
  10798. position: Vector3;
  10799. /**
  10800. * In 2d mode (needCube being false), the direction used to cast the shadow.
  10801. */
  10802. direction: Vector3;
  10803. /**
  10804. * The transformed position. Position of the light in world space taking parenting in account.
  10805. */
  10806. transformedPosition: Vector3;
  10807. /**
  10808. * The transformed direction. Direction of the light in world space taking parenting in account.
  10809. */
  10810. transformedDirection: Vector3;
  10811. /**
  10812. * The friendly name of the light in the scene.
  10813. */
  10814. name: string;
  10815. /**
  10816. * Defines the shadow projection clipping minimum z value.
  10817. */
  10818. shadowMinZ: number;
  10819. /**
  10820. * Defines the shadow projection clipping maximum z value.
  10821. */
  10822. shadowMaxZ: number;
  10823. /**
  10824. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  10825. * @returns true if the information has been computed, false if it does not need to (no parenting)
  10826. */
  10827. computeTransformedInformation(): boolean;
  10828. /**
  10829. * Gets the scene the light belongs to.
  10830. * @returns The scene
  10831. */
  10832. getScene(): Scene;
  10833. /**
  10834. * Callback defining a custom Projection Matrix Builder.
  10835. * This can be used to override the default projection matrix computation.
  10836. */
  10837. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  10838. /**
  10839. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  10840. * @param matrix The materix to updated with the projection information
  10841. * @param viewMatrix The transform matrix of the light
  10842. * @param renderList The list of mesh to render in the map
  10843. * @returns The current light
  10844. */
  10845. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  10846. /**
  10847. * Gets the current depth scale used in ESM.
  10848. * @returns The scale
  10849. */
  10850. getDepthScale(): number;
  10851. /**
  10852. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  10853. * @returns true if a cube texture needs to be use
  10854. */
  10855. needCube(): boolean;
  10856. /**
  10857. * Detects if the projection matrix requires to be recomputed this frame.
  10858. * @returns true if it requires to be recomputed otherwise, false.
  10859. */
  10860. needProjectionMatrixCompute(): boolean;
  10861. /**
  10862. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  10863. */
  10864. forceProjectionMatrixCompute(): void;
  10865. /**
  10866. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  10867. * @param faceIndex The index of the face we are computed the direction to generate shadow
  10868. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  10869. */
  10870. getShadowDirection(faceIndex?: number): Vector3;
  10871. /**
  10872. * Gets the minZ used for shadow according to both the scene and the light.
  10873. * @param activeCamera The camera we are returning the min for
  10874. * @returns the depth min z
  10875. */
  10876. getDepthMinZ(activeCamera: Camera): number;
  10877. /**
  10878. * Gets the maxZ used for shadow according to both the scene and the light.
  10879. * @param activeCamera The camera we are returning the max for
  10880. * @returns the depth max z
  10881. */
  10882. getDepthMaxZ(activeCamera: Camera): number;
  10883. }
  10884. /**
  10885. * Base implementation IShadowLight
  10886. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  10887. */
  10888. export abstract class ShadowLight extends Light implements IShadowLight {
  10889. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  10890. protected _position: Vector3;
  10891. protected _setPosition(value: Vector3): void;
  10892. /**
  10893. * Sets the position the shadow will be casted from. Also use as the light position for both
  10894. * point and spot lights.
  10895. */
  10896. /**
  10897. * Sets the position the shadow will be casted from. Also use as the light position for both
  10898. * point and spot lights.
  10899. */
  10900. position: Vector3;
  10901. protected _direction: Vector3;
  10902. protected _setDirection(value: Vector3): void;
  10903. /**
  10904. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  10905. * Also use as the light direction on spot and directional lights.
  10906. */
  10907. /**
  10908. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  10909. * Also use as the light direction on spot and directional lights.
  10910. */
  10911. direction: Vector3;
  10912. private _shadowMinZ;
  10913. /**
  10914. * Gets the shadow projection clipping minimum z value.
  10915. */
  10916. /**
  10917. * Sets the shadow projection clipping minimum z value.
  10918. */
  10919. shadowMinZ: number;
  10920. private _shadowMaxZ;
  10921. /**
  10922. * Sets the shadow projection clipping maximum z value.
  10923. */
  10924. /**
  10925. * Gets the shadow projection clipping maximum z value.
  10926. */
  10927. shadowMaxZ: number;
  10928. /**
  10929. * Callback defining a custom Projection Matrix Builder.
  10930. * This can be used to override the default projection matrix computation.
  10931. */
  10932. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  10933. /**
  10934. * The transformed position. Position of the light in world space taking parenting in account.
  10935. */
  10936. transformedPosition: Vector3;
  10937. /**
  10938. * The transformed direction. Direction of the light in world space taking parenting in account.
  10939. */
  10940. transformedDirection: Vector3;
  10941. private _needProjectionMatrixCompute;
  10942. /**
  10943. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  10944. * @returns true if the information has been computed, false if it does not need to (no parenting)
  10945. */
  10946. computeTransformedInformation(): boolean;
  10947. /**
  10948. * Return the depth scale used for the shadow map.
  10949. * @returns the depth scale.
  10950. */
  10951. getDepthScale(): number;
  10952. /**
  10953. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  10954. * @param faceIndex The index of the face we are computed the direction to generate shadow
  10955. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  10956. */
  10957. getShadowDirection(faceIndex?: number): Vector3;
  10958. /**
  10959. * Returns the ShadowLight absolute position in the World.
  10960. * @returns the position vector in world space
  10961. */
  10962. getAbsolutePosition(): Vector3;
  10963. /**
  10964. * Sets the ShadowLight direction toward the passed target.
  10965. * @param target The point to target in local space
  10966. * @returns the updated ShadowLight direction
  10967. */
  10968. setDirectionToTarget(target: Vector3): Vector3;
  10969. /**
  10970. * Returns the light rotation in euler definition.
  10971. * @returns the x y z rotation in local space.
  10972. */
  10973. getRotation(): Vector3;
  10974. /**
  10975. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  10976. * @returns true if a cube texture needs to be use
  10977. */
  10978. needCube(): boolean;
  10979. /**
  10980. * Detects if the projection matrix requires to be recomputed this frame.
  10981. * @returns true if it requires to be recomputed otherwise, false.
  10982. */
  10983. needProjectionMatrixCompute(): boolean;
  10984. /**
  10985. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  10986. */
  10987. forceProjectionMatrixCompute(): void;
  10988. /** @hidden */
  10989. _initCache(): void;
  10990. /** @hidden */
  10991. _isSynchronized(): boolean;
  10992. /**
  10993. * Computes the world matrix of the node
  10994. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  10995. * @returns the world matrix
  10996. */
  10997. computeWorldMatrix(force?: boolean): Matrix;
  10998. /**
  10999. * Gets the minZ used for shadow according to both the scene and the light.
  11000. * @param activeCamera The camera we are returning the min for
  11001. * @returns the depth min z
  11002. */
  11003. getDepthMinZ(activeCamera: Camera): number;
  11004. /**
  11005. * Gets the maxZ used for shadow according to both the scene and the light.
  11006. * @param activeCamera The camera we are returning the max for
  11007. * @returns the depth max z
  11008. */
  11009. getDepthMaxZ(activeCamera: Camera): number;
  11010. /**
  11011. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  11012. * @param matrix The materix to updated with the projection information
  11013. * @param viewMatrix The transform matrix of the light
  11014. * @param renderList The list of mesh to render in the map
  11015. * @returns The current light
  11016. */
  11017. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  11018. }
  11019. }
  11020. declare module "babylonjs/Materials/materialHelper" {
  11021. import { Nullable } from "babylonjs/types";
  11022. import { Scene } from "babylonjs/scene";
  11023. import { Engine } from "babylonjs/Engines/engine";
  11024. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11025. import { Light } from "babylonjs/Lights/light";
  11026. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  11027. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  11028. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  11029. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  11030. /**
  11031. * "Static Class" containing the most commonly used helper while dealing with material for
  11032. * rendering purpose.
  11033. *
  11034. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  11035. *
  11036. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  11037. */
  11038. export class MaterialHelper {
  11039. /**
  11040. * Bind the current view position to an effect.
  11041. * @param effect The effect to be bound
  11042. * @param scene The scene the eyes position is used from
  11043. */
  11044. static BindEyePosition(effect: Effect, scene: Scene): void;
  11045. /**
  11046. * Helps preparing the defines values about the UVs in used in the effect.
  11047. * UVs are shared as much as we can accross channels in the shaders.
  11048. * @param texture The texture we are preparing the UVs for
  11049. * @param defines The defines to update
  11050. * @param key The channel key "diffuse", "specular"... used in the shader
  11051. */
  11052. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  11053. /**
  11054. * Binds a texture matrix value to its corrsponding uniform
  11055. * @param texture The texture to bind the matrix for
  11056. * @param uniformBuffer The uniform buffer receivin the data
  11057. * @param key The channel key "diffuse", "specular"... used in the shader
  11058. */
  11059. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  11060. /**
  11061. * Gets the current status of the fog (should it be enabled?)
  11062. * @param mesh defines the mesh to evaluate for fog support
  11063. * @param scene defines the hosting scene
  11064. * @returns true if fog must be enabled
  11065. */
  11066. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  11067. /**
  11068. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  11069. * @param mesh defines the current mesh
  11070. * @param scene defines the current scene
  11071. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  11072. * @param pointsCloud defines if point cloud rendering has to be turned on
  11073. * @param fogEnabled defines if fog has to be turned on
  11074. * @param alphaTest defines if alpha testing has to be turned on
  11075. * @param defines defines the current list of defines
  11076. */
  11077. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  11078. /**
  11079. * Helper used to prepare the list of defines associated with frame values for shader compilation
  11080. * @param scene defines the current scene
  11081. * @param engine defines the current engine
  11082. * @param defines specifies the list of active defines
  11083. * @param useInstances defines if instances have to be turned on
  11084. * @param useClipPlane defines if clip plane have to be turned on
  11085. */
  11086. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  11087. /**
  11088. * Prepares the defines for bones
  11089. * @param mesh The mesh containing the geometry data we will draw
  11090. * @param defines The defines to update
  11091. */
  11092. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  11093. /**
  11094. * Prepares the defines for morph targets
  11095. * @param mesh The mesh containing the geometry data we will draw
  11096. * @param defines The defines to update
  11097. */
  11098. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  11099. /**
  11100. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  11101. * @param mesh The mesh containing the geometry data we will draw
  11102. * @param defines The defines to update
  11103. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  11104. * @param useBones Precise whether bones should be used or not (override mesh info)
  11105. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  11106. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  11107. * @returns false if defines are considered not dirty and have not been checked
  11108. */
  11109. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  11110. /**
  11111. * Prepares the defines related to multiview
  11112. * @param scene The scene we are intending to draw
  11113. * @param defines The defines to update
  11114. */
  11115. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  11116. /**
  11117. * Prepares the defines related to the light information passed in parameter
  11118. * @param scene The scene we are intending to draw
  11119. * @param mesh The mesh the effect is compiling for
  11120. * @param light The light the effect is compiling for
  11121. * @param lightIndex The index of the light
  11122. * @param defines The defines to update
  11123. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  11124. * @param state Defines the current state regarding what is needed (normals, etc...)
  11125. */
  11126. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  11127. needNormals: boolean;
  11128. needRebuild: boolean;
  11129. shadowEnabled: boolean;
  11130. specularEnabled: boolean;
  11131. lightmapMode: boolean;
  11132. }): void;
  11133. /**
  11134. * Prepares the defines related to the light information passed in parameter
  11135. * @param scene The scene we are intending to draw
  11136. * @param mesh The mesh the effect is compiling for
  11137. * @param defines The defines to update
  11138. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  11139. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  11140. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  11141. * @returns true if normals will be required for the rest of the effect
  11142. */
  11143. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  11144. /**
  11145. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  11146. * @param lightIndex defines the light index
  11147. * @param uniformsList The uniform list
  11148. * @param samplersList The sampler list
  11149. * @param projectedLightTexture defines if projected texture must be used
  11150. * @param uniformBuffersList defines an optional list of uniform buffers
  11151. */
  11152. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  11153. /**
  11154. * Prepares the uniforms and samplers list to be used in the effect
  11155. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  11156. * @param samplersList The sampler list
  11157. * @param defines The defines helping in the list generation
  11158. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  11159. */
  11160. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  11161. /**
  11162. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  11163. * @param defines The defines to update while falling back
  11164. * @param fallbacks The authorized effect fallbacks
  11165. * @param maxSimultaneousLights The maximum number of lights allowed
  11166. * @param rank the current rank of the Effect
  11167. * @returns The newly affected rank
  11168. */
  11169. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  11170. private static _TmpMorphInfluencers;
  11171. /**
  11172. * Prepares the list of attributes required for morph targets according to the effect defines.
  11173. * @param attribs The current list of supported attribs
  11174. * @param mesh The mesh to prepare the morph targets attributes for
  11175. * @param influencers The number of influencers
  11176. */
  11177. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  11178. /**
  11179. * Prepares the list of attributes required for morph targets according to the effect defines.
  11180. * @param attribs The current list of supported attribs
  11181. * @param mesh The mesh to prepare the morph targets attributes for
  11182. * @param defines The current Defines of the effect
  11183. */
  11184. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  11185. /**
  11186. * Prepares the list of attributes required for bones according to the effect defines.
  11187. * @param attribs The current list of supported attribs
  11188. * @param mesh The mesh to prepare the bones attributes for
  11189. * @param defines The current Defines of the effect
  11190. * @param fallbacks The current efffect fallback strategy
  11191. */
  11192. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  11193. /**
  11194. * Check and prepare the list of attributes required for instances according to the effect defines.
  11195. * @param attribs The current list of supported attribs
  11196. * @param defines The current MaterialDefines of the effect
  11197. */
  11198. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  11199. /**
  11200. * Add the list of attributes required for instances to the attribs array.
  11201. * @param attribs The current list of supported attribs
  11202. */
  11203. static PushAttributesForInstances(attribs: string[]): void;
  11204. /**
  11205. * Binds the light shadow information to the effect for the given mesh.
  11206. * @param light The light containing the generator
  11207. * @param scene The scene the lights belongs to
  11208. * @param mesh The mesh we are binding the information to render
  11209. * @param lightIndex The light index in the effect used to render the mesh
  11210. * @param effect The effect we are binding the data to
  11211. */
  11212. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  11213. /**
  11214. * Binds the light information to the effect.
  11215. * @param light The light containing the generator
  11216. * @param effect The effect we are binding the data to
  11217. * @param lightIndex The light index in the effect used to render
  11218. */
  11219. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  11220. /**
  11221. * Binds the lights information from the scene to the effect for the given mesh.
  11222. * @param light Light to bind
  11223. * @param lightIndex Light index
  11224. * @param scene The scene where the light belongs to
  11225. * @param mesh The mesh we are binding the information to render
  11226. * @param effect The effect we are binding the data to
  11227. * @param useSpecular Defines if specular is supported
  11228. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  11229. */
  11230. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean): void;
  11231. /**
  11232. * Binds the lights information from the scene to the effect for the given mesh.
  11233. * @param scene The scene the lights belongs to
  11234. * @param mesh The mesh we are binding the information to render
  11235. * @param effect The effect we are binding the data to
  11236. * @param defines The generated defines for the effect
  11237. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  11238. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  11239. */
  11240. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  11241. private static _tempFogColor;
  11242. /**
  11243. * Binds the fog information from the scene to the effect for the given mesh.
  11244. * @param scene The scene the lights belongs to
  11245. * @param mesh The mesh we are binding the information to render
  11246. * @param effect The effect we are binding the data to
  11247. * @param linearSpace Defines if the fog effect is applied in linear space
  11248. */
  11249. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  11250. /**
  11251. * Binds the bones information from the mesh to the effect.
  11252. * @param mesh The mesh we are binding the information to render
  11253. * @param effect The effect we are binding the data to
  11254. */
  11255. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  11256. /**
  11257. * Binds the morph targets information from the mesh to the effect.
  11258. * @param abstractMesh The mesh we are binding the information to render
  11259. * @param effect The effect we are binding the data to
  11260. */
  11261. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  11262. /**
  11263. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  11264. * @param defines The generated defines used in the effect
  11265. * @param effect The effect we are binding the data to
  11266. * @param scene The scene we are willing to render with logarithmic scale for
  11267. */
  11268. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  11269. /**
  11270. * Binds the clip plane information from the scene to the effect.
  11271. * @param scene The scene the clip plane information are extracted from
  11272. * @param effect The effect we are binding the data to
  11273. */
  11274. static BindClipPlane(effect: Effect, scene: Scene): void;
  11275. }
  11276. }
  11277. declare module "babylonjs/Shaders/shadowMap.fragment" {
  11278. /** @hidden */
  11279. export var shadowMapPixelShader: {
  11280. name: string;
  11281. shader: string;
  11282. };
  11283. }
  11284. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  11285. /** @hidden */
  11286. export var bonesDeclaration: {
  11287. name: string;
  11288. shader: string;
  11289. };
  11290. }
  11291. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  11292. /** @hidden */
  11293. export var morphTargetsVertexGlobalDeclaration: {
  11294. name: string;
  11295. shader: string;
  11296. };
  11297. }
  11298. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  11299. /** @hidden */
  11300. export var morphTargetsVertexDeclaration: {
  11301. name: string;
  11302. shader: string;
  11303. };
  11304. }
  11305. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  11306. /** @hidden */
  11307. export var instancesDeclaration: {
  11308. name: string;
  11309. shader: string;
  11310. };
  11311. }
  11312. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  11313. /** @hidden */
  11314. export var helperFunctions: {
  11315. name: string;
  11316. shader: string;
  11317. };
  11318. }
  11319. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  11320. /** @hidden */
  11321. export var morphTargetsVertex: {
  11322. name: string;
  11323. shader: string;
  11324. };
  11325. }
  11326. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  11327. /** @hidden */
  11328. export var instancesVertex: {
  11329. name: string;
  11330. shader: string;
  11331. };
  11332. }
  11333. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  11334. /** @hidden */
  11335. export var bonesVertex: {
  11336. name: string;
  11337. shader: string;
  11338. };
  11339. }
  11340. declare module "babylonjs/Shaders/shadowMap.vertex" {
  11341. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  11342. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  11343. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  11344. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  11345. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  11346. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  11347. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  11348. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  11349. /** @hidden */
  11350. export var shadowMapVertexShader: {
  11351. name: string;
  11352. shader: string;
  11353. };
  11354. }
  11355. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  11356. /** @hidden */
  11357. export var depthBoxBlurPixelShader: {
  11358. name: string;
  11359. shader: string;
  11360. };
  11361. }
  11362. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  11363. import { Nullable } from "babylonjs/types";
  11364. import { Scene } from "babylonjs/scene";
  11365. import { Matrix } from "babylonjs/Maths/math";
  11366. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11367. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11368. import { Mesh } from "babylonjs/Meshes/mesh";
  11369. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  11370. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  11371. import { Effect } from "babylonjs/Materials/effect";
  11372. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11373. import "babylonjs/Shaders/shadowMap.fragment";
  11374. import "babylonjs/Shaders/shadowMap.vertex";
  11375. import "babylonjs/Shaders/depthBoxBlur.fragment";
  11376. import { Observable } from "babylonjs/Misc/observable";
  11377. /**
  11378. * Defines the options associated with the creation of a custom shader for a shadow generator.
  11379. */
  11380. export interface ICustomShaderOptions {
  11381. /**
  11382. * Gets or sets the custom shader name to use
  11383. */
  11384. shaderName: string;
  11385. /**
  11386. * The list of attribute names used in the shader
  11387. */
  11388. attributes?: string[];
  11389. /**
  11390. * The list of unifrom names used in the shader
  11391. */
  11392. uniforms?: string[];
  11393. /**
  11394. * The list of sampler names used in the shader
  11395. */
  11396. samplers?: string[];
  11397. /**
  11398. * The list of defines used in the shader
  11399. */
  11400. defines?: string[];
  11401. }
  11402. /**
  11403. * Interface to implement to create a shadow generator compatible with BJS.
  11404. */
  11405. export interface IShadowGenerator {
  11406. /**
  11407. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  11408. * @returns The render target texture if present otherwise, null
  11409. */
  11410. getShadowMap(): Nullable<RenderTargetTexture>;
  11411. /**
  11412. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  11413. * @returns The render target texture if the shadow map is present otherwise, null
  11414. */
  11415. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  11416. /**
  11417. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  11418. * @param subMesh The submesh we want to render in the shadow map
  11419. * @param useInstances Defines wether will draw in the map using instances
  11420. * @returns true if ready otherwise, false
  11421. */
  11422. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11423. /**
  11424. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  11425. * @param defines Defines of the material we want to update
  11426. * @param lightIndex Index of the light in the enabled light list of the material
  11427. */
  11428. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  11429. /**
  11430. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  11431. * defined in the generator but impacting the effect).
  11432. * It implies the unifroms available on the materials are the standard BJS ones.
  11433. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  11434. * @param effect The effect we are binfing the information for
  11435. */
  11436. bindShadowLight(lightIndex: string, effect: Effect): void;
  11437. /**
  11438. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  11439. * (eq to shadow prjection matrix * light transform matrix)
  11440. * @returns The transform matrix used to create the shadow map
  11441. */
  11442. getTransformMatrix(): Matrix;
  11443. /**
  11444. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  11445. * Cube and 2D textures for instance.
  11446. */
  11447. recreateShadowMap(): void;
  11448. /**
  11449. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11450. * @param onCompiled Callback triggered at the and of the effects compilation
  11451. * @param options Sets of optional options forcing the compilation with different modes
  11452. */
  11453. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  11454. useInstances: boolean;
  11455. }>): void;
  11456. /**
  11457. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11458. * @param options Sets of optional options forcing the compilation with different modes
  11459. * @returns A promise that resolves when the compilation completes
  11460. */
  11461. forceCompilationAsync(options?: Partial<{
  11462. useInstances: boolean;
  11463. }>): Promise<void>;
  11464. /**
  11465. * Serializes the shadow generator setup to a json object.
  11466. * @returns The serialized JSON object
  11467. */
  11468. serialize(): any;
  11469. /**
  11470. * Disposes the Shadow map and related Textures and effects.
  11471. */
  11472. dispose(): void;
  11473. }
  11474. /**
  11475. * Default implementation IShadowGenerator.
  11476. * This is the main object responsible of generating shadows in the framework.
  11477. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  11478. */
  11479. export class ShadowGenerator implements IShadowGenerator {
  11480. /**
  11481. * Shadow generator mode None: no filtering applied.
  11482. */
  11483. static readonly FILTER_NONE: number;
  11484. /**
  11485. * Shadow generator mode ESM: Exponential Shadow Mapping.
  11486. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11487. */
  11488. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  11489. /**
  11490. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  11491. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  11492. */
  11493. static readonly FILTER_POISSONSAMPLING: number;
  11494. /**
  11495. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  11496. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11497. */
  11498. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  11499. /**
  11500. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  11501. * edge artifacts on steep falloff.
  11502. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11503. */
  11504. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  11505. /**
  11506. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  11507. * edge artifacts on steep falloff.
  11508. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11509. */
  11510. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  11511. /**
  11512. * Shadow generator mode PCF: Percentage Closer Filtering
  11513. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  11514. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  11515. */
  11516. static readonly FILTER_PCF: number;
  11517. /**
  11518. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  11519. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  11520. * Contact Hardening
  11521. */
  11522. static readonly FILTER_PCSS: number;
  11523. /**
  11524. * Reserved for PCF and PCSS
  11525. * Highest Quality.
  11526. *
  11527. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  11528. *
  11529. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  11530. */
  11531. static readonly QUALITY_HIGH: number;
  11532. /**
  11533. * Reserved for PCF and PCSS
  11534. * Good tradeoff for quality/perf cross devices
  11535. *
  11536. * Execute PCF on a 3*3 kernel.
  11537. *
  11538. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  11539. */
  11540. static readonly QUALITY_MEDIUM: number;
  11541. /**
  11542. * Reserved for PCF and PCSS
  11543. * The lowest quality but the fastest.
  11544. *
  11545. * Execute PCF on a 1*1 kernel.
  11546. *
  11547. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  11548. */
  11549. static readonly QUALITY_LOW: number;
  11550. /** Gets or sets the custom shader name to use */
  11551. customShaderOptions: ICustomShaderOptions;
  11552. /**
  11553. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  11554. */
  11555. onBeforeShadowMapRenderObservable: Observable<Effect>;
  11556. /**
  11557. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  11558. */
  11559. onAfterShadowMapRenderObservable: Observable<Effect>;
  11560. /**
  11561. * Observable triggered before a mesh is rendered in the shadow map.
  11562. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  11563. */
  11564. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  11565. /**
  11566. * Observable triggered after a mesh is rendered in the shadow map.
  11567. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  11568. */
  11569. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  11570. private _bias;
  11571. /**
  11572. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  11573. */
  11574. /**
  11575. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  11576. */
  11577. bias: number;
  11578. private _normalBias;
  11579. /**
  11580. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  11581. */
  11582. /**
  11583. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  11584. */
  11585. normalBias: number;
  11586. private _blurBoxOffset;
  11587. /**
  11588. * Gets the blur box offset: offset applied during the blur pass.
  11589. * Only useful if useKernelBlur = false
  11590. */
  11591. /**
  11592. * Sets the blur box offset: offset applied during the blur pass.
  11593. * Only useful if useKernelBlur = false
  11594. */
  11595. blurBoxOffset: number;
  11596. private _blurScale;
  11597. /**
  11598. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  11599. * 2 means half of the size.
  11600. */
  11601. /**
  11602. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  11603. * 2 means half of the size.
  11604. */
  11605. blurScale: number;
  11606. private _blurKernel;
  11607. /**
  11608. * Gets the blur kernel: kernel size of the blur pass.
  11609. * Only useful if useKernelBlur = true
  11610. */
  11611. /**
  11612. * Sets the blur kernel: kernel size of the blur pass.
  11613. * Only useful if useKernelBlur = true
  11614. */
  11615. blurKernel: number;
  11616. private _useKernelBlur;
  11617. /**
  11618. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  11619. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  11620. */
  11621. /**
  11622. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  11623. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  11624. */
  11625. useKernelBlur: boolean;
  11626. private _depthScale;
  11627. /**
  11628. * Gets the depth scale used in ESM mode.
  11629. */
  11630. /**
  11631. * Sets the depth scale used in ESM mode.
  11632. * This can override the scale stored on the light.
  11633. */
  11634. depthScale: number;
  11635. private _filter;
  11636. /**
  11637. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  11638. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  11639. */
  11640. /**
  11641. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  11642. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  11643. */
  11644. filter: number;
  11645. /**
  11646. * Gets if the current filter is set to Poisson Sampling.
  11647. */
  11648. /**
  11649. * Sets the current filter to Poisson Sampling.
  11650. */
  11651. usePoissonSampling: boolean;
  11652. /**
  11653. * Gets if the current filter is set to ESM.
  11654. */
  11655. /**
  11656. * Sets the current filter is to ESM.
  11657. */
  11658. useExponentialShadowMap: boolean;
  11659. /**
  11660. * Gets if the current filter is set to filtered ESM.
  11661. */
  11662. /**
  11663. * Gets if the current filter is set to filtered ESM.
  11664. */
  11665. useBlurExponentialShadowMap: boolean;
  11666. /**
  11667. * Gets if the current filter is set to "close ESM" (using the inverse of the
  11668. * exponential to prevent steep falloff artifacts).
  11669. */
  11670. /**
  11671. * Sets the current filter to "close ESM" (using the inverse of the
  11672. * exponential to prevent steep falloff artifacts).
  11673. */
  11674. useCloseExponentialShadowMap: boolean;
  11675. /**
  11676. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  11677. * exponential to prevent steep falloff artifacts).
  11678. */
  11679. /**
  11680. * Sets the current filter to filtered "close ESM" (using the inverse of the
  11681. * exponential to prevent steep falloff artifacts).
  11682. */
  11683. useBlurCloseExponentialShadowMap: boolean;
  11684. /**
  11685. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  11686. */
  11687. /**
  11688. * Sets the current filter to "PCF" (percentage closer filtering).
  11689. */
  11690. usePercentageCloserFiltering: boolean;
  11691. private _filteringQuality;
  11692. /**
  11693. * Gets the PCF or PCSS Quality.
  11694. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  11695. */
  11696. /**
  11697. * Sets the PCF or PCSS Quality.
  11698. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  11699. */
  11700. filteringQuality: number;
  11701. /**
  11702. * Gets if the current filter is set to "PCSS" (contact hardening).
  11703. */
  11704. /**
  11705. * Sets the current filter to "PCSS" (contact hardening).
  11706. */
  11707. useContactHardeningShadow: boolean;
  11708. private _contactHardeningLightSizeUVRatio;
  11709. /**
  11710. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  11711. * Using a ratio helps keeping shape stability independently of the map size.
  11712. *
  11713. * It does not account for the light projection as it was having too much
  11714. * instability during the light setup or during light position changes.
  11715. *
  11716. * Only valid if useContactHardeningShadow is true.
  11717. */
  11718. /**
  11719. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  11720. * Using a ratio helps keeping shape stability independently of the map size.
  11721. *
  11722. * It does not account for the light projection as it was having too much
  11723. * instability during the light setup or during light position changes.
  11724. *
  11725. * Only valid if useContactHardeningShadow is true.
  11726. */
  11727. contactHardeningLightSizeUVRatio: number;
  11728. private _darkness;
  11729. /** Gets or sets the actual darkness of a shadow */
  11730. darkness: number;
  11731. /**
  11732. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  11733. * 0 means strongest and 1 would means no shadow.
  11734. * @returns the darkness.
  11735. */
  11736. getDarkness(): number;
  11737. /**
  11738. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  11739. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  11740. * @returns the shadow generator allowing fluent coding.
  11741. */
  11742. setDarkness(darkness: number): ShadowGenerator;
  11743. private _transparencyShadow;
  11744. /** Gets or sets the ability to have transparent shadow */
  11745. transparencyShadow: boolean;
  11746. /**
  11747. * Sets the ability to have transparent shadow (boolean).
  11748. * @param transparent True if transparent else False
  11749. * @returns the shadow generator allowing fluent coding
  11750. */
  11751. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  11752. private _shadowMap;
  11753. private _shadowMap2;
  11754. /**
  11755. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  11756. * @returns The render target texture if present otherwise, null
  11757. */
  11758. getShadowMap(): Nullable<RenderTargetTexture>;
  11759. /**
  11760. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  11761. * @returns The render target texture if the shadow map is present otherwise, null
  11762. */
  11763. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  11764. /**
  11765. * Gets the class name of that object
  11766. * @returns "ShadowGenerator"
  11767. */
  11768. getClassName(): string;
  11769. /**
  11770. * Helper function to add a mesh and its descendants to the list of shadow casters.
  11771. * @param mesh Mesh to add
  11772. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  11773. * @returns the Shadow Generator itself
  11774. */
  11775. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  11776. /**
  11777. * Helper function to remove a mesh and its descendants from the list of shadow casters
  11778. * @param mesh Mesh to remove
  11779. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  11780. * @returns the Shadow Generator itself
  11781. */
  11782. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  11783. /**
  11784. * Controls the extent to which the shadows fade out at the edge of the frustum
  11785. * Used only by directionals and spots
  11786. */
  11787. frustumEdgeFalloff: number;
  11788. private _light;
  11789. /**
  11790. * Returns the associated light object.
  11791. * @returns the light generating the shadow
  11792. */
  11793. getLight(): IShadowLight;
  11794. /**
  11795. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  11796. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  11797. * It might on the other hand introduce peter panning.
  11798. */
  11799. forceBackFacesOnly: boolean;
  11800. private _scene;
  11801. private _lightDirection;
  11802. private _effect;
  11803. private _viewMatrix;
  11804. private _projectionMatrix;
  11805. private _transformMatrix;
  11806. private _cachedPosition;
  11807. private _cachedDirection;
  11808. private _cachedDefines;
  11809. private _currentRenderID;
  11810. private _boxBlurPostprocess;
  11811. private _kernelBlurXPostprocess;
  11812. private _kernelBlurYPostprocess;
  11813. private _blurPostProcesses;
  11814. private _mapSize;
  11815. private _currentFaceIndex;
  11816. private _currentFaceIndexCache;
  11817. private _textureType;
  11818. private _defaultTextureMatrix;
  11819. /** @hidden */
  11820. static _SceneComponentInitialization: (scene: Scene) => void;
  11821. /**
  11822. * Creates a ShadowGenerator object.
  11823. * A ShadowGenerator is the required tool to use the shadows.
  11824. * Each light casting shadows needs to use its own ShadowGenerator.
  11825. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  11826. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  11827. * @param light The light object generating the shadows.
  11828. * @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.
  11829. */
  11830. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  11831. private _initializeGenerator;
  11832. private _initializeShadowMap;
  11833. private _initializeBlurRTTAndPostProcesses;
  11834. private _renderForShadowMap;
  11835. private _renderSubMeshForShadowMap;
  11836. private _applyFilterValues;
  11837. /**
  11838. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11839. * @param onCompiled Callback triggered at the and of the effects compilation
  11840. * @param options Sets of optional options forcing the compilation with different modes
  11841. */
  11842. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  11843. useInstances: boolean;
  11844. }>): void;
  11845. /**
  11846. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11847. * @param options Sets of optional options forcing the compilation with different modes
  11848. * @returns A promise that resolves when the compilation completes
  11849. */
  11850. forceCompilationAsync(options?: Partial<{
  11851. useInstances: boolean;
  11852. }>): Promise<void>;
  11853. /**
  11854. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  11855. * @param subMesh The submesh we want to render in the shadow map
  11856. * @param useInstances Defines wether will draw in the map using instances
  11857. * @returns true if ready otherwise, false
  11858. */
  11859. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11860. /**
  11861. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  11862. * @param defines Defines of the material we want to update
  11863. * @param lightIndex Index of the light in the enabled light list of the material
  11864. */
  11865. prepareDefines(defines: any, lightIndex: number): void;
  11866. /**
  11867. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  11868. * defined in the generator but impacting the effect).
  11869. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  11870. * @param effect The effect we are binfing the information for
  11871. */
  11872. bindShadowLight(lightIndex: string, effect: Effect): void;
  11873. /**
  11874. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  11875. * (eq to shadow prjection matrix * light transform matrix)
  11876. * @returns The transform matrix used to create the shadow map
  11877. */
  11878. getTransformMatrix(): Matrix;
  11879. /**
  11880. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  11881. * Cube and 2D textures for instance.
  11882. */
  11883. recreateShadowMap(): void;
  11884. private _disposeBlurPostProcesses;
  11885. private _disposeRTTandPostProcesses;
  11886. /**
  11887. * Disposes the ShadowGenerator.
  11888. * Returns nothing.
  11889. */
  11890. dispose(): void;
  11891. /**
  11892. * Serializes the shadow generator setup to a json object.
  11893. * @returns The serialized JSON object
  11894. */
  11895. serialize(): any;
  11896. /**
  11897. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  11898. * @param parsedShadowGenerator The JSON object to parse
  11899. * @param scene The scene to create the shadow map for
  11900. * @returns The parsed shadow generator
  11901. */
  11902. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  11903. }
  11904. }
  11905. declare module "babylonjs/Lights/light" {
  11906. import { Nullable } from "babylonjs/types";
  11907. import { Scene } from "babylonjs/scene";
  11908. import { Vector3, Color3 } from "babylonjs/Maths/math";
  11909. import { Node } from "babylonjs/node";
  11910. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11911. import { Effect } from "babylonjs/Materials/effect";
  11912. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  11913. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  11914. /**
  11915. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  11916. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  11917. * 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.
  11918. */
  11919. export abstract class Light extends Node {
  11920. /**
  11921. * Falloff Default: light is falling off following the material specification:
  11922. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  11923. */
  11924. static readonly FALLOFF_DEFAULT: number;
  11925. /**
  11926. * Falloff Physical: light is falling off following the inverse squared distance law.
  11927. */
  11928. static readonly FALLOFF_PHYSICAL: number;
  11929. /**
  11930. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  11931. * to enhance interoperability with other engines.
  11932. */
  11933. static readonly FALLOFF_GLTF: number;
  11934. /**
  11935. * Falloff Standard: light is falling off like in the standard material
  11936. * to enhance interoperability with other materials.
  11937. */
  11938. static readonly FALLOFF_STANDARD: number;
  11939. /**
  11940. * If every light affecting the material is in this lightmapMode,
  11941. * material.lightmapTexture adds or multiplies
  11942. * (depends on material.useLightmapAsShadowmap)
  11943. * after every other light calculations.
  11944. */
  11945. static readonly LIGHTMAP_DEFAULT: number;
  11946. /**
  11947. * material.lightmapTexture as only diffuse lighting from this light
  11948. * adds only specular lighting from this light
  11949. * adds dynamic shadows
  11950. */
  11951. static readonly LIGHTMAP_SPECULAR: number;
  11952. /**
  11953. * material.lightmapTexture as only lighting
  11954. * no light calculation from this light
  11955. * only adds dynamic shadows from this light
  11956. */
  11957. static readonly LIGHTMAP_SHADOWSONLY: number;
  11958. /**
  11959. * Each light type uses the default quantity according to its type:
  11960. * point/spot lights use luminous intensity
  11961. * directional lights use illuminance
  11962. */
  11963. static readonly INTENSITYMODE_AUTOMATIC: number;
  11964. /**
  11965. * lumen (lm)
  11966. */
  11967. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  11968. /**
  11969. * candela (lm/sr)
  11970. */
  11971. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  11972. /**
  11973. * lux (lm/m^2)
  11974. */
  11975. static readonly INTENSITYMODE_ILLUMINANCE: number;
  11976. /**
  11977. * nit (cd/m^2)
  11978. */
  11979. static readonly INTENSITYMODE_LUMINANCE: number;
  11980. /**
  11981. * Light type const id of the point light.
  11982. */
  11983. static readonly LIGHTTYPEID_POINTLIGHT: number;
  11984. /**
  11985. * Light type const id of the directional light.
  11986. */
  11987. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  11988. /**
  11989. * Light type const id of the spot light.
  11990. */
  11991. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  11992. /**
  11993. * Light type const id of the hemispheric light.
  11994. */
  11995. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  11996. /**
  11997. * Diffuse gives the basic color to an object.
  11998. */
  11999. diffuse: Color3;
  12000. /**
  12001. * Specular produces a highlight color on an object.
  12002. * Note: This is note affecting PBR materials.
  12003. */
  12004. specular: Color3;
  12005. /**
  12006. * Defines the falloff type for this light. This lets overrriding how punctual light are
  12007. * falling off base on range or angle.
  12008. * This can be set to any values in Light.FALLOFF_x.
  12009. *
  12010. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  12011. * other types of materials.
  12012. */
  12013. falloffType: number;
  12014. /**
  12015. * Strength of the light.
  12016. * Note: By default it is define in the framework own unit.
  12017. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  12018. */
  12019. intensity: number;
  12020. private _range;
  12021. protected _inverseSquaredRange: number;
  12022. /**
  12023. * Defines how far from the source the light is impacting in scene units.
  12024. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  12025. */
  12026. /**
  12027. * Defines how far from the source the light is impacting in scene units.
  12028. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  12029. */
  12030. range: number;
  12031. /**
  12032. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  12033. * of light.
  12034. */
  12035. private _photometricScale;
  12036. private _intensityMode;
  12037. /**
  12038. * Gets the photometric scale used to interpret the intensity.
  12039. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  12040. */
  12041. /**
  12042. * Sets the photometric scale used to interpret the intensity.
  12043. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  12044. */
  12045. intensityMode: number;
  12046. private _radius;
  12047. /**
  12048. * Gets the light radius used by PBR Materials to simulate soft area lights.
  12049. */
  12050. /**
  12051. * sets the light radius used by PBR Materials to simulate soft area lights.
  12052. */
  12053. radius: number;
  12054. private _renderPriority;
  12055. /**
  12056. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  12057. * exceeding the number allowed of the materials.
  12058. */
  12059. renderPriority: number;
  12060. private _shadowEnabled;
  12061. /**
  12062. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  12063. * the current shadow generator.
  12064. */
  12065. /**
  12066. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  12067. * the current shadow generator.
  12068. */
  12069. shadowEnabled: boolean;
  12070. private _includedOnlyMeshes;
  12071. /**
  12072. * Gets the only meshes impacted by this light.
  12073. */
  12074. /**
  12075. * Sets the only meshes impacted by this light.
  12076. */
  12077. includedOnlyMeshes: AbstractMesh[];
  12078. private _excludedMeshes;
  12079. /**
  12080. * Gets the meshes not impacted by this light.
  12081. */
  12082. /**
  12083. * Sets the meshes not impacted by this light.
  12084. */
  12085. excludedMeshes: AbstractMesh[];
  12086. private _excludeWithLayerMask;
  12087. /**
  12088. * Gets the layer id use to find what meshes are not impacted by the light.
  12089. * Inactive if 0
  12090. */
  12091. /**
  12092. * Sets the layer id use to find what meshes are not impacted by the light.
  12093. * Inactive if 0
  12094. */
  12095. excludeWithLayerMask: number;
  12096. private _includeOnlyWithLayerMask;
  12097. /**
  12098. * Gets the layer id use to find what meshes are impacted by the light.
  12099. * Inactive if 0
  12100. */
  12101. /**
  12102. * Sets the layer id use to find what meshes are impacted by the light.
  12103. * Inactive if 0
  12104. */
  12105. includeOnlyWithLayerMask: number;
  12106. private _lightmapMode;
  12107. /**
  12108. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  12109. */
  12110. /**
  12111. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  12112. */
  12113. lightmapMode: number;
  12114. /**
  12115. * Shadow generator associted to the light.
  12116. * @hidden Internal use only.
  12117. */
  12118. _shadowGenerator: Nullable<IShadowGenerator>;
  12119. /**
  12120. * @hidden Internal use only.
  12121. */
  12122. _excludedMeshesIds: string[];
  12123. /**
  12124. * @hidden Internal use only.
  12125. */
  12126. _includedOnlyMeshesIds: string[];
  12127. /**
  12128. * The current light unifom buffer.
  12129. * @hidden Internal use only.
  12130. */
  12131. _uniformBuffer: UniformBuffer;
  12132. /**
  12133. * Creates a Light object in the scene.
  12134. * Documentation : https://doc.babylonjs.com/babylon101/lights
  12135. * @param name The firendly name of the light
  12136. * @param scene The scene the light belongs too
  12137. */
  12138. constructor(name: string, scene: Scene);
  12139. protected abstract _buildUniformLayout(): void;
  12140. /**
  12141. * Sets the passed Effect "effect" with the Light information.
  12142. * @param effect The effect to update
  12143. * @param lightIndex The index of the light in the effect to update
  12144. * @returns The light
  12145. */
  12146. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  12147. /**
  12148. * Returns the string "Light".
  12149. * @returns the class name
  12150. */
  12151. getClassName(): string;
  12152. /** @hidden */
  12153. readonly _isLight: boolean;
  12154. /**
  12155. * Converts the light information to a readable string for debug purpose.
  12156. * @param fullDetails Supports for multiple levels of logging within scene loading
  12157. * @returns the human readable light info
  12158. */
  12159. toString(fullDetails?: boolean): string;
  12160. /** @hidden */
  12161. protected _syncParentEnabledState(): void;
  12162. /**
  12163. * Set the enabled state of this node.
  12164. * @param value - the new enabled state
  12165. */
  12166. setEnabled(value: boolean): void;
  12167. /**
  12168. * Returns the Light associated shadow generator if any.
  12169. * @return the associated shadow generator.
  12170. */
  12171. getShadowGenerator(): Nullable<IShadowGenerator>;
  12172. /**
  12173. * Returns a Vector3, the absolute light position in the World.
  12174. * @returns the world space position of the light
  12175. */
  12176. getAbsolutePosition(): Vector3;
  12177. /**
  12178. * Specifies if the light will affect the passed mesh.
  12179. * @param mesh The mesh to test against the light
  12180. * @return true the mesh is affected otherwise, false.
  12181. */
  12182. canAffectMesh(mesh: AbstractMesh): boolean;
  12183. /**
  12184. * Sort function to order lights for rendering.
  12185. * @param a First Light object to compare to second.
  12186. * @param b Second Light object to compare first.
  12187. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  12188. */
  12189. static CompareLightsPriority(a: Light, b: Light): number;
  12190. /**
  12191. * Releases resources associated with this node.
  12192. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  12193. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  12194. */
  12195. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  12196. /**
  12197. * Returns the light type ID (integer).
  12198. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12199. */
  12200. getTypeID(): number;
  12201. /**
  12202. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  12203. * @returns the scaled intensity in intensity mode unit
  12204. */
  12205. getScaledIntensity(): number;
  12206. /**
  12207. * Returns a new Light object, named "name", from the current one.
  12208. * @param name The name of the cloned light
  12209. * @returns the new created light
  12210. */
  12211. clone(name: string): Nullable<Light>;
  12212. /**
  12213. * Serializes the current light into a Serialization object.
  12214. * @returns the serialized object.
  12215. */
  12216. serialize(): any;
  12217. /**
  12218. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  12219. * This new light is named "name" and added to the passed scene.
  12220. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  12221. * @param name The friendly name of the light
  12222. * @param scene The scene the new light will belong to
  12223. * @returns the constructor function
  12224. */
  12225. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  12226. /**
  12227. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  12228. * @param parsedLight The JSON representation of the light
  12229. * @param scene The scene to create the parsed light in
  12230. * @returns the created light after parsing
  12231. */
  12232. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  12233. private _hookArrayForExcluded;
  12234. private _hookArrayForIncludedOnly;
  12235. private _resyncMeshes;
  12236. /**
  12237. * Forces the meshes to update their light related information in their rendering used effects
  12238. * @hidden Internal Use Only
  12239. */
  12240. _markMeshesAsLightDirty(): void;
  12241. /**
  12242. * Recomputes the cached photometric scale if needed.
  12243. */
  12244. private _computePhotometricScale;
  12245. /**
  12246. * Returns the Photometric Scale according to the light type and intensity mode.
  12247. */
  12248. private _getPhotometricScale;
  12249. /**
  12250. * Reorder the light in the scene according to their defined priority.
  12251. * @hidden Internal Use Only
  12252. */
  12253. _reorderLightsInScene(): void;
  12254. /**
  12255. * Prepares the list of defines specific to the light type.
  12256. * @param defines the list of defines
  12257. * @param lightIndex defines the index of the light for the effect
  12258. */
  12259. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12260. }
  12261. }
  12262. declare module "babylonjs/Meshes/instancedMesh" {
  12263. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  12264. import { Vector3, Matrix } from "babylonjs/Maths/math";
  12265. import { Camera } from "babylonjs/Cameras/camera";
  12266. import { Node } from "babylonjs/node";
  12267. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12268. import { Mesh } from "babylonjs/Meshes/mesh";
  12269. import { Material } from "babylonjs/Materials/material";
  12270. import { Skeleton } from "babylonjs/Bones/skeleton";
  12271. import { Light } from "babylonjs/Lights/light";
  12272. /**
  12273. * Creates an instance based on a source mesh.
  12274. */
  12275. export class InstancedMesh extends AbstractMesh {
  12276. private _sourceMesh;
  12277. private _currentLOD;
  12278. /** @hidden */
  12279. _indexInSourceMeshInstanceArray: number;
  12280. constructor(name: string, source: Mesh);
  12281. /**
  12282. * Returns the string "InstancedMesh".
  12283. */
  12284. getClassName(): string;
  12285. /** Gets the list of lights affecting that mesh */
  12286. readonly lightSources: Light[];
  12287. _resyncLightSources(): void;
  12288. _resyncLighSource(light: Light): void;
  12289. _removeLightSource(light: Light): void;
  12290. /**
  12291. * If the source mesh receives shadows
  12292. */
  12293. readonly receiveShadows: boolean;
  12294. /**
  12295. * The material of the source mesh
  12296. */
  12297. readonly material: Nullable<Material>;
  12298. /**
  12299. * Visibility of the source mesh
  12300. */
  12301. readonly visibility: number;
  12302. /**
  12303. * Skeleton of the source mesh
  12304. */
  12305. readonly skeleton: Nullable<Skeleton>;
  12306. /**
  12307. * Rendering ground id of the source mesh
  12308. */
  12309. renderingGroupId: number;
  12310. /**
  12311. * Returns the total number of vertices (integer).
  12312. */
  12313. getTotalVertices(): number;
  12314. /**
  12315. * Returns a positive integer : the total number of indices in this mesh geometry.
  12316. * @returns the numner of indices or zero if the mesh has no geometry.
  12317. */
  12318. getTotalIndices(): number;
  12319. /**
  12320. * The source mesh of the instance
  12321. */
  12322. readonly sourceMesh: Mesh;
  12323. /**
  12324. * Is this node ready to be used/rendered
  12325. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  12326. * @return {boolean} is it ready
  12327. */
  12328. isReady(completeCheck?: boolean): boolean;
  12329. /**
  12330. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  12331. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  12332. * @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.
  12333. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  12334. */
  12335. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  12336. /**
  12337. * Sets the vertex data of the mesh geometry for the requested `kind`.
  12338. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  12339. * The `data` are either a numeric array either a Float32Array.
  12340. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  12341. * 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).
  12342. * Note that a new underlying VertexBuffer object is created each call.
  12343. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  12344. *
  12345. * Possible `kind` values :
  12346. * - VertexBuffer.PositionKind
  12347. * - VertexBuffer.UVKind
  12348. * - VertexBuffer.UV2Kind
  12349. * - VertexBuffer.UV3Kind
  12350. * - VertexBuffer.UV4Kind
  12351. * - VertexBuffer.UV5Kind
  12352. * - VertexBuffer.UV6Kind
  12353. * - VertexBuffer.ColorKind
  12354. * - VertexBuffer.MatricesIndicesKind
  12355. * - VertexBuffer.MatricesIndicesExtraKind
  12356. * - VertexBuffer.MatricesWeightsKind
  12357. * - VertexBuffer.MatricesWeightsExtraKind
  12358. *
  12359. * Returns the Mesh.
  12360. */
  12361. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  12362. /**
  12363. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  12364. * If the mesh has no geometry, it is simply returned as it is.
  12365. * The `data` are either a numeric array either a Float32Array.
  12366. * No new underlying VertexBuffer object is created.
  12367. * 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.
  12368. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  12369. *
  12370. * Possible `kind` values :
  12371. * - VertexBuffer.PositionKind
  12372. * - VertexBuffer.UVKind
  12373. * - VertexBuffer.UV2Kind
  12374. * - VertexBuffer.UV3Kind
  12375. * - VertexBuffer.UV4Kind
  12376. * - VertexBuffer.UV5Kind
  12377. * - VertexBuffer.UV6Kind
  12378. * - VertexBuffer.ColorKind
  12379. * - VertexBuffer.MatricesIndicesKind
  12380. * - VertexBuffer.MatricesIndicesExtraKind
  12381. * - VertexBuffer.MatricesWeightsKind
  12382. * - VertexBuffer.MatricesWeightsExtraKind
  12383. *
  12384. * Returns the Mesh.
  12385. */
  12386. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  12387. /**
  12388. * Sets the mesh indices.
  12389. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  12390. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  12391. * This method creates a new index buffer each call.
  12392. * Returns the Mesh.
  12393. */
  12394. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  12395. /**
  12396. * Boolean : True if the mesh owns the requested kind of data.
  12397. */
  12398. isVerticesDataPresent(kind: string): boolean;
  12399. /**
  12400. * Returns an array of indices (IndicesArray).
  12401. */
  12402. getIndices(): Nullable<IndicesArray>;
  12403. readonly _positions: Nullable<Vector3[]>;
  12404. /**
  12405. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  12406. * This means the mesh underlying bounding box and sphere are recomputed.
  12407. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  12408. * @returns the current mesh
  12409. */
  12410. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  12411. /** @hidden */
  12412. _preActivate(): InstancedMesh;
  12413. /** @hidden */
  12414. _activate(renderId: number, intermediateRendering: boolean): boolean;
  12415. /** @hidden */
  12416. _postActivate(): void;
  12417. getWorldMatrix(): Matrix;
  12418. readonly isAnInstance: boolean;
  12419. /**
  12420. * Returns the current associated LOD AbstractMesh.
  12421. */
  12422. getLOD(camera: Camera): AbstractMesh;
  12423. /** @hidden */
  12424. _syncSubMeshes(): InstancedMesh;
  12425. /** @hidden */
  12426. _generatePointsArray(): boolean;
  12427. /**
  12428. * Creates a new InstancedMesh from the current mesh.
  12429. * - name (string) : the cloned mesh name
  12430. * - newParent (optional Node) : the optional Node to parent the clone to.
  12431. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  12432. *
  12433. * Returns the clone.
  12434. */
  12435. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  12436. /**
  12437. * Disposes the InstancedMesh.
  12438. * Returns nothing.
  12439. */
  12440. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  12441. }
  12442. }
  12443. declare module "babylonjs/Materials/shaderMaterial" {
  12444. import { Scene } from "babylonjs/scene";
  12445. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  12446. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12447. import { Mesh } from "babylonjs/Meshes/mesh";
  12448. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  12449. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  12450. import { Texture } from "babylonjs/Materials/Textures/texture";
  12451. import { Material } from "babylonjs/Materials/material";
  12452. /**
  12453. * Defines the options associated with the creation of a shader material.
  12454. */
  12455. export interface IShaderMaterialOptions {
  12456. /**
  12457. * Does the material work in alpha blend mode
  12458. */
  12459. needAlphaBlending: boolean;
  12460. /**
  12461. * Does the material work in alpha test mode
  12462. */
  12463. needAlphaTesting: boolean;
  12464. /**
  12465. * The list of attribute names used in the shader
  12466. */
  12467. attributes: string[];
  12468. /**
  12469. * The list of unifrom names used in the shader
  12470. */
  12471. uniforms: string[];
  12472. /**
  12473. * The list of UBO names used in the shader
  12474. */
  12475. uniformBuffers: string[];
  12476. /**
  12477. * The list of sampler names used in the shader
  12478. */
  12479. samplers: string[];
  12480. /**
  12481. * The list of defines used in the shader
  12482. */
  12483. defines: string[];
  12484. }
  12485. /**
  12486. * 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.
  12487. *
  12488. * This returned material effects how the mesh will look based on the code in the shaders.
  12489. *
  12490. * @see http://doc.babylonjs.com/how_to/shader_material
  12491. */
  12492. export class ShaderMaterial extends Material {
  12493. private _shaderPath;
  12494. private _options;
  12495. private _textures;
  12496. private _textureArrays;
  12497. private _floats;
  12498. private _ints;
  12499. private _floatsArrays;
  12500. private _colors3;
  12501. private _colors3Arrays;
  12502. private _colors4;
  12503. private _colors4Arrays;
  12504. private _vectors2;
  12505. private _vectors3;
  12506. private _vectors4;
  12507. private _matrices;
  12508. private _matrices3x3;
  12509. private _matrices2x2;
  12510. private _vectors2Arrays;
  12511. private _vectors3Arrays;
  12512. private _vectors4Arrays;
  12513. private _cachedWorldViewMatrix;
  12514. private _cachedWorldViewProjectionMatrix;
  12515. private _renderId;
  12516. /**
  12517. * Instantiate a new shader material.
  12518. * 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.
  12519. * This returned material effects how the mesh will look based on the code in the shaders.
  12520. * @see http://doc.babylonjs.com/how_to/shader_material
  12521. * @param name Define the name of the material in the scene
  12522. * @param scene Define the scene the material belongs to
  12523. * @param shaderPath Defines the route to the shader code in one of three ways:
  12524. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  12525. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  12526. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  12527. * @param options Define the options used to create the shader
  12528. */
  12529. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  12530. /**
  12531. * Gets the options used to compile the shader.
  12532. * They can be modified to trigger a new compilation
  12533. */
  12534. readonly options: IShaderMaterialOptions;
  12535. /**
  12536. * Gets the current class name of the material e.g. "ShaderMaterial"
  12537. * Mainly use in serialization.
  12538. * @returns the class name
  12539. */
  12540. getClassName(): string;
  12541. /**
  12542. * Specifies if the material will require alpha blending
  12543. * @returns a boolean specifying if alpha blending is needed
  12544. */
  12545. needAlphaBlending(): boolean;
  12546. /**
  12547. * Specifies if this material should be rendered in alpha test mode
  12548. * @returns a boolean specifying if an alpha test is needed.
  12549. */
  12550. needAlphaTesting(): boolean;
  12551. private _checkUniform;
  12552. /**
  12553. * Set a texture in the shader.
  12554. * @param name Define the name of the uniform samplers as defined in the shader
  12555. * @param texture Define the texture to bind to this sampler
  12556. * @return the material itself allowing "fluent" like uniform updates
  12557. */
  12558. setTexture(name: string, texture: Texture): ShaderMaterial;
  12559. /**
  12560. * Set a texture array in the shader.
  12561. * @param name Define the name of the uniform sampler array as defined in the shader
  12562. * @param textures Define the list of textures to bind to this sampler
  12563. * @return the material itself allowing "fluent" like uniform updates
  12564. */
  12565. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  12566. /**
  12567. * Set a float in the shader.
  12568. * @param name Define the name of the uniform as defined in the shader
  12569. * @param value Define the value to give to the uniform
  12570. * @return the material itself allowing "fluent" like uniform updates
  12571. */
  12572. setFloat(name: string, value: number): ShaderMaterial;
  12573. /**
  12574. * Set a int in the shader.
  12575. * @param name Define the name of the uniform as defined in the shader
  12576. * @param value Define the value to give to the uniform
  12577. * @return the material itself allowing "fluent" like uniform updates
  12578. */
  12579. setInt(name: string, value: number): ShaderMaterial;
  12580. /**
  12581. * Set an array of floats in the shader.
  12582. * @param name Define the name of the uniform as defined in the shader
  12583. * @param value Define the value to give to the uniform
  12584. * @return the material itself allowing "fluent" like uniform updates
  12585. */
  12586. setFloats(name: string, value: number[]): ShaderMaterial;
  12587. /**
  12588. * Set a vec3 in the shader from a Color3.
  12589. * @param name Define the name of the uniform as defined in the shader
  12590. * @param value Define the value to give to the uniform
  12591. * @return the material itself allowing "fluent" like uniform updates
  12592. */
  12593. setColor3(name: string, value: Color3): ShaderMaterial;
  12594. /**
  12595. * Set a vec3 array in the shader from a Color3 array.
  12596. * @param name Define the name of the uniform as defined in the shader
  12597. * @param value Define the value to give to the uniform
  12598. * @return the material itself allowing "fluent" like uniform updates
  12599. */
  12600. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  12601. /**
  12602. * Set a vec4 in the shader from a Color4.
  12603. * @param name Define the name of the uniform as defined in the shader
  12604. * @param value Define the value to give to the uniform
  12605. * @return the material itself allowing "fluent" like uniform updates
  12606. */
  12607. setColor4(name: string, value: Color4): ShaderMaterial;
  12608. /**
  12609. * Set a vec4 array in the shader from a Color4 array.
  12610. * @param name Define the name of the uniform as defined in the shader
  12611. * @param value Define the value to give to the uniform
  12612. * @return the material itself allowing "fluent" like uniform updates
  12613. */
  12614. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  12615. /**
  12616. * Set a vec2 in the shader from a Vector2.
  12617. * @param name Define the name of the uniform as defined in the shader
  12618. * @param value Define the value to give to the uniform
  12619. * @return the material itself allowing "fluent" like uniform updates
  12620. */
  12621. setVector2(name: string, value: Vector2): ShaderMaterial;
  12622. /**
  12623. * Set a vec3 in the shader from a Vector3.
  12624. * @param name Define the name of the uniform as defined in the shader
  12625. * @param value Define the value to give to the uniform
  12626. * @return the material itself allowing "fluent" like uniform updates
  12627. */
  12628. setVector3(name: string, value: Vector3): ShaderMaterial;
  12629. /**
  12630. * Set a vec4 in the shader from a Vector4.
  12631. * @param name Define the name of the uniform as defined in the shader
  12632. * @param value Define the value to give to the uniform
  12633. * @return the material itself allowing "fluent" like uniform updates
  12634. */
  12635. setVector4(name: string, value: Vector4): ShaderMaterial;
  12636. /**
  12637. * Set a mat4 in the shader from a Matrix.
  12638. * @param name Define the name of the uniform as defined in the shader
  12639. * @param value Define the value to give to the uniform
  12640. * @return the material itself allowing "fluent" like uniform updates
  12641. */
  12642. setMatrix(name: string, value: Matrix): ShaderMaterial;
  12643. /**
  12644. * Set a mat3 in the shader from a Float32Array.
  12645. * @param name Define the name of the uniform as defined in the shader
  12646. * @param value Define the value to give to the uniform
  12647. * @return the material itself allowing "fluent" like uniform updates
  12648. */
  12649. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  12650. /**
  12651. * Set a mat2 in the shader from a Float32Array.
  12652. * @param name Define the name of the uniform as defined in the shader
  12653. * @param value Define the value to give to the uniform
  12654. * @return the material itself allowing "fluent" like uniform updates
  12655. */
  12656. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  12657. /**
  12658. * Set a vec2 array in the shader from a number array.
  12659. * @param name Define the name of the uniform as defined in the shader
  12660. * @param value Define the value to give to the uniform
  12661. * @return the material itself allowing "fluent" like uniform updates
  12662. */
  12663. setArray2(name: string, value: number[]): ShaderMaterial;
  12664. /**
  12665. * Set a vec3 array in the shader from a number array.
  12666. * @param name Define the name of the uniform as defined in the shader
  12667. * @param value Define the value to give to the uniform
  12668. * @return the material itself allowing "fluent" like uniform updates
  12669. */
  12670. setArray3(name: string, value: number[]): ShaderMaterial;
  12671. /**
  12672. * Set a vec4 array in the shader from a number array.
  12673. * @param name Define the name of the uniform as defined in the shader
  12674. * @param value Define the value to give to the uniform
  12675. * @return the material itself allowing "fluent" like uniform updates
  12676. */
  12677. setArray4(name: string, value: number[]): ShaderMaterial;
  12678. private _checkCache;
  12679. /**
  12680. * Specifies that the submesh is ready to be used
  12681. * @param mesh defines the mesh to check
  12682. * @param subMesh defines which submesh to check
  12683. * @param useInstances specifies that instances should be used
  12684. * @returns a boolean indicating that the submesh is ready or not
  12685. */
  12686. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  12687. /**
  12688. * Checks if the material is ready to render the requested mesh
  12689. * @param mesh Define the mesh to render
  12690. * @param useInstances Define whether or not the material is used with instances
  12691. * @returns true if ready, otherwise false
  12692. */
  12693. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  12694. /**
  12695. * Binds the world matrix to the material
  12696. * @param world defines the world transformation matrix
  12697. */
  12698. bindOnlyWorldMatrix(world: Matrix): void;
  12699. /**
  12700. * Binds the material to the mesh
  12701. * @param world defines the world transformation matrix
  12702. * @param mesh defines the mesh to bind the material to
  12703. */
  12704. bind(world: Matrix, mesh?: Mesh): void;
  12705. /**
  12706. * Gets the active textures from the material
  12707. * @returns an array of textures
  12708. */
  12709. getActiveTextures(): BaseTexture[];
  12710. /**
  12711. * Specifies if the material uses a texture
  12712. * @param texture defines the texture to check against the material
  12713. * @returns a boolean specifying if the material uses the texture
  12714. */
  12715. hasTexture(texture: BaseTexture): boolean;
  12716. /**
  12717. * Makes a duplicate of the material, and gives it a new name
  12718. * @param name defines the new name for the duplicated material
  12719. * @returns the cloned material
  12720. */
  12721. clone(name: string): ShaderMaterial;
  12722. /**
  12723. * Disposes the material
  12724. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  12725. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  12726. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  12727. */
  12728. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  12729. /**
  12730. * Serializes this material in a JSON representation
  12731. * @returns the serialized material object
  12732. */
  12733. serialize(): any;
  12734. /**
  12735. * Creates a shader material from parsed shader material data
  12736. * @param source defines the JSON represnetation of the material
  12737. * @param scene defines the hosting scene
  12738. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  12739. * @returns a new material
  12740. */
  12741. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  12742. }
  12743. }
  12744. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  12745. /** @hidden */
  12746. export var clipPlaneFragmentDeclaration: {
  12747. name: string;
  12748. shader: string;
  12749. };
  12750. }
  12751. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  12752. /** @hidden */
  12753. export var clipPlaneFragment: {
  12754. name: string;
  12755. shader: string;
  12756. };
  12757. }
  12758. declare module "babylonjs/Shaders/color.fragment" {
  12759. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  12760. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  12761. /** @hidden */
  12762. export var colorPixelShader: {
  12763. name: string;
  12764. shader: string;
  12765. };
  12766. }
  12767. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  12768. /** @hidden */
  12769. export var clipPlaneVertexDeclaration: {
  12770. name: string;
  12771. shader: string;
  12772. };
  12773. }
  12774. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  12775. /** @hidden */
  12776. export var clipPlaneVertex: {
  12777. name: string;
  12778. shader: string;
  12779. };
  12780. }
  12781. declare module "babylonjs/Shaders/color.vertex" {
  12782. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  12783. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  12784. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  12785. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  12786. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  12787. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  12788. /** @hidden */
  12789. export var colorVertexShader: {
  12790. name: string;
  12791. shader: string;
  12792. };
  12793. }
  12794. declare module "babylonjs/Meshes/linesMesh" {
  12795. import { Nullable } from "babylonjs/types";
  12796. import { Scene } from "babylonjs/scene";
  12797. import { Color3 } from "babylonjs/Maths/math";
  12798. import { Node } from "babylonjs/node";
  12799. import { SubMesh } from "babylonjs/Meshes/subMesh";
  12800. import { Mesh } from "babylonjs/Meshes/mesh";
  12801. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  12802. import { Effect } from "babylonjs/Materials/effect";
  12803. import { Material } from "babylonjs/Materials/material";
  12804. import "babylonjs/Shaders/color.fragment";
  12805. import "babylonjs/Shaders/color.vertex";
  12806. /**
  12807. * Line mesh
  12808. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  12809. */
  12810. export class LinesMesh extends Mesh {
  12811. /**
  12812. * If vertex color should be applied to the mesh
  12813. */
  12814. readonly useVertexColor?: boolean | undefined;
  12815. /**
  12816. * If vertex alpha should be applied to the mesh
  12817. */
  12818. readonly useVertexAlpha?: boolean | undefined;
  12819. /**
  12820. * Color of the line (Default: White)
  12821. */
  12822. color: Color3;
  12823. /**
  12824. * Alpha of the line (Default: 1)
  12825. */
  12826. alpha: number;
  12827. /**
  12828. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  12829. * This margin is expressed in world space coordinates, so its value may vary.
  12830. * Default value is 0.1
  12831. */
  12832. intersectionThreshold: number;
  12833. private _colorShader;
  12834. private color4;
  12835. /**
  12836. * Creates a new LinesMesh
  12837. * @param name defines the name
  12838. * @param scene defines the hosting scene
  12839. * @param parent defines the parent mesh if any
  12840. * @param source defines the optional source LinesMesh used to clone data from
  12841. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  12842. * When false, achieved by calling a clone(), also passing False.
  12843. * This will make creation of children, recursive.
  12844. * @param useVertexColor defines if this LinesMesh supports vertex color
  12845. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  12846. */
  12847. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  12848. /**
  12849. * If vertex color should be applied to the mesh
  12850. */
  12851. useVertexColor?: boolean | undefined,
  12852. /**
  12853. * If vertex alpha should be applied to the mesh
  12854. */
  12855. useVertexAlpha?: boolean | undefined);
  12856. private _addClipPlaneDefine;
  12857. private _removeClipPlaneDefine;
  12858. isReady(): boolean;
  12859. /**
  12860. * Returns the string "LineMesh"
  12861. */
  12862. getClassName(): string;
  12863. /**
  12864. * @hidden
  12865. */
  12866. /**
  12867. * @hidden
  12868. */
  12869. material: Material;
  12870. /**
  12871. * @hidden
  12872. */
  12873. readonly checkCollisions: boolean;
  12874. /** @hidden */
  12875. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  12876. /** @hidden */
  12877. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  12878. /**
  12879. * Disposes of the line mesh
  12880. * @param doNotRecurse If children should be disposed
  12881. */
  12882. dispose(doNotRecurse?: boolean): void;
  12883. /**
  12884. * Returns a new LineMesh object cloned from the current one.
  12885. */
  12886. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  12887. /**
  12888. * Creates a new InstancedLinesMesh object from the mesh model.
  12889. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  12890. * @param name defines the name of the new instance
  12891. * @returns a new InstancedLinesMesh
  12892. */
  12893. createInstance(name: string): InstancedLinesMesh;
  12894. }
  12895. /**
  12896. * Creates an instance based on a source LinesMesh
  12897. */
  12898. export class InstancedLinesMesh extends InstancedMesh {
  12899. /**
  12900. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  12901. * This margin is expressed in world space coordinates, so its value may vary.
  12902. * Initilized with the intersectionThreshold value of the source LinesMesh
  12903. */
  12904. intersectionThreshold: number;
  12905. constructor(name: string, source: LinesMesh);
  12906. /**
  12907. * Returns the string "InstancedLinesMesh".
  12908. */
  12909. getClassName(): string;
  12910. }
  12911. }
  12912. declare module "babylonjs/Meshes/groundMesh" {
  12913. import { Scene } from "babylonjs/scene";
  12914. import { Vector3 } from "babylonjs/Maths/math";
  12915. import { Mesh } from "babylonjs/Meshes/mesh";
  12916. /**
  12917. * Mesh representing the gorund
  12918. */
  12919. export class GroundMesh extends Mesh {
  12920. /** If octree should be generated */
  12921. generateOctree: boolean;
  12922. private _heightQuads;
  12923. /** @hidden */
  12924. _subdivisionsX: number;
  12925. /** @hidden */
  12926. _subdivisionsY: number;
  12927. /** @hidden */
  12928. _width: number;
  12929. /** @hidden */
  12930. _height: number;
  12931. /** @hidden */
  12932. _minX: number;
  12933. /** @hidden */
  12934. _maxX: number;
  12935. /** @hidden */
  12936. _minZ: number;
  12937. /** @hidden */
  12938. _maxZ: number;
  12939. constructor(name: string, scene: Scene);
  12940. /**
  12941. * "GroundMesh"
  12942. * @returns "GroundMesh"
  12943. */
  12944. getClassName(): string;
  12945. /**
  12946. * The minimum of x and y subdivisions
  12947. */
  12948. readonly subdivisions: number;
  12949. /**
  12950. * X subdivisions
  12951. */
  12952. readonly subdivisionsX: number;
  12953. /**
  12954. * Y subdivisions
  12955. */
  12956. readonly subdivisionsY: number;
  12957. /**
  12958. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  12959. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  12960. * @param chunksCount the number of subdivisions for x and y
  12961. * @param octreeBlocksSize (Default: 32)
  12962. */
  12963. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  12964. /**
  12965. * Returns a height (y) value in the Worl system :
  12966. * the ground altitude at the coordinates (x, z) expressed in the World system.
  12967. * @param x x coordinate
  12968. * @param z z coordinate
  12969. * @returns the ground y position if (x, z) are outside the ground surface.
  12970. */
  12971. getHeightAtCoordinates(x: number, z: number): number;
  12972. /**
  12973. * Returns a normalized vector (Vector3) orthogonal to the ground
  12974. * at the ground coordinates (x, z) expressed in the World system.
  12975. * @param x x coordinate
  12976. * @param z z coordinate
  12977. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  12978. */
  12979. getNormalAtCoordinates(x: number, z: number): Vector3;
  12980. /**
  12981. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  12982. * at the ground coordinates (x, z) expressed in the World system.
  12983. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  12984. * @param x x coordinate
  12985. * @param z z coordinate
  12986. * @param ref vector to store the result
  12987. * @returns the GroundMesh.
  12988. */
  12989. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  12990. /**
  12991. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  12992. * if the ground has been updated.
  12993. * This can be used in the render loop.
  12994. * @returns the GroundMesh.
  12995. */
  12996. updateCoordinateHeights(): GroundMesh;
  12997. private _getFacetAt;
  12998. private _initHeightQuads;
  12999. private _computeHeightQuads;
  13000. /**
  13001. * Serializes this ground mesh
  13002. * @param serializationObject object to write serialization to
  13003. */
  13004. serialize(serializationObject: any): void;
  13005. /**
  13006. * Parses a serialized ground mesh
  13007. * @param parsedMesh the serialized mesh
  13008. * @param scene the scene to create the ground mesh in
  13009. * @returns the created ground mesh
  13010. */
  13011. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  13012. }
  13013. }
  13014. declare module "babylonjs/Physics/physicsJoint" {
  13015. import { Vector3 } from "babylonjs/Maths/math";
  13016. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  13017. /**
  13018. * Interface for Physics-Joint data
  13019. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13020. */
  13021. export interface PhysicsJointData {
  13022. /**
  13023. * The main pivot of the joint
  13024. */
  13025. mainPivot?: Vector3;
  13026. /**
  13027. * The connected pivot of the joint
  13028. */
  13029. connectedPivot?: Vector3;
  13030. /**
  13031. * The main axis of the joint
  13032. */
  13033. mainAxis?: Vector3;
  13034. /**
  13035. * The connected axis of the joint
  13036. */
  13037. connectedAxis?: Vector3;
  13038. /**
  13039. * The collision of the joint
  13040. */
  13041. collision?: boolean;
  13042. /**
  13043. * Native Oimo/Cannon/Energy data
  13044. */
  13045. nativeParams?: any;
  13046. }
  13047. /**
  13048. * This is a holder class for the physics joint created by the physics plugin
  13049. * It holds a set of functions to control the underlying joint
  13050. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13051. */
  13052. export class PhysicsJoint {
  13053. /**
  13054. * The type of the physics joint
  13055. */
  13056. type: number;
  13057. /**
  13058. * The data for the physics joint
  13059. */
  13060. jointData: PhysicsJointData;
  13061. private _physicsJoint;
  13062. protected _physicsPlugin: IPhysicsEnginePlugin;
  13063. /**
  13064. * Initializes the physics joint
  13065. * @param type The type of the physics joint
  13066. * @param jointData The data for the physics joint
  13067. */
  13068. constructor(
  13069. /**
  13070. * The type of the physics joint
  13071. */
  13072. type: number,
  13073. /**
  13074. * The data for the physics joint
  13075. */
  13076. jointData: PhysicsJointData);
  13077. /**
  13078. * Gets the physics joint
  13079. */
  13080. /**
  13081. * Sets the physics joint
  13082. */
  13083. physicsJoint: any;
  13084. /**
  13085. * Sets the physics plugin
  13086. */
  13087. physicsPlugin: IPhysicsEnginePlugin;
  13088. /**
  13089. * Execute a function that is physics-plugin specific.
  13090. * @param {Function} func the function that will be executed.
  13091. * It accepts two parameters: the physics world and the physics joint
  13092. */
  13093. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  13094. /**
  13095. * Distance-Joint type
  13096. */
  13097. static DistanceJoint: number;
  13098. /**
  13099. * Hinge-Joint type
  13100. */
  13101. static HingeJoint: number;
  13102. /**
  13103. * Ball-and-Socket joint type
  13104. */
  13105. static BallAndSocketJoint: number;
  13106. /**
  13107. * Wheel-Joint type
  13108. */
  13109. static WheelJoint: number;
  13110. /**
  13111. * Slider-Joint type
  13112. */
  13113. static SliderJoint: number;
  13114. /**
  13115. * Prismatic-Joint type
  13116. */
  13117. static PrismaticJoint: number;
  13118. /**
  13119. * Universal-Joint type
  13120. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  13121. */
  13122. static UniversalJoint: number;
  13123. /**
  13124. * Hinge-Joint 2 type
  13125. */
  13126. static Hinge2Joint: number;
  13127. /**
  13128. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  13129. */
  13130. static PointToPointJoint: number;
  13131. /**
  13132. * Spring-Joint type
  13133. */
  13134. static SpringJoint: number;
  13135. /**
  13136. * Lock-Joint type
  13137. */
  13138. static LockJoint: number;
  13139. }
  13140. /**
  13141. * A class representing a physics distance joint
  13142. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13143. */
  13144. export class DistanceJoint extends PhysicsJoint {
  13145. /**
  13146. *
  13147. * @param jointData The data for the Distance-Joint
  13148. */
  13149. constructor(jointData: DistanceJointData);
  13150. /**
  13151. * Update the predefined distance.
  13152. * @param maxDistance The maximum preferred distance
  13153. * @param minDistance The minimum preferred distance
  13154. */
  13155. updateDistance(maxDistance: number, minDistance?: number): void;
  13156. }
  13157. /**
  13158. * Represents a Motor-Enabled Joint
  13159. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13160. */
  13161. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  13162. /**
  13163. * Initializes the Motor-Enabled Joint
  13164. * @param type The type of the joint
  13165. * @param jointData The physica joint data for the joint
  13166. */
  13167. constructor(type: number, jointData: PhysicsJointData);
  13168. /**
  13169. * Set the motor values.
  13170. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13171. * @param force the force to apply
  13172. * @param maxForce max force for this motor.
  13173. */
  13174. setMotor(force?: number, maxForce?: number): void;
  13175. /**
  13176. * Set the motor's limits.
  13177. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13178. * @param upperLimit The upper limit of the motor
  13179. * @param lowerLimit The lower limit of the motor
  13180. */
  13181. setLimit(upperLimit: number, lowerLimit?: number): void;
  13182. }
  13183. /**
  13184. * This class represents a single physics Hinge-Joint
  13185. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13186. */
  13187. export class HingeJoint extends MotorEnabledJoint {
  13188. /**
  13189. * Initializes the Hinge-Joint
  13190. * @param jointData The joint data for the Hinge-Joint
  13191. */
  13192. constructor(jointData: PhysicsJointData);
  13193. /**
  13194. * Set the motor values.
  13195. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13196. * @param {number} force the force to apply
  13197. * @param {number} maxForce max force for this motor.
  13198. */
  13199. setMotor(force?: number, maxForce?: number): void;
  13200. /**
  13201. * Set the motor's limits.
  13202. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13203. * @param upperLimit The upper limit of the motor
  13204. * @param lowerLimit The lower limit of the motor
  13205. */
  13206. setLimit(upperLimit: number, lowerLimit?: number): void;
  13207. }
  13208. /**
  13209. * This class represents a dual hinge physics joint (same as wheel joint)
  13210. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13211. */
  13212. export class Hinge2Joint extends MotorEnabledJoint {
  13213. /**
  13214. * Initializes the Hinge2-Joint
  13215. * @param jointData The joint data for the Hinge2-Joint
  13216. */
  13217. constructor(jointData: PhysicsJointData);
  13218. /**
  13219. * Set the motor values.
  13220. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13221. * @param {number} targetSpeed the speed the motor is to reach
  13222. * @param {number} maxForce max force for this motor.
  13223. * @param {motorIndex} the motor's index, 0 or 1.
  13224. */
  13225. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  13226. /**
  13227. * Set the motor limits.
  13228. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13229. * @param {number} upperLimit the upper limit
  13230. * @param {number} lowerLimit lower limit
  13231. * @param {motorIndex} the motor's index, 0 or 1.
  13232. */
  13233. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  13234. }
  13235. /**
  13236. * Interface for a motor enabled joint
  13237. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13238. */
  13239. export interface IMotorEnabledJoint {
  13240. /**
  13241. * Physics joint
  13242. */
  13243. physicsJoint: any;
  13244. /**
  13245. * Sets the motor of the motor-enabled joint
  13246. * @param force The force of the motor
  13247. * @param maxForce The maximum force of the motor
  13248. * @param motorIndex The index of the motor
  13249. */
  13250. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  13251. /**
  13252. * Sets the limit of the motor
  13253. * @param upperLimit The upper limit of the motor
  13254. * @param lowerLimit The lower limit of the motor
  13255. * @param motorIndex The index of the motor
  13256. */
  13257. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  13258. }
  13259. /**
  13260. * Joint data for a Distance-Joint
  13261. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13262. */
  13263. export interface DistanceJointData extends PhysicsJointData {
  13264. /**
  13265. * Max distance the 2 joint objects can be apart
  13266. */
  13267. maxDistance: number;
  13268. }
  13269. /**
  13270. * Joint data from a spring joint
  13271. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13272. */
  13273. export interface SpringJointData extends PhysicsJointData {
  13274. /**
  13275. * Length of the spring
  13276. */
  13277. length: number;
  13278. /**
  13279. * Stiffness of the spring
  13280. */
  13281. stiffness: number;
  13282. /**
  13283. * Damping of the spring
  13284. */
  13285. damping: number;
  13286. /** this callback will be called when applying the force to the impostors. */
  13287. forceApplicationCallback: () => void;
  13288. }
  13289. }
  13290. declare module "babylonjs/Physics/physicsRaycastResult" {
  13291. import { Vector3 } from "babylonjs/Maths/math";
  13292. /**
  13293. * Holds the data for the raycast result
  13294. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13295. */
  13296. export class PhysicsRaycastResult {
  13297. private _hasHit;
  13298. private _hitDistance;
  13299. private _hitNormalWorld;
  13300. private _hitPointWorld;
  13301. private _rayFromWorld;
  13302. private _rayToWorld;
  13303. /**
  13304. * Gets if there was a hit
  13305. */
  13306. readonly hasHit: boolean;
  13307. /**
  13308. * Gets the distance from the hit
  13309. */
  13310. readonly hitDistance: number;
  13311. /**
  13312. * Gets the hit normal/direction in the world
  13313. */
  13314. readonly hitNormalWorld: Vector3;
  13315. /**
  13316. * Gets the hit point in the world
  13317. */
  13318. readonly hitPointWorld: Vector3;
  13319. /**
  13320. * Gets the ray "start point" of the ray in the world
  13321. */
  13322. readonly rayFromWorld: Vector3;
  13323. /**
  13324. * Gets the ray "end point" of the ray in the world
  13325. */
  13326. readonly rayToWorld: Vector3;
  13327. /**
  13328. * Sets the hit data (normal & point in world space)
  13329. * @param hitNormalWorld defines the normal in world space
  13330. * @param hitPointWorld defines the point in world space
  13331. */
  13332. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  13333. /**
  13334. * Sets the distance from the start point to the hit point
  13335. * @param distance
  13336. */
  13337. setHitDistance(distance: number): void;
  13338. /**
  13339. * Calculates the distance manually
  13340. */
  13341. calculateHitDistance(): void;
  13342. /**
  13343. * Resets all the values to default
  13344. * @param from The from point on world space
  13345. * @param to The to point on world space
  13346. */
  13347. reset(from?: Vector3, to?: Vector3): void;
  13348. }
  13349. /**
  13350. * Interface for the size containing width and height
  13351. */
  13352. interface IXYZ {
  13353. /**
  13354. * X
  13355. */
  13356. x: number;
  13357. /**
  13358. * Y
  13359. */
  13360. y: number;
  13361. /**
  13362. * Z
  13363. */
  13364. z: number;
  13365. }
  13366. }
  13367. declare module "babylonjs/Physics/IPhysicsEngine" {
  13368. import { Nullable } from "babylonjs/types";
  13369. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  13370. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13371. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  13372. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  13373. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  13374. /**
  13375. * Interface used to describe a physics joint
  13376. */
  13377. export interface PhysicsImpostorJoint {
  13378. /** Defines the main impostor to which the joint is linked */
  13379. mainImpostor: PhysicsImpostor;
  13380. /** Defines the impostor that is connected to the main impostor using this joint */
  13381. connectedImpostor: PhysicsImpostor;
  13382. /** Defines the joint itself */
  13383. joint: PhysicsJoint;
  13384. }
  13385. /** @hidden */
  13386. export interface IPhysicsEnginePlugin {
  13387. world: any;
  13388. name: string;
  13389. setGravity(gravity: Vector3): void;
  13390. setTimeStep(timeStep: number): void;
  13391. getTimeStep(): number;
  13392. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  13393. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  13394. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  13395. generatePhysicsBody(impostor: PhysicsImpostor): void;
  13396. removePhysicsBody(impostor: PhysicsImpostor): void;
  13397. generateJoint(joint: PhysicsImpostorJoint): void;
  13398. removeJoint(joint: PhysicsImpostorJoint): void;
  13399. isSupported(): boolean;
  13400. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  13401. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  13402. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  13403. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  13404. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  13405. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  13406. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  13407. getBodyMass(impostor: PhysicsImpostor): number;
  13408. getBodyFriction(impostor: PhysicsImpostor): number;
  13409. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  13410. getBodyRestitution(impostor: PhysicsImpostor): number;
  13411. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  13412. getBodyPressure?(impostor: PhysicsImpostor): number;
  13413. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  13414. getBodyStiffness?(impostor: PhysicsImpostor): number;
  13415. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  13416. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  13417. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  13418. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  13419. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  13420. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  13421. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  13422. sleepBody(impostor: PhysicsImpostor): void;
  13423. wakeUpBody(impostor: PhysicsImpostor): void;
  13424. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  13425. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  13426. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  13427. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  13428. getRadius(impostor: PhysicsImpostor): number;
  13429. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  13430. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  13431. dispose(): void;
  13432. }
  13433. /**
  13434. * Interface used to define a physics engine
  13435. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  13436. */
  13437. export interface IPhysicsEngine {
  13438. /**
  13439. * Gets the gravity vector used by the simulation
  13440. */
  13441. gravity: Vector3;
  13442. /**
  13443. * Sets the gravity vector used by the simulation
  13444. * @param gravity defines the gravity vector to use
  13445. */
  13446. setGravity(gravity: Vector3): void;
  13447. /**
  13448. * Set the time step of the physics engine.
  13449. * Default is 1/60.
  13450. * To slow it down, enter 1/600 for example.
  13451. * To speed it up, 1/30
  13452. * @param newTimeStep the new timestep to apply to this world.
  13453. */
  13454. setTimeStep(newTimeStep: number): void;
  13455. /**
  13456. * Get the time step of the physics engine.
  13457. * @returns the current time step
  13458. */
  13459. getTimeStep(): number;
  13460. /**
  13461. * Release all resources
  13462. */
  13463. dispose(): void;
  13464. /**
  13465. * Gets the name of the current physics plugin
  13466. * @returns the name of the plugin
  13467. */
  13468. getPhysicsPluginName(): string;
  13469. /**
  13470. * Adding a new impostor for the impostor tracking.
  13471. * This will be done by the impostor itself.
  13472. * @param impostor the impostor to add
  13473. */
  13474. addImpostor(impostor: PhysicsImpostor): void;
  13475. /**
  13476. * Remove an impostor from the engine.
  13477. * This impostor and its mesh will not longer be updated by the physics engine.
  13478. * @param impostor the impostor to remove
  13479. */
  13480. removeImpostor(impostor: PhysicsImpostor): void;
  13481. /**
  13482. * Add a joint to the physics engine
  13483. * @param mainImpostor defines the main impostor to which the joint is added.
  13484. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  13485. * @param joint defines the joint that will connect both impostors.
  13486. */
  13487. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  13488. /**
  13489. * Removes a joint from the simulation
  13490. * @param mainImpostor defines the impostor used with the joint
  13491. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  13492. * @param joint defines the joint to remove
  13493. */
  13494. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  13495. /**
  13496. * Gets the current plugin used to run the simulation
  13497. * @returns current plugin
  13498. */
  13499. getPhysicsPlugin(): IPhysicsEnginePlugin;
  13500. /**
  13501. * Gets the list of physic impostors
  13502. * @returns an array of PhysicsImpostor
  13503. */
  13504. getImpostors(): Array<PhysicsImpostor>;
  13505. /**
  13506. * Gets the impostor for a physics enabled object
  13507. * @param object defines the object impersonated by the impostor
  13508. * @returns the PhysicsImpostor or null if not found
  13509. */
  13510. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  13511. /**
  13512. * Gets the impostor for a physics body object
  13513. * @param body defines physics body used by the impostor
  13514. * @returns the PhysicsImpostor or null if not found
  13515. */
  13516. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  13517. /**
  13518. * Does a raycast in the physics world
  13519. * @param from when should the ray start?
  13520. * @param to when should the ray end?
  13521. * @returns PhysicsRaycastResult
  13522. */
  13523. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  13524. /**
  13525. * Called by the scene. No need to call it.
  13526. * @param delta defines the timespam between frames
  13527. */
  13528. _step(delta: number): void;
  13529. }
  13530. }
  13531. declare module "babylonjs/Physics/physicsImpostor" {
  13532. import { Nullable, IndicesArray } from "babylonjs/types";
  13533. import { Vector3, Matrix, Quaternion, Space } from "babylonjs/Maths/math";
  13534. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13535. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13536. import { Scene } from "babylonjs/scene";
  13537. import { Bone } from "babylonjs/Bones/bone";
  13538. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  13539. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  13540. /**
  13541. * The interface for the physics imposter parameters
  13542. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13543. */
  13544. export interface PhysicsImpostorParameters {
  13545. /**
  13546. * The mass of the physics imposter
  13547. */
  13548. mass: number;
  13549. /**
  13550. * The friction of the physics imposter
  13551. */
  13552. friction?: number;
  13553. /**
  13554. * The coefficient of restitution of the physics imposter
  13555. */
  13556. restitution?: number;
  13557. /**
  13558. * The native options of the physics imposter
  13559. */
  13560. nativeOptions?: any;
  13561. /**
  13562. * Specifies if the parent should be ignored
  13563. */
  13564. ignoreParent?: boolean;
  13565. /**
  13566. * Specifies if bi-directional transformations should be disabled
  13567. */
  13568. disableBidirectionalTransformation?: boolean;
  13569. /**
  13570. * The pressure inside the physics imposter, soft object only
  13571. */
  13572. pressure?: number;
  13573. /**
  13574. * The stiffness the physics imposter, soft object only
  13575. */
  13576. stiffness?: number;
  13577. /**
  13578. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  13579. */
  13580. velocityIterations?: number;
  13581. /**
  13582. * The number of iterations used in maintaining consistent vertex positions, soft object only
  13583. */
  13584. positionIterations?: number;
  13585. /**
  13586. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  13587. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  13588. * Add to fix multiple points
  13589. */
  13590. fixedPoints?: number;
  13591. /**
  13592. * The collision margin around a soft object
  13593. */
  13594. margin?: number;
  13595. /**
  13596. * The collision margin around a soft object
  13597. */
  13598. damping?: number;
  13599. /**
  13600. * The path for a rope based on an extrusion
  13601. */
  13602. path?: any;
  13603. /**
  13604. * The shape of an extrusion used for a rope based on an extrusion
  13605. */
  13606. shape?: any;
  13607. }
  13608. /**
  13609. * Interface for a physics-enabled object
  13610. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13611. */
  13612. export interface IPhysicsEnabledObject {
  13613. /**
  13614. * The position of the physics-enabled object
  13615. */
  13616. position: Vector3;
  13617. /**
  13618. * The rotation of the physics-enabled object
  13619. */
  13620. rotationQuaternion: Nullable<Quaternion>;
  13621. /**
  13622. * The scale of the physics-enabled object
  13623. */
  13624. scaling: Vector3;
  13625. /**
  13626. * The rotation of the physics-enabled object
  13627. */
  13628. rotation?: Vector3;
  13629. /**
  13630. * The parent of the physics-enabled object
  13631. */
  13632. parent?: any;
  13633. /**
  13634. * The bounding info of the physics-enabled object
  13635. * @returns The bounding info of the physics-enabled object
  13636. */
  13637. getBoundingInfo(): BoundingInfo;
  13638. /**
  13639. * Computes the world matrix
  13640. * @param force Specifies if the world matrix should be computed by force
  13641. * @returns A world matrix
  13642. */
  13643. computeWorldMatrix(force: boolean): Matrix;
  13644. /**
  13645. * Gets the world matrix
  13646. * @returns A world matrix
  13647. */
  13648. getWorldMatrix?(): Matrix;
  13649. /**
  13650. * Gets the child meshes
  13651. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  13652. * @returns An array of abstract meshes
  13653. */
  13654. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  13655. /**
  13656. * Gets the vertex data
  13657. * @param kind The type of vertex data
  13658. * @returns A nullable array of numbers, or a float32 array
  13659. */
  13660. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  13661. /**
  13662. * Gets the indices from the mesh
  13663. * @returns A nullable array of index arrays
  13664. */
  13665. getIndices?(): Nullable<IndicesArray>;
  13666. /**
  13667. * Gets the scene from the mesh
  13668. * @returns the indices array or null
  13669. */
  13670. getScene?(): Scene;
  13671. /**
  13672. * Gets the absolute position from the mesh
  13673. * @returns the absolute position
  13674. */
  13675. getAbsolutePosition(): Vector3;
  13676. /**
  13677. * Gets the absolute pivot point from the mesh
  13678. * @returns the absolute pivot point
  13679. */
  13680. getAbsolutePivotPoint(): Vector3;
  13681. /**
  13682. * Rotates the mesh
  13683. * @param axis The axis of rotation
  13684. * @param amount The amount of rotation
  13685. * @param space The space of the rotation
  13686. * @returns The rotation transform node
  13687. */
  13688. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  13689. /**
  13690. * Translates the mesh
  13691. * @param axis The axis of translation
  13692. * @param distance The distance of translation
  13693. * @param space The space of the translation
  13694. * @returns The transform node
  13695. */
  13696. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  13697. /**
  13698. * Sets the absolute position of the mesh
  13699. * @param absolutePosition The absolute position of the mesh
  13700. * @returns The transform node
  13701. */
  13702. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13703. /**
  13704. * Gets the class name of the mesh
  13705. * @returns The class name
  13706. */
  13707. getClassName(): string;
  13708. }
  13709. /**
  13710. * Represents a physics imposter
  13711. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13712. */
  13713. export class PhysicsImpostor {
  13714. /**
  13715. * The physics-enabled object used as the physics imposter
  13716. */
  13717. object: IPhysicsEnabledObject;
  13718. /**
  13719. * The type of the physics imposter
  13720. */
  13721. type: number;
  13722. private _options;
  13723. private _scene?;
  13724. /**
  13725. * The default object size of the imposter
  13726. */
  13727. static DEFAULT_OBJECT_SIZE: Vector3;
  13728. /**
  13729. * The identity quaternion of the imposter
  13730. */
  13731. static IDENTITY_QUATERNION: Quaternion;
  13732. /** @hidden */
  13733. _pluginData: any;
  13734. private _physicsEngine;
  13735. private _physicsBody;
  13736. private _bodyUpdateRequired;
  13737. private _onBeforePhysicsStepCallbacks;
  13738. private _onAfterPhysicsStepCallbacks;
  13739. /** @hidden */
  13740. _onPhysicsCollideCallbacks: Array<{
  13741. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  13742. otherImpostors: Array<PhysicsImpostor>;
  13743. }>;
  13744. private _deltaPosition;
  13745. private _deltaRotation;
  13746. private _deltaRotationConjugated;
  13747. /** @hidden */
  13748. _isFromLine: boolean;
  13749. private _parent;
  13750. private _isDisposed;
  13751. private static _tmpVecs;
  13752. private static _tmpQuat;
  13753. /**
  13754. * Specifies if the physics imposter is disposed
  13755. */
  13756. readonly isDisposed: boolean;
  13757. /**
  13758. * Gets the mass of the physics imposter
  13759. */
  13760. mass: number;
  13761. /**
  13762. * Gets the coefficient of friction
  13763. */
  13764. /**
  13765. * Sets the coefficient of friction
  13766. */
  13767. friction: number;
  13768. /**
  13769. * Gets the coefficient of restitution
  13770. */
  13771. /**
  13772. * Sets the coefficient of restitution
  13773. */
  13774. restitution: number;
  13775. /**
  13776. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  13777. */
  13778. /**
  13779. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  13780. */
  13781. pressure: number;
  13782. /**
  13783. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  13784. */
  13785. /**
  13786. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  13787. */
  13788. stiffness: number;
  13789. /**
  13790. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  13791. */
  13792. /**
  13793. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  13794. */
  13795. velocityIterations: number;
  13796. /**
  13797. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  13798. */
  13799. /**
  13800. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  13801. */
  13802. positionIterations: number;
  13803. /**
  13804. * The unique id of the physics imposter
  13805. * set by the physics engine when adding this impostor to the array
  13806. */
  13807. uniqueId: number;
  13808. /**
  13809. * @hidden
  13810. */
  13811. soft: boolean;
  13812. /**
  13813. * @hidden
  13814. */
  13815. segments: number;
  13816. private _joints;
  13817. /**
  13818. * Initializes the physics imposter
  13819. * @param object The physics-enabled object used as the physics imposter
  13820. * @param type The type of the physics imposter
  13821. * @param _options The options for the physics imposter
  13822. * @param _scene The Babylon scene
  13823. */
  13824. constructor(
  13825. /**
  13826. * The physics-enabled object used as the physics imposter
  13827. */
  13828. object: IPhysicsEnabledObject,
  13829. /**
  13830. * The type of the physics imposter
  13831. */
  13832. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  13833. /**
  13834. * This function will completly initialize this impostor.
  13835. * It will create a new body - but only if this mesh has no parent.
  13836. * If it has, this impostor will not be used other than to define the impostor
  13837. * of the child mesh.
  13838. * @hidden
  13839. */
  13840. _init(): void;
  13841. private _getPhysicsParent;
  13842. /**
  13843. * Should a new body be generated.
  13844. * @returns boolean specifying if body initialization is required
  13845. */
  13846. isBodyInitRequired(): boolean;
  13847. /**
  13848. * Sets the updated scaling
  13849. * @param updated Specifies if the scaling is updated
  13850. */
  13851. setScalingUpdated(): void;
  13852. /**
  13853. * Force a regeneration of this or the parent's impostor's body.
  13854. * Use under cautious - This will remove all joints already implemented.
  13855. */
  13856. forceUpdate(): void;
  13857. /**
  13858. * Gets the body that holds this impostor. Either its own, or its parent.
  13859. */
  13860. /**
  13861. * Set the physics body. Used mainly by the physics engine/plugin
  13862. */
  13863. physicsBody: any;
  13864. /**
  13865. * Get the parent of the physics imposter
  13866. * @returns Physics imposter or null
  13867. */
  13868. /**
  13869. * Sets the parent of the physics imposter
  13870. */
  13871. parent: Nullable<PhysicsImpostor>;
  13872. /**
  13873. * Resets the update flags
  13874. */
  13875. resetUpdateFlags(): void;
  13876. /**
  13877. * Gets the object extend size
  13878. * @returns the object extend size
  13879. */
  13880. getObjectExtendSize(): Vector3;
  13881. /**
  13882. * Gets the object center
  13883. * @returns The object center
  13884. */
  13885. getObjectCenter(): Vector3;
  13886. /**
  13887. * Get a specific parametes from the options parameter
  13888. * @param paramName The object parameter name
  13889. * @returns The object parameter
  13890. */
  13891. getParam(paramName: string): any;
  13892. /**
  13893. * Sets a specific parameter in the options given to the physics plugin
  13894. * @param paramName The parameter name
  13895. * @param value The value of the parameter
  13896. */
  13897. setParam(paramName: string, value: number): void;
  13898. /**
  13899. * Specifically change the body's mass option. Won't recreate the physics body object
  13900. * @param mass The mass of the physics imposter
  13901. */
  13902. setMass(mass: number): void;
  13903. /**
  13904. * Gets the linear velocity
  13905. * @returns linear velocity or null
  13906. */
  13907. getLinearVelocity(): Nullable<Vector3>;
  13908. /**
  13909. * Sets the linear velocity
  13910. * @param velocity linear velocity or null
  13911. */
  13912. setLinearVelocity(velocity: Nullable<Vector3>): void;
  13913. /**
  13914. * Gets the angular velocity
  13915. * @returns angular velocity or null
  13916. */
  13917. getAngularVelocity(): Nullable<Vector3>;
  13918. /**
  13919. * Sets the angular velocity
  13920. * @param velocity The velocity or null
  13921. */
  13922. setAngularVelocity(velocity: Nullable<Vector3>): void;
  13923. /**
  13924. * Execute a function with the physics plugin native code
  13925. * Provide a function the will have two variables - the world object and the physics body object
  13926. * @param func The function to execute with the physics plugin native code
  13927. */
  13928. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  13929. /**
  13930. * Register a function that will be executed before the physics world is stepping forward
  13931. * @param func The function to execute before the physics world is stepped forward
  13932. */
  13933. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13934. /**
  13935. * Unregister a function that will be executed before the physics world is stepping forward
  13936. * @param func The function to execute before the physics world is stepped forward
  13937. */
  13938. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13939. /**
  13940. * Register a function that will be executed after the physics step
  13941. * @param func The function to execute after physics step
  13942. */
  13943. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13944. /**
  13945. * Unregisters a function that will be executed after the physics step
  13946. * @param func The function to execute after physics step
  13947. */
  13948. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13949. /**
  13950. * register a function that will be executed when this impostor collides against a different body
  13951. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  13952. * @param func Callback that is executed on collision
  13953. */
  13954. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  13955. /**
  13956. * Unregisters the physics imposter on contact
  13957. * @param collideAgainst The physics object to collide against
  13958. * @param func Callback to execute on collision
  13959. */
  13960. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  13961. private _tmpQuat;
  13962. private _tmpQuat2;
  13963. /**
  13964. * Get the parent rotation
  13965. * @returns The parent rotation
  13966. */
  13967. getParentsRotation(): Quaternion;
  13968. /**
  13969. * this function is executed by the physics engine.
  13970. */
  13971. beforeStep: () => void;
  13972. /**
  13973. * this function is executed by the physics engine
  13974. */
  13975. afterStep: () => void;
  13976. /**
  13977. * Legacy collision detection event support
  13978. */
  13979. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  13980. /**
  13981. * event and body object due to cannon's event-based architecture.
  13982. */
  13983. onCollide: (e: {
  13984. body: any;
  13985. }) => void;
  13986. /**
  13987. * Apply a force
  13988. * @param force The force to apply
  13989. * @param contactPoint The contact point for the force
  13990. * @returns The physics imposter
  13991. */
  13992. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  13993. /**
  13994. * Apply an impulse
  13995. * @param force The impulse force
  13996. * @param contactPoint The contact point for the impulse force
  13997. * @returns The physics imposter
  13998. */
  13999. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  14000. /**
  14001. * A help function to create a joint
  14002. * @param otherImpostor A physics imposter used to create a joint
  14003. * @param jointType The type of joint
  14004. * @param jointData The data for the joint
  14005. * @returns The physics imposter
  14006. */
  14007. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  14008. /**
  14009. * Add a joint to this impostor with a different impostor
  14010. * @param otherImpostor A physics imposter used to add a joint
  14011. * @param joint The joint to add
  14012. * @returns The physics imposter
  14013. */
  14014. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  14015. /**
  14016. * Add an anchor to a cloth impostor
  14017. * @param otherImpostor rigid impostor to anchor to
  14018. * @param width ratio across width from 0 to 1
  14019. * @param height ratio up height from 0 to 1
  14020. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  14021. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  14022. * @returns impostor the soft imposter
  14023. */
  14024. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  14025. /**
  14026. * Add a hook to a rope impostor
  14027. * @param otherImpostor rigid impostor to anchor to
  14028. * @param length ratio across rope from 0 to 1
  14029. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  14030. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  14031. * @returns impostor the rope imposter
  14032. */
  14033. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  14034. /**
  14035. * Will keep this body still, in a sleep mode.
  14036. * @returns the physics imposter
  14037. */
  14038. sleep(): PhysicsImpostor;
  14039. /**
  14040. * Wake the body up.
  14041. * @returns The physics imposter
  14042. */
  14043. wakeUp(): PhysicsImpostor;
  14044. /**
  14045. * Clones the physics imposter
  14046. * @param newObject The physics imposter clones to this physics-enabled object
  14047. * @returns A nullable physics imposter
  14048. */
  14049. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  14050. /**
  14051. * Disposes the physics imposter
  14052. */
  14053. dispose(): void;
  14054. /**
  14055. * Sets the delta position
  14056. * @param position The delta position amount
  14057. */
  14058. setDeltaPosition(position: Vector3): void;
  14059. /**
  14060. * Sets the delta rotation
  14061. * @param rotation The delta rotation amount
  14062. */
  14063. setDeltaRotation(rotation: Quaternion): void;
  14064. /**
  14065. * Gets the box size of the physics imposter and stores the result in the input parameter
  14066. * @param result Stores the box size
  14067. * @returns The physics imposter
  14068. */
  14069. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  14070. /**
  14071. * Gets the radius of the physics imposter
  14072. * @returns Radius of the physics imposter
  14073. */
  14074. getRadius(): number;
  14075. /**
  14076. * Sync a bone with this impostor
  14077. * @param bone The bone to sync to the impostor.
  14078. * @param boneMesh The mesh that the bone is influencing.
  14079. * @param jointPivot The pivot of the joint / bone in local space.
  14080. * @param distToJoint Optional distance from the impostor to the joint.
  14081. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  14082. */
  14083. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  14084. /**
  14085. * Sync impostor to a bone
  14086. * @param bone The bone that the impostor will be synced to.
  14087. * @param boneMesh The mesh that the bone is influencing.
  14088. * @param jointPivot The pivot of the joint / bone in local space.
  14089. * @param distToJoint Optional distance from the impostor to the joint.
  14090. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  14091. * @param boneAxis Optional vector3 axis the bone is aligned with
  14092. */
  14093. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  14094. /**
  14095. * No-Imposter type
  14096. */
  14097. static NoImpostor: number;
  14098. /**
  14099. * Sphere-Imposter type
  14100. */
  14101. static SphereImpostor: number;
  14102. /**
  14103. * Box-Imposter type
  14104. */
  14105. static BoxImpostor: number;
  14106. /**
  14107. * Plane-Imposter type
  14108. */
  14109. static PlaneImpostor: number;
  14110. /**
  14111. * Mesh-imposter type
  14112. */
  14113. static MeshImpostor: number;
  14114. /**
  14115. * Capsule-Impostor type (Ammo.js plugin only)
  14116. */
  14117. static CapsuleImpostor: number;
  14118. /**
  14119. * Cylinder-Imposter type
  14120. */
  14121. static CylinderImpostor: number;
  14122. /**
  14123. * Particle-Imposter type
  14124. */
  14125. static ParticleImpostor: number;
  14126. /**
  14127. * Heightmap-Imposter type
  14128. */
  14129. static HeightmapImpostor: number;
  14130. /**
  14131. * ConvexHull-Impostor type (Ammo.js plugin only)
  14132. */
  14133. static ConvexHullImpostor: number;
  14134. /**
  14135. * Rope-Imposter type
  14136. */
  14137. static RopeImpostor: number;
  14138. /**
  14139. * Cloth-Imposter type
  14140. */
  14141. static ClothImpostor: number;
  14142. /**
  14143. * Softbody-Imposter type
  14144. */
  14145. static SoftbodyImpostor: number;
  14146. }
  14147. }
  14148. declare module "babylonjs/Meshes/mesh" {
  14149. import { Observable } from "babylonjs/Misc/observable";
  14150. import { IAnimatable } from "babylonjs/Misc/tools";
  14151. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  14152. import { Camera } from "babylonjs/Cameras/camera";
  14153. import { Scene } from "babylonjs/scene";
  14154. import { Matrix, Vector3, Vector2, Color4, Plane, Vector4, Path3D } from "babylonjs/Maths/math";
  14155. import { Engine } from "babylonjs/Engines/engine";
  14156. import { Node } from "babylonjs/node";
  14157. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  14158. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  14159. import { Buffer } from "babylonjs/Meshes/buffer";
  14160. import { Geometry } from "babylonjs/Meshes/geometry";
  14161. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14162. import { SubMesh } from "babylonjs/Meshes/subMesh";
  14163. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  14164. import { Effect } from "babylonjs/Materials/effect";
  14165. import { Material } from "babylonjs/Materials/material";
  14166. import { Skeleton } from "babylonjs/Bones/skeleton";
  14167. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  14168. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  14169. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  14170. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  14171. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  14172. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  14173. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  14174. /**
  14175. * @hidden
  14176. **/
  14177. export class _CreationDataStorage {
  14178. closePath?: boolean;
  14179. closeArray?: boolean;
  14180. idx: number[];
  14181. dashSize: number;
  14182. gapSize: number;
  14183. path3D: Path3D;
  14184. pathArray: Vector3[][];
  14185. arc: number;
  14186. radius: number;
  14187. cap: number;
  14188. tessellation: number;
  14189. }
  14190. /**
  14191. * @hidden
  14192. **/
  14193. class _InstanceDataStorage {
  14194. visibleInstances: any;
  14195. batchCache: _InstancesBatch;
  14196. instancesBufferSize: number;
  14197. instancesBuffer: Nullable<Buffer>;
  14198. instancesData: Float32Array;
  14199. overridenInstanceCount: number;
  14200. isFrozen: boolean;
  14201. previousBatch: Nullable<_InstancesBatch>;
  14202. hardwareInstancedRendering: boolean;
  14203. sideOrientation: number;
  14204. }
  14205. /**
  14206. * @hidden
  14207. **/
  14208. export class _InstancesBatch {
  14209. mustReturn: boolean;
  14210. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  14211. renderSelf: boolean[];
  14212. hardwareInstancedRendering: boolean[];
  14213. }
  14214. /**
  14215. * Class used to represent renderable models
  14216. */
  14217. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  14218. /**
  14219. * Mesh side orientation : usually the external or front surface
  14220. */
  14221. static readonly FRONTSIDE: number;
  14222. /**
  14223. * Mesh side orientation : usually the internal or back surface
  14224. */
  14225. static readonly BACKSIDE: number;
  14226. /**
  14227. * Mesh side orientation : both internal and external or front and back surfaces
  14228. */
  14229. static readonly DOUBLESIDE: number;
  14230. /**
  14231. * Mesh side orientation : by default, `FRONTSIDE`
  14232. */
  14233. static readonly DEFAULTSIDE: number;
  14234. /**
  14235. * Mesh cap setting : no cap
  14236. */
  14237. static readonly NO_CAP: number;
  14238. /**
  14239. * Mesh cap setting : one cap at the beginning of the mesh
  14240. */
  14241. static readonly CAP_START: number;
  14242. /**
  14243. * Mesh cap setting : one cap at the end of the mesh
  14244. */
  14245. static readonly CAP_END: number;
  14246. /**
  14247. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  14248. */
  14249. static readonly CAP_ALL: number;
  14250. /**
  14251. * Mesh pattern setting : no flip or rotate
  14252. */
  14253. static readonly NO_FLIP: number;
  14254. /**
  14255. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  14256. */
  14257. static readonly FLIP_TILE: number;
  14258. /**
  14259. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  14260. */
  14261. static readonly ROTATE_TILE: number;
  14262. /**
  14263. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  14264. */
  14265. static readonly FLIP_ROW: number;
  14266. /**
  14267. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  14268. */
  14269. static readonly ROTATE_ROW: number;
  14270. /**
  14271. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  14272. */
  14273. static readonly FLIP_N_ROTATE_TILE: number;
  14274. /**
  14275. * Mesh pattern setting : rotate pattern and rotate
  14276. */
  14277. static readonly FLIP_N_ROTATE_ROW: number;
  14278. /**
  14279. * Mesh tile positioning : part tiles same on left/right or top/bottom
  14280. */
  14281. static readonly CENTER: number;
  14282. /**
  14283. * Mesh tile positioning : part tiles on left
  14284. */
  14285. static readonly LEFT: number;
  14286. /**
  14287. * Mesh tile positioning : part tiles on right
  14288. */
  14289. static readonly RIGHT: number;
  14290. /**
  14291. * Mesh tile positioning : part tiles on top
  14292. */
  14293. static readonly TOP: number;
  14294. /**
  14295. * Mesh tile positioning : part tiles on bottom
  14296. */
  14297. static readonly BOTTOM: number;
  14298. /**
  14299. * Gets the default side orientation.
  14300. * @param orientation the orientation to value to attempt to get
  14301. * @returns the default orientation
  14302. * @hidden
  14303. */
  14304. static _GetDefaultSideOrientation(orientation?: number): number;
  14305. private _internalMeshDataInfo;
  14306. /**
  14307. * An event triggered before rendering the mesh
  14308. */
  14309. readonly onBeforeRenderObservable: Observable<Mesh>;
  14310. /**
  14311. * An event triggered before binding the mesh
  14312. */
  14313. readonly onBeforeBindObservable: Observable<Mesh>;
  14314. /**
  14315. * An event triggered after rendering the mesh
  14316. */
  14317. readonly onAfterRenderObservable: Observable<Mesh>;
  14318. /**
  14319. * An event triggered before drawing the mesh
  14320. */
  14321. readonly onBeforeDrawObservable: Observable<Mesh>;
  14322. private _onBeforeDrawObserver;
  14323. /**
  14324. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  14325. */
  14326. onBeforeDraw: () => void;
  14327. /**
  14328. * Gets the delay loading state of the mesh (when delay loading is turned on)
  14329. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  14330. */
  14331. delayLoadState: number;
  14332. /**
  14333. * Gets the list of instances created from this mesh
  14334. * it is not supposed to be modified manually.
  14335. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  14336. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  14337. */
  14338. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  14339. /**
  14340. * Gets the file containing delay loading data for this mesh
  14341. */
  14342. delayLoadingFile: string;
  14343. /** @hidden */
  14344. _binaryInfo: any;
  14345. /**
  14346. * User defined function used to change how LOD level selection is done
  14347. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  14348. */
  14349. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  14350. /**
  14351. * Gets or sets the morph target manager
  14352. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  14353. */
  14354. morphTargetManager: Nullable<MorphTargetManager>;
  14355. /** @hidden */
  14356. _creationDataStorage: Nullable<_CreationDataStorage>;
  14357. /** @hidden */
  14358. _geometry: Nullable<Geometry>;
  14359. /** @hidden */
  14360. _delayInfo: Array<string>;
  14361. /** @hidden */
  14362. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  14363. /** @hidden */
  14364. _instanceDataStorage: _InstanceDataStorage;
  14365. private _effectiveMaterial;
  14366. /** @hidden */
  14367. _shouldGenerateFlatShading: boolean;
  14368. /** @hidden */
  14369. _originalBuilderSideOrientation: number;
  14370. /**
  14371. * Use this property to change the original side orientation defined at construction time
  14372. */
  14373. overrideMaterialSideOrientation: Nullable<number>;
  14374. /**
  14375. * Gets the source mesh (the one used to clone this one from)
  14376. */
  14377. readonly source: Nullable<Mesh>;
  14378. /**
  14379. * Gets or sets a boolean indicating that this mesh does not use index buffer
  14380. */
  14381. isUnIndexed: boolean;
  14382. /**
  14383. * @constructor
  14384. * @param name The value used by scene.getMeshByName() to do a lookup.
  14385. * @param scene The scene to add this mesh to.
  14386. * @param parent The parent of this mesh, if it has one
  14387. * @param source An optional Mesh from which geometry is shared, cloned.
  14388. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  14389. * When false, achieved by calling a clone(), also passing False.
  14390. * This will make creation of children, recursive.
  14391. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  14392. */
  14393. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  14394. /**
  14395. * Gets the class name
  14396. * @returns the string "Mesh".
  14397. */
  14398. getClassName(): string;
  14399. /** @hidden */
  14400. readonly _isMesh: boolean;
  14401. /**
  14402. * Returns a description of this mesh
  14403. * @param fullDetails define if full details about this mesh must be used
  14404. * @returns a descriptive string representing this mesh
  14405. */
  14406. toString(fullDetails?: boolean): string;
  14407. /** @hidden */
  14408. _unBindEffect(): void;
  14409. /**
  14410. * Gets a boolean indicating if this mesh has LOD
  14411. */
  14412. readonly hasLODLevels: boolean;
  14413. /**
  14414. * Gets the list of MeshLODLevel associated with the current mesh
  14415. * @returns an array of MeshLODLevel
  14416. */
  14417. getLODLevels(): MeshLODLevel[];
  14418. private _sortLODLevels;
  14419. /**
  14420. * Add a mesh as LOD level triggered at the given distance.
  14421. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  14422. * @param distance The distance from the center of the object to show this level
  14423. * @param mesh The mesh to be added as LOD level (can be null)
  14424. * @return This mesh (for chaining)
  14425. */
  14426. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  14427. /**
  14428. * Returns the LOD level mesh at the passed distance or null if not found.
  14429. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  14430. * @param distance The distance from the center of the object to show this level
  14431. * @returns a Mesh or `null`
  14432. */
  14433. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  14434. /**
  14435. * Remove a mesh from the LOD array
  14436. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  14437. * @param mesh defines the mesh to be removed
  14438. * @return This mesh (for chaining)
  14439. */
  14440. removeLODLevel(mesh: Mesh): Mesh;
  14441. /**
  14442. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  14443. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  14444. * @param camera defines the camera to use to compute distance
  14445. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  14446. * @return This mesh (for chaining)
  14447. */
  14448. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  14449. /**
  14450. * Gets the mesh internal Geometry object
  14451. */
  14452. readonly geometry: Nullable<Geometry>;
  14453. /**
  14454. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  14455. * @returns the total number of vertices
  14456. */
  14457. getTotalVertices(): number;
  14458. /**
  14459. * Returns the content of an associated vertex buffer
  14460. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  14461. * - VertexBuffer.PositionKind
  14462. * - VertexBuffer.UVKind
  14463. * - VertexBuffer.UV2Kind
  14464. * - VertexBuffer.UV3Kind
  14465. * - VertexBuffer.UV4Kind
  14466. * - VertexBuffer.UV5Kind
  14467. * - VertexBuffer.UV6Kind
  14468. * - VertexBuffer.ColorKind
  14469. * - VertexBuffer.MatricesIndicesKind
  14470. * - VertexBuffer.MatricesIndicesExtraKind
  14471. * - VertexBuffer.MatricesWeightsKind
  14472. * - VertexBuffer.MatricesWeightsExtraKind
  14473. * @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
  14474. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  14475. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  14476. */
  14477. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  14478. /**
  14479. * Returns the mesh VertexBuffer object from the requested `kind`
  14480. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  14481. * - VertexBuffer.PositionKind
  14482. * - VertexBuffer.NormalKind
  14483. * - VertexBuffer.UVKind
  14484. * - VertexBuffer.UV2Kind
  14485. * - VertexBuffer.UV3Kind
  14486. * - VertexBuffer.UV4Kind
  14487. * - VertexBuffer.UV5Kind
  14488. * - VertexBuffer.UV6Kind
  14489. * - VertexBuffer.ColorKind
  14490. * - VertexBuffer.MatricesIndicesKind
  14491. * - VertexBuffer.MatricesIndicesExtraKind
  14492. * - VertexBuffer.MatricesWeightsKind
  14493. * - VertexBuffer.MatricesWeightsExtraKind
  14494. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  14495. */
  14496. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  14497. /**
  14498. * Tests if a specific vertex buffer is associated with this mesh
  14499. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  14500. * - VertexBuffer.PositionKind
  14501. * - VertexBuffer.NormalKind
  14502. * - VertexBuffer.UVKind
  14503. * - VertexBuffer.UV2Kind
  14504. * - VertexBuffer.UV3Kind
  14505. * - VertexBuffer.UV4Kind
  14506. * - VertexBuffer.UV5Kind
  14507. * - VertexBuffer.UV6Kind
  14508. * - VertexBuffer.ColorKind
  14509. * - VertexBuffer.MatricesIndicesKind
  14510. * - VertexBuffer.MatricesIndicesExtraKind
  14511. * - VertexBuffer.MatricesWeightsKind
  14512. * - VertexBuffer.MatricesWeightsExtraKind
  14513. * @returns a boolean
  14514. */
  14515. isVerticesDataPresent(kind: string): boolean;
  14516. /**
  14517. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  14518. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  14519. * - VertexBuffer.PositionKind
  14520. * - VertexBuffer.UVKind
  14521. * - VertexBuffer.UV2Kind
  14522. * - VertexBuffer.UV3Kind
  14523. * - VertexBuffer.UV4Kind
  14524. * - VertexBuffer.UV5Kind
  14525. * - VertexBuffer.UV6Kind
  14526. * - VertexBuffer.ColorKind
  14527. * - VertexBuffer.MatricesIndicesKind
  14528. * - VertexBuffer.MatricesIndicesExtraKind
  14529. * - VertexBuffer.MatricesWeightsKind
  14530. * - VertexBuffer.MatricesWeightsExtraKind
  14531. * @returns a boolean
  14532. */
  14533. isVertexBufferUpdatable(kind: string): boolean;
  14534. /**
  14535. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  14536. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  14537. * - VertexBuffer.PositionKind
  14538. * - VertexBuffer.NormalKind
  14539. * - VertexBuffer.UVKind
  14540. * - VertexBuffer.UV2Kind
  14541. * - VertexBuffer.UV3Kind
  14542. * - VertexBuffer.UV4Kind
  14543. * - VertexBuffer.UV5Kind
  14544. * - VertexBuffer.UV6Kind
  14545. * - VertexBuffer.ColorKind
  14546. * - VertexBuffer.MatricesIndicesKind
  14547. * - VertexBuffer.MatricesIndicesExtraKind
  14548. * - VertexBuffer.MatricesWeightsKind
  14549. * - VertexBuffer.MatricesWeightsExtraKind
  14550. * @returns an array of strings
  14551. */
  14552. getVerticesDataKinds(): string[];
  14553. /**
  14554. * Returns a positive integer : the total number of indices in this mesh geometry.
  14555. * @returns the numner of indices or zero if the mesh has no geometry.
  14556. */
  14557. getTotalIndices(): number;
  14558. /**
  14559. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  14560. * @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.
  14561. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  14562. * @returns the indices array or an empty array if the mesh has no geometry
  14563. */
  14564. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  14565. readonly isBlocked: boolean;
  14566. /**
  14567. * Determine if the current mesh is ready to be rendered
  14568. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  14569. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  14570. * @returns true if all associated assets are ready (material, textures, shaders)
  14571. */
  14572. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  14573. /**
  14574. * 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.
  14575. */
  14576. readonly areNormalsFrozen: boolean;
  14577. /**
  14578. * 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.
  14579. * @returns the current mesh
  14580. */
  14581. freezeNormals(): Mesh;
  14582. /**
  14583. * 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
  14584. * @returns the current mesh
  14585. */
  14586. unfreezeNormals(): Mesh;
  14587. /**
  14588. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  14589. */
  14590. overridenInstanceCount: number;
  14591. /** @hidden */
  14592. _preActivate(): Mesh;
  14593. /** @hidden */
  14594. _preActivateForIntermediateRendering(renderId: number): Mesh;
  14595. /** @hidden */
  14596. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  14597. /**
  14598. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  14599. * This means the mesh underlying bounding box and sphere are recomputed.
  14600. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  14601. * @returns the current mesh
  14602. */
  14603. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  14604. /** @hidden */
  14605. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  14606. /**
  14607. * This function will subdivide the mesh into multiple submeshes
  14608. * @param count defines the expected number of submeshes
  14609. */
  14610. subdivide(count: number): void;
  14611. /**
  14612. * Copy a FloatArray into a specific associated vertex buffer
  14613. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  14614. * - VertexBuffer.PositionKind
  14615. * - VertexBuffer.UVKind
  14616. * - VertexBuffer.UV2Kind
  14617. * - VertexBuffer.UV3Kind
  14618. * - VertexBuffer.UV4Kind
  14619. * - VertexBuffer.UV5Kind
  14620. * - VertexBuffer.UV6Kind
  14621. * - VertexBuffer.ColorKind
  14622. * - VertexBuffer.MatricesIndicesKind
  14623. * - VertexBuffer.MatricesIndicesExtraKind
  14624. * - VertexBuffer.MatricesWeightsKind
  14625. * - VertexBuffer.MatricesWeightsExtraKind
  14626. * @param data defines the data source
  14627. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  14628. * @param stride defines the data stride size (can be null)
  14629. * @returns the current mesh
  14630. */
  14631. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  14632. /**
  14633. * Flags an associated vertex buffer as updatable
  14634. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  14635. * - VertexBuffer.PositionKind
  14636. * - VertexBuffer.UVKind
  14637. * - VertexBuffer.UV2Kind
  14638. * - VertexBuffer.UV3Kind
  14639. * - VertexBuffer.UV4Kind
  14640. * - VertexBuffer.UV5Kind
  14641. * - VertexBuffer.UV6Kind
  14642. * - VertexBuffer.ColorKind
  14643. * - VertexBuffer.MatricesIndicesKind
  14644. * - VertexBuffer.MatricesIndicesExtraKind
  14645. * - VertexBuffer.MatricesWeightsKind
  14646. * - VertexBuffer.MatricesWeightsExtraKind
  14647. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  14648. */
  14649. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  14650. /**
  14651. * Sets the mesh global Vertex Buffer
  14652. * @param buffer defines the buffer to use
  14653. * @returns the current mesh
  14654. */
  14655. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  14656. /**
  14657. * Update a specific associated vertex buffer
  14658. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  14659. * - VertexBuffer.PositionKind
  14660. * - VertexBuffer.UVKind
  14661. * - VertexBuffer.UV2Kind
  14662. * - VertexBuffer.UV3Kind
  14663. * - VertexBuffer.UV4Kind
  14664. * - VertexBuffer.UV5Kind
  14665. * - VertexBuffer.UV6Kind
  14666. * - VertexBuffer.ColorKind
  14667. * - VertexBuffer.MatricesIndicesKind
  14668. * - VertexBuffer.MatricesIndicesExtraKind
  14669. * - VertexBuffer.MatricesWeightsKind
  14670. * - VertexBuffer.MatricesWeightsExtraKind
  14671. * @param data defines the data source
  14672. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  14673. * @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)
  14674. * @returns the current mesh
  14675. */
  14676. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  14677. /**
  14678. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  14679. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  14680. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  14681. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  14682. * @returns the current mesh
  14683. */
  14684. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  14685. /**
  14686. * Creates a un-shared specific occurence of the geometry for the mesh.
  14687. * @returns the current mesh
  14688. */
  14689. makeGeometryUnique(): Mesh;
  14690. /**
  14691. * Set the index buffer of this mesh
  14692. * @param indices defines the source data
  14693. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  14694. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  14695. * @returns the current mesh
  14696. */
  14697. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  14698. /**
  14699. * Update the current index buffer
  14700. * @param indices defines the source data
  14701. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  14702. * @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)
  14703. * @returns the current mesh
  14704. */
  14705. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  14706. /**
  14707. * Invert the geometry to move from a right handed system to a left handed one.
  14708. * @returns the current mesh
  14709. */
  14710. toLeftHanded(): Mesh;
  14711. /** @hidden */
  14712. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  14713. /** @hidden */
  14714. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  14715. /**
  14716. * Registers for this mesh a javascript function called just before the rendering process
  14717. * @param func defines the function to call before rendering this mesh
  14718. * @returns the current mesh
  14719. */
  14720. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  14721. /**
  14722. * Disposes a previously registered javascript function called before the rendering
  14723. * @param func defines the function to remove
  14724. * @returns the current mesh
  14725. */
  14726. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  14727. /**
  14728. * Registers for this mesh a javascript function called just after the rendering is complete
  14729. * @param func defines the function to call after rendering this mesh
  14730. * @returns the current mesh
  14731. */
  14732. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  14733. /**
  14734. * Disposes a previously registered javascript function called after the rendering.
  14735. * @param func defines the function to remove
  14736. * @returns the current mesh
  14737. */
  14738. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  14739. /** @hidden */
  14740. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  14741. /** @hidden */
  14742. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  14743. /** @hidden */
  14744. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  14745. /** @hidden */
  14746. _rebuild(): void;
  14747. /** @hidden */
  14748. _freeze(): void;
  14749. /** @hidden */
  14750. _unFreeze(): void;
  14751. /**
  14752. * 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
  14753. * @param subMesh defines the subMesh to render
  14754. * @param enableAlphaMode defines if alpha mode can be changed
  14755. * @returns the current mesh
  14756. */
  14757. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  14758. private _onBeforeDraw;
  14759. /**
  14760. * Renormalize the mesh and patch it up if there are no weights
  14761. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  14762. * However in the case of zero weights then we set just a single influence to 1.
  14763. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  14764. */
  14765. cleanMatrixWeights(): void;
  14766. private normalizeSkinFourWeights;
  14767. private normalizeSkinWeightsAndExtra;
  14768. /**
  14769. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  14770. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  14771. * the user know there was an issue with importing the mesh
  14772. * @returns a validation object with skinned, valid and report string
  14773. */
  14774. validateSkinning(): {
  14775. skinned: boolean;
  14776. valid: boolean;
  14777. report: string;
  14778. };
  14779. /** @hidden */
  14780. _checkDelayState(): Mesh;
  14781. private _queueLoad;
  14782. /**
  14783. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  14784. * A mesh is in the frustum if its bounding box intersects the frustum
  14785. * @param frustumPlanes defines the frustum to test
  14786. * @returns true if the mesh is in the frustum planes
  14787. */
  14788. isInFrustum(frustumPlanes: Plane[]): boolean;
  14789. /**
  14790. * Sets the mesh material by the material or multiMaterial `id` property
  14791. * @param id is a string identifying the material or the multiMaterial
  14792. * @returns the current mesh
  14793. */
  14794. setMaterialByID(id: string): Mesh;
  14795. /**
  14796. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  14797. * @returns an array of IAnimatable
  14798. */
  14799. getAnimatables(): IAnimatable[];
  14800. /**
  14801. * Modifies the mesh geometry according to the passed transformation matrix.
  14802. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  14803. * The mesh normals are modified using the same transformation.
  14804. * Note that, under the hood, this method sets a new VertexBuffer each call.
  14805. * @param transform defines the transform matrix to use
  14806. * @see http://doc.babylonjs.com/resources/baking_transformations
  14807. * @returns the current mesh
  14808. */
  14809. bakeTransformIntoVertices(transform: Matrix): Mesh;
  14810. /**
  14811. * Modifies the mesh geometry according to its own current World Matrix.
  14812. * The mesh World Matrix is then reset.
  14813. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  14814. * Note that, under the hood, this method sets a new VertexBuffer each call.
  14815. * @see http://doc.babylonjs.com/resources/baking_transformations
  14816. * @returns the current mesh
  14817. */
  14818. bakeCurrentTransformIntoVertices(): Mesh;
  14819. /** @hidden */
  14820. readonly _positions: Nullable<Vector3[]>;
  14821. /** @hidden */
  14822. _resetPointsArrayCache(): Mesh;
  14823. /** @hidden */
  14824. _generatePointsArray(): boolean;
  14825. /**
  14826. * Returns a new Mesh object generated from the current mesh properties.
  14827. * This method must not get confused with createInstance()
  14828. * @param name is a string, the name given to the new mesh
  14829. * @param newParent can be any Node object (default `null`)
  14830. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  14831. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  14832. * @returns a new mesh
  14833. */
  14834. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  14835. /**
  14836. * Releases resources associated with this mesh.
  14837. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14838. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14839. */
  14840. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14841. /**
  14842. * Modifies the mesh geometry according to a displacement map.
  14843. * 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.
  14844. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  14845. * @param url is a string, the URL from the image file is to be downloaded.
  14846. * @param minHeight is the lower limit of the displacement.
  14847. * @param maxHeight is the upper limit of the displacement.
  14848. * @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.
  14849. * @param uvOffset is an optional vector2 used to offset UV.
  14850. * @param uvScale is an optional vector2 used to scale UV.
  14851. * @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.
  14852. * @returns the Mesh.
  14853. */
  14854. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  14855. /**
  14856. * Modifies the mesh geometry according to a displacementMap buffer.
  14857. * 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.
  14858. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  14859. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  14860. * @param heightMapWidth is the width of the buffer image.
  14861. * @param heightMapHeight is the height of the buffer image.
  14862. * @param minHeight is the lower limit of the displacement.
  14863. * @param maxHeight is the upper limit of the displacement.
  14864. * @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.
  14865. * @param uvOffset is an optional vector2 used to offset UV.
  14866. * @param uvScale is an optional vector2 used to scale UV.
  14867. * @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.
  14868. * @returns the Mesh.
  14869. */
  14870. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  14871. /**
  14872. * Modify the mesh to get a flat shading rendering.
  14873. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  14874. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  14875. * @returns current mesh
  14876. */
  14877. convertToFlatShadedMesh(): Mesh;
  14878. /**
  14879. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  14880. * In other words, more vertices, no more indices and a single bigger VBO.
  14881. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  14882. * @returns current mesh
  14883. */
  14884. convertToUnIndexedMesh(): Mesh;
  14885. /**
  14886. * Inverses facet orientations.
  14887. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  14888. * @param flipNormals will also inverts the normals
  14889. * @returns current mesh
  14890. */
  14891. flipFaces(flipNormals?: boolean): Mesh;
  14892. /**
  14893. * Increase the number of facets and hence vertices in a mesh
  14894. * Vertex normals are interpolated from existing vertex normals
  14895. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  14896. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  14897. */
  14898. increaseVertices(numberPerEdge: number): void;
  14899. /**
  14900. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  14901. * This will undo any application of covertToFlatShadedMesh
  14902. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  14903. */
  14904. forceSharedVertices(): void;
  14905. /** @hidden */
  14906. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  14907. /** @hidden */
  14908. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  14909. /**
  14910. * Creates a new InstancedMesh object from the mesh model.
  14911. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  14912. * @param name defines the name of the new instance
  14913. * @returns a new InstancedMesh
  14914. */
  14915. createInstance(name: string): InstancedMesh;
  14916. /**
  14917. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  14918. * After this call, all the mesh instances have the same submeshes than the current mesh.
  14919. * @returns the current mesh
  14920. */
  14921. synchronizeInstances(): Mesh;
  14922. /**
  14923. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  14924. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  14925. * This should be used together with the simplification to avoid disappearing triangles.
  14926. * @param successCallback an optional success callback to be called after the optimization finished.
  14927. * @returns the current mesh
  14928. */
  14929. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  14930. /**
  14931. * Serialize current mesh
  14932. * @param serializationObject defines the object which will receive the serialization data
  14933. */
  14934. serialize(serializationObject: any): void;
  14935. /** @hidden */
  14936. _syncGeometryWithMorphTargetManager(): void;
  14937. /** @hidden */
  14938. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  14939. /**
  14940. * Returns a new Mesh object parsed from the source provided.
  14941. * @param parsedMesh is the source
  14942. * @param scene defines the hosting scene
  14943. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  14944. * @returns a new Mesh
  14945. */
  14946. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  14947. /**
  14948. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  14949. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  14950. * @param name defines the name of the mesh to create
  14951. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  14952. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  14953. * @param closePath creates a seam between the first and the last points of each path of the path array
  14954. * @param offset is taken in account only if the `pathArray` is containing a single path
  14955. * @param scene defines the hosting scene
  14956. * @param updatable defines if the mesh must be flagged as updatable
  14957. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14958. * @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)
  14959. * @returns a new Mesh
  14960. */
  14961. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  14962. /**
  14963. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  14964. * @param name defines the name of the mesh to create
  14965. * @param radius sets the radius size (float) of the polygon (default 0.5)
  14966. * @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
  14967. * @param scene defines the hosting scene
  14968. * @param updatable defines if the mesh must be flagged as updatable
  14969. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14970. * @returns a new Mesh
  14971. */
  14972. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  14973. /**
  14974. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  14975. * @param name defines the name of the mesh to create
  14976. * @param size sets the size (float) of each box side (default 1)
  14977. * @param scene defines the hosting scene
  14978. * @param updatable defines if the mesh must be flagged as updatable
  14979. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14980. * @returns a new Mesh
  14981. */
  14982. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  14983. /**
  14984. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  14985. * @param name defines the name of the mesh to create
  14986. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  14987. * @param diameter sets the diameter size (float) of the sphere (default 1)
  14988. * @param scene defines the hosting scene
  14989. * @param updatable defines if the mesh must be flagged as updatable
  14990. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14991. * @returns a new Mesh
  14992. */
  14993. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  14994. /**
  14995. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  14996. * @param name defines the name of the mesh to create
  14997. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  14998. * @param diameter sets the diameter size (float) of the sphere (default 1)
  14999. * @param scene defines the hosting scene
  15000. * @returns a new Mesh
  15001. */
  15002. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  15003. /**
  15004. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  15005. * @param name defines the name of the mesh to create
  15006. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  15007. * @param diameterTop set the top cap diameter (floats, default 1)
  15008. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  15009. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  15010. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  15011. * @param scene defines the hosting scene
  15012. * @param updatable defines if the mesh must be flagged as updatable
  15013. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15014. * @returns a new Mesh
  15015. */
  15016. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  15017. /**
  15018. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  15019. * @param name defines the name of the mesh to create
  15020. * @param diameter sets the diameter size (float) of the torus (default 1)
  15021. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  15022. * @param tessellation sets the number of torus sides (postive integer, default 16)
  15023. * @param scene defines the hosting scene
  15024. * @param updatable defines if the mesh must be flagged as updatable
  15025. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15026. * @returns a new Mesh
  15027. */
  15028. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  15029. /**
  15030. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  15031. * @param name defines the name of the mesh to create
  15032. * @param radius sets the global radius size (float) of the torus knot (default 2)
  15033. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  15034. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  15035. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  15036. * @param p the number of windings on X axis (positive integers, default 2)
  15037. * @param q the number of windings on Y axis (positive integers, default 3)
  15038. * @param scene defines the hosting scene
  15039. * @param updatable defines if the mesh must be flagged as updatable
  15040. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15041. * @returns a new Mesh
  15042. */
  15043. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  15044. /**
  15045. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  15046. * @param name defines the name of the mesh to create
  15047. * @param points is an array successive Vector3
  15048. * @param scene defines the hosting scene
  15049. * @param updatable defines if the mesh must be flagged as updatable
  15050. * @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).
  15051. * @returns a new Mesh
  15052. */
  15053. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  15054. /**
  15055. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  15056. * @param name defines the name of the mesh to create
  15057. * @param points is an array successive Vector3
  15058. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  15059. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  15060. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  15061. * @param scene defines the hosting scene
  15062. * @param updatable defines if the mesh must be flagged as updatable
  15063. * @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)
  15064. * @returns a new Mesh
  15065. */
  15066. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  15067. /**
  15068. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  15069. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  15070. * 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.
  15071. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  15072. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15073. * Remember you can only change the shape positions, not their number when updating a polygon.
  15074. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  15075. * @param name defines the name of the mesh to create
  15076. * @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
  15077. * @param scene defines the hosting scene
  15078. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  15079. * @param updatable defines if the mesh must be flagged as updatable
  15080. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15081. * @param earcutInjection can be used to inject your own earcut reference
  15082. * @returns a new Mesh
  15083. */
  15084. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  15085. /**
  15086. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  15087. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  15088. * @param name defines the name of the mesh to create
  15089. * @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
  15090. * @param depth defines the height of extrusion
  15091. * @param scene defines the hosting scene
  15092. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  15093. * @param updatable defines if the mesh must be flagged as updatable
  15094. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15095. * @param earcutInjection can be used to inject your own earcut reference
  15096. * @returns a new Mesh
  15097. */
  15098. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  15099. /**
  15100. * Creates an extruded shape mesh.
  15101. * 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
  15102. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  15103. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  15104. * @param name defines the name of the mesh to create
  15105. * @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
  15106. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  15107. * @param scale is the value to scale the shape
  15108. * @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
  15109. * @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
  15110. * @param scene defines the hosting scene
  15111. * @param updatable defines if the mesh must be flagged as updatable
  15112. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15113. * @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)
  15114. * @returns a new Mesh
  15115. */
  15116. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  15117. /**
  15118. * Creates an custom extruded shape mesh.
  15119. * The custom extrusion is a parametric shape.
  15120. * It has no predefined shape. Its final shape will depend on the input parameters.
  15121. * Please consider using the same method from the MeshBuilder class instead
  15122. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  15123. * @param name defines the name of the mesh to create
  15124. * @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
  15125. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  15126. * @param scaleFunction is a custom Javascript function called on each path point
  15127. * @param rotationFunction is a custom Javascript function called on each path point
  15128. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  15129. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  15130. * @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
  15131. * @param scene defines the hosting scene
  15132. * @param updatable defines if the mesh must be flagged as updatable
  15133. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15134. * @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)
  15135. * @returns a new Mesh
  15136. */
  15137. 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;
  15138. /**
  15139. * Creates lathe mesh.
  15140. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  15141. * Please consider using the same method from the MeshBuilder class instead
  15142. * @param name defines the name of the mesh to create
  15143. * @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
  15144. * @param radius is the radius value of the lathe
  15145. * @param tessellation is the side number of the lathe.
  15146. * @param scene defines the hosting scene
  15147. * @param updatable defines if the mesh must be flagged as updatable
  15148. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15149. * @returns a new Mesh
  15150. */
  15151. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  15152. /**
  15153. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  15154. * @param name defines the name of the mesh to create
  15155. * @param size sets the size (float) of both sides of the plane at once (default 1)
  15156. * @param scene defines the hosting scene
  15157. * @param updatable defines if the mesh must be flagged as updatable
  15158. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15159. * @returns a new Mesh
  15160. */
  15161. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  15162. /**
  15163. * Creates a ground mesh.
  15164. * Please consider using the same method from the MeshBuilder class instead
  15165. * @param name defines the name of the mesh to create
  15166. * @param width set the width of the ground
  15167. * @param height set the height of the ground
  15168. * @param subdivisions sets the number of subdivisions per side
  15169. * @param scene defines the hosting scene
  15170. * @param updatable defines if the mesh must be flagged as updatable
  15171. * @returns a new Mesh
  15172. */
  15173. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  15174. /**
  15175. * Creates a tiled ground mesh.
  15176. * Please consider using the same method from the MeshBuilder class instead
  15177. * @param name defines the name of the mesh to create
  15178. * @param xmin set the ground minimum X coordinate
  15179. * @param zmin set the ground minimum Y coordinate
  15180. * @param xmax set the ground maximum X coordinate
  15181. * @param zmax set the ground maximum Z coordinate
  15182. * @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
  15183. * @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
  15184. * @param scene defines the hosting scene
  15185. * @param updatable defines if the mesh must be flagged as updatable
  15186. * @returns a new Mesh
  15187. */
  15188. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  15189. w: number;
  15190. h: number;
  15191. }, precision: {
  15192. w: number;
  15193. h: number;
  15194. }, scene: Scene, updatable?: boolean): Mesh;
  15195. /**
  15196. * Creates a ground mesh from a height map.
  15197. * Please consider using the same method from the MeshBuilder class instead
  15198. * @see http://doc.babylonjs.com/babylon101/height_map
  15199. * @param name defines the name of the mesh to create
  15200. * @param url sets the URL of the height map image resource
  15201. * @param width set the ground width size
  15202. * @param height set the ground height size
  15203. * @param subdivisions sets the number of subdivision per side
  15204. * @param minHeight is the minimum altitude on the ground
  15205. * @param maxHeight is the maximum altitude on the ground
  15206. * @param scene defines the hosting scene
  15207. * @param updatable defines if the mesh must be flagged as updatable
  15208. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  15209. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  15210. * @returns a new Mesh
  15211. */
  15212. 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;
  15213. /**
  15214. * Creates a tube mesh.
  15215. * The tube is a parametric shape.
  15216. * It has no predefined shape. Its final shape will depend on the input parameters.
  15217. * Please consider using the same method from the MeshBuilder class instead
  15218. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  15219. * @param name defines the name of the mesh to create
  15220. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  15221. * @param radius sets the tube radius size
  15222. * @param tessellation is the number of sides on the tubular surface
  15223. * @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
  15224. * @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
  15225. * @param scene defines the hosting scene
  15226. * @param updatable defines if the mesh must be flagged as updatable
  15227. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15228. * @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)
  15229. * @returns a new Mesh
  15230. */
  15231. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  15232. (i: number, distance: number): number;
  15233. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  15234. /**
  15235. * Creates a polyhedron mesh.
  15236. * Please consider using the same method from the MeshBuilder class instead.
  15237. * * 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
  15238. * * The parameter `size` (positive float, default 1) sets the polygon size
  15239. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  15240. * * 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`
  15241. * * 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
  15242. * * 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)`)
  15243. * * 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
  15244. * * 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
  15245. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  15246. * * If you create a double-sided mesh, you can choose what parts of 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
  15247. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  15248. * @param name defines the name of the mesh to create
  15249. * @param options defines the options used to create the mesh
  15250. * @param scene defines the hosting scene
  15251. * @returns a new Mesh
  15252. */
  15253. static CreatePolyhedron(name: string, options: {
  15254. type?: number;
  15255. size?: number;
  15256. sizeX?: number;
  15257. sizeY?: number;
  15258. sizeZ?: number;
  15259. custom?: any;
  15260. faceUV?: Vector4[];
  15261. faceColors?: Color4[];
  15262. updatable?: boolean;
  15263. sideOrientation?: number;
  15264. }, scene: Scene): Mesh;
  15265. /**
  15266. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  15267. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  15268. * * 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`)
  15269. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  15270. * * 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
  15271. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  15272. * * If you create a double-sided mesh, you can choose what parts of 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
  15273. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  15274. * @param name defines the name of the mesh
  15275. * @param options defines the options used to create the mesh
  15276. * @param scene defines the hosting scene
  15277. * @returns a new Mesh
  15278. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  15279. */
  15280. static CreateIcoSphere(name: string, options: {
  15281. radius?: number;
  15282. flat?: boolean;
  15283. subdivisions?: number;
  15284. sideOrientation?: number;
  15285. updatable?: boolean;
  15286. }, scene: Scene): Mesh;
  15287. /**
  15288. * Creates a decal mesh.
  15289. * Please consider using the same method from the MeshBuilder class instead.
  15290. * A decal is a mesh usually applied as a model onto the surface of another mesh
  15291. * @param name defines the name of the mesh
  15292. * @param sourceMesh defines the mesh receiving the decal
  15293. * @param position sets the position of the decal in world coordinates
  15294. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  15295. * @param size sets the decal scaling
  15296. * @param angle sets the angle to rotate the decal
  15297. * @returns a new Mesh
  15298. */
  15299. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  15300. /**
  15301. * Prepare internal position array for software CPU skinning
  15302. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  15303. */
  15304. setPositionsForCPUSkinning(): Float32Array;
  15305. /**
  15306. * Prepare internal normal array for software CPU skinning
  15307. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  15308. */
  15309. setNormalsForCPUSkinning(): Float32Array;
  15310. /**
  15311. * Updates the vertex buffer by applying transformation from the bones
  15312. * @param skeleton defines the skeleton to apply to current mesh
  15313. * @returns the current mesh
  15314. */
  15315. applySkeleton(skeleton: Skeleton): Mesh;
  15316. /**
  15317. * 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
  15318. * @param meshes defines the list of meshes to scan
  15319. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  15320. */
  15321. static MinMax(meshes: AbstractMesh[]): {
  15322. min: Vector3;
  15323. max: Vector3;
  15324. };
  15325. /**
  15326. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  15327. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  15328. * @returns a vector3
  15329. */
  15330. static Center(meshesOrMinMaxVector: {
  15331. min: Vector3;
  15332. max: Vector3;
  15333. } | AbstractMesh[]): Vector3;
  15334. /**
  15335. * Merge the array of meshes into a single mesh for performance reasons.
  15336. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  15337. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  15338. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  15339. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  15340. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  15341. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  15342. * @returns a new mesh
  15343. */
  15344. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  15345. /** @hidden */
  15346. addInstance(instance: InstancedMesh): void;
  15347. /** @hidden */
  15348. removeInstance(instance: InstancedMesh): void;
  15349. }
  15350. }
  15351. declare module "babylonjs/Actions/action" {
  15352. import { Observable } from "babylonjs/Misc/observable";
  15353. import { Condition } from "babylonjs/Actions/condition";
  15354. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  15355. import { ActionManager } from "babylonjs/Actions/actionManager";
  15356. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  15357. /**
  15358. * Interface used to define Action
  15359. */
  15360. export interface IAction {
  15361. /**
  15362. * Trigger for the action
  15363. */
  15364. trigger: number;
  15365. /** Options of the trigger */
  15366. triggerOptions: any;
  15367. /**
  15368. * Gets the trigger parameters
  15369. * @returns the trigger parameters
  15370. */
  15371. getTriggerParameter(): any;
  15372. /**
  15373. * Internal only - executes current action event
  15374. * @hidden
  15375. */
  15376. _executeCurrent(evt?: ActionEvent): void;
  15377. /**
  15378. * Serialize placeholder for child classes
  15379. * @param parent of child
  15380. * @returns the serialized object
  15381. */
  15382. serialize(parent: any): any;
  15383. /**
  15384. * Internal only
  15385. * @hidden
  15386. */
  15387. _prepare(): void;
  15388. /**
  15389. * Internal only - manager for action
  15390. * @hidden
  15391. */
  15392. _actionManager: AbstractActionManager;
  15393. /**
  15394. * Adds action to chain of actions, may be a DoNothingAction
  15395. * @param action defines the next action to execute
  15396. * @returns The action passed in
  15397. * @see https://www.babylonjs-playground.com/#1T30HR#0
  15398. */
  15399. then(action: IAction): IAction;
  15400. }
  15401. /**
  15402. * The action to be carried out following a trigger
  15403. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  15404. */
  15405. export class Action implements IAction {
  15406. /** the trigger, with or without parameters, for the action */
  15407. triggerOptions: any;
  15408. /**
  15409. * Trigger for the action
  15410. */
  15411. trigger: number;
  15412. /**
  15413. * Internal only - manager for action
  15414. * @hidden
  15415. */
  15416. _actionManager: ActionManager;
  15417. private _nextActiveAction;
  15418. private _child;
  15419. private _condition?;
  15420. private _triggerParameter;
  15421. /**
  15422. * An event triggered prior to action being executed.
  15423. */
  15424. onBeforeExecuteObservable: Observable<Action>;
  15425. /**
  15426. * Creates a new Action
  15427. * @param triggerOptions the trigger, with or without parameters, for the action
  15428. * @param condition an optional determinant of action
  15429. */
  15430. constructor(
  15431. /** the trigger, with or without parameters, for the action */
  15432. triggerOptions: any, condition?: Condition);
  15433. /**
  15434. * Internal only
  15435. * @hidden
  15436. */
  15437. _prepare(): void;
  15438. /**
  15439. * Gets the trigger parameters
  15440. * @returns the trigger parameters
  15441. */
  15442. getTriggerParameter(): any;
  15443. /**
  15444. * Internal only - executes current action event
  15445. * @hidden
  15446. */
  15447. _executeCurrent(evt?: ActionEvent): void;
  15448. /**
  15449. * Execute placeholder for child classes
  15450. * @param evt optional action event
  15451. */
  15452. execute(evt?: ActionEvent): void;
  15453. /**
  15454. * Skips to next active action
  15455. */
  15456. skipToNextActiveAction(): void;
  15457. /**
  15458. * Adds action to chain of actions, may be a DoNothingAction
  15459. * @param action defines the next action to execute
  15460. * @returns The action passed in
  15461. * @see https://www.babylonjs-playground.com/#1T30HR#0
  15462. */
  15463. then(action: Action): Action;
  15464. /**
  15465. * Internal only
  15466. * @hidden
  15467. */
  15468. _getProperty(propertyPath: string): string;
  15469. /**
  15470. * Internal only
  15471. * @hidden
  15472. */
  15473. _getEffectiveTarget(target: any, propertyPath: string): any;
  15474. /**
  15475. * Serialize placeholder for child classes
  15476. * @param parent of child
  15477. * @returns the serialized object
  15478. */
  15479. serialize(parent: any): any;
  15480. /**
  15481. * Internal only called by serialize
  15482. * @hidden
  15483. */
  15484. protected _serialize(serializedAction: any, parent?: any): any;
  15485. /**
  15486. * Internal only
  15487. * @hidden
  15488. */
  15489. static _SerializeValueAsString: (value: any) => string;
  15490. /**
  15491. * Internal only
  15492. * @hidden
  15493. */
  15494. static _GetTargetProperty: (target: import("babylonjs/scene").Scene | import("babylonjs/node").Node) => {
  15495. name: string;
  15496. targetType: string;
  15497. value: string;
  15498. };
  15499. }
  15500. }
  15501. declare module "babylonjs/Actions/condition" {
  15502. import { ActionManager } from "babylonjs/Actions/actionManager";
  15503. /**
  15504. * A Condition applied to an Action
  15505. */
  15506. export class Condition {
  15507. /**
  15508. * Internal only - manager for action
  15509. * @hidden
  15510. */
  15511. _actionManager: ActionManager;
  15512. /**
  15513. * Internal only
  15514. * @hidden
  15515. */
  15516. _evaluationId: number;
  15517. /**
  15518. * Internal only
  15519. * @hidden
  15520. */
  15521. _currentResult: boolean;
  15522. /**
  15523. * Creates a new Condition
  15524. * @param actionManager the manager of the action the condition is applied to
  15525. */
  15526. constructor(actionManager: ActionManager);
  15527. /**
  15528. * Check if the current condition is valid
  15529. * @returns a boolean
  15530. */
  15531. isValid(): boolean;
  15532. /**
  15533. * Internal only
  15534. * @hidden
  15535. */
  15536. _getProperty(propertyPath: string): string;
  15537. /**
  15538. * Internal only
  15539. * @hidden
  15540. */
  15541. _getEffectiveTarget(target: any, propertyPath: string): any;
  15542. /**
  15543. * Serialize placeholder for child classes
  15544. * @returns the serialized object
  15545. */
  15546. serialize(): any;
  15547. /**
  15548. * Internal only
  15549. * @hidden
  15550. */
  15551. protected _serialize(serializedCondition: any): any;
  15552. }
  15553. /**
  15554. * Defines specific conditional operators as extensions of Condition
  15555. */
  15556. export class ValueCondition extends Condition {
  15557. /** path to specify the property of the target the conditional operator uses */
  15558. propertyPath: string;
  15559. /** the value compared by the conditional operator against the current value of the property */
  15560. value: any;
  15561. /** the conditional operator, default ValueCondition.IsEqual */
  15562. operator: number;
  15563. /**
  15564. * Internal only
  15565. * @hidden
  15566. */
  15567. private static _IsEqual;
  15568. /**
  15569. * Internal only
  15570. * @hidden
  15571. */
  15572. private static _IsDifferent;
  15573. /**
  15574. * Internal only
  15575. * @hidden
  15576. */
  15577. private static _IsGreater;
  15578. /**
  15579. * Internal only
  15580. * @hidden
  15581. */
  15582. private static _IsLesser;
  15583. /**
  15584. * returns the number for IsEqual
  15585. */
  15586. static readonly IsEqual: number;
  15587. /**
  15588. * Returns the number for IsDifferent
  15589. */
  15590. static readonly IsDifferent: number;
  15591. /**
  15592. * Returns the number for IsGreater
  15593. */
  15594. static readonly IsGreater: number;
  15595. /**
  15596. * Returns the number for IsLesser
  15597. */
  15598. static readonly IsLesser: number;
  15599. /**
  15600. * Internal only The action manager for the condition
  15601. * @hidden
  15602. */
  15603. _actionManager: ActionManager;
  15604. /**
  15605. * Internal only
  15606. * @hidden
  15607. */
  15608. private _target;
  15609. /**
  15610. * Internal only
  15611. * @hidden
  15612. */
  15613. private _effectiveTarget;
  15614. /**
  15615. * Internal only
  15616. * @hidden
  15617. */
  15618. private _property;
  15619. /**
  15620. * Creates a new ValueCondition
  15621. * @param actionManager manager for the action the condition applies to
  15622. * @param target for the action
  15623. * @param propertyPath path to specify the property of the target the conditional operator uses
  15624. * @param value the value compared by the conditional operator against the current value of the property
  15625. * @param operator the conditional operator, default ValueCondition.IsEqual
  15626. */
  15627. constructor(actionManager: ActionManager, target: any,
  15628. /** path to specify the property of the target the conditional operator uses */
  15629. propertyPath: string,
  15630. /** the value compared by the conditional operator against the current value of the property */
  15631. value: any,
  15632. /** the conditional operator, default ValueCondition.IsEqual */
  15633. operator?: number);
  15634. /**
  15635. * Compares the given value with the property value for the specified conditional operator
  15636. * @returns the result of the comparison
  15637. */
  15638. isValid(): boolean;
  15639. /**
  15640. * Serialize the ValueCondition into a JSON compatible object
  15641. * @returns serialization object
  15642. */
  15643. serialize(): any;
  15644. /**
  15645. * Gets the name of the conditional operator for the ValueCondition
  15646. * @param operator the conditional operator
  15647. * @returns the name
  15648. */
  15649. static GetOperatorName(operator: number): string;
  15650. }
  15651. /**
  15652. * Defines a predicate condition as an extension of Condition
  15653. */
  15654. export class PredicateCondition extends Condition {
  15655. /** defines the predicate function used to validate the condition */
  15656. predicate: () => boolean;
  15657. /**
  15658. * Internal only - manager for action
  15659. * @hidden
  15660. */
  15661. _actionManager: ActionManager;
  15662. /**
  15663. * Creates a new PredicateCondition
  15664. * @param actionManager manager for the action the condition applies to
  15665. * @param predicate defines the predicate function used to validate the condition
  15666. */
  15667. constructor(actionManager: ActionManager,
  15668. /** defines the predicate function used to validate the condition */
  15669. predicate: () => boolean);
  15670. /**
  15671. * @returns the validity of the predicate condition
  15672. */
  15673. isValid(): boolean;
  15674. }
  15675. /**
  15676. * Defines a state condition as an extension of Condition
  15677. */
  15678. export class StateCondition extends Condition {
  15679. /** Value to compare with target state */
  15680. value: string;
  15681. /**
  15682. * Internal only - manager for action
  15683. * @hidden
  15684. */
  15685. _actionManager: ActionManager;
  15686. /**
  15687. * Internal only
  15688. * @hidden
  15689. */
  15690. private _target;
  15691. /**
  15692. * Creates a new StateCondition
  15693. * @param actionManager manager for the action the condition applies to
  15694. * @param target of the condition
  15695. * @param value to compare with target state
  15696. */
  15697. constructor(actionManager: ActionManager, target: any,
  15698. /** Value to compare with target state */
  15699. value: string);
  15700. /**
  15701. * Gets a boolean indicating if the current condition is met
  15702. * @returns the validity of the state
  15703. */
  15704. isValid(): boolean;
  15705. /**
  15706. * Serialize the StateCondition into a JSON compatible object
  15707. * @returns serialization object
  15708. */
  15709. serialize(): any;
  15710. }
  15711. }
  15712. declare module "babylonjs/Actions/directActions" {
  15713. import { Action } from "babylonjs/Actions/action";
  15714. import { Condition } from "babylonjs/Actions/condition";
  15715. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  15716. /**
  15717. * This defines an action responsible to toggle a boolean once triggered.
  15718. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15719. */
  15720. export class SwitchBooleanAction extends Action {
  15721. /**
  15722. * The path to the boolean property in the target object
  15723. */
  15724. propertyPath: string;
  15725. private _target;
  15726. private _effectiveTarget;
  15727. private _property;
  15728. /**
  15729. * Instantiate the action
  15730. * @param triggerOptions defines the trigger options
  15731. * @param target defines the object containing the boolean
  15732. * @param propertyPath defines the path to the boolean property in the target object
  15733. * @param condition defines the trigger related conditions
  15734. */
  15735. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  15736. /** @hidden */
  15737. _prepare(): void;
  15738. /**
  15739. * Execute the action toggle the boolean value.
  15740. */
  15741. execute(): void;
  15742. /**
  15743. * Serializes the actions and its related information.
  15744. * @param parent defines the object to serialize in
  15745. * @returns the serialized object
  15746. */
  15747. serialize(parent: any): any;
  15748. }
  15749. /**
  15750. * This defines an action responsible to set a the state field of the target
  15751. * to a desired value once triggered.
  15752. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15753. */
  15754. export class SetStateAction extends Action {
  15755. /**
  15756. * The value to store in the state field.
  15757. */
  15758. value: string;
  15759. private _target;
  15760. /**
  15761. * Instantiate the action
  15762. * @param triggerOptions defines the trigger options
  15763. * @param target defines the object containing the state property
  15764. * @param value defines the value to store in the state field
  15765. * @param condition defines the trigger related conditions
  15766. */
  15767. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  15768. /**
  15769. * Execute the action and store the value on the target state property.
  15770. */
  15771. execute(): void;
  15772. /**
  15773. * Serializes the actions and its related information.
  15774. * @param parent defines the object to serialize in
  15775. * @returns the serialized object
  15776. */
  15777. serialize(parent: any): any;
  15778. }
  15779. /**
  15780. * This defines an action responsible to set a property of the target
  15781. * to a desired value once triggered.
  15782. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15783. */
  15784. export class SetValueAction extends Action {
  15785. /**
  15786. * The path of the property to set in the target.
  15787. */
  15788. propertyPath: string;
  15789. /**
  15790. * The value to set in the property
  15791. */
  15792. value: any;
  15793. private _target;
  15794. private _effectiveTarget;
  15795. private _property;
  15796. /**
  15797. * Instantiate the action
  15798. * @param triggerOptions defines the trigger options
  15799. * @param target defines the object containing the property
  15800. * @param propertyPath defines the path of the property to set in the target
  15801. * @param value defines the value to set in the property
  15802. * @param condition defines the trigger related conditions
  15803. */
  15804. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  15805. /** @hidden */
  15806. _prepare(): void;
  15807. /**
  15808. * Execute the action and set the targetted property to the desired value.
  15809. */
  15810. execute(): void;
  15811. /**
  15812. * Serializes the actions and its related information.
  15813. * @param parent defines the object to serialize in
  15814. * @returns the serialized object
  15815. */
  15816. serialize(parent: any): any;
  15817. }
  15818. /**
  15819. * This defines an action responsible to increment the target value
  15820. * to a desired value once triggered.
  15821. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15822. */
  15823. export class IncrementValueAction extends Action {
  15824. /**
  15825. * The path of the property to increment in the target.
  15826. */
  15827. propertyPath: string;
  15828. /**
  15829. * The value we should increment the property by.
  15830. */
  15831. value: any;
  15832. private _target;
  15833. private _effectiveTarget;
  15834. private _property;
  15835. /**
  15836. * Instantiate the action
  15837. * @param triggerOptions defines the trigger options
  15838. * @param target defines the object containing the property
  15839. * @param propertyPath defines the path of the property to increment in the target
  15840. * @param value defines the value value we should increment the property by
  15841. * @param condition defines the trigger related conditions
  15842. */
  15843. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  15844. /** @hidden */
  15845. _prepare(): void;
  15846. /**
  15847. * Execute the action and increment the target of the value amount.
  15848. */
  15849. execute(): void;
  15850. /**
  15851. * Serializes the actions and its related information.
  15852. * @param parent defines the object to serialize in
  15853. * @returns the serialized object
  15854. */
  15855. serialize(parent: any): any;
  15856. }
  15857. /**
  15858. * This defines an action responsible to start an animation once triggered.
  15859. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15860. */
  15861. export class PlayAnimationAction extends Action {
  15862. /**
  15863. * Where the animation should start (animation frame)
  15864. */
  15865. from: number;
  15866. /**
  15867. * Where the animation should stop (animation frame)
  15868. */
  15869. to: number;
  15870. /**
  15871. * Define if the animation should loop or stop after the first play.
  15872. */
  15873. loop?: boolean;
  15874. private _target;
  15875. /**
  15876. * Instantiate the action
  15877. * @param triggerOptions defines the trigger options
  15878. * @param target defines the target animation or animation name
  15879. * @param from defines from where the animation should start (animation frame)
  15880. * @param end defines where the animation should stop (animation frame)
  15881. * @param loop defines if the animation should loop or stop after the first play
  15882. * @param condition defines the trigger related conditions
  15883. */
  15884. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  15885. /** @hidden */
  15886. _prepare(): void;
  15887. /**
  15888. * Execute the action and play the animation.
  15889. */
  15890. execute(): void;
  15891. /**
  15892. * Serializes the actions and its related information.
  15893. * @param parent defines the object to serialize in
  15894. * @returns the serialized object
  15895. */
  15896. serialize(parent: any): any;
  15897. }
  15898. /**
  15899. * This defines an action responsible to stop an animation once triggered.
  15900. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15901. */
  15902. export class StopAnimationAction extends Action {
  15903. private _target;
  15904. /**
  15905. * Instantiate the action
  15906. * @param triggerOptions defines the trigger options
  15907. * @param target defines the target animation or animation name
  15908. * @param condition defines the trigger related conditions
  15909. */
  15910. constructor(triggerOptions: any, target: any, condition?: Condition);
  15911. /** @hidden */
  15912. _prepare(): void;
  15913. /**
  15914. * Execute the action and stop the animation.
  15915. */
  15916. execute(): void;
  15917. /**
  15918. * Serializes the actions and its related information.
  15919. * @param parent defines the object to serialize in
  15920. * @returns the serialized object
  15921. */
  15922. serialize(parent: any): any;
  15923. }
  15924. /**
  15925. * This defines an action responsible that does nothing once triggered.
  15926. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15927. */
  15928. export class DoNothingAction extends Action {
  15929. /**
  15930. * Instantiate the action
  15931. * @param triggerOptions defines the trigger options
  15932. * @param condition defines the trigger related conditions
  15933. */
  15934. constructor(triggerOptions?: any, condition?: Condition);
  15935. /**
  15936. * Execute the action and do nothing.
  15937. */
  15938. execute(): void;
  15939. /**
  15940. * Serializes the actions and its related information.
  15941. * @param parent defines the object to serialize in
  15942. * @returns the serialized object
  15943. */
  15944. serialize(parent: any): any;
  15945. }
  15946. /**
  15947. * This defines an action responsible to trigger several actions once triggered.
  15948. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15949. */
  15950. export class CombineAction extends Action {
  15951. /**
  15952. * The list of aggregated animations to run.
  15953. */
  15954. children: Action[];
  15955. /**
  15956. * Instantiate the action
  15957. * @param triggerOptions defines the trigger options
  15958. * @param children defines the list of aggregated animations to run
  15959. * @param condition defines the trigger related conditions
  15960. */
  15961. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  15962. /** @hidden */
  15963. _prepare(): void;
  15964. /**
  15965. * Execute the action and executes all the aggregated actions.
  15966. */
  15967. execute(evt: ActionEvent): void;
  15968. /**
  15969. * Serializes the actions and its related information.
  15970. * @param parent defines the object to serialize in
  15971. * @returns the serialized object
  15972. */
  15973. serialize(parent: any): any;
  15974. }
  15975. /**
  15976. * This defines an action responsible to run code (external event) once triggered.
  15977. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15978. */
  15979. export class ExecuteCodeAction extends Action {
  15980. /**
  15981. * The callback function to run.
  15982. */
  15983. func: (evt: ActionEvent) => void;
  15984. /**
  15985. * Instantiate the action
  15986. * @param triggerOptions defines the trigger options
  15987. * @param func defines the callback function to run
  15988. * @param condition defines the trigger related conditions
  15989. */
  15990. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  15991. /**
  15992. * Execute the action and run the attached code.
  15993. */
  15994. execute(evt: ActionEvent): void;
  15995. }
  15996. /**
  15997. * This defines an action responsible to set the parent property of the target once triggered.
  15998. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15999. */
  16000. export class SetParentAction extends Action {
  16001. private _parent;
  16002. private _target;
  16003. /**
  16004. * Instantiate the action
  16005. * @param triggerOptions defines the trigger options
  16006. * @param target defines the target containing the parent property
  16007. * @param parent defines from where the animation should start (animation frame)
  16008. * @param condition defines the trigger related conditions
  16009. */
  16010. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  16011. /** @hidden */
  16012. _prepare(): void;
  16013. /**
  16014. * Execute the action and set the parent property.
  16015. */
  16016. execute(): void;
  16017. /**
  16018. * Serializes the actions and its related information.
  16019. * @param parent defines the object to serialize in
  16020. * @returns the serialized object
  16021. */
  16022. serialize(parent: any): any;
  16023. }
  16024. }
  16025. declare module "babylonjs/Actions/actionManager" {
  16026. import { Nullable } from "babylonjs/types";
  16027. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16028. import { Scene } from "babylonjs/scene";
  16029. import { IAction } from "babylonjs/Actions/action";
  16030. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  16031. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  16032. /**
  16033. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  16034. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  16035. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  16036. */
  16037. export class ActionManager extends AbstractActionManager {
  16038. /**
  16039. * Nothing
  16040. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16041. */
  16042. static readonly NothingTrigger: number;
  16043. /**
  16044. * On pick
  16045. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16046. */
  16047. static readonly OnPickTrigger: number;
  16048. /**
  16049. * On left pick
  16050. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16051. */
  16052. static readonly OnLeftPickTrigger: number;
  16053. /**
  16054. * On right pick
  16055. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16056. */
  16057. static readonly OnRightPickTrigger: number;
  16058. /**
  16059. * On center pick
  16060. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16061. */
  16062. static readonly OnCenterPickTrigger: number;
  16063. /**
  16064. * On pick down
  16065. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16066. */
  16067. static readonly OnPickDownTrigger: number;
  16068. /**
  16069. * On double pick
  16070. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16071. */
  16072. static readonly OnDoublePickTrigger: number;
  16073. /**
  16074. * On pick up
  16075. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16076. */
  16077. static readonly OnPickUpTrigger: number;
  16078. /**
  16079. * On pick out.
  16080. * This trigger will only be raised if you also declared a OnPickDown
  16081. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16082. */
  16083. static readonly OnPickOutTrigger: number;
  16084. /**
  16085. * On long press
  16086. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16087. */
  16088. static readonly OnLongPressTrigger: number;
  16089. /**
  16090. * On pointer over
  16091. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16092. */
  16093. static readonly OnPointerOverTrigger: number;
  16094. /**
  16095. * On pointer out
  16096. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16097. */
  16098. static readonly OnPointerOutTrigger: number;
  16099. /**
  16100. * On every frame
  16101. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16102. */
  16103. static readonly OnEveryFrameTrigger: number;
  16104. /**
  16105. * On intersection enter
  16106. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16107. */
  16108. static readonly OnIntersectionEnterTrigger: number;
  16109. /**
  16110. * On intersection exit
  16111. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16112. */
  16113. static readonly OnIntersectionExitTrigger: number;
  16114. /**
  16115. * On key down
  16116. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16117. */
  16118. static readonly OnKeyDownTrigger: number;
  16119. /**
  16120. * On key up
  16121. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16122. */
  16123. static readonly OnKeyUpTrigger: number;
  16124. private _scene;
  16125. /**
  16126. * Creates a new action manager
  16127. * @param scene defines the hosting scene
  16128. */
  16129. constructor(scene: Scene);
  16130. /**
  16131. * Releases all associated resources
  16132. */
  16133. dispose(): void;
  16134. /**
  16135. * Gets hosting scene
  16136. * @returns the hosting scene
  16137. */
  16138. getScene(): Scene;
  16139. /**
  16140. * Does this action manager handles actions of any of the given triggers
  16141. * @param triggers defines the triggers to be tested
  16142. * @return a boolean indicating whether one (or more) of the triggers is handled
  16143. */
  16144. hasSpecificTriggers(triggers: number[]): boolean;
  16145. /**
  16146. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  16147. * speed.
  16148. * @param triggerA defines the trigger to be tested
  16149. * @param triggerB defines the trigger to be tested
  16150. * @return a boolean indicating whether one (or more) of the triggers is handled
  16151. */
  16152. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  16153. /**
  16154. * Does this action manager handles actions of a given trigger
  16155. * @param trigger defines the trigger to be tested
  16156. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  16157. * @return whether the trigger is handled
  16158. */
  16159. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  16160. /**
  16161. * Does this action manager has pointer triggers
  16162. */
  16163. readonly hasPointerTriggers: boolean;
  16164. /**
  16165. * Does this action manager has pick triggers
  16166. */
  16167. readonly hasPickTriggers: boolean;
  16168. /**
  16169. * Registers an action to this action manager
  16170. * @param action defines the action to be registered
  16171. * @return the action amended (prepared) after registration
  16172. */
  16173. registerAction(action: IAction): Nullable<IAction>;
  16174. /**
  16175. * Unregisters an action to this action manager
  16176. * @param action defines the action to be unregistered
  16177. * @return a boolean indicating whether the action has been unregistered
  16178. */
  16179. unregisterAction(action: IAction): Boolean;
  16180. /**
  16181. * Process a specific trigger
  16182. * @param trigger defines the trigger to process
  16183. * @param evt defines the event details to be processed
  16184. */
  16185. processTrigger(trigger: number, evt?: IActionEvent): void;
  16186. /** @hidden */
  16187. _getEffectiveTarget(target: any, propertyPath: string): any;
  16188. /** @hidden */
  16189. _getProperty(propertyPath: string): string;
  16190. /**
  16191. * Serialize this manager to a JSON object
  16192. * @param name defines the property name to store this manager
  16193. * @returns a JSON representation of this manager
  16194. */
  16195. serialize(name: string): any;
  16196. /**
  16197. * Creates a new ActionManager from a JSON data
  16198. * @param parsedActions defines the JSON data to read from
  16199. * @param object defines the hosting mesh
  16200. * @param scene defines the hosting scene
  16201. */
  16202. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  16203. /**
  16204. * Get a trigger name by index
  16205. * @param trigger defines the trigger index
  16206. * @returns a trigger name
  16207. */
  16208. static GetTriggerName(trigger: number): string;
  16209. }
  16210. }
  16211. declare module "babylonjs/Culling/ray" {
  16212. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  16213. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  16214. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16215. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  16216. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  16217. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  16218. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  16219. /**
  16220. * Class representing a ray with position and direction
  16221. */
  16222. export class Ray {
  16223. /** origin point */
  16224. origin: Vector3;
  16225. /** direction */
  16226. direction: Vector3;
  16227. /** length of the ray */
  16228. length: number;
  16229. private static readonly TmpVector3;
  16230. private _tmpRay;
  16231. /**
  16232. * Creates a new ray
  16233. * @param origin origin point
  16234. * @param direction direction
  16235. * @param length length of the ray
  16236. */
  16237. constructor(
  16238. /** origin point */
  16239. origin: Vector3,
  16240. /** direction */
  16241. direction: Vector3,
  16242. /** length of the ray */
  16243. length?: number);
  16244. /**
  16245. * Checks if the ray intersects a box
  16246. * @param minimum bound of the box
  16247. * @param maximum bound of the box
  16248. * @param intersectionTreshold extra extend to be added to the box in all direction
  16249. * @returns if the box was hit
  16250. */
  16251. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  16252. /**
  16253. * Checks if the ray intersects a box
  16254. * @param box the bounding box to check
  16255. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  16256. * @returns if the box was hit
  16257. */
  16258. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  16259. /**
  16260. * If the ray hits a sphere
  16261. * @param sphere the bounding sphere to check
  16262. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  16263. * @returns true if it hits the sphere
  16264. */
  16265. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  16266. /**
  16267. * If the ray hits a triange
  16268. * @param vertex0 triangle vertex
  16269. * @param vertex1 triangle vertex
  16270. * @param vertex2 triangle vertex
  16271. * @returns intersection information if hit
  16272. */
  16273. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  16274. /**
  16275. * Checks if ray intersects a plane
  16276. * @param plane the plane to check
  16277. * @returns the distance away it was hit
  16278. */
  16279. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  16280. /**
  16281. * Checks if ray intersects a mesh
  16282. * @param mesh the mesh to check
  16283. * @param fastCheck if only the bounding box should checked
  16284. * @returns picking info of the intersecton
  16285. */
  16286. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  16287. /**
  16288. * Checks if ray intersects a mesh
  16289. * @param meshes the meshes to check
  16290. * @param fastCheck if only the bounding box should checked
  16291. * @param results array to store result in
  16292. * @returns Array of picking infos
  16293. */
  16294. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  16295. private _comparePickingInfo;
  16296. private static smallnum;
  16297. private static rayl;
  16298. /**
  16299. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  16300. * @param sega the first point of the segment to test the intersection against
  16301. * @param segb the second point of the segment to test the intersection against
  16302. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  16303. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  16304. */
  16305. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  16306. /**
  16307. * Update the ray from viewport position
  16308. * @param x position
  16309. * @param y y position
  16310. * @param viewportWidth viewport width
  16311. * @param viewportHeight viewport height
  16312. * @param world world matrix
  16313. * @param view view matrix
  16314. * @param projection projection matrix
  16315. * @returns this ray updated
  16316. */
  16317. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  16318. /**
  16319. * Creates a ray with origin and direction of 0,0,0
  16320. * @returns the new ray
  16321. */
  16322. static Zero(): Ray;
  16323. /**
  16324. * Creates a new ray from screen space and viewport
  16325. * @param x position
  16326. * @param y y position
  16327. * @param viewportWidth viewport width
  16328. * @param viewportHeight viewport height
  16329. * @param world world matrix
  16330. * @param view view matrix
  16331. * @param projection projection matrix
  16332. * @returns new ray
  16333. */
  16334. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  16335. /**
  16336. * 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
  16337. * transformed to the given world matrix.
  16338. * @param origin The origin point
  16339. * @param end The end point
  16340. * @param world a matrix to transform the ray to. Default is the identity matrix.
  16341. * @returns the new ray
  16342. */
  16343. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  16344. /**
  16345. * Transforms a ray by a matrix
  16346. * @param ray ray to transform
  16347. * @param matrix matrix to apply
  16348. * @returns the resulting new ray
  16349. */
  16350. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  16351. /**
  16352. * Transforms a ray by a matrix
  16353. * @param ray ray to transform
  16354. * @param matrix matrix to apply
  16355. * @param result ray to store result in
  16356. */
  16357. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  16358. /**
  16359. * Unproject a ray from screen space to object space
  16360. * @param sourceX defines the screen space x coordinate to use
  16361. * @param sourceY defines the screen space y coordinate to use
  16362. * @param viewportWidth defines the current width of the viewport
  16363. * @param viewportHeight defines the current height of the viewport
  16364. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  16365. * @param view defines the view matrix to use
  16366. * @param projection defines the projection matrix to use
  16367. */
  16368. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  16369. }
  16370. /**
  16371. * Type used to define predicate used to select faces when a mesh intersection is detected
  16372. */
  16373. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  16374. module "babylonjs/scene" {
  16375. interface Scene {
  16376. /** @hidden */
  16377. _tempPickingRay: Nullable<Ray>;
  16378. /** @hidden */
  16379. _cachedRayForTransform: Ray;
  16380. /** @hidden */
  16381. _pickWithRayInverseMatrix: Matrix;
  16382. /** @hidden */
  16383. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  16384. /** @hidden */
  16385. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  16386. }
  16387. }
  16388. }
  16389. declare module "babylonjs/Sprites/spriteSceneComponent" {
  16390. import { Nullable } from "babylonjs/types";
  16391. import { Observable } from "babylonjs/Misc/observable";
  16392. import { Scene } from "babylonjs/scene";
  16393. import { Sprite } from "babylonjs/Sprites/sprite";
  16394. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16395. import { Ray } from "babylonjs/Culling/ray";
  16396. import { Camera } from "babylonjs/Cameras/camera";
  16397. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  16398. import { ISceneComponent } from "babylonjs/sceneComponent";
  16399. module "babylonjs/scene" {
  16400. interface Scene {
  16401. /** @hidden */
  16402. _pointerOverSprite: Nullable<Sprite>;
  16403. /** @hidden */
  16404. _pickedDownSprite: Nullable<Sprite>;
  16405. /** @hidden */
  16406. _tempSpritePickingRay: Nullable<Ray>;
  16407. /**
  16408. * All of the sprite managers added to this scene
  16409. * @see http://doc.babylonjs.com/babylon101/sprites
  16410. */
  16411. spriteManagers: Array<ISpriteManager>;
  16412. /**
  16413. * An event triggered when sprites rendering is about to start
  16414. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  16415. */
  16416. onBeforeSpritesRenderingObservable: Observable<Scene>;
  16417. /**
  16418. * An event triggered when sprites rendering is done
  16419. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  16420. */
  16421. onAfterSpritesRenderingObservable: Observable<Scene>;
  16422. /** @hidden */
  16423. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  16424. /** Launch a ray to try to pick a sprite in the scene
  16425. * @param x position on screen
  16426. * @param y position on screen
  16427. * @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
  16428. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  16429. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  16430. * @returns a PickingInfo
  16431. */
  16432. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  16433. /** Use the given ray to pick a sprite in the scene
  16434. * @param ray The ray (in world space) to use to pick meshes
  16435. * @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
  16436. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  16437. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  16438. * @returns a PickingInfo
  16439. */
  16440. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  16441. /**
  16442. * Force the sprite under the pointer
  16443. * @param sprite defines the sprite to use
  16444. */
  16445. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  16446. /**
  16447. * Gets the sprite under the pointer
  16448. * @returns a Sprite or null if no sprite is under the pointer
  16449. */
  16450. getPointerOverSprite(): Nullable<Sprite>;
  16451. }
  16452. }
  16453. /**
  16454. * Defines the sprite scene component responsible to manage sprites
  16455. * in a given scene.
  16456. */
  16457. export class SpriteSceneComponent implements ISceneComponent {
  16458. /**
  16459. * The component name helpfull to identify the component in the list of scene components.
  16460. */
  16461. readonly name: string;
  16462. /**
  16463. * The scene the component belongs to.
  16464. */
  16465. scene: Scene;
  16466. /** @hidden */
  16467. private _spritePredicate;
  16468. /**
  16469. * Creates a new instance of the component for the given scene
  16470. * @param scene Defines the scene to register the component in
  16471. */
  16472. constructor(scene: Scene);
  16473. /**
  16474. * Registers the component in a given scene
  16475. */
  16476. register(): void;
  16477. /**
  16478. * Rebuilds the elements related to this component in case of
  16479. * context lost for instance.
  16480. */
  16481. rebuild(): void;
  16482. /**
  16483. * Disposes the component and the associated ressources.
  16484. */
  16485. dispose(): void;
  16486. private _pickSpriteButKeepRay;
  16487. private _pointerMove;
  16488. private _pointerDown;
  16489. private _pointerUp;
  16490. }
  16491. }
  16492. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  16493. /** @hidden */
  16494. export var fogFragmentDeclaration: {
  16495. name: string;
  16496. shader: string;
  16497. };
  16498. }
  16499. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  16500. /** @hidden */
  16501. export var fogFragment: {
  16502. name: string;
  16503. shader: string;
  16504. };
  16505. }
  16506. declare module "babylonjs/Shaders/sprites.fragment" {
  16507. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  16508. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  16509. /** @hidden */
  16510. export var spritesPixelShader: {
  16511. name: string;
  16512. shader: string;
  16513. };
  16514. }
  16515. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  16516. /** @hidden */
  16517. export var fogVertexDeclaration: {
  16518. name: string;
  16519. shader: string;
  16520. };
  16521. }
  16522. declare module "babylonjs/Shaders/sprites.vertex" {
  16523. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  16524. /** @hidden */
  16525. export var spritesVertexShader: {
  16526. name: string;
  16527. shader: string;
  16528. };
  16529. }
  16530. declare module "babylonjs/Sprites/spriteManager" {
  16531. import { IDisposable, Scene } from "babylonjs/scene";
  16532. import { Nullable } from "babylonjs/types";
  16533. import { Observable } from "babylonjs/Misc/observable";
  16534. import { Sprite } from "babylonjs/Sprites/sprite";
  16535. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  16536. import { Camera } from "babylonjs/Cameras/camera";
  16537. import { Texture } from "babylonjs/Materials/Textures/texture";
  16538. import "babylonjs/Shaders/sprites.fragment";
  16539. import "babylonjs/Shaders/sprites.vertex";
  16540. import { Ray } from "babylonjs/Culling/ray";
  16541. /**
  16542. * Defines the minimum interface to fullfil in order to be a sprite manager.
  16543. */
  16544. export interface ISpriteManager extends IDisposable {
  16545. /**
  16546. * Restricts the camera to viewing objects with the same layerMask.
  16547. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  16548. */
  16549. layerMask: number;
  16550. /**
  16551. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  16552. */
  16553. isPickable: boolean;
  16554. /**
  16555. * Specifies the rendering group id for this mesh (0 by default)
  16556. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  16557. */
  16558. renderingGroupId: number;
  16559. /**
  16560. * Defines the list of sprites managed by the manager.
  16561. */
  16562. sprites: Array<Sprite>;
  16563. /**
  16564. * Tests the intersection of a sprite with a specific ray.
  16565. * @param ray The ray we are sending to test the collision
  16566. * @param camera The camera space we are sending rays in
  16567. * @param predicate A predicate allowing excluding sprites from the list of object to test
  16568. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  16569. * @returns picking info or null.
  16570. */
  16571. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  16572. /**
  16573. * Renders the list of sprites on screen.
  16574. */
  16575. render(): void;
  16576. }
  16577. /**
  16578. * Class used to manage multiple sprites on the same spritesheet
  16579. * @see http://doc.babylonjs.com/babylon101/sprites
  16580. */
  16581. export class SpriteManager implements ISpriteManager {
  16582. /** defines the manager's name */
  16583. name: string;
  16584. /** Gets the list of sprites */
  16585. sprites: Sprite[];
  16586. /** Gets or sets the rendering group id (0 by default) */
  16587. renderingGroupId: number;
  16588. /** Gets or sets camera layer mask */
  16589. layerMask: number;
  16590. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  16591. fogEnabled: boolean;
  16592. /** Gets or sets a boolean indicating if the sprites are pickable */
  16593. isPickable: boolean;
  16594. /** Defines the default width of a cell in the spritesheet */
  16595. cellWidth: number;
  16596. /** Defines the default height of a cell in the spritesheet */
  16597. cellHeight: number;
  16598. /**
  16599. * An event triggered when the manager is disposed.
  16600. */
  16601. onDisposeObservable: Observable<SpriteManager>;
  16602. private _onDisposeObserver;
  16603. /**
  16604. * Callback called when the manager is disposed
  16605. */
  16606. onDispose: () => void;
  16607. private _capacity;
  16608. private _spriteTexture;
  16609. private _epsilon;
  16610. private _scene;
  16611. private _vertexData;
  16612. private _buffer;
  16613. private _vertexBuffers;
  16614. private _indexBuffer;
  16615. private _effectBase;
  16616. private _effectFog;
  16617. /**
  16618. * Gets or sets the spritesheet texture
  16619. */
  16620. texture: Texture;
  16621. /**
  16622. * Creates a new sprite manager
  16623. * @param name defines the manager's name
  16624. * @param imgUrl defines the sprite sheet url
  16625. * @param capacity defines the maximum allowed number of sprites
  16626. * @param cellSize defines the size of a sprite cell
  16627. * @param scene defines the hosting scene
  16628. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  16629. * @param samplingMode defines the smapling mode to use with spritesheet
  16630. */
  16631. constructor(
  16632. /** defines the manager's name */
  16633. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  16634. private _appendSpriteVertex;
  16635. /**
  16636. * Intersects the sprites with a ray
  16637. * @param ray defines the ray to intersect with
  16638. * @param camera defines the current active camera
  16639. * @param predicate defines a predicate used to select candidate sprites
  16640. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  16641. * @returns null if no hit or a PickingInfo
  16642. */
  16643. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  16644. /**
  16645. * Render all child sprites
  16646. */
  16647. render(): void;
  16648. /**
  16649. * Release associated resources
  16650. */
  16651. dispose(): void;
  16652. }
  16653. }
  16654. declare module "babylonjs/Sprites/sprite" {
  16655. import { Vector3, Color4 } from "babylonjs/Maths/math";
  16656. import { Nullable } from "babylonjs/types";
  16657. import { ActionManager } from "babylonjs/Actions/actionManager";
  16658. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16659. /**
  16660. * Class used to represent a sprite
  16661. * @see http://doc.babylonjs.com/babylon101/sprites
  16662. */
  16663. export class Sprite {
  16664. /** defines the name */
  16665. name: string;
  16666. /** Gets or sets the current world position */
  16667. position: Vector3;
  16668. /** Gets or sets the main color */
  16669. color: Color4;
  16670. /** Gets or sets the width */
  16671. width: number;
  16672. /** Gets or sets the height */
  16673. height: number;
  16674. /** Gets or sets rotation angle */
  16675. angle: number;
  16676. /** Gets or sets the cell index in the sprite sheet */
  16677. cellIndex: number;
  16678. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  16679. invertU: number;
  16680. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  16681. invertV: number;
  16682. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  16683. disposeWhenFinishedAnimating: boolean;
  16684. /** Gets the list of attached animations */
  16685. animations: Animation[];
  16686. /** Gets or sets a boolean indicating if the sprite can be picked */
  16687. isPickable: boolean;
  16688. /**
  16689. * Gets or sets the associated action manager
  16690. */
  16691. actionManager: Nullable<ActionManager>;
  16692. private _animationStarted;
  16693. private _loopAnimation;
  16694. private _fromIndex;
  16695. private _toIndex;
  16696. private _delay;
  16697. private _direction;
  16698. private _manager;
  16699. private _time;
  16700. private _onAnimationEnd;
  16701. /**
  16702. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  16703. */
  16704. isVisible: boolean;
  16705. /**
  16706. * Gets or sets the sprite size
  16707. */
  16708. size: number;
  16709. /**
  16710. * Creates a new Sprite
  16711. * @param name defines the name
  16712. * @param manager defines the manager
  16713. */
  16714. constructor(
  16715. /** defines the name */
  16716. name: string, manager: ISpriteManager);
  16717. /**
  16718. * Starts an animation
  16719. * @param from defines the initial key
  16720. * @param to defines the end key
  16721. * @param loop defines if the animation must loop
  16722. * @param delay defines the start delay (in ms)
  16723. * @param onAnimationEnd defines a callback to call when animation ends
  16724. */
  16725. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  16726. /** Stops current animation (if any) */
  16727. stopAnimation(): void;
  16728. /** @hidden */
  16729. _animate(deltaTime: number): void;
  16730. /** Release associated resources */
  16731. dispose(): void;
  16732. }
  16733. }
  16734. declare module "babylonjs/Collisions/pickingInfo" {
  16735. import { Nullable } from "babylonjs/types";
  16736. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  16737. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16738. import { Sprite } from "babylonjs/Sprites/sprite";
  16739. import { Ray } from "babylonjs/Culling/ray";
  16740. /**
  16741. * Information about the result of picking within a scene
  16742. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  16743. */
  16744. export class PickingInfo {
  16745. /** @hidden */
  16746. _pickingUnavailable: boolean;
  16747. /**
  16748. * If the pick collided with an object
  16749. */
  16750. hit: boolean;
  16751. /**
  16752. * Distance away where the pick collided
  16753. */
  16754. distance: number;
  16755. /**
  16756. * The location of pick collision
  16757. */
  16758. pickedPoint: Nullable<Vector3>;
  16759. /**
  16760. * The mesh corresponding the the pick collision
  16761. */
  16762. pickedMesh: Nullable<AbstractMesh>;
  16763. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  16764. bu: number;
  16765. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  16766. bv: number;
  16767. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  16768. faceId: number;
  16769. /** Id of the the submesh that was picked */
  16770. subMeshId: number;
  16771. /** If a sprite was picked, this will be the sprite the pick collided with */
  16772. pickedSprite: Nullable<Sprite>;
  16773. /**
  16774. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  16775. */
  16776. originMesh: Nullable<AbstractMesh>;
  16777. /**
  16778. * The ray that was used to perform the picking.
  16779. */
  16780. ray: Nullable<Ray>;
  16781. /**
  16782. * Gets the normal correspodning to the face the pick collided with
  16783. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  16784. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  16785. * @returns The normal correspodning to the face the pick collided with
  16786. */
  16787. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  16788. /**
  16789. * Gets the texture coordinates of where the pick occured
  16790. * @returns the vector containing the coordnates of the texture
  16791. */
  16792. getTextureCoordinates(): Nullable<Vector2>;
  16793. }
  16794. }
  16795. declare module "babylonjs/Events/pointerEvents" {
  16796. import { Nullable } from "babylonjs/types";
  16797. import { Vector2 } from "babylonjs/Maths/math";
  16798. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  16799. import { Ray } from "babylonjs/Culling/ray";
  16800. /**
  16801. * Gather the list of pointer event types as constants.
  16802. */
  16803. export class PointerEventTypes {
  16804. /**
  16805. * 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.
  16806. */
  16807. static readonly POINTERDOWN: number;
  16808. /**
  16809. * The pointerup event is fired when a pointer is no longer active.
  16810. */
  16811. static readonly POINTERUP: number;
  16812. /**
  16813. * The pointermove event is fired when a pointer changes coordinates.
  16814. */
  16815. static readonly POINTERMOVE: number;
  16816. /**
  16817. * The pointerwheel event is fired when a mouse wheel has been rotated.
  16818. */
  16819. static readonly POINTERWHEEL: number;
  16820. /**
  16821. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  16822. */
  16823. static readonly POINTERPICK: number;
  16824. /**
  16825. * The pointertap event is fired when a the object has been touched and released without drag.
  16826. */
  16827. static readonly POINTERTAP: number;
  16828. /**
  16829. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  16830. */
  16831. static readonly POINTERDOUBLETAP: number;
  16832. }
  16833. /**
  16834. * Base class of pointer info types.
  16835. */
  16836. export class PointerInfoBase {
  16837. /**
  16838. * Defines the type of event (PointerEventTypes)
  16839. */
  16840. type: number;
  16841. /**
  16842. * Defines the related dom event
  16843. */
  16844. event: PointerEvent | MouseWheelEvent;
  16845. /**
  16846. * Instantiates the base class of pointers info.
  16847. * @param type Defines the type of event (PointerEventTypes)
  16848. * @param event Defines the related dom event
  16849. */
  16850. constructor(
  16851. /**
  16852. * Defines the type of event (PointerEventTypes)
  16853. */
  16854. type: number,
  16855. /**
  16856. * Defines the related dom event
  16857. */
  16858. event: PointerEvent | MouseWheelEvent);
  16859. }
  16860. /**
  16861. * This class is used to store pointer related info for the onPrePointerObservable event.
  16862. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  16863. */
  16864. export class PointerInfoPre extends PointerInfoBase {
  16865. /**
  16866. * Ray from a pointer if availible (eg. 6dof controller)
  16867. */
  16868. ray: Nullable<Ray>;
  16869. /**
  16870. * Defines the local position of the pointer on the canvas.
  16871. */
  16872. localPosition: Vector2;
  16873. /**
  16874. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  16875. */
  16876. skipOnPointerObservable: boolean;
  16877. /**
  16878. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  16879. * @param type Defines the type of event (PointerEventTypes)
  16880. * @param event Defines the related dom event
  16881. * @param localX Defines the local x coordinates of the pointer when the event occured
  16882. * @param localY Defines the local y coordinates of the pointer when the event occured
  16883. */
  16884. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  16885. }
  16886. /**
  16887. * This type contains all the data related to a pointer event in Babylon.js.
  16888. * 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.
  16889. */
  16890. export class PointerInfo extends PointerInfoBase {
  16891. /**
  16892. * Defines the picking info associated to the info (if any)\
  16893. */
  16894. pickInfo: Nullable<PickingInfo>;
  16895. /**
  16896. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  16897. * @param type Defines the type of event (PointerEventTypes)
  16898. * @param event Defines the related dom event
  16899. * @param pickInfo Defines the picking info associated to the info (if any)\
  16900. */
  16901. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  16902. /**
  16903. * Defines the picking info associated to the info (if any)\
  16904. */
  16905. pickInfo: Nullable<PickingInfo>);
  16906. }
  16907. /**
  16908. * Data relating to a touch event on the screen.
  16909. */
  16910. export interface PointerTouch {
  16911. /**
  16912. * X coordinate of touch.
  16913. */
  16914. x: number;
  16915. /**
  16916. * Y coordinate of touch.
  16917. */
  16918. y: number;
  16919. /**
  16920. * Id of touch. Unique for each finger.
  16921. */
  16922. pointerId: number;
  16923. /**
  16924. * Event type passed from DOM.
  16925. */
  16926. type: any;
  16927. }
  16928. }
  16929. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  16930. import { Observable } from "babylonjs/Misc/observable";
  16931. import { Nullable } from "babylonjs/types";
  16932. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  16933. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  16934. /**
  16935. * Manage the mouse inputs to control the movement of a free camera.
  16936. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  16937. */
  16938. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  16939. /**
  16940. * Define if touch is enabled in the mouse input
  16941. */
  16942. touchEnabled: boolean;
  16943. /**
  16944. * Defines the camera the input is attached to.
  16945. */
  16946. camera: FreeCamera;
  16947. /**
  16948. * Defines the buttons associated with the input to handle camera move.
  16949. */
  16950. buttons: number[];
  16951. /**
  16952. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  16953. */
  16954. angularSensibility: number;
  16955. private _pointerInput;
  16956. private _onMouseMove;
  16957. private _observer;
  16958. private previousPosition;
  16959. /**
  16960. * Observable for when a pointer move event occurs containing the move offset
  16961. */
  16962. onPointerMovedObservable: Observable<{
  16963. offsetX: number;
  16964. offsetY: number;
  16965. }>;
  16966. /**
  16967. * @hidden
  16968. * If the camera should be rotated automatically based on pointer movement
  16969. */
  16970. _allowCameraRotation: boolean;
  16971. /**
  16972. * Manage the mouse inputs to control the movement of a free camera.
  16973. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  16974. * @param touchEnabled Defines if touch is enabled or not
  16975. */
  16976. constructor(
  16977. /**
  16978. * Define if touch is enabled in the mouse input
  16979. */
  16980. touchEnabled?: boolean);
  16981. /**
  16982. * Attach the input controls to a specific dom element to get the input from.
  16983. * @param element Defines the element the controls should be listened from
  16984. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  16985. */
  16986. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  16987. /**
  16988. * Called on JS contextmenu event.
  16989. * Override this method to provide functionality.
  16990. */
  16991. protected onContextMenu(evt: PointerEvent): void;
  16992. /**
  16993. * Detach the current controls from the specified dom element.
  16994. * @param element Defines the element to stop listening the inputs from
  16995. */
  16996. detachControl(element: Nullable<HTMLElement>): void;
  16997. /**
  16998. * Gets the class name of the current intput.
  16999. * @returns the class name
  17000. */
  17001. getClassName(): string;
  17002. /**
  17003. * Get the friendly name associated with the input class.
  17004. * @returns the input friendly name
  17005. */
  17006. getSimpleName(): string;
  17007. }
  17008. }
  17009. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  17010. import { Nullable } from "babylonjs/types";
  17011. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  17012. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  17013. /**
  17014. * Manage the touch inputs to control the movement of a free camera.
  17015. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  17016. */
  17017. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  17018. /**
  17019. * Defines the camera the input is attached to.
  17020. */
  17021. camera: FreeCamera;
  17022. /**
  17023. * Defines the touch sensibility for rotation.
  17024. * The higher the faster.
  17025. */
  17026. touchAngularSensibility: number;
  17027. /**
  17028. * Defines the touch sensibility for move.
  17029. * The higher the faster.
  17030. */
  17031. touchMoveSensibility: number;
  17032. private _offsetX;
  17033. private _offsetY;
  17034. private _pointerPressed;
  17035. private _pointerInput;
  17036. private _observer;
  17037. private _onLostFocus;
  17038. /**
  17039. * Attach the input controls to a specific dom element to get the input from.
  17040. * @param element Defines the element the controls should be listened from
  17041. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  17042. */
  17043. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  17044. /**
  17045. * Detach the current controls from the specified dom element.
  17046. * @param element Defines the element to stop listening the inputs from
  17047. */
  17048. detachControl(element: Nullable<HTMLElement>): void;
  17049. /**
  17050. * Update the current camera state depending on the inputs that have been used this frame.
  17051. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  17052. */
  17053. checkInputs(): void;
  17054. /**
  17055. * Gets the class name of the current intput.
  17056. * @returns the class name
  17057. */
  17058. getClassName(): string;
  17059. /**
  17060. * Get the friendly name associated with the input class.
  17061. * @returns the input friendly name
  17062. */
  17063. getSimpleName(): string;
  17064. }
  17065. }
  17066. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  17067. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  17068. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  17069. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  17070. import { Nullable } from "babylonjs/types";
  17071. /**
  17072. * Default Inputs manager for the FreeCamera.
  17073. * It groups all the default supported inputs for ease of use.
  17074. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  17075. */
  17076. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  17077. /**
  17078. * @hidden
  17079. */
  17080. _mouseInput: Nullable<FreeCameraMouseInput>;
  17081. /**
  17082. * Instantiates a new FreeCameraInputsManager.
  17083. * @param camera Defines the camera the inputs belong to
  17084. */
  17085. constructor(camera: FreeCamera);
  17086. /**
  17087. * Add keyboard input support to the input manager.
  17088. * @returns the current input manager
  17089. */
  17090. addKeyboard(): FreeCameraInputsManager;
  17091. /**
  17092. * Add mouse input support to the input manager.
  17093. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  17094. * @returns the current input manager
  17095. */
  17096. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  17097. /**
  17098. * Removes the mouse input support from the manager
  17099. * @returns the current input manager
  17100. */
  17101. removeMouse(): FreeCameraInputsManager;
  17102. /**
  17103. * Add touch input support to the input manager.
  17104. * @returns the current input manager
  17105. */
  17106. addTouch(): FreeCameraInputsManager;
  17107. /**
  17108. * Remove all attached input methods from a camera
  17109. */
  17110. clear(): void;
  17111. }
  17112. }
  17113. declare module "babylonjs/Cameras/freeCamera" {
  17114. import { Vector3 } from "babylonjs/Maths/math";
  17115. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17116. import { Scene } from "babylonjs/scene";
  17117. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  17118. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  17119. /**
  17120. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  17121. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  17122. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  17123. */
  17124. export class FreeCamera extends TargetCamera {
  17125. /**
  17126. * Define the collision ellipsoid of the camera.
  17127. * This is helpful to simulate a camera body like the player body around the camera
  17128. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  17129. */
  17130. ellipsoid: Vector3;
  17131. /**
  17132. * Define an offset for the position of the ellipsoid around the camera.
  17133. * This can be helpful to determine the center of the body near the gravity center of the body
  17134. * instead of its head.
  17135. */
  17136. ellipsoidOffset: Vector3;
  17137. /**
  17138. * Enable or disable collisions of the camera with the rest of the scene objects.
  17139. */
  17140. checkCollisions: boolean;
  17141. /**
  17142. * Enable or disable gravity on the camera.
  17143. */
  17144. applyGravity: boolean;
  17145. /**
  17146. * Define the input manager associated to the camera.
  17147. */
  17148. inputs: FreeCameraInputsManager;
  17149. /**
  17150. * Gets the input sensibility for a mouse input. (default is 2000.0)
  17151. * Higher values reduce sensitivity.
  17152. */
  17153. /**
  17154. * Sets the input sensibility for a mouse input. (default is 2000.0)
  17155. * Higher values reduce sensitivity.
  17156. */
  17157. angularSensibility: number;
  17158. /**
  17159. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  17160. */
  17161. keysUp: number[];
  17162. /**
  17163. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  17164. */
  17165. keysDown: number[];
  17166. /**
  17167. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  17168. */
  17169. keysLeft: number[];
  17170. /**
  17171. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  17172. */
  17173. keysRight: number[];
  17174. /**
  17175. * Event raised when the camera collide with a mesh in the scene.
  17176. */
  17177. onCollide: (collidedMesh: AbstractMesh) => void;
  17178. private _collider;
  17179. private _needMoveForGravity;
  17180. private _oldPosition;
  17181. private _diffPosition;
  17182. private _newPosition;
  17183. /** @hidden */
  17184. _localDirection: Vector3;
  17185. /** @hidden */
  17186. _transformedDirection: Vector3;
  17187. /**
  17188. * Instantiates a Free Camera.
  17189. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  17190. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  17191. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  17192. * @param name Define the name of the camera in the scene
  17193. * @param position Define the start position of the camera in the scene
  17194. * @param scene Define the scene the camera belongs to
  17195. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  17196. */
  17197. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  17198. /**
  17199. * Attached controls to the current camera.
  17200. * @param element Defines the element the controls should be listened from
  17201. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  17202. */
  17203. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  17204. /**
  17205. * Detach the current controls from the camera.
  17206. * The camera will stop reacting to inputs.
  17207. * @param element Defines the element to stop listening the inputs from
  17208. */
  17209. detachControl(element: HTMLElement): void;
  17210. private _collisionMask;
  17211. /**
  17212. * Define a collision mask to limit the list of object the camera can collide with
  17213. */
  17214. collisionMask: number;
  17215. /** @hidden */
  17216. _collideWithWorld(displacement: Vector3): void;
  17217. private _onCollisionPositionChange;
  17218. /** @hidden */
  17219. _checkInputs(): void;
  17220. /** @hidden */
  17221. _decideIfNeedsToMove(): boolean;
  17222. /** @hidden */
  17223. _updatePosition(): void;
  17224. /**
  17225. * Destroy the camera and release the current resources hold by it.
  17226. */
  17227. dispose(): void;
  17228. /**
  17229. * Gets the current object class name.
  17230. * @return the class name
  17231. */
  17232. getClassName(): string;
  17233. }
  17234. }
  17235. declare module "babylonjs/Gamepads/gamepad" {
  17236. import { Observable } from "babylonjs/Misc/observable";
  17237. /**
  17238. * Represents a gamepad control stick position
  17239. */
  17240. export class StickValues {
  17241. /**
  17242. * The x component of the control stick
  17243. */
  17244. x: number;
  17245. /**
  17246. * The y component of the control stick
  17247. */
  17248. y: number;
  17249. /**
  17250. * Initializes the gamepad x and y control stick values
  17251. * @param x The x component of the gamepad control stick value
  17252. * @param y The y component of the gamepad control stick value
  17253. */
  17254. constructor(
  17255. /**
  17256. * The x component of the control stick
  17257. */
  17258. x: number,
  17259. /**
  17260. * The y component of the control stick
  17261. */
  17262. y: number);
  17263. }
  17264. /**
  17265. * An interface which manages callbacks for gamepad button changes
  17266. */
  17267. export interface GamepadButtonChanges {
  17268. /**
  17269. * Called when a gamepad has been changed
  17270. */
  17271. changed: boolean;
  17272. /**
  17273. * Called when a gamepad press event has been triggered
  17274. */
  17275. pressChanged: boolean;
  17276. /**
  17277. * Called when a touch event has been triggered
  17278. */
  17279. touchChanged: boolean;
  17280. /**
  17281. * Called when a value has changed
  17282. */
  17283. valueChanged: boolean;
  17284. }
  17285. /**
  17286. * Represents a gamepad
  17287. */
  17288. export class Gamepad {
  17289. /**
  17290. * The id of the gamepad
  17291. */
  17292. id: string;
  17293. /**
  17294. * The index of the gamepad
  17295. */
  17296. index: number;
  17297. /**
  17298. * The browser gamepad
  17299. */
  17300. browserGamepad: any;
  17301. /**
  17302. * Specifies what type of gamepad this represents
  17303. */
  17304. type: number;
  17305. private _leftStick;
  17306. private _rightStick;
  17307. /** @hidden */
  17308. _isConnected: boolean;
  17309. private _leftStickAxisX;
  17310. private _leftStickAxisY;
  17311. private _rightStickAxisX;
  17312. private _rightStickAxisY;
  17313. /**
  17314. * Triggered when the left control stick has been changed
  17315. */
  17316. private _onleftstickchanged;
  17317. /**
  17318. * Triggered when the right control stick has been changed
  17319. */
  17320. private _onrightstickchanged;
  17321. /**
  17322. * Represents a gamepad controller
  17323. */
  17324. static GAMEPAD: number;
  17325. /**
  17326. * Represents a generic controller
  17327. */
  17328. static GENERIC: number;
  17329. /**
  17330. * Represents an XBox controller
  17331. */
  17332. static XBOX: number;
  17333. /**
  17334. * Represents a pose-enabled controller
  17335. */
  17336. static POSE_ENABLED: number;
  17337. /**
  17338. * Specifies whether the left control stick should be Y-inverted
  17339. */
  17340. protected _invertLeftStickY: boolean;
  17341. /**
  17342. * Specifies if the gamepad has been connected
  17343. */
  17344. readonly isConnected: boolean;
  17345. /**
  17346. * Initializes the gamepad
  17347. * @param id The id of the gamepad
  17348. * @param index The index of the gamepad
  17349. * @param browserGamepad The browser gamepad
  17350. * @param leftStickX The x component of the left joystick
  17351. * @param leftStickY The y component of the left joystick
  17352. * @param rightStickX The x component of the right joystick
  17353. * @param rightStickY The y component of the right joystick
  17354. */
  17355. constructor(
  17356. /**
  17357. * The id of the gamepad
  17358. */
  17359. id: string,
  17360. /**
  17361. * The index of the gamepad
  17362. */
  17363. index: number,
  17364. /**
  17365. * The browser gamepad
  17366. */
  17367. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  17368. /**
  17369. * Callback triggered when the left joystick has changed
  17370. * @param callback
  17371. */
  17372. onleftstickchanged(callback: (values: StickValues) => void): void;
  17373. /**
  17374. * Callback triggered when the right joystick has changed
  17375. * @param callback
  17376. */
  17377. onrightstickchanged(callback: (values: StickValues) => void): void;
  17378. /**
  17379. * Gets the left joystick
  17380. */
  17381. /**
  17382. * Sets the left joystick values
  17383. */
  17384. leftStick: StickValues;
  17385. /**
  17386. * Gets the right joystick
  17387. */
  17388. /**
  17389. * Sets the right joystick value
  17390. */
  17391. rightStick: StickValues;
  17392. /**
  17393. * Updates the gamepad joystick positions
  17394. */
  17395. update(): void;
  17396. /**
  17397. * Disposes the gamepad
  17398. */
  17399. dispose(): void;
  17400. }
  17401. /**
  17402. * Represents a generic gamepad
  17403. */
  17404. export class GenericPad extends Gamepad {
  17405. private _buttons;
  17406. private _onbuttondown;
  17407. private _onbuttonup;
  17408. /**
  17409. * Observable triggered when a button has been pressed
  17410. */
  17411. onButtonDownObservable: Observable<number>;
  17412. /**
  17413. * Observable triggered when a button has been released
  17414. */
  17415. onButtonUpObservable: Observable<number>;
  17416. /**
  17417. * Callback triggered when a button has been pressed
  17418. * @param callback Called when a button has been pressed
  17419. */
  17420. onbuttondown(callback: (buttonPressed: number) => void): void;
  17421. /**
  17422. * Callback triggered when a button has been released
  17423. * @param callback Called when a button has been released
  17424. */
  17425. onbuttonup(callback: (buttonReleased: number) => void): void;
  17426. /**
  17427. * Initializes the generic gamepad
  17428. * @param id The id of the generic gamepad
  17429. * @param index The index of the generic gamepad
  17430. * @param browserGamepad The browser gamepad
  17431. */
  17432. constructor(id: string, index: number, browserGamepad: any);
  17433. private _setButtonValue;
  17434. /**
  17435. * Updates the generic gamepad
  17436. */
  17437. update(): void;
  17438. /**
  17439. * Disposes the generic gamepad
  17440. */
  17441. dispose(): void;
  17442. }
  17443. }
  17444. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  17445. import { Observable } from "babylonjs/Misc/observable";
  17446. import { Nullable } from "babylonjs/types";
  17447. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  17448. import { TransformNode } from "babylonjs/Meshes/transformNode";
  17449. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17450. import { Ray } from "babylonjs/Culling/ray";
  17451. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  17452. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  17453. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  17454. /**
  17455. * Defines the types of pose enabled controllers that are supported
  17456. */
  17457. export enum PoseEnabledControllerType {
  17458. /**
  17459. * HTC Vive
  17460. */
  17461. VIVE = 0,
  17462. /**
  17463. * Oculus Rift
  17464. */
  17465. OCULUS = 1,
  17466. /**
  17467. * Windows mixed reality
  17468. */
  17469. WINDOWS = 2,
  17470. /**
  17471. * Samsung gear VR
  17472. */
  17473. GEAR_VR = 3,
  17474. /**
  17475. * Google Daydream
  17476. */
  17477. DAYDREAM = 4,
  17478. /**
  17479. * Generic
  17480. */
  17481. GENERIC = 5
  17482. }
  17483. /**
  17484. * Defines the MutableGamepadButton interface for the state of a gamepad button
  17485. */
  17486. export interface MutableGamepadButton {
  17487. /**
  17488. * Value of the button/trigger
  17489. */
  17490. value: number;
  17491. /**
  17492. * If the button/trigger is currently touched
  17493. */
  17494. touched: boolean;
  17495. /**
  17496. * If the button/trigger is currently pressed
  17497. */
  17498. pressed: boolean;
  17499. }
  17500. /**
  17501. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  17502. * @hidden
  17503. */
  17504. export interface ExtendedGamepadButton extends GamepadButton {
  17505. /**
  17506. * If the button/trigger is currently pressed
  17507. */
  17508. readonly pressed: boolean;
  17509. /**
  17510. * If the button/trigger is currently touched
  17511. */
  17512. readonly touched: boolean;
  17513. /**
  17514. * Value of the button/trigger
  17515. */
  17516. readonly value: number;
  17517. }
  17518. /** @hidden */
  17519. export interface _GamePadFactory {
  17520. /**
  17521. * Returns wether or not the current gamepad can be created for this type of controller.
  17522. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  17523. * @returns true if it can be created, otherwise false
  17524. */
  17525. canCreate(gamepadInfo: any): boolean;
  17526. /**
  17527. * Creates a new instance of the Gamepad.
  17528. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  17529. * @returns the new gamepad instance
  17530. */
  17531. create(gamepadInfo: any): Gamepad;
  17532. }
  17533. /**
  17534. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  17535. */
  17536. export class PoseEnabledControllerHelper {
  17537. /** @hidden */
  17538. static _ControllerFactories: _GamePadFactory[];
  17539. /** @hidden */
  17540. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  17541. /**
  17542. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  17543. * @param vrGamepad the gamepad to initialized
  17544. * @returns a vr controller of the type the gamepad identified as
  17545. */
  17546. static InitiateController(vrGamepad: any): Gamepad;
  17547. }
  17548. /**
  17549. * Defines the PoseEnabledController object that contains state of a vr capable controller
  17550. */
  17551. export class PoseEnabledController extends Gamepad implements PoseControlled {
  17552. private _deviceRoomPosition;
  17553. private _deviceRoomRotationQuaternion;
  17554. /**
  17555. * The device position in babylon space
  17556. */
  17557. devicePosition: Vector3;
  17558. /**
  17559. * The device rotation in babylon space
  17560. */
  17561. deviceRotationQuaternion: Quaternion;
  17562. /**
  17563. * The scale factor of the device in babylon space
  17564. */
  17565. deviceScaleFactor: number;
  17566. /**
  17567. * (Likely devicePosition should be used instead) The device position in its room space
  17568. */
  17569. position: Vector3;
  17570. /**
  17571. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  17572. */
  17573. rotationQuaternion: Quaternion;
  17574. /**
  17575. * The type of controller (Eg. Windows mixed reality)
  17576. */
  17577. controllerType: PoseEnabledControllerType;
  17578. protected _calculatedPosition: Vector3;
  17579. private _calculatedRotation;
  17580. /**
  17581. * The raw pose from the device
  17582. */
  17583. rawPose: DevicePose;
  17584. private _trackPosition;
  17585. private _maxRotationDistFromHeadset;
  17586. private _draggedRoomRotation;
  17587. /**
  17588. * @hidden
  17589. */
  17590. _disableTrackPosition(fixedPosition: Vector3): void;
  17591. /**
  17592. * Internal, the mesh attached to the controller
  17593. * @hidden
  17594. */
  17595. _mesh: Nullable<AbstractMesh>;
  17596. private _poseControlledCamera;
  17597. private _leftHandSystemQuaternion;
  17598. /**
  17599. * Internal, matrix used to convert room space to babylon space
  17600. * @hidden
  17601. */
  17602. _deviceToWorld: Matrix;
  17603. /**
  17604. * Node to be used when casting a ray from the controller
  17605. * @hidden
  17606. */
  17607. _pointingPoseNode: Nullable<TransformNode>;
  17608. /**
  17609. * Name of the child mesh that can be used to cast a ray from the controller
  17610. */
  17611. static readonly POINTING_POSE: string;
  17612. /**
  17613. * Creates a new PoseEnabledController from a gamepad
  17614. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  17615. */
  17616. constructor(browserGamepad: any);
  17617. private _workingMatrix;
  17618. /**
  17619. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  17620. */
  17621. update(): void;
  17622. /**
  17623. * Updates only the pose device and mesh without doing any button event checking
  17624. */
  17625. protected _updatePoseAndMesh(): void;
  17626. /**
  17627. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  17628. * @param poseData raw pose fromthe device
  17629. */
  17630. updateFromDevice(poseData: DevicePose): void;
  17631. /**
  17632. * @hidden
  17633. */
  17634. _meshAttachedObservable: Observable<AbstractMesh>;
  17635. /**
  17636. * Attaches a mesh to the controller
  17637. * @param mesh the mesh to be attached
  17638. */
  17639. attachToMesh(mesh: AbstractMesh): void;
  17640. /**
  17641. * Attaches the controllers mesh to a camera
  17642. * @param camera the camera the mesh should be attached to
  17643. */
  17644. attachToPoseControlledCamera(camera: TargetCamera): void;
  17645. /**
  17646. * Disposes of the controller
  17647. */
  17648. dispose(): void;
  17649. /**
  17650. * The mesh that is attached to the controller
  17651. */
  17652. readonly mesh: Nullable<AbstractMesh>;
  17653. /**
  17654. * Gets the ray of the controller in the direction the controller is pointing
  17655. * @param length the length the resulting ray should be
  17656. * @returns a ray in the direction the controller is pointing
  17657. */
  17658. getForwardRay(length?: number): Ray;
  17659. }
  17660. }
  17661. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  17662. import { Observable } from "babylonjs/Misc/observable";
  17663. import { Scene } from "babylonjs/scene";
  17664. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17665. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  17666. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  17667. /**
  17668. * Defines the WebVRController object that represents controllers tracked in 3D space
  17669. */
  17670. export abstract class WebVRController extends PoseEnabledController {
  17671. /**
  17672. * Internal, the default controller model for the controller
  17673. */
  17674. protected _defaultModel: AbstractMesh;
  17675. /**
  17676. * Fired when the trigger state has changed
  17677. */
  17678. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  17679. /**
  17680. * Fired when the main button state has changed
  17681. */
  17682. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  17683. /**
  17684. * Fired when the secondary button state has changed
  17685. */
  17686. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  17687. /**
  17688. * Fired when the pad state has changed
  17689. */
  17690. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  17691. /**
  17692. * Fired when controllers stick values have changed
  17693. */
  17694. onPadValuesChangedObservable: Observable<StickValues>;
  17695. /**
  17696. * Array of button availible on the controller
  17697. */
  17698. protected _buttons: Array<MutableGamepadButton>;
  17699. private _onButtonStateChange;
  17700. /**
  17701. * Fired when a controller button's state has changed
  17702. * @param callback the callback containing the button that was modified
  17703. */
  17704. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  17705. /**
  17706. * X and Y axis corresponding to the controllers joystick
  17707. */
  17708. pad: StickValues;
  17709. /**
  17710. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  17711. */
  17712. hand: string;
  17713. /**
  17714. * The default controller model for the controller
  17715. */
  17716. readonly defaultModel: AbstractMesh;
  17717. /**
  17718. * Creates a new WebVRController from a gamepad
  17719. * @param vrGamepad the gamepad that the WebVRController should be created from
  17720. */
  17721. constructor(vrGamepad: any);
  17722. /**
  17723. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  17724. */
  17725. update(): void;
  17726. /**
  17727. * Function to be called when a button is modified
  17728. */
  17729. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  17730. /**
  17731. * Loads a mesh and attaches it to the controller
  17732. * @param scene the scene the mesh should be added to
  17733. * @param meshLoaded callback for when the mesh has been loaded
  17734. */
  17735. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  17736. private _setButtonValue;
  17737. private _changes;
  17738. private _checkChanges;
  17739. /**
  17740. * Disposes of th webVRCOntroller
  17741. */
  17742. dispose(): void;
  17743. }
  17744. }
  17745. declare module "babylonjs/Lights/hemisphericLight" {
  17746. import { Nullable } from "babylonjs/types";
  17747. import { Scene } from "babylonjs/scene";
  17748. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  17749. import { Effect } from "babylonjs/Materials/effect";
  17750. import { Light } from "babylonjs/Lights/light";
  17751. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  17752. /**
  17753. * The HemisphericLight simulates the ambient environment light,
  17754. * so the passed direction is the light reflection direction, not the incoming direction.
  17755. */
  17756. export class HemisphericLight extends Light {
  17757. /**
  17758. * The groundColor is the light in the opposite direction to the one specified during creation.
  17759. * 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.
  17760. */
  17761. groundColor: Color3;
  17762. /**
  17763. * The light reflection direction, not the incoming direction.
  17764. */
  17765. direction: Vector3;
  17766. /**
  17767. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  17768. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  17769. * The HemisphericLight can't cast shadows.
  17770. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17771. * @param name The friendly name of the light
  17772. * @param direction The direction of the light reflection
  17773. * @param scene The scene the light belongs to
  17774. */
  17775. constructor(name: string, direction: Vector3, scene: Scene);
  17776. protected _buildUniformLayout(): void;
  17777. /**
  17778. * Returns the string "HemisphericLight".
  17779. * @return The class name
  17780. */
  17781. getClassName(): string;
  17782. /**
  17783. * Sets the HemisphericLight direction towards the passed target (Vector3).
  17784. * Returns the updated direction.
  17785. * @param target The target the direction should point to
  17786. * @return The computed direction
  17787. */
  17788. setDirectionToTarget(target: Vector3): Vector3;
  17789. /**
  17790. * Returns the shadow generator associated to the light.
  17791. * @returns Always null for hemispheric lights because it does not support shadows.
  17792. */
  17793. getShadowGenerator(): Nullable<IShadowGenerator>;
  17794. /**
  17795. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  17796. * @param effect The effect to update
  17797. * @param lightIndex The index of the light in the effect to update
  17798. * @returns The hemispheric light
  17799. */
  17800. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  17801. /**
  17802. * Computes the world matrix of the node
  17803. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  17804. * @param useWasUpdatedFlag defines a reserved property
  17805. * @returns the world matrix
  17806. */
  17807. computeWorldMatrix(): Matrix;
  17808. /**
  17809. * Returns the integer 3.
  17810. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  17811. */
  17812. getTypeID(): number;
  17813. /**
  17814. * Prepares the list of defines specific to the light type.
  17815. * @param defines the list of defines
  17816. * @param lightIndex defines the index of the light for the effect
  17817. */
  17818. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17819. }
  17820. }
  17821. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  17822. /** @hidden */
  17823. export var vrMultiviewToSingleviewPixelShader: {
  17824. name: string;
  17825. shader: string;
  17826. };
  17827. }
  17828. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  17829. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17830. import { Scene } from "babylonjs/scene";
  17831. /**
  17832. * Renders to multiple views with a single draw call
  17833. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  17834. */
  17835. export class MultiviewRenderTarget extends RenderTargetTexture {
  17836. /**
  17837. * Creates a multiview render target
  17838. * @param scene scene used with the render target
  17839. * @param size the size of the render target (used for each view)
  17840. */
  17841. constructor(scene: Scene, size?: number | {
  17842. width: number;
  17843. height: number;
  17844. } | {
  17845. ratio: number;
  17846. });
  17847. /**
  17848. * @hidden
  17849. * @param faceIndex the face index, if its a cube texture
  17850. */
  17851. _bindFrameBuffer(faceIndex?: number): void;
  17852. /**
  17853. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  17854. * @returns the view count
  17855. */
  17856. getViewCount(): number;
  17857. }
  17858. }
  17859. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  17860. import { Camera } from "babylonjs/Cameras/camera";
  17861. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  17862. import { Nullable } from "babylonjs/types";
  17863. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17864. import { Matrix } from "babylonjs/Maths/math";
  17865. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  17866. module "babylonjs/Engines/engine" {
  17867. interface Engine {
  17868. /**
  17869. * Creates a new multiview render target
  17870. * @param width defines the width of the texture
  17871. * @param height defines the height of the texture
  17872. * @returns the created multiview texture
  17873. */
  17874. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  17875. /**
  17876. * Binds a multiview framebuffer to be drawn to
  17877. * @param multiviewTexture texture to bind
  17878. */
  17879. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  17880. }
  17881. }
  17882. module "babylonjs/Cameras/camera" {
  17883. interface Camera {
  17884. /**
  17885. * @hidden
  17886. * 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)
  17887. */
  17888. _useMultiviewToSingleView: boolean;
  17889. /**
  17890. * @hidden
  17891. * 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)
  17892. */
  17893. _multiviewTexture: Nullable<RenderTargetTexture>;
  17894. /**
  17895. * @hidden
  17896. * ensures the multiview texture of the camera exists and has the specified width/height
  17897. * @param width height to set on the multiview texture
  17898. * @param height width to set on the multiview texture
  17899. */
  17900. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  17901. }
  17902. }
  17903. module "babylonjs/scene" {
  17904. interface Scene {
  17905. /** @hidden */
  17906. _transformMatrixR: Matrix;
  17907. /** @hidden */
  17908. _multiviewSceneUbo: Nullable<UniformBuffer>;
  17909. /** @hidden */
  17910. _createMultiviewUbo(): void;
  17911. /** @hidden */
  17912. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  17913. /** @hidden */
  17914. _renderMultiviewToSingleView(camera: Camera): void;
  17915. }
  17916. }
  17917. }
  17918. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  17919. import { Camera } from "babylonjs/Cameras/camera";
  17920. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17921. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  17922. import "babylonjs/Engines/Extensions/engine.multiview";
  17923. /**
  17924. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  17925. * This will not be used for webXR as it supports displaying texture arrays directly
  17926. */
  17927. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  17928. /**
  17929. * Initializes a VRMultiviewToSingleview
  17930. * @param name name of the post process
  17931. * @param camera camera to be applied to
  17932. * @param scaleFactor scaling factor to the size of the output texture
  17933. */
  17934. constructor(name: string, camera: Camera, scaleFactor: number);
  17935. }
  17936. }
  17937. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  17938. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  17939. import { Nullable } from "babylonjs/types";
  17940. import { Size } from "babylonjs/Maths/math";
  17941. import { Observable } from "babylonjs/Misc/observable";
  17942. module "babylonjs/Engines/engine" {
  17943. interface Engine {
  17944. /** @hidden */
  17945. _vrDisplay: any;
  17946. /** @hidden */
  17947. _vrSupported: boolean;
  17948. /** @hidden */
  17949. _oldSize: Size;
  17950. /** @hidden */
  17951. _oldHardwareScaleFactor: number;
  17952. /** @hidden */
  17953. _vrExclusivePointerMode: boolean;
  17954. /** @hidden */
  17955. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  17956. /** @hidden */
  17957. _onVRDisplayPointerRestricted: () => void;
  17958. /** @hidden */
  17959. _onVRDisplayPointerUnrestricted: () => void;
  17960. /** @hidden */
  17961. _onVrDisplayConnect: Nullable<(display: any) => void>;
  17962. /** @hidden */
  17963. _onVrDisplayDisconnect: Nullable<() => void>;
  17964. /** @hidden */
  17965. _onVrDisplayPresentChange: Nullable<() => void>;
  17966. /**
  17967. * Observable signaled when VR display mode changes
  17968. */
  17969. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  17970. /**
  17971. * Observable signaled when VR request present is complete
  17972. */
  17973. onVRRequestPresentComplete: Observable<boolean>;
  17974. /**
  17975. * Observable signaled when VR request present starts
  17976. */
  17977. onVRRequestPresentStart: Observable<Engine>;
  17978. /**
  17979. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  17980. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  17981. */
  17982. isInVRExclusivePointerMode: boolean;
  17983. /**
  17984. * Gets a boolean indicating if a webVR device was detected
  17985. * @returns true if a webVR device was detected
  17986. */
  17987. isVRDevicePresent(): boolean;
  17988. /**
  17989. * Gets the current webVR device
  17990. * @returns the current webVR device (or null)
  17991. */
  17992. getVRDevice(): any;
  17993. /**
  17994. * Initializes a webVR display and starts listening to display change events
  17995. * The onVRDisplayChangedObservable will be notified upon these changes
  17996. * @returns A promise containing a VRDisplay and if vr is supported
  17997. */
  17998. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  17999. /** @hidden */
  18000. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  18001. /**
  18002. * Call this function to switch to webVR mode
  18003. * Will do nothing if webVR is not supported or if there is no webVR device
  18004. * @see http://doc.babylonjs.com/how_to/webvr_camera
  18005. */
  18006. enableVR(): void;
  18007. /** @hidden */
  18008. _onVRFullScreenTriggered(): void;
  18009. }
  18010. }
  18011. }
  18012. declare module "babylonjs/Cameras/VR/webVRCamera" {
  18013. import { Nullable } from "babylonjs/types";
  18014. import { Observable } from "babylonjs/Misc/observable";
  18015. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18016. import { Scene } from "babylonjs/scene";
  18017. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  18018. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  18019. import { Node } from "babylonjs/node";
  18020. import { Ray } from "babylonjs/Culling/ray";
  18021. import "babylonjs/Cameras/RigModes/webVRRigMode";
  18022. import "babylonjs/Engines/Extensions/engine.webVR";
  18023. /**
  18024. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  18025. * IMPORTANT!! The data is right-hand data.
  18026. * @export
  18027. * @interface DevicePose
  18028. */
  18029. export interface DevicePose {
  18030. /**
  18031. * The position of the device, values in array are [x,y,z].
  18032. */
  18033. readonly position: Nullable<Float32Array>;
  18034. /**
  18035. * The linearVelocity of the device, values in array are [x,y,z].
  18036. */
  18037. readonly linearVelocity: Nullable<Float32Array>;
  18038. /**
  18039. * The linearAcceleration of the device, values in array are [x,y,z].
  18040. */
  18041. readonly linearAcceleration: Nullable<Float32Array>;
  18042. /**
  18043. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  18044. */
  18045. readonly orientation: Nullable<Float32Array>;
  18046. /**
  18047. * The angularVelocity of the device, values in array are [x,y,z].
  18048. */
  18049. readonly angularVelocity: Nullable<Float32Array>;
  18050. /**
  18051. * The angularAcceleration of the device, values in array are [x,y,z].
  18052. */
  18053. readonly angularAcceleration: Nullable<Float32Array>;
  18054. }
  18055. /**
  18056. * Interface representing a pose controlled object in Babylon.
  18057. * A pose controlled object has both regular pose values as well as pose values
  18058. * from an external device such as a VR head mounted display
  18059. */
  18060. export interface PoseControlled {
  18061. /**
  18062. * The position of the object in babylon space.
  18063. */
  18064. position: Vector3;
  18065. /**
  18066. * The rotation quaternion of the object in babylon space.
  18067. */
  18068. rotationQuaternion: Quaternion;
  18069. /**
  18070. * The position of the device in babylon space.
  18071. */
  18072. devicePosition?: Vector3;
  18073. /**
  18074. * The rotation quaternion of the device in babylon space.
  18075. */
  18076. deviceRotationQuaternion: Quaternion;
  18077. /**
  18078. * The raw pose coming from the device.
  18079. */
  18080. rawPose: Nullable<DevicePose>;
  18081. /**
  18082. * The scale of the device to be used when translating from device space to babylon space.
  18083. */
  18084. deviceScaleFactor: number;
  18085. /**
  18086. * Updates the poseControlled values based on the input device pose.
  18087. * @param poseData the pose data to update the object with
  18088. */
  18089. updateFromDevice(poseData: DevicePose): void;
  18090. }
  18091. /**
  18092. * Set of options to customize the webVRCamera
  18093. */
  18094. export interface WebVROptions {
  18095. /**
  18096. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  18097. */
  18098. trackPosition?: boolean;
  18099. /**
  18100. * Sets the scale of the vrDevice in babylon space. (default: 1)
  18101. */
  18102. positionScale?: number;
  18103. /**
  18104. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  18105. */
  18106. displayName?: string;
  18107. /**
  18108. * Should the native controller meshes be initialized. (default: true)
  18109. */
  18110. controllerMeshes?: boolean;
  18111. /**
  18112. * Creating a default HemiLight only on controllers. (default: true)
  18113. */
  18114. defaultLightingOnControllers?: boolean;
  18115. /**
  18116. * If you don't want to use the default VR button of the helper. (default: false)
  18117. */
  18118. useCustomVRButton?: boolean;
  18119. /**
  18120. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  18121. */
  18122. customVRButton?: HTMLButtonElement;
  18123. /**
  18124. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  18125. */
  18126. rayLength?: number;
  18127. /**
  18128. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  18129. */
  18130. defaultHeight?: number;
  18131. /**
  18132. * If multiview should be used if availible (default: false)
  18133. */
  18134. useMultiview?: boolean;
  18135. }
  18136. /**
  18137. * This represents a WebVR camera.
  18138. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  18139. * @example http://doc.babylonjs.com/how_to/webvr_camera
  18140. */
  18141. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  18142. private webVROptions;
  18143. /**
  18144. * @hidden
  18145. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  18146. */
  18147. _vrDevice: any;
  18148. /**
  18149. * The rawPose of the vrDevice.
  18150. */
  18151. rawPose: Nullable<DevicePose>;
  18152. private _onVREnabled;
  18153. private _specsVersion;
  18154. private _attached;
  18155. private _frameData;
  18156. protected _descendants: Array<Node>;
  18157. private _deviceRoomPosition;
  18158. /** @hidden */
  18159. _deviceRoomRotationQuaternion: Quaternion;
  18160. private _standingMatrix;
  18161. /**
  18162. * Represents device position in babylon space.
  18163. */
  18164. devicePosition: Vector3;
  18165. /**
  18166. * Represents device rotation in babylon space.
  18167. */
  18168. deviceRotationQuaternion: Quaternion;
  18169. /**
  18170. * The scale of the device to be used when translating from device space to babylon space.
  18171. */
  18172. deviceScaleFactor: number;
  18173. private _deviceToWorld;
  18174. private _worldToDevice;
  18175. /**
  18176. * References to the webVR controllers for the vrDevice.
  18177. */
  18178. controllers: Array<WebVRController>;
  18179. /**
  18180. * Emits an event when a controller is attached.
  18181. */
  18182. onControllersAttachedObservable: Observable<WebVRController[]>;
  18183. /**
  18184. * Emits an event when a controller's mesh has been loaded;
  18185. */
  18186. onControllerMeshLoadedObservable: Observable<WebVRController>;
  18187. /**
  18188. * Emits an event when the HMD's pose has been updated.
  18189. */
  18190. onPoseUpdatedFromDeviceObservable: Observable<any>;
  18191. private _poseSet;
  18192. /**
  18193. * If the rig cameras be used as parent instead of this camera.
  18194. */
  18195. rigParenting: boolean;
  18196. private _lightOnControllers;
  18197. private _defaultHeight?;
  18198. /**
  18199. * Instantiates a WebVRFreeCamera.
  18200. * @param name The name of the WebVRFreeCamera
  18201. * @param position The starting anchor position for the camera
  18202. * @param scene The scene the camera belongs to
  18203. * @param webVROptions a set of customizable options for the webVRCamera
  18204. */
  18205. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  18206. /**
  18207. * Gets the device distance from the ground in meters.
  18208. * @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.
  18209. */
  18210. deviceDistanceToRoomGround(): number;
  18211. /**
  18212. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  18213. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  18214. */
  18215. useStandingMatrix(callback?: (bool: boolean) => void): void;
  18216. /**
  18217. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  18218. * @returns A promise with a boolean set to if the standing matrix is supported.
  18219. */
  18220. useStandingMatrixAsync(): Promise<boolean>;
  18221. /**
  18222. * Disposes the camera
  18223. */
  18224. dispose(): void;
  18225. /**
  18226. * Gets a vrController by name.
  18227. * @param name The name of the controller to retreive
  18228. * @returns the controller matching the name specified or null if not found
  18229. */
  18230. getControllerByName(name: string): Nullable<WebVRController>;
  18231. private _leftController;
  18232. /**
  18233. * The controller corresponding to the users left hand.
  18234. */
  18235. readonly leftController: Nullable<WebVRController>;
  18236. private _rightController;
  18237. /**
  18238. * The controller corresponding to the users right hand.
  18239. */
  18240. readonly rightController: Nullable<WebVRController>;
  18241. /**
  18242. * Casts a ray forward from the vrCamera's gaze.
  18243. * @param length Length of the ray (default: 100)
  18244. * @returns the ray corresponding to the gaze
  18245. */
  18246. getForwardRay(length?: number): Ray;
  18247. /**
  18248. * @hidden
  18249. * Updates the camera based on device's frame data
  18250. */
  18251. _checkInputs(): void;
  18252. /**
  18253. * Updates the poseControlled values based on the input device pose.
  18254. * @param poseData Pose coming from the device
  18255. */
  18256. updateFromDevice(poseData: DevicePose): void;
  18257. private _htmlElementAttached;
  18258. private _detachIfAttached;
  18259. /**
  18260. * WebVR's attach control will start broadcasting frames to the device.
  18261. * Note that in certain browsers (chrome for example) this function must be called
  18262. * within a user-interaction callback. Example:
  18263. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  18264. *
  18265. * @param element html element to attach the vrDevice to
  18266. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  18267. */
  18268. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18269. /**
  18270. * Detaches the camera from the html element and disables VR
  18271. *
  18272. * @param element html element to detach from
  18273. */
  18274. detachControl(element: HTMLElement): void;
  18275. /**
  18276. * @returns the name of this class
  18277. */
  18278. getClassName(): string;
  18279. /**
  18280. * Calls resetPose on the vrDisplay
  18281. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  18282. */
  18283. resetToCurrentRotation(): void;
  18284. /**
  18285. * @hidden
  18286. * Updates the rig cameras (left and right eye)
  18287. */
  18288. _updateRigCameras(): void;
  18289. private _workingVector;
  18290. private _oneVector;
  18291. private _workingMatrix;
  18292. private updateCacheCalled;
  18293. private _correctPositionIfNotTrackPosition;
  18294. /**
  18295. * @hidden
  18296. * Updates the cached values of the camera
  18297. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  18298. */
  18299. _updateCache(ignoreParentClass?: boolean): void;
  18300. /**
  18301. * @hidden
  18302. * Get current device position in babylon world
  18303. */
  18304. _computeDevicePosition(): void;
  18305. /**
  18306. * Updates the current device position and rotation in the babylon world
  18307. */
  18308. update(): void;
  18309. /**
  18310. * @hidden
  18311. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  18312. * @returns an identity matrix
  18313. */
  18314. _getViewMatrix(): Matrix;
  18315. private _tmpMatrix;
  18316. /**
  18317. * This function is called by the two RIG cameras.
  18318. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  18319. * @hidden
  18320. */
  18321. _getWebVRViewMatrix(): Matrix;
  18322. /** @hidden */
  18323. _getWebVRProjectionMatrix(): Matrix;
  18324. private _onGamepadConnectedObserver;
  18325. private _onGamepadDisconnectedObserver;
  18326. private _updateCacheWhenTrackingDisabledObserver;
  18327. /**
  18328. * Initializes the controllers and their meshes
  18329. */
  18330. initControllers(): void;
  18331. }
  18332. }
  18333. declare module "babylonjs/PostProcesses/postProcess" {
  18334. import { Nullable } from "babylonjs/types";
  18335. import { SmartArray } from "babylonjs/Misc/smartArray";
  18336. import { Observable } from "babylonjs/Misc/observable";
  18337. import { Color4, Vector2 } from "babylonjs/Maths/math";
  18338. import { Camera } from "babylonjs/Cameras/camera";
  18339. import { Effect } from "babylonjs/Materials/effect";
  18340. import "babylonjs/Shaders/postprocess.vertex";
  18341. import { IInspectable } from "babylonjs/Misc/iInspectable";
  18342. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  18343. import { Engine } from "babylonjs/Engines/engine";
  18344. /**
  18345. * Size options for a post process
  18346. */
  18347. export type PostProcessOptions = {
  18348. width: number;
  18349. height: number;
  18350. };
  18351. /**
  18352. * PostProcess can be used to apply a shader to a texture after it has been rendered
  18353. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  18354. */
  18355. export class PostProcess {
  18356. /** Name of the PostProcess. */
  18357. name: string;
  18358. /**
  18359. * Gets or sets the unique id of the post process
  18360. */
  18361. uniqueId: number;
  18362. /**
  18363. * Width of the texture to apply the post process on
  18364. */
  18365. width: number;
  18366. /**
  18367. * Height of the texture to apply the post process on
  18368. */
  18369. height: number;
  18370. /**
  18371. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  18372. * @hidden
  18373. */
  18374. _outputTexture: Nullable<InternalTexture>;
  18375. /**
  18376. * Sampling mode used by the shader
  18377. * See https://doc.babylonjs.com/classes/3.1/texture
  18378. */
  18379. renderTargetSamplingMode: number;
  18380. /**
  18381. * Clear color to use when screen clearing
  18382. */
  18383. clearColor: Color4;
  18384. /**
  18385. * If the buffer needs to be cleared before applying the post process. (default: true)
  18386. * Should be set to false if shader will overwrite all previous pixels.
  18387. */
  18388. autoClear: boolean;
  18389. /**
  18390. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  18391. */
  18392. alphaMode: number;
  18393. /**
  18394. * Sets the setAlphaBlendConstants of the babylon engine
  18395. */
  18396. alphaConstants: Color4;
  18397. /**
  18398. * Animations to be used for the post processing
  18399. */
  18400. animations: import("babylonjs/Animations/animation").Animation[];
  18401. /**
  18402. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  18403. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  18404. */
  18405. enablePixelPerfectMode: boolean;
  18406. /**
  18407. * Force the postprocess to be applied without taking in account viewport
  18408. */
  18409. forceFullscreenViewport: boolean;
  18410. /**
  18411. * List of inspectable custom properties (used by the Inspector)
  18412. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18413. */
  18414. inspectableCustomProperties: IInspectable[];
  18415. /**
  18416. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  18417. *
  18418. * | Value | Type | Description |
  18419. * | ----- | ----------------------------------- | ----------- |
  18420. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  18421. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  18422. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  18423. *
  18424. */
  18425. scaleMode: number;
  18426. /**
  18427. * Force textures to be a power of two (default: false)
  18428. */
  18429. alwaysForcePOT: boolean;
  18430. private _samples;
  18431. /**
  18432. * Number of sample textures (default: 1)
  18433. */
  18434. samples: number;
  18435. /**
  18436. * Modify the scale of the post process to be the same as the viewport (default: false)
  18437. */
  18438. adaptScaleToCurrentViewport: boolean;
  18439. private _camera;
  18440. private _scene;
  18441. private _engine;
  18442. private _options;
  18443. private _reusable;
  18444. private _textureType;
  18445. /**
  18446. * Smart array of input and output textures for the post process.
  18447. * @hidden
  18448. */
  18449. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  18450. /**
  18451. * The index in _textures that corresponds to the output texture.
  18452. * @hidden
  18453. */
  18454. _currentRenderTextureInd: number;
  18455. private _effect;
  18456. private _samplers;
  18457. private _fragmentUrl;
  18458. private _vertexUrl;
  18459. private _parameters;
  18460. private _scaleRatio;
  18461. protected _indexParameters: any;
  18462. private _shareOutputWithPostProcess;
  18463. private _texelSize;
  18464. private _forcedOutputTexture;
  18465. /**
  18466. * Returns the fragment url or shader name used in the post process.
  18467. * @returns the fragment url or name in the shader store.
  18468. */
  18469. getEffectName(): string;
  18470. /**
  18471. * An event triggered when the postprocess is activated.
  18472. */
  18473. onActivateObservable: Observable<Camera>;
  18474. private _onActivateObserver;
  18475. /**
  18476. * A function that is added to the onActivateObservable
  18477. */
  18478. onActivate: Nullable<(camera: Camera) => void>;
  18479. /**
  18480. * An event triggered when the postprocess changes its size.
  18481. */
  18482. onSizeChangedObservable: Observable<PostProcess>;
  18483. private _onSizeChangedObserver;
  18484. /**
  18485. * A function that is added to the onSizeChangedObservable
  18486. */
  18487. onSizeChanged: (postProcess: PostProcess) => void;
  18488. /**
  18489. * An event triggered when the postprocess applies its effect.
  18490. */
  18491. onApplyObservable: Observable<Effect>;
  18492. private _onApplyObserver;
  18493. /**
  18494. * A function that is added to the onApplyObservable
  18495. */
  18496. onApply: (effect: Effect) => void;
  18497. /**
  18498. * An event triggered before rendering the postprocess
  18499. */
  18500. onBeforeRenderObservable: Observable<Effect>;
  18501. private _onBeforeRenderObserver;
  18502. /**
  18503. * A function that is added to the onBeforeRenderObservable
  18504. */
  18505. onBeforeRender: (effect: Effect) => void;
  18506. /**
  18507. * An event triggered after rendering the postprocess
  18508. */
  18509. onAfterRenderObservable: Observable<Effect>;
  18510. private _onAfterRenderObserver;
  18511. /**
  18512. * A function that is added to the onAfterRenderObservable
  18513. */
  18514. onAfterRender: (efect: Effect) => void;
  18515. /**
  18516. * 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
  18517. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  18518. */
  18519. inputTexture: InternalTexture;
  18520. /**
  18521. * Gets the camera which post process is applied to.
  18522. * @returns The camera the post process is applied to.
  18523. */
  18524. getCamera(): Camera;
  18525. /**
  18526. * Gets the texel size of the postprocess.
  18527. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  18528. */
  18529. readonly texelSize: Vector2;
  18530. /**
  18531. * Creates a new instance PostProcess
  18532. * @param name The name of the PostProcess.
  18533. * @param fragmentUrl The url of the fragment shader to be used.
  18534. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  18535. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  18536. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  18537. * @param camera The camera to apply the render pass to.
  18538. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  18539. * @param engine The engine which the post process will be applied. (default: current engine)
  18540. * @param reusable If the post process can be reused on the same frame. (default: false)
  18541. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  18542. * @param textureType Type of textures used when performing the post process. (default: 0)
  18543. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  18544. * @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
  18545. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  18546. */
  18547. constructor(
  18548. /** Name of the PostProcess. */
  18549. 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);
  18550. /**
  18551. * Gets a string idenfifying the name of the class
  18552. * @returns "PostProcess" string
  18553. */
  18554. getClassName(): string;
  18555. /**
  18556. * Gets the engine which this post process belongs to.
  18557. * @returns The engine the post process was enabled with.
  18558. */
  18559. getEngine(): Engine;
  18560. /**
  18561. * The effect that is created when initializing the post process.
  18562. * @returns The created effect corresponding the the postprocess.
  18563. */
  18564. getEffect(): Effect;
  18565. /**
  18566. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  18567. * @param postProcess The post process to share the output with.
  18568. * @returns This post process.
  18569. */
  18570. shareOutputWith(postProcess: PostProcess): PostProcess;
  18571. /**
  18572. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  18573. * This should be called if the post process that shares output with this post process is disabled/disposed.
  18574. */
  18575. useOwnOutput(): void;
  18576. /**
  18577. * Updates the effect with the current post process compile time values and recompiles the shader.
  18578. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  18579. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  18580. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  18581. * @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
  18582. * @param onCompiled Called when the shader has been compiled.
  18583. * @param onError Called if there is an error when compiling a shader.
  18584. */
  18585. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18586. /**
  18587. * The post process is reusable if it can be used multiple times within one frame.
  18588. * @returns If the post process is reusable
  18589. */
  18590. isReusable(): boolean;
  18591. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  18592. markTextureDirty(): void;
  18593. /**
  18594. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  18595. * 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.
  18596. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  18597. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  18598. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  18599. * @returns The target texture that was bound to be written to.
  18600. */
  18601. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  18602. /**
  18603. * If the post process is supported.
  18604. */
  18605. readonly isSupported: boolean;
  18606. /**
  18607. * The aspect ratio of the output texture.
  18608. */
  18609. readonly aspectRatio: number;
  18610. /**
  18611. * Get a value indicating if the post-process is ready to be used
  18612. * @returns true if the post-process is ready (shader is compiled)
  18613. */
  18614. isReady(): boolean;
  18615. /**
  18616. * Binds all textures and uniforms to the shader, this will be run on every pass.
  18617. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  18618. */
  18619. apply(): Nullable<Effect>;
  18620. private _disposeTextures;
  18621. /**
  18622. * Disposes the post process.
  18623. * @param camera The camera to dispose the post process on.
  18624. */
  18625. dispose(camera?: Camera): void;
  18626. }
  18627. }
  18628. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  18629. /** @hidden */
  18630. export var kernelBlurVaryingDeclaration: {
  18631. name: string;
  18632. shader: string;
  18633. };
  18634. }
  18635. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  18636. /** @hidden */
  18637. export var kernelBlurFragment: {
  18638. name: string;
  18639. shader: string;
  18640. };
  18641. }
  18642. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  18643. /** @hidden */
  18644. export var kernelBlurFragment2: {
  18645. name: string;
  18646. shader: string;
  18647. };
  18648. }
  18649. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  18650. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  18651. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  18652. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  18653. /** @hidden */
  18654. export var kernelBlurPixelShader: {
  18655. name: string;
  18656. shader: string;
  18657. };
  18658. }
  18659. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  18660. /** @hidden */
  18661. export var kernelBlurVertex: {
  18662. name: string;
  18663. shader: string;
  18664. };
  18665. }
  18666. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  18667. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  18668. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  18669. /** @hidden */
  18670. export var kernelBlurVertexShader: {
  18671. name: string;
  18672. shader: string;
  18673. };
  18674. }
  18675. declare module "babylonjs/PostProcesses/blurPostProcess" {
  18676. import { Vector2 } from "babylonjs/Maths/math";
  18677. import { Nullable } from "babylonjs/types";
  18678. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  18679. import { Camera } from "babylonjs/Cameras/camera";
  18680. import { Effect } from "babylonjs/Materials/effect";
  18681. import { Engine } from "babylonjs/Engines/engine";
  18682. import "babylonjs/Shaders/kernelBlur.fragment";
  18683. import "babylonjs/Shaders/kernelBlur.vertex";
  18684. /**
  18685. * The Blur Post Process which blurs an image based on a kernel and direction.
  18686. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  18687. */
  18688. export class BlurPostProcess extends PostProcess {
  18689. /** The direction in which to blur the image. */
  18690. direction: Vector2;
  18691. private blockCompilation;
  18692. protected _kernel: number;
  18693. protected _idealKernel: number;
  18694. protected _packedFloat: boolean;
  18695. private _staticDefines;
  18696. /**
  18697. * Sets the length in pixels of the blur sample region
  18698. */
  18699. /**
  18700. * Gets the length in pixels of the blur sample region
  18701. */
  18702. kernel: number;
  18703. /**
  18704. * Sets wether or not the blur needs to unpack/repack floats
  18705. */
  18706. /**
  18707. * Gets wether or not the blur is unpacking/repacking floats
  18708. */
  18709. packedFloat: boolean;
  18710. /**
  18711. * Creates a new instance BlurPostProcess
  18712. * @param name The name of the effect.
  18713. * @param direction The direction in which to blur the image.
  18714. * @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.
  18715. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  18716. * @param camera The camera to apply the render pass to.
  18717. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  18718. * @param engine The engine which the post process will be applied. (default: current engine)
  18719. * @param reusable If the post process can be reused on the same frame. (default: false)
  18720. * @param textureType Type of textures used when performing the post process. (default: 0)
  18721. * @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)
  18722. */
  18723. constructor(name: string,
  18724. /** The direction in which to blur the image. */
  18725. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  18726. /**
  18727. * Updates the effect with the current post process compile time values and recompiles the shader.
  18728. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  18729. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  18730. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  18731. * @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
  18732. * @param onCompiled Called when the shader has been compiled.
  18733. * @param onError Called if there is an error when compiling a shader.
  18734. */
  18735. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18736. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18737. /**
  18738. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  18739. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  18740. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  18741. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  18742. * The gaps between physical kernels are compensated for in the weighting of the samples
  18743. * @param idealKernel Ideal blur kernel.
  18744. * @return Nearest best kernel.
  18745. */
  18746. protected _nearestBestKernel(idealKernel: number): number;
  18747. /**
  18748. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  18749. * @param x The point on the Gaussian distribution to sample.
  18750. * @return the value of the Gaussian function at x.
  18751. */
  18752. protected _gaussianWeight(x: number): number;
  18753. /**
  18754. * Generates a string that can be used as a floating point number in GLSL.
  18755. * @param x Value to print.
  18756. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  18757. * @return GLSL float string.
  18758. */
  18759. protected _glslFloat(x: number, decimalFigures?: number): string;
  18760. }
  18761. }
  18762. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  18763. import { Scene } from "babylonjs/scene";
  18764. import { Plane } from "babylonjs/Maths/math";
  18765. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  18766. /**
  18767. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18768. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18769. * You can then easily use it as a reflectionTexture on a flat surface.
  18770. * In case the surface is not a plane, please consider relying on reflection probes.
  18771. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18772. */
  18773. export class MirrorTexture extends RenderTargetTexture {
  18774. private scene;
  18775. /**
  18776. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  18777. * 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.
  18778. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18779. */
  18780. mirrorPlane: Plane;
  18781. /**
  18782. * Define the blur ratio used to blur the reflection if needed.
  18783. */
  18784. blurRatio: number;
  18785. /**
  18786. * Define the adaptive blur kernel used to blur the reflection if needed.
  18787. * This will autocompute the closest best match for the `blurKernel`
  18788. */
  18789. adaptiveBlurKernel: number;
  18790. /**
  18791. * Define the blur kernel used to blur the reflection if needed.
  18792. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18793. */
  18794. blurKernel: number;
  18795. /**
  18796. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  18797. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18798. */
  18799. blurKernelX: number;
  18800. /**
  18801. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  18802. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18803. */
  18804. blurKernelY: number;
  18805. private _autoComputeBlurKernel;
  18806. protected _onRatioRescale(): void;
  18807. private _updateGammaSpace;
  18808. private _imageProcessingConfigChangeObserver;
  18809. private _transformMatrix;
  18810. private _mirrorMatrix;
  18811. private _savedViewMatrix;
  18812. private _blurX;
  18813. private _blurY;
  18814. private _adaptiveBlurKernel;
  18815. private _blurKernelX;
  18816. private _blurKernelY;
  18817. private _blurRatio;
  18818. /**
  18819. * Instantiates a Mirror Texture.
  18820. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18821. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18822. * You can then easily use it as a reflectionTexture on a flat surface.
  18823. * In case the surface is not a plane, please consider relying on reflection probes.
  18824. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18825. * @param name
  18826. * @param size
  18827. * @param scene
  18828. * @param generateMipMaps
  18829. * @param type
  18830. * @param samplingMode
  18831. * @param generateDepthBuffer
  18832. */
  18833. constructor(name: string, size: number | {
  18834. width: number;
  18835. height: number;
  18836. } | {
  18837. ratio: number;
  18838. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  18839. private _preparePostProcesses;
  18840. /**
  18841. * Clone the mirror texture.
  18842. * @returns the cloned texture
  18843. */
  18844. clone(): MirrorTexture;
  18845. /**
  18846. * Serialize the texture to a JSON representation you could use in Parse later on
  18847. * @returns the serialized JSON representation
  18848. */
  18849. serialize(): any;
  18850. /**
  18851. * Dispose the texture and release its associated resources.
  18852. */
  18853. dispose(): void;
  18854. }
  18855. }
  18856. declare module "babylonjs/Materials/Textures/texture" {
  18857. import { Observable } from "babylonjs/Misc/observable";
  18858. import { Nullable } from "babylonjs/types";
  18859. import { Scene } from "babylonjs/scene";
  18860. import { Matrix } from "babylonjs/Maths/math";
  18861. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18862. import { IInspectable } from "babylonjs/Misc/iInspectable";
  18863. /**
  18864. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18865. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18866. */
  18867. export class Texture extends BaseTexture {
  18868. /** @hidden */
  18869. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  18870. /** @hidden */
  18871. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  18872. /** @hidden */
  18873. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  18874. /** nearest is mag = nearest and min = nearest and mip = linear */
  18875. static readonly NEAREST_SAMPLINGMODE: number;
  18876. /** nearest is mag = nearest and min = nearest and mip = linear */
  18877. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  18878. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18879. static readonly BILINEAR_SAMPLINGMODE: number;
  18880. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18881. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  18882. /** Trilinear is mag = linear and min = linear and mip = linear */
  18883. static readonly TRILINEAR_SAMPLINGMODE: number;
  18884. /** Trilinear is mag = linear and min = linear and mip = linear */
  18885. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  18886. /** mag = nearest and min = nearest and mip = nearest */
  18887. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  18888. /** mag = nearest and min = linear and mip = nearest */
  18889. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  18890. /** mag = nearest and min = linear and mip = linear */
  18891. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  18892. /** mag = nearest and min = linear and mip = none */
  18893. static readonly NEAREST_LINEAR: number;
  18894. /** mag = nearest and min = nearest and mip = none */
  18895. static readonly NEAREST_NEAREST: number;
  18896. /** mag = linear and min = nearest and mip = nearest */
  18897. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  18898. /** mag = linear and min = nearest and mip = linear */
  18899. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  18900. /** mag = linear and min = linear and mip = none */
  18901. static readonly LINEAR_LINEAR: number;
  18902. /** mag = linear and min = nearest and mip = none */
  18903. static readonly LINEAR_NEAREST: number;
  18904. /** Explicit coordinates mode */
  18905. static readonly EXPLICIT_MODE: number;
  18906. /** Spherical coordinates mode */
  18907. static readonly SPHERICAL_MODE: number;
  18908. /** Planar coordinates mode */
  18909. static readonly PLANAR_MODE: number;
  18910. /** Cubic coordinates mode */
  18911. static readonly CUBIC_MODE: number;
  18912. /** Projection coordinates mode */
  18913. static readonly PROJECTION_MODE: number;
  18914. /** Inverse Cubic coordinates mode */
  18915. static readonly SKYBOX_MODE: number;
  18916. /** Inverse Cubic coordinates mode */
  18917. static readonly INVCUBIC_MODE: number;
  18918. /** Equirectangular coordinates mode */
  18919. static readonly EQUIRECTANGULAR_MODE: number;
  18920. /** Equirectangular Fixed coordinates mode */
  18921. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  18922. /** Equirectangular Fixed Mirrored coordinates mode */
  18923. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  18924. /** Texture is not repeating outside of 0..1 UVs */
  18925. static readonly CLAMP_ADDRESSMODE: number;
  18926. /** Texture is repeating outside of 0..1 UVs */
  18927. static readonly WRAP_ADDRESSMODE: number;
  18928. /** Texture is repeating and mirrored */
  18929. static readonly MIRROR_ADDRESSMODE: number;
  18930. /**
  18931. * 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
  18932. */
  18933. static UseSerializedUrlIfAny: boolean;
  18934. /**
  18935. * Define the url of the texture.
  18936. */
  18937. url: Nullable<string>;
  18938. /**
  18939. * Define an offset on the texture to offset the u coordinates of the UVs
  18940. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18941. */
  18942. uOffset: number;
  18943. /**
  18944. * Define an offset on the texture to offset the v coordinates of the UVs
  18945. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18946. */
  18947. vOffset: number;
  18948. /**
  18949. * Define an offset on the texture to scale the u coordinates of the UVs
  18950. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18951. */
  18952. uScale: number;
  18953. /**
  18954. * Define an offset on the texture to scale the v coordinates of the UVs
  18955. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18956. */
  18957. vScale: number;
  18958. /**
  18959. * Define an offset on the texture to rotate around the u coordinates of the UVs
  18960. * @see http://doc.babylonjs.com/how_to/more_materials
  18961. */
  18962. uAng: number;
  18963. /**
  18964. * Define an offset on the texture to rotate around the v coordinates of the UVs
  18965. * @see http://doc.babylonjs.com/how_to/more_materials
  18966. */
  18967. vAng: number;
  18968. /**
  18969. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  18970. * @see http://doc.babylonjs.com/how_to/more_materials
  18971. */
  18972. wAng: number;
  18973. /**
  18974. * Defines the center of rotation (U)
  18975. */
  18976. uRotationCenter: number;
  18977. /**
  18978. * Defines the center of rotation (V)
  18979. */
  18980. vRotationCenter: number;
  18981. /**
  18982. * Defines the center of rotation (W)
  18983. */
  18984. wRotationCenter: number;
  18985. /**
  18986. * Are mip maps generated for this texture or not.
  18987. */
  18988. readonly noMipmap: boolean;
  18989. /**
  18990. * List of inspectable custom properties (used by the Inspector)
  18991. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18992. */
  18993. inspectableCustomProperties: Nullable<IInspectable[]>;
  18994. private _noMipmap;
  18995. /** @hidden */
  18996. _invertY: boolean;
  18997. private _rowGenerationMatrix;
  18998. private _cachedTextureMatrix;
  18999. private _projectionModeMatrix;
  19000. private _t0;
  19001. private _t1;
  19002. private _t2;
  19003. private _cachedUOffset;
  19004. private _cachedVOffset;
  19005. private _cachedUScale;
  19006. private _cachedVScale;
  19007. private _cachedUAng;
  19008. private _cachedVAng;
  19009. private _cachedWAng;
  19010. private _cachedProjectionMatrixId;
  19011. private _cachedCoordinatesMode;
  19012. /** @hidden */
  19013. protected _initialSamplingMode: number;
  19014. /** @hidden */
  19015. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  19016. private _deleteBuffer;
  19017. protected _format: Nullable<number>;
  19018. private _delayedOnLoad;
  19019. private _delayedOnError;
  19020. /**
  19021. * Observable triggered once the texture has been loaded.
  19022. */
  19023. onLoadObservable: Observable<Texture>;
  19024. protected _isBlocking: boolean;
  19025. /**
  19026. * Is the texture preventing material to render while loading.
  19027. * If false, a default texture will be used instead of the loading one during the preparation step.
  19028. */
  19029. isBlocking: boolean;
  19030. /**
  19031. * Get the current sampling mode associated with the texture.
  19032. */
  19033. readonly samplingMode: number;
  19034. /**
  19035. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  19036. */
  19037. readonly invertY: boolean;
  19038. /**
  19039. * Instantiates a new texture.
  19040. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  19041. * @see http://doc.babylonjs.com/babylon101/materials#texture
  19042. * @param url define the url of the picture to load as a texture
  19043. * @param scene define the scene the texture will belong to
  19044. * @param noMipmap define if the texture will require mip maps or not
  19045. * @param invertY define if the texture needs to be inverted on the y axis during loading
  19046. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  19047. * @param onLoad define a callback triggered when the texture has been loaded
  19048. * @param onError define a callback triggered when an error occurred during the loading session
  19049. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  19050. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  19051. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  19052. */
  19053. 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);
  19054. /**
  19055. * Update the url (and optional buffer) of this texture if url was null during construction.
  19056. * @param url the url of the texture
  19057. * @param buffer the buffer of the texture (defaults to null)
  19058. * @param onLoad callback called when the texture is loaded (defaults to null)
  19059. */
  19060. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  19061. /**
  19062. * Finish the loading sequence of a texture flagged as delayed load.
  19063. * @hidden
  19064. */
  19065. delayLoad(): void;
  19066. private _prepareRowForTextureGeneration;
  19067. /**
  19068. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  19069. * @returns the transform matrix of the texture.
  19070. */
  19071. getTextureMatrix(): Matrix;
  19072. /**
  19073. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  19074. * @returns The reflection texture transform
  19075. */
  19076. getReflectionTextureMatrix(): Matrix;
  19077. /**
  19078. * Clones the texture.
  19079. * @returns the cloned texture
  19080. */
  19081. clone(): Texture;
  19082. /**
  19083. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  19084. * @returns The JSON representation of the texture
  19085. */
  19086. serialize(): any;
  19087. /**
  19088. * Get the current class name of the texture useful for serialization or dynamic coding.
  19089. * @returns "Texture"
  19090. */
  19091. getClassName(): string;
  19092. /**
  19093. * Dispose the texture and release its associated resources.
  19094. */
  19095. dispose(): void;
  19096. /**
  19097. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  19098. * @param parsedTexture Define the JSON representation of the texture
  19099. * @param scene Define the scene the parsed texture should be instantiated in
  19100. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  19101. * @returns The parsed texture if successful
  19102. */
  19103. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  19104. /**
  19105. * Creates a texture from its base 64 representation.
  19106. * @param data Define the base64 payload without the data: prefix
  19107. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  19108. * @param scene Define the scene the texture should belong to
  19109. * @param noMipmap Forces the texture to not create mip map information if true
  19110. * @param invertY define if the texture needs to be inverted on the y axis during loading
  19111. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  19112. * @param onLoad define a callback triggered when the texture has been loaded
  19113. * @param onError define a callback triggered when an error occurred during the loading session
  19114. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  19115. * @returns the created texture
  19116. */
  19117. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  19118. /**
  19119. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  19120. * @param data Define the base64 payload without the data: prefix
  19121. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  19122. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  19123. * @param scene Define the scene the texture should belong to
  19124. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  19125. * @param noMipmap Forces the texture to not create mip map information if true
  19126. * @param invertY define if the texture needs to be inverted on the y axis during loading
  19127. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  19128. * @param onLoad define a callback triggered when the texture has been loaded
  19129. * @param onError define a callback triggered when an error occurred during the loading session
  19130. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  19131. * @returns the created texture
  19132. */
  19133. 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;
  19134. }
  19135. }
  19136. declare module "babylonjs/PostProcesses/postProcessManager" {
  19137. import { Nullable } from "babylonjs/types";
  19138. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  19139. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  19140. import { Scene } from "babylonjs/scene";
  19141. /**
  19142. * PostProcessManager is used to manage one or more post processes or post process pipelines
  19143. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  19144. */
  19145. export class PostProcessManager {
  19146. private _scene;
  19147. private _indexBuffer;
  19148. private _vertexBuffers;
  19149. /**
  19150. * Creates a new instance PostProcess
  19151. * @param scene The scene that the post process is associated with.
  19152. */
  19153. constructor(scene: Scene);
  19154. private _prepareBuffers;
  19155. private _buildIndexBuffer;
  19156. /**
  19157. * Rebuilds the vertex buffers of the manager.
  19158. * @hidden
  19159. */
  19160. _rebuild(): void;
  19161. /**
  19162. * Prepares a frame to be run through a post process.
  19163. * @param sourceTexture The input texture to the post procesess. (default: null)
  19164. * @param postProcesses An array of post processes to be run. (default: null)
  19165. * @returns True if the post processes were able to be run.
  19166. * @hidden
  19167. */
  19168. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  19169. /**
  19170. * Manually render a set of post processes to a texture.
  19171. * @param postProcesses An array of post processes to be run.
  19172. * @param targetTexture The target texture to render to.
  19173. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  19174. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  19175. * @param lodLevel defines which lod of the texture to render to
  19176. */
  19177. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  19178. /**
  19179. * Finalize the result of the output of the postprocesses.
  19180. * @param doNotPresent If true the result will not be displayed to the screen.
  19181. * @param targetTexture The target texture to render to.
  19182. * @param faceIndex The index of the face to bind the target texture to.
  19183. * @param postProcesses The array of post processes to render.
  19184. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  19185. * @hidden
  19186. */
  19187. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  19188. /**
  19189. * Disposes of the post process manager.
  19190. */
  19191. dispose(): void;
  19192. }
  19193. }
  19194. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  19195. import { Scene } from "babylonjs/scene";
  19196. import { ISceneComponent } from "babylonjs/sceneComponent";
  19197. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  19198. module "babylonjs/abstractScene" {
  19199. interface AbstractScene {
  19200. /**
  19201. * The list of procedural textures added to the scene
  19202. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  19203. */
  19204. proceduralTextures: Array<ProceduralTexture>;
  19205. }
  19206. }
  19207. /**
  19208. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  19209. * in a given scene.
  19210. */
  19211. export class ProceduralTextureSceneComponent implements ISceneComponent {
  19212. /**
  19213. * The component name helpfull to identify the component in the list of scene components.
  19214. */
  19215. readonly name: string;
  19216. /**
  19217. * The scene the component belongs to.
  19218. */
  19219. scene: Scene;
  19220. /**
  19221. * Creates a new instance of the component for the given scene
  19222. * @param scene Defines the scene to register the component in
  19223. */
  19224. constructor(scene: Scene);
  19225. /**
  19226. * Registers the component in a given scene
  19227. */
  19228. register(): void;
  19229. /**
  19230. * Rebuilds the elements related to this component in case of
  19231. * context lost for instance.
  19232. */
  19233. rebuild(): void;
  19234. /**
  19235. * Disposes the component and the associated ressources.
  19236. */
  19237. dispose(): void;
  19238. private _beforeClear;
  19239. }
  19240. }
  19241. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  19242. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  19243. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  19244. module "babylonjs/Engines/engine" {
  19245. interface Engine {
  19246. /**
  19247. * Creates a new render target cube texture
  19248. * @param size defines the size of the texture
  19249. * @param options defines the options used to create the texture
  19250. * @returns a new render target cube texture stored in an InternalTexture
  19251. */
  19252. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  19253. }
  19254. }
  19255. }
  19256. declare module "babylonjs/Shaders/procedural.vertex" {
  19257. /** @hidden */
  19258. export var proceduralVertexShader: {
  19259. name: string;
  19260. shader: string;
  19261. };
  19262. }
  19263. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  19264. import { Observable } from "babylonjs/Misc/observable";
  19265. import { Nullable } from "babylonjs/types";
  19266. import { Scene } from "babylonjs/scene";
  19267. import { Matrix, Vector3, Vector2, Color3, Color4 } from "babylonjs/Maths/math";
  19268. import { Effect } from "babylonjs/Materials/effect";
  19269. import { Texture } from "babylonjs/Materials/Textures/texture";
  19270. import "babylonjs/Engines/Extensions/engine.renderTarget";
  19271. import "babylonjs/Shaders/procedural.vertex";
  19272. /**
  19273. * 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.
  19274. * This is the base class of any Procedural texture and contains most of the shareable code.
  19275. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  19276. */
  19277. export class ProceduralTexture extends Texture {
  19278. isCube: boolean;
  19279. /**
  19280. * Define if the texture is enabled or not (disabled texture will not render)
  19281. */
  19282. isEnabled: boolean;
  19283. /**
  19284. * Define if the texture must be cleared before rendering (default is true)
  19285. */
  19286. autoClear: boolean;
  19287. /**
  19288. * Callback called when the texture is generated
  19289. */
  19290. onGenerated: () => void;
  19291. /**
  19292. * Event raised when the texture is generated
  19293. */
  19294. onGeneratedObservable: Observable<ProceduralTexture>;
  19295. /** @hidden */
  19296. _generateMipMaps: boolean;
  19297. /** @hidden **/
  19298. _effect: Effect;
  19299. /** @hidden */
  19300. _textures: {
  19301. [key: string]: Texture;
  19302. };
  19303. private _size;
  19304. private _currentRefreshId;
  19305. private _refreshRate;
  19306. private _vertexBuffers;
  19307. private _indexBuffer;
  19308. private _uniforms;
  19309. private _samplers;
  19310. private _fragment;
  19311. private _floats;
  19312. private _ints;
  19313. private _floatsArrays;
  19314. private _colors3;
  19315. private _colors4;
  19316. private _vectors2;
  19317. private _vectors3;
  19318. private _matrices;
  19319. private _fallbackTexture;
  19320. private _fallbackTextureUsed;
  19321. private _engine;
  19322. private _cachedDefines;
  19323. private _contentUpdateId;
  19324. private _contentData;
  19325. /**
  19326. * Instantiates a new procedural texture.
  19327. * 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.
  19328. * This is the base class of any Procedural texture and contains most of the shareable code.
  19329. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  19330. * @param name Define the name of the texture
  19331. * @param size Define the size of the texture to create
  19332. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  19333. * @param scene Define the scene the texture belongs to
  19334. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  19335. * @param generateMipMaps Define if the texture should creates mip maps or not
  19336. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  19337. */
  19338. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  19339. /**
  19340. * The effect that is created when initializing the post process.
  19341. * @returns The created effect corresponding the the postprocess.
  19342. */
  19343. getEffect(): Effect;
  19344. /**
  19345. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  19346. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  19347. */
  19348. getContent(): Nullable<ArrayBufferView>;
  19349. private _createIndexBuffer;
  19350. /** @hidden */
  19351. _rebuild(): void;
  19352. /**
  19353. * Resets the texture in order to recreate its associated resources.
  19354. * This can be called in case of context loss
  19355. */
  19356. reset(): void;
  19357. protected _getDefines(): string;
  19358. /**
  19359. * Is the texture ready to be used ? (rendered at least once)
  19360. * @returns true if ready, otherwise, false.
  19361. */
  19362. isReady(): boolean;
  19363. /**
  19364. * Resets the refresh counter of the texture and start bak from scratch.
  19365. * Could be useful to regenerate the texture if it is setup to render only once.
  19366. */
  19367. resetRefreshCounter(): void;
  19368. /**
  19369. * Set the fragment shader to use in order to render the texture.
  19370. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  19371. */
  19372. setFragment(fragment: any): void;
  19373. /**
  19374. * Define the refresh rate of the texture or the rendering frequency.
  19375. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  19376. */
  19377. refreshRate: number;
  19378. /** @hidden */
  19379. _shouldRender(): boolean;
  19380. /**
  19381. * Get the size the texture is rendering at.
  19382. * @returns the size (texture is always squared)
  19383. */
  19384. getRenderSize(): number;
  19385. /**
  19386. * Resize the texture to new value.
  19387. * @param size Define the new size the texture should have
  19388. * @param generateMipMaps Define whether the new texture should create mip maps
  19389. */
  19390. resize(size: number, generateMipMaps: boolean): void;
  19391. private _checkUniform;
  19392. /**
  19393. * Set a texture in the shader program used to render.
  19394. * @param name Define the name of the uniform samplers as defined in the shader
  19395. * @param texture Define the texture to bind to this sampler
  19396. * @return the texture itself allowing "fluent" like uniform updates
  19397. */
  19398. setTexture(name: string, texture: Texture): ProceduralTexture;
  19399. /**
  19400. * Set a float in the shader.
  19401. * @param name Define the name of the uniform as defined in the shader
  19402. * @param value Define the value to give to the uniform
  19403. * @return the texture itself allowing "fluent" like uniform updates
  19404. */
  19405. setFloat(name: string, value: number): ProceduralTexture;
  19406. /**
  19407. * Set a int in the shader.
  19408. * @param name Define the name of the uniform as defined in the shader
  19409. * @param value Define the value to give to the uniform
  19410. * @return the texture itself allowing "fluent" like uniform updates
  19411. */
  19412. setInt(name: string, value: number): ProceduralTexture;
  19413. /**
  19414. * Set an array of floats in the shader.
  19415. * @param name Define the name of the uniform as defined in the shader
  19416. * @param value Define the value to give to the uniform
  19417. * @return the texture itself allowing "fluent" like uniform updates
  19418. */
  19419. setFloats(name: string, value: number[]): ProceduralTexture;
  19420. /**
  19421. * Set a vec3 in the shader from a Color3.
  19422. * @param name Define the name of the uniform as defined in the shader
  19423. * @param value Define the value to give to the uniform
  19424. * @return the texture itself allowing "fluent" like uniform updates
  19425. */
  19426. setColor3(name: string, value: Color3): ProceduralTexture;
  19427. /**
  19428. * Set a vec4 in the shader from a Color4.
  19429. * @param name Define the name of the uniform as defined in the shader
  19430. * @param value Define the value to give to the uniform
  19431. * @return the texture itself allowing "fluent" like uniform updates
  19432. */
  19433. setColor4(name: string, value: Color4): ProceduralTexture;
  19434. /**
  19435. * Set a vec2 in the shader from a Vector2.
  19436. * @param name Define the name of the uniform as defined in the shader
  19437. * @param value Define the value to give to the uniform
  19438. * @return the texture itself allowing "fluent" like uniform updates
  19439. */
  19440. setVector2(name: string, value: Vector2): ProceduralTexture;
  19441. /**
  19442. * Set a vec3 in the shader from a Vector3.
  19443. * @param name Define the name of the uniform as defined in the shader
  19444. * @param value Define the value to give to the uniform
  19445. * @return the texture itself allowing "fluent" like uniform updates
  19446. */
  19447. setVector3(name: string, value: Vector3): ProceduralTexture;
  19448. /**
  19449. * Set a mat4 in the shader from a MAtrix.
  19450. * @param name Define the name of the uniform as defined in the shader
  19451. * @param value Define the value to give to the uniform
  19452. * @return the texture itself allowing "fluent" like uniform updates
  19453. */
  19454. setMatrix(name: string, value: Matrix): ProceduralTexture;
  19455. /**
  19456. * Render the texture to its associated render target.
  19457. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  19458. */
  19459. render(useCameraPostProcess?: boolean): void;
  19460. /**
  19461. * Clone the texture.
  19462. * @returns the cloned texture
  19463. */
  19464. clone(): ProceduralTexture;
  19465. /**
  19466. * Dispose the texture and release its asoociated resources.
  19467. */
  19468. dispose(): void;
  19469. }
  19470. }
  19471. declare module "babylonjs/Particles/baseParticleSystem" {
  19472. import { Nullable } from "babylonjs/types";
  19473. import { Color4, Vector2, Vector3 } from "babylonjs/Maths/math";
  19474. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19475. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  19476. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  19477. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  19478. import { Scene } from "babylonjs/scene";
  19479. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/tools";
  19480. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  19481. import { Texture } from "babylonjs/Materials/Textures/texture";
  19482. import { Animation } from "babylonjs/Animations/animation";
  19483. /**
  19484. * This represents the base class for particle system in Babylon.
  19485. * 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.
  19486. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  19487. * @example https://doc.babylonjs.com/babylon101/particles
  19488. */
  19489. export class BaseParticleSystem {
  19490. /**
  19491. * Source color is added to the destination color without alpha affecting the result
  19492. */
  19493. static BLENDMODE_ONEONE: number;
  19494. /**
  19495. * Blend current color and particle color using particle’s alpha
  19496. */
  19497. static BLENDMODE_STANDARD: number;
  19498. /**
  19499. * Add current color and particle color multiplied by particle’s alpha
  19500. */
  19501. static BLENDMODE_ADD: number;
  19502. /**
  19503. * Multiply current color with particle color
  19504. */
  19505. static BLENDMODE_MULTIPLY: number;
  19506. /**
  19507. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  19508. */
  19509. static BLENDMODE_MULTIPLYADD: number;
  19510. /**
  19511. * List of animations used by the particle system.
  19512. */
  19513. animations: Animation[];
  19514. /**
  19515. * The id of the Particle system.
  19516. */
  19517. id: string;
  19518. /**
  19519. * The friendly name of the Particle system.
  19520. */
  19521. name: string;
  19522. /**
  19523. * The rendering group used by the Particle system to chose when to render.
  19524. */
  19525. renderingGroupId: number;
  19526. /**
  19527. * The emitter represents the Mesh or position we are attaching the particle system to.
  19528. */
  19529. emitter: Nullable<AbstractMesh | Vector3>;
  19530. /**
  19531. * The maximum number of particles to emit per frame
  19532. */
  19533. emitRate: number;
  19534. /**
  19535. * If you want to launch only a few particles at once, that can be done, as well.
  19536. */
  19537. manualEmitCount: number;
  19538. /**
  19539. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  19540. */
  19541. updateSpeed: number;
  19542. /**
  19543. * The amount of time the particle system is running (depends of the overall update speed).
  19544. */
  19545. targetStopDuration: number;
  19546. /**
  19547. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  19548. */
  19549. disposeOnStop: boolean;
  19550. /**
  19551. * Minimum power of emitting particles.
  19552. */
  19553. minEmitPower: number;
  19554. /**
  19555. * Maximum power of emitting particles.
  19556. */
  19557. maxEmitPower: number;
  19558. /**
  19559. * Minimum life time of emitting particles.
  19560. */
  19561. minLifeTime: number;
  19562. /**
  19563. * Maximum life time of emitting particles.
  19564. */
  19565. maxLifeTime: number;
  19566. /**
  19567. * Minimum Size of emitting particles.
  19568. */
  19569. minSize: number;
  19570. /**
  19571. * Maximum Size of emitting particles.
  19572. */
  19573. maxSize: number;
  19574. /**
  19575. * Minimum scale of emitting particles on X axis.
  19576. */
  19577. minScaleX: number;
  19578. /**
  19579. * Maximum scale of emitting particles on X axis.
  19580. */
  19581. maxScaleX: number;
  19582. /**
  19583. * Minimum scale of emitting particles on Y axis.
  19584. */
  19585. minScaleY: number;
  19586. /**
  19587. * Maximum scale of emitting particles on Y axis.
  19588. */
  19589. maxScaleY: number;
  19590. /**
  19591. * Gets or sets the minimal initial rotation in radians.
  19592. */
  19593. minInitialRotation: number;
  19594. /**
  19595. * Gets or sets the maximal initial rotation in radians.
  19596. */
  19597. maxInitialRotation: number;
  19598. /**
  19599. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  19600. */
  19601. minAngularSpeed: number;
  19602. /**
  19603. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  19604. */
  19605. maxAngularSpeed: number;
  19606. /**
  19607. * The texture used to render each particle. (this can be a spritesheet)
  19608. */
  19609. particleTexture: Nullable<Texture>;
  19610. /**
  19611. * The layer mask we are rendering the particles through.
  19612. */
  19613. layerMask: number;
  19614. /**
  19615. * This can help using your own shader to render the particle system.
  19616. * The according effect will be created
  19617. */
  19618. customShader: any;
  19619. /**
  19620. * By default particle system starts as soon as they are created. This prevents the
  19621. * automatic start to happen and let you decide when to start emitting particles.
  19622. */
  19623. preventAutoStart: boolean;
  19624. private _noiseTexture;
  19625. /**
  19626. * Gets or sets a texture used to add random noise to particle positions
  19627. */
  19628. noiseTexture: Nullable<ProceduralTexture>;
  19629. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  19630. noiseStrength: Vector3;
  19631. /**
  19632. * Callback triggered when the particle animation is ending.
  19633. */
  19634. onAnimationEnd: Nullable<() => void>;
  19635. /**
  19636. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  19637. */
  19638. blendMode: number;
  19639. /**
  19640. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  19641. * to override the particles.
  19642. */
  19643. forceDepthWrite: boolean;
  19644. /** 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 */
  19645. preWarmCycles: number;
  19646. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  19647. preWarmStepOffset: number;
  19648. /**
  19649. * 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)
  19650. */
  19651. spriteCellChangeSpeed: number;
  19652. /**
  19653. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  19654. */
  19655. startSpriteCellID: number;
  19656. /**
  19657. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  19658. */
  19659. endSpriteCellID: number;
  19660. /**
  19661. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  19662. */
  19663. spriteCellWidth: number;
  19664. /**
  19665. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  19666. */
  19667. spriteCellHeight: number;
  19668. /**
  19669. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  19670. */
  19671. spriteRandomStartCell: boolean;
  19672. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  19673. translationPivot: Vector2;
  19674. /** @hidden */
  19675. protected _isAnimationSheetEnabled: boolean;
  19676. /**
  19677. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  19678. */
  19679. beginAnimationOnStart: boolean;
  19680. /**
  19681. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  19682. */
  19683. beginAnimationFrom: number;
  19684. /**
  19685. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  19686. */
  19687. beginAnimationTo: number;
  19688. /**
  19689. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  19690. */
  19691. beginAnimationLoop: boolean;
  19692. /**
  19693. * Gets or sets a world offset applied to all particles
  19694. */
  19695. worldOffset: Vector3;
  19696. /**
  19697. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  19698. */
  19699. isAnimationSheetEnabled: boolean;
  19700. /**
  19701. * Get hosting scene
  19702. * @returns the scene
  19703. */
  19704. getScene(): Scene;
  19705. /**
  19706. * You can use gravity if you want to give an orientation to your particles.
  19707. */
  19708. gravity: Vector3;
  19709. protected _colorGradients: Nullable<Array<ColorGradient>>;
  19710. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  19711. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  19712. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  19713. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  19714. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  19715. protected _dragGradients: Nullable<Array<FactorGradient>>;
  19716. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  19717. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  19718. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  19719. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  19720. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  19721. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  19722. /**
  19723. * Defines the delay in milliseconds before starting the system (0 by default)
  19724. */
  19725. startDelay: number;
  19726. /**
  19727. * Gets the current list of drag gradients.
  19728. * You must use addDragGradient and removeDragGradient to udpate this list
  19729. * @returns the list of drag gradients
  19730. */
  19731. getDragGradients(): Nullable<Array<FactorGradient>>;
  19732. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  19733. limitVelocityDamping: number;
  19734. /**
  19735. * Gets the current list of limit velocity gradients.
  19736. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  19737. * @returns the list of limit velocity gradients
  19738. */
  19739. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  19740. /**
  19741. * Gets the current list of color gradients.
  19742. * You must use addColorGradient and removeColorGradient to udpate this list
  19743. * @returns the list of color gradients
  19744. */
  19745. getColorGradients(): Nullable<Array<ColorGradient>>;
  19746. /**
  19747. * Gets the current list of size gradients.
  19748. * You must use addSizeGradient and removeSizeGradient to udpate this list
  19749. * @returns the list of size gradients
  19750. */
  19751. getSizeGradients(): Nullable<Array<FactorGradient>>;
  19752. /**
  19753. * Gets the current list of color remap gradients.
  19754. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19755. * @returns the list of color remap gradients
  19756. */
  19757. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19758. /**
  19759. * Gets the current list of alpha remap gradients.
  19760. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19761. * @returns the list of alpha remap gradients
  19762. */
  19763. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19764. /**
  19765. * Gets the current list of life time gradients.
  19766. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19767. * @returns the list of life time gradients
  19768. */
  19769. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19770. /**
  19771. * Gets the current list of angular speed gradients.
  19772. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  19773. * @returns the list of angular speed gradients
  19774. */
  19775. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  19776. /**
  19777. * Gets the current list of velocity gradients.
  19778. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  19779. * @returns the list of velocity gradients
  19780. */
  19781. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  19782. /**
  19783. * Gets the current list of start size gradients.
  19784. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19785. * @returns the list of start size gradients
  19786. */
  19787. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19788. /**
  19789. * Gets the current list of emit rate gradients.
  19790. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19791. * @returns the list of emit rate gradients
  19792. */
  19793. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19794. /**
  19795. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  19796. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19797. */
  19798. direction1: Vector3;
  19799. /**
  19800. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  19801. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19802. */
  19803. direction2: Vector3;
  19804. /**
  19805. * 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.
  19806. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19807. */
  19808. minEmitBox: Vector3;
  19809. /**
  19810. * 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.
  19811. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19812. */
  19813. maxEmitBox: Vector3;
  19814. /**
  19815. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  19816. */
  19817. color1: Color4;
  19818. /**
  19819. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  19820. */
  19821. color2: Color4;
  19822. /**
  19823. * Color the particle will have at the end of its lifetime
  19824. */
  19825. colorDead: Color4;
  19826. /**
  19827. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  19828. */
  19829. textureMask: Color4;
  19830. /**
  19831. * The particle emitter type defines the emitter used by the particle system.
  19832. * It can be for example box, sphere, or cone...
  19833. */
  19834. particleEmitterType: IParticleEmitterType;
  19835. /** @hidden */
  19836. _isSubEmitter: boolean;
  19837. /**
  19838. * Gets or sets the billboard mode to use when isBillboardBased = true.
  19839. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  19840. */
  19841. billboardMode: number;
  19842. protected _isBillboardBased: boolean;
  19843. /**
  19844. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  19845. */
  19846. isBillboardBased: boolean;
  19847. /**
  19848. * The scene the particle system belongs to.
  19849. */
  19850. protected _scene: Scene;
  19851. /**
  19852. * Local cache of defines for image processing.
  19853. */
  19854. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  19855. /**
  19856. * Default configuration related to image processing available in the standard Material.
  19857. */
  19858. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  19859. /**
  19860. * Gets the image processing configuration used either in this material.
  19861. */
  19862. /**
  19863. * Sets the Default image processing configuration used either in the this material.
  19864. *
  19865. * If sets to null, the scene one is in use.
  19866. */
  19867. imageProcessingConfiguration: ImageProcessingConfiguration;
  19868. /**
  19869. * Attaches a new image processing configuration to the Standard Material.
  19870. * @param configuration
  19871. */
  19872. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  19873. /** @hidden */
  19874. protected _reset(): void;
  19875. /** @hidden */
  19876. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  19877. /**
  19878. * Instantiates a particle system.
  19879. * 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.
  19880. * @param name The name of the particle system
  19881. */
  19882. constructor(name: string);
  19883. /**
  19884. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19885. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19886. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19887. * @returns the emitter
  19888. */
  19889. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19890. /**
  19891. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19892. * @param radius The radius of the hemisphere to emit from
  19893. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19894. * @returns the emitter
  19895. */
  19896. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  19897. /**
  19898. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19899. * @param radius The radius of the sphere to emit from
  19900. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19901. * @returns the emitter
  19902. */
  19903. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  19904. /**
  19905. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19906. * @param radius The radius of the sphere to emit from
  19907. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19908. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19909. * @returns the emitter
  19910. */
  19911. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  19912. /**
  19913. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19914. * @param radius The radius of the emission cylinder
  19915. * @param height The height of the emission cylinder
  19916. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19917. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19918. * @returns the emitter
  19919. */
  19920. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  19921. /**
  19922. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19923. * @param radius The radius of the cylinder to emit from
  19924. * @param height The height of the emission cylinder
  19925. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19926. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19927. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19928. * @returns the emitter
  19929. */
  19930. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  19931. /**
  19932. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19933. * @param radius The radius of the cone to emit from
  19934. * @param angle The base angle of the cone
  19935. * @returns the emitter
  19936. */
  19937. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  19938. /**
  19939. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19940. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19941. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19942. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19943. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19944. * @returns the emitter
  19945. */
  19946. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19947. }
  19948. }
  19949. declare module "babylonjs/Particles/subEmitter" {
  19950. import { Scene } from "babylonjs/scene";
  19951. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  19952. /**
  19953. * Type of sub emitter
  19954. */
  19955. export enum SubEmitterType {
  19956. /**
  19957. * Attached to the particle over it's lifetime
  19958. */
  19959. ATTACHED = 0,
  19960. /**
  19961. * Created when the particle dies
  19962. */
  19963. END = 1
  19964. }
  19965. /**
  19966. * Sub emitter class used to emit particles from an existing particle
  19967. */
  19968. export class SubEmitter {
  19969. /**
  19970. * the particle system to be used by the sub emitter
  19971. */
  19972. particleSystem: ParticleSystem;
  19973. /**
  19974. * Type of the submitter (Default: END)
  19975. */
  19976. type: SubEmitterType;
  19977. /**
  19978. * 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)
  19979. * Note: This only is supported when using an emitter of type Mesh
  19980. */
  19981. inheritDirection: boolean;
  19982. /**
  19983. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  19984. */
  19985. inheritedVelocityAmount: number;
  19986. /**
  19987. * Creates a sub emitter
  19988. * @param particleSystem the particle system to be used by the sub emitter
  19989. */
  19990. constructor(
  19991. /**
  19992. * the particle system to be used by the sub emitter
  19993. */
  19994. particleSystem: ParticleSystem);
  19995. /**
  19996. * Clones the sub emitter
  19997. * @returns the cloned sub emitter
  19998. */
  19999. clone(): SubEmitter;
  20000. /**
  20001. * Serialize current object to a JSON object
  20002. * @returns the serialized object
  20003. */
  20004. serialize(): any;
  20005. /** @hidden */
  20006. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  20007. /**
  20008. * Creates a new SubEmitter from a serialized JSON version
  20009. * @param serializationObject defines the JSON object to read from
  20010. * @param scene defines the hosting scene
  20011. * @param rootUrl defines the rootUrl for data loading
  20012. * @returns a new SubEmitter
  20013. */
  20014. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  20015. /** Release associated resources */
  20016. dispose(): void;
  20017. }
  20018. }
  20019. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  20020. /** @hidden */
  20021. export var imageProcessingDeclaration: {
  20022. name: string;
  20023. shader: string;
  20024. };
  20025. }
  20026. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  20027. /** @hidden */
  20028. export var imageProcessingFunctions: {
  20029. name: string;
  20030. shader: string;
  20031. };
  20032. }
  20033. declare module "babylonjs/Shaders/particles.fragment" {
  20034. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  20035. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  20036. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  20037. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  20038. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  20039. /** @hidden */
  20040. export var particlesPixelShader: {
  20041. name: string;
  20042. shader: string;
  20043. };
  20044. }
  20045. declare module "babylonjs/Shaders/particles.vertex" {
  20046. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  20047. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  20048. /** @hidden */
  20049. export var particlesVertexShader: {
  20050. name: string;
  20051. shader: string;
  20052. };
  20053. }
  20054. declare module "babylonjs/Particles/particleSystem" {
  20055. import { Nullable } from "babylonjs/types";
  20056. import { IAnimatable, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  20057. import { Observable } from "babylonjs/Misc/observable";
  20058. import { Color4, Color3, Vector3, Matrix } from "babylonjs/Maths/math";
  20059. import { Effect } from "babylonjs/Materials/effect";
  20060. import { Scene, IDisposable } from "babylonjs/scene";
  20061. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20062. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  20063. import { Particle } from "babylonjs/Particles/particle";
  20064. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  20065. import "babylonjs/Shaders/particles.fragment";
  20066. import "babylonjs/Shaders/particles.vertex";
  20067. /**
  20068. * This represents a particle system in Babylon.
  20069. * 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.
  20070. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  20071. * @example https://doc.babylonjs.com/babylon101/particles
  20072. */
  20073. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  20074. /**
  20075. * Billboard mode will only apply to Y axis
  20076. */
  20077. static readonly BILLBOARDMODE_Y: number;
  20078. /**
  20079. * Billboard mode will apply to all axes
  20080. */
  20081. static readonly BILLBOARDMODE_ALL: number;
  20082. /**
  20083. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  20084. */
  20085. static readonly BILLBOARDMODE_STRETCHED: number;
  20086. /**
  20087. * This function can be defined to provide custom update for active particles.
  20088. * This function will be called instead of regular update (age, position, color, etc.).
  20089. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  20090. */
  20091. updateFunction: (particles: Particle[]) => void;
  20092. private _emitterWorldMatrix;
  20093. /**
  20094. * This function can be defined to specify initial direction for every new particle.
  20095. * It by default use the emitterType defined function
  20096. */
  20097. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  20098. /**
  20099. * This function can be defined to specify initial position for every new particle.
  20100. * It by default use the emitterType defined function
  20101. */
  20102. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  20103. /**
  20104. * @hidden
  20105. */
  20106. _inheritedVelocityOffset: Vector3;
  20107. /**
  20108. * An event triggered when the system is disposed
  20109. */
  20110. onDisposeObservable: Observable<ParticleSystem>;
  20111. private _onDisposeObserver;
  20112. /**
  20113. * Sets a callback that will be triggered when the system is disposed
  20114. */
  20115. onDispose: () => void;
  20116. private _particles;
  20117. private _epsilon;
  20118. private _capacity;
  20119. private _stockParticles;
  20120. private _newPartsExcess;
  20121. private _vertexData;
  20122. private _vertexBuffer;
  20123. private _vertexBuffers;
  20124. private _spriteBuffer;
  20125. private _indexBuffer;
  20126. private _effect;
  20127. private _customEffect;
  20128. private _cachedDefines;
  20129. private _scaledColorStep;
  20130. private _colorDiff;
  20131. private _scaledDirection;
  20132. private _scaledGravity;
  20133. private _currentRenderId;
  20134. private _alive;
  20135. private _useInstancing;
  20136. private _started;
  20137. private _stopped;
  20138. private _actualFrame;
  20139. private _scaledUpdateSpeed;
  20140. private _vertexBufferSize;
  20141. /** @hidden */
  20142. _currentEmitRateGradient: Nullable<FactorGradient>;
  20143. /** @hidden */
  20144. _currentEmitRate1: number;
  20145. /** @hidden */
  20146. _currentEmitRate2: number;
  20147. /** @hidden */
  20148. _currentStartSizeGradient: Nullable<FactorGradient>;
  20149. /** @hidden */
  20150. _currentStartSize1: number;
  20151. /** @hidden */
  20152. _currentStartSize2: number;
  20153. private readonly _rawTextureWidth;
  20154. private _rampGradientsTexture;
  20155. private _useRampGradients;
  20156. /** Gets or sets a boolean indicating that ramp gradients must be used
  20157. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  20158. */
  20159. useRampGradients: boolean;
  20160. /**
  20161. * 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.
  20162. * 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: [])
  20163. */
  20164. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  20165. private _subEmitters;
  20166. /**
  20167. * @hidden
  20168. * If the particle systems emitter should be disposed when the particle system is disposed
  20169. */
  20170. _disposeEmitterOnDispose: boolean;
  20171. /**
  20172. * The current active Sub-systems, this property is used by the root particle system only.
  20173. */
  20174. activeSubSystems: Array<ParticleSystem>;
  20175. private _rootParticleSystem;
  20176. /**
  20177. * Gets the current list of active particles
  20178. */
  20179. readonly particles: Particle[];
  20180. /**
  20181. * Returns the string "ParticleSystem"
  20182. * @returns a string containing the class name
  20183. */
  20184. getClassName(): string;
  20185. /**
  20186. * Instantiates a particle system.
  20187. * 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.
  20188. * @param name The name of the particle system
  20189. * @param capacity The max number of particles alive at the same time
  20190. * @param scene The scene the particle system belongs to
  20191. * @param customEffect a custom effect used to change the way particles are rendered by default
  20192. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  20193. * @param epsilon Offset used to render the particles
  20194. */
  20195. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  20196. private _addFactorGradient;
  20197. private _removeFactorGradient;
  20198. /**
  20199. * Adds a new life time gradient
  20200. * @param gradient defines the gradient to use (between 0 and 1)
  20201. * @param factor defines the life time factor to affect to the specified gradient
  20202. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20203. * @returns the current particle system
  20204. */
  20205. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20206. /**
  20207. * Remove a specific life time gradient
  20208. * @param gradient defines the gradient to remove
  20209. * @returns the current particle system
  20210. */
  20211. removeLifeTimeGradient(gradient: number): IParticleSystem;
  20212. /**
  20213. * Adds a new size gradient
  20214. * @param gradient defines the gradient to use (between 0 and 1)
  20215. * @param factor defines the size factor to affect to the specified gradient
  20216. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20217. * @returns the current particle system
  20218. */
  20219. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20220. /**
  20221. * Remove a specific size gradient
  20222. * @param gradient defines the gradient to remove
  20223. * @returns the current particle system
  20224. */
  20225. removeSizeGradient(gradient: number): IParticleSystem;
  20226. /**
  20227. * Adds a new color remap gradient
  20228. * @param gradient defines the gradient to use (between 0 and 1)
  20229. * @param min defines the color remap minimal range
  20230. * @param max defines the color remap maximal range
  20231. * @returns the current particle system
  20232. */
  20233. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  20234. /**
  20235. * Remove a specific color remap gradient
  20236. * @param gradient defines the gradient to remove
  20237. * @returns the current particle system
  20238. */
  20239. removeColorRemapGradient(gradient: number): IParticleSystem;
  20240. /**
  20241. * Adds a new alpha remap gradient
  20242. * @param gradient defines the gradient to use (between 0 and 1)
  20243. * @param min defines the alpha remap minimal range
  20244. * @param max defines the alpha remap maximal range
  20245. * @returns the current particle system
  20246. */
  20247. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  20248. /**
  20249. * Remove a specific alpha remap gradient
  20250. * @param gradient defines the gradient to remove
  20251. * @returns the current particle system
  20252. */
  20253. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  20254. /**
  20255. * Adds a new angular speed gradient
  20256. * @param gradient defines the gradient to use (between 0 and 1)
  20257. * @param factor defines the angular speed to affect to the specified gradient
  20258. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20259. * @returns the current particle system
  20260. */
  20261. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20262. /**
  20263. * Remove a specific angular speed gradient
  20264. * @param gradient defines the gradient to remove
  20265. * @returns the current particle system
  20266. */
  20267. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  20268. /**
  20269. * Adds a new velocity gradient
  20270. * @param gradient defines the gradient to use (between 0 and 1)
  20271. * @param factor defines the velocity to affect to the specified gradient
  20272. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20273. * @returns the current particle system
  20274. */
  20275. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20276. /**
  20277. * Remove a specific velocity gradient
  20278. * @param gradient defines the gradient to remove
  20279. * @returns the current particle system
  20280. */
  20281. removeVelocityGradient(gradient: number): IParticleSystem;
  20282. /**
  20283. * Adds a new limit velocity gradient
  20284. * @param gradient defines the gradient to use (between 0 and 1)
  20285. * @param factor defines the limit velocity value to affect to the specified gradient
  20286. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20287. * @returns the current particle system
  20288. */
  20289. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20290. /**
  20291. * Remove a specific limit velocity gradient
  20292. * @param gradient defines the gradient to remove
  20293. * @returns the current particle system
  20294. */
  20295. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  20296. /**
  20297. * Adds a new drag gradient
  20298. * @param gradient defines the gradient to use (between 0 and 1)
  20299. * @param factor defines the drag value to affect to the specified gradient
  20300. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20301. * @returns the current particle system
  20302. */
  20303. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20304. /**
  20305. * Remove a specific drag gradient
  20306. * @param gradient defines the gradient to remove
  20307. * @returns the current particle system
  20308. */
  20309. removeDragGradient(gradient: number): IParticleSystem;
  20310. /**
  20311. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  20312. * @param gradient defines the gradient to use (between 0 and 1)
  20313. * @param factor defines the emit rate value to affect to the specified gradient
  20314. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20315. * @returns the current particle system
  20316. */
  20317. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20318. /**
  20319. * Remove a specific emit rate gradient
  20320. * @param gradient defines the gradient to remove
  20321. * @returns the current particle system
  20322. */
  20323. removeEmitRateGradient(gradient: number): IParticleSystem;
  20324. /**
  20325. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  20326. * @param gradient defines the gradient to use (between 0 and 1)
  20327. * @param factor defines the start size value to affect to the specified gradient
  20328. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20329. * @returns the current particle system
  20330. */
  20331. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20332. /**
  20333. * Remove a specific start size gradient
  20334. * @param gradient defines the gradient to remove
  20335. * @returns the current particle system
  20336. */
  20337. removeStartSizeGradient(gradient: number): IParticleSystem;
  20338. private _createRampGradientTexture;
  20339. /**
  20340. * Gets the current list of ramp gradients.
  20341. * You must use addRampGradient and removeRampGradient to udpate this list
  20342. * @returns the list of ramp gradients
  20343. */
  20344. getRampGradients(): Nullable<Array<Color3Gradient>>;
  20345. /**
  20346. * Adds a new ramp gradient used to remap particle colors
  20347. * @param gradient defines the gradient to use (between 0 and 1)
  20348. * @param color defines the color to affect to the specified gradient
  20349. * @returns the current particle system
  20350. */
  20351. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  20352. /**
  20353. * Remove a specific ramp gradient
  20354. * @param gradient defines the gradient to remove
  20355. * @returns the current particle system
  20356. */
  20357. removeRampGradient(gradient: number): ParticleSystem;
  20358. /**
  20359. * Adds a new color gradient
  20360. * @param gradient defines the gradient to use (between 0 and 1)
  20361. * @param color1 defines the color to affect to the specified gradient
  20362. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  20363. * @returns this particle system
  20364. */
  20365. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  20366. /**
  20367. * Remove a specific color gradient
  20368. * @param gradient defines the gradient to remove
  20369. * @returns this particle system
  20370. */
  20371. removeColorGradient(gradient: number): IParticleSystem;
  20372. private _fetchR;
  20373. protected _reset(): void;
  20374. private _resetEffect;
  20375. private _createVertexBuffers;
  20376. private _createIndexBuffer;
  20377. /**
  20378. * Gets the maximum number of particles active at the same time.
  20379. * @returns The max number of active particles.
  20380. */
  20381. getCapacity(): number;
  20382. /**
  20383. * Gets whether there are still active particles in the system.
  20384. * @returns True if it is alive, otherwise false.
  20385. */
  20386. isAlive(): boolean;
  20387. /**
  20388. * Gets if the system has been started. (Note: this will still be true after stop is called)
  20389. * @returns True if it has been started, otherwise false.
  20390. */
  20391. isStarted(): boolean;
  20392. private _prepareSubEmitterInternalArray;
  20393. /**
  20394. * Starts the particle system and begins to emit
  20395. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  20396. */
  20397. start(delay?: number): void;
  20398. /**
  20399. * Stops the particle system.
  20400. * @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.
  20401. */
  20402. stop(stopSubEmitters?: boolean): void;
  20403. /**
  20404. * Remove all active particles
  20405. */
  20406. reset(): void;
  20407. /**
  20408. * @hidden (for internal use only)
  20409. */
  20410. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  20411. /**
  20412. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  20413. * Its lifetime will start back at 0.
  20414. */
  20415. recycleParticle: (particle: Particle) => void;
  20416. private _stopSubEmitters;
  20417. private _createParticle;
  20418. private _removeFromRoot;
  20419. private _emitFromParticle;
  20420. private _update;
  20421. /** @hidden */
  20422. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  20423. /** @hidden */
  20424. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  20425. /** @hidden */
  20426. private _getEffect;
  20427. /**
  20428. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  20429. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  20430. */
  20431. animate(preWarmOnly?: boolean): void;
  20432. private _appendParticleVertices;
  20433. /**
  20434. * Rebuilds the particle system.
  20435. */
  20436. rebuild(): void;
  20437. /**
  20438. * Is this system ready to be used/rendered
  20439. * @return true if the system is ready
  20440. */
  20441. isReady(): boolean;
  20442. private _render;
  20443. /**
  20444. * Renders the particle system in its current state.
  20445. * @returns the current number of particles
  20446. */
  20447. render(): number;
  20448. /**
  20449. * Disposes the particle system and free the associated resources
  20450. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  20451. */
  20452. dispose(disposeTexture?: boolean): void;
  20453. /**
  20454. * Clones the particle system.
  20455. * @param name The name of the cloned object
  20456. * @param newEmitter The new emitter to use
  20457. * @returns the cloned particle system
  20458. */
  20459. clone(name: string, newEmitter: any): ParticleSystem;
  20460. /**
  20461. * Serializes the particle system to a JSON object.
  20462. * @returns the JSON object
  20463. */
  20464. serialize(): any;
  20465. /** @hidden */
  20466. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  20467. /** @hidden */
  20468. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  20469. /**
  20470. * Parses a JSON object to create a particle system.
  20471. * @param parsedParticleSystem The JSON object to parse
  20472. * @param scene The scene to create the particle system in
  20473. * @param rootUrl The root url to use to load external dependencies like texture
  20474. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  20475. * @returns the Parsed particle system
  20476. */
  20477. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  20478. }
  20479. }
  20480. declare module "babylonjs/Particles/particle" {
  20481. import { Nullable } from "babylonjs/types";
  20482. import { Color4, Vector2, Vector3, Vector4 } from "babylonjs/Maths/math";
  20483. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  20484. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  20485. import { ColorGradient, FactorGradient } from "babylonjs/Misc/tools";
  20486. /**
  20487. * A particle represents one of the element emitted by a particle system.
  20488. * This is mainly define by its coordinates, direction, velocity and age.
  20489. */
  20490. export class Particle {
  20491. /**
  20492. * The particle system the particle belongs to.
  20493. */
  20494. particleSystem: ParticleSystem;
  20495. private static _Count;
  20496. /**
  20497. * Unique ID of the particle
  20498. */
  20499. id: number;
  20500. /**
  20501. * The world position of the particle in the scene.
  20502. */
  20503. position: Vector3;
  20504. /**
  20505. * The world direction of the particle in the scene.
  20506. */
  20507. direction: Vector3;
  20508. /**
  20509. * The color of the particle.
  20510. */
  20511. color: Color4;
  20512. /**
  20513. * The color change of the particle per step.
  20514. */
  20515. colorStep: Color4;
  20516. /**
  20517. * Defines how long will the life of the particle be.
  20518. */
  20519. lifeTime: number;
  20520. /**
  20521. * The current age of the particle.
  20522. */
  20523. age: number;
  20524. /**
  20525. * The current size of the particle.
  20526. */
  20527. size: number;
  20528. /**
  20529. * The current scale of the particle.
  20530. */
  20531. scale: Vector2;
  20532. /**
  20533. * The current angle of the particle.
  20534. */
  20535. angle: number;
  20536. /**
  20537. * Defines how fast is the angle changing.
  20538. */
  20539. angularSpeed: number;
  20540. /**
  20541. * Defines the cell index used by the particle to be rendered from a sprite.
  20542. */
  20543. cellIndex: number;
  20544. /**
  20545. * The information required to support color remapping
  20546. */
  20547. remapData: Vector4;
  20548. /** @hidden */
  20549. _randomCellOffset?: number;
  20550. /** @hidden */
  20551. _initialDirection: Nullable<Vector3>;
  20552. /** @hidden */
  20553. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  20554. /** @hidden */
  20555. _initialStartSpriteCellID: number;
  20556. /** @hidden */
  20557. _initialEndSpriteCellID: number;
  20558. /** @hidden */
  20559. _currentColorGradient: Nullable<ColorGradient>;
  20560. /** @hidden */
  20561. _currentColor1: Color4;
  20562. /** @hidden */
  20563. _currentColor2: Color4;
  20564. /** @hidden */
  20565. _currentSizeGradient: Nullable<FactorGradient>;
  20566. /** @hidden */
  20567. _currentSize1: number;
  20568. /** @hidden */
  20569. _currentSize2: number;
  20570. /** @hidden */
  20571. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  20572. /** @hidden */
  20573. _currentAngularSpeed1: number;
  20574. /** @hidden */
  20575. _currentAngularSpeed2: number;
  20576. /** @hidden */
  20577. _currentVelocityGradient: Nullable<FactorGradient>;
  20578. /** @hidden */
  20579. _currentVelocity1: number;
  20580. /** @hidden */
  20581. _currentVelocity2: number;
  20582. /** @hidden */
  20583. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  20584. /** @hidden */
  20585. _currentLimitVelocity1: number;
  20586. /** @hidden */
  20587. _currentLimitVelocity2: number;
  20588. /** @hidden */
  20589. _currentDragGradient: Nullable<FactorGradient>;
  20590. /** @hidden */
  20591. _currentDrag1: number;
  20592. /** @hidden */
  20593. _currentDrag2: number;
  20594. /** @hidden */
  20595. _randomNoiseCoordinates1: Vector3;
  20596. /** @hidden */
  20597. _randomNoiseCoordinates2: Vector3;
  20598. /**
  20599. * Creates a new instance Particle
  20600. * @param particleSystem the particle system the particle belongs to
  20601. */
  20602. constructor(
  20603. /**
  20604. * The particle system the particle belongs to.
  20605. */
  20606. particleSystem: ParticleSystem);
  20607. private updateCellInfoFromSystem;
  20608. /**
  20609. * Defines how the sprite cell index is updated for the particle
  20610. */
  20611. updateCellIndex(): void;
  20612. /** @hidden */
  20613. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  20614. /** @hidden */
  20615. _inheritParticleInfoToSubEmitters(): void;
  20616. /** @hidden */
  20617. _reset(): void;
  20618. /**
  20619. * Copy the properties of particle to another one.
  20620. * @param other the particle to copy the information to.
  20621. */
  20622. copyTo(other: Particle): void;
  20623. }
  20624. }
  20625. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  20626. import { Vector3, Matrix } from "babylonjs/Maths/math";
  20627. import { Effect } from "babylonjs/Materials/effect";
  20628. import { Particle } from "babylonjs/Particles/particle";
  20629. /**
  20630. * Particle emitter represents a volume emitting particles.
  20631. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  20632. */
  20633. export interface IParticleEmitterType {
  20634. /**
  20635. * Called by the particle System when the direction is computed for the created particle.
  20636. * @param worldMatrix is the world matrix of the particle system
  20637. * @param directionToUpdate is the direction vector to update with the result
  20638. * @param particle is the particle we are computed the direction for
  20639. */
  20640. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20641. /**
  20642. * Called by the particle System when the position is computed for the created particle.
  20643. * @param worldMatrix is the world matrix of the particle system
  20644. * @param positionToUpdate is the position vector to update with the result
  20645. * @param particle is the particle we are computed the position for
  20646. */
  20647. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20648. /**
  20649. * Clones the current emitter and returns a copy of it
  20650. * @returns the new emitter
  20651. */
  20652. clone(): IParticleEmitterType;
  20653. /**
  20654. * Called by the GPUParticleSystem to setup the update shader
  20655. * @param effect defines the update shader
  20656. */
  20657. applyToShader(effect: Effect): void;
  20658. /**
  20659. * Returns a string to use to update the GPU particles update shader
  20660. * @returns the effect defines string
  20661. */
  20662. getEffectDefines(): string;
  20663. /**
  20664. * Returns a string representing the class name
  20665. * @returns a string containing the class name
  20666. */
  20667. getClassName(): string;
  20668. /**
  20669. * Serializes the particle system to a JSON object.
  20670. * @returns the JSON object
  20671. */
  20672. serialize(): any;
  20673. /**
  20674. * Parse properties from a JSON object
  20675. * @param serializationObject defines the JSON object
  20676. */
  20677. parse(serializationObject: any): void;
  20678. }
  20679. }
  20680. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  20681. import { Vector3, Matrix } from "babylonjs/Maths/math";
  20682. import { Effect } from "babylonjs/Materials/effect";
  20683. import { Particle } from "babylonjs/Particles/particle";
  20684. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  20685. /**
  20686. * Particle emitter emitting particles from the inside of a box.
  20687. * It emits the particles randomly between 2 given directions.
  20688. */
  20689. export class BoxParticleEmitter implements IParticleEmitterType {
  20690. /**
  20691. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  20692. */
  20693. direction1: Vector3;
  20694. /**
  20695. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  20696. */
  20697. direction2: Vector3;
  20698. /**
  20699. * 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.
  20700. */
  20701. minEmitBox: Vector3;
  20702. /**
  20703. * 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.
  20704. */
  20705. maxEmitBox: Vector3;
  20706. /**
  20707. * Creates a new instance BoxParticleEmitter
  20708. */
  20709. constructor();
  20710. /**
  20711. * Called by the particle System when the direction is computed for the created particle.
  20712. * @param worldMatrix is the world matrix of the particle system
  20713. * @param directionToUpdate is the direction vector to update with the result
  20714. * @param particle is the particle we are computed the direction for
  20715. */
  20716. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20717. /**
  20718. * Called by the particle System when the position is computed for the created particle.
  20719. * @param worldMatrix is the world matrix of the particle system
  20720. * @param positionToUpdate is the position vector to update with the result
  20721. * @param particle is the particle we are computed the position for
  20722. */
  20723. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20724. /**
  20725. * Clones the current emitter and returns a copy of it
  20726. * @returns the new emitter
  20727. */
  20728. clone(): BoxParticleEmitter;
  20729. /**
  20730. * Called by the GPUParticleSystem to setup the update shader
  20731. * @param effect defines the update shader
  20732. */
  20733. applyToShader(effect: Effect): void;
  20734. /**
  20735. * Returns a string to use to update the GPU particles update shader
  20736. * @returns a string containng the defines string
  20737. */
  20738. getEffectDefines(): string;
  20739. /**
  20740. * Returns the string "BoxParticleEmitter"
  20741. * @returns a string containing the class name
  20742. */
  20743. getClassName(): string;
  20744. /**
  20745. * Serializes the particle system to a JSON object.
  20746. * @returns the JSON object
  20747. */
  20748. serialize(): any;
  20749. /**
  20750. * Parse properties from a JSON object
  20751. * @param serializationObject defines the JSON object
  20752. */
  20753. parse(serializationObject: any): void;
  20754. }
  20755. }
  20756. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  20757. import { Vector3, Matrix } from "babylonjs/Maths/math";
  20758. import { Effect } from "babylonjs/Materials/effect";
  20759. import { Particle } from "babylonjs/Particles/particle";
  20760. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  20761. /**
  20762. * Particle emitter emitting particles from the inside of a cone.
  20763. * It emits the particles alongside the cone volume from the base to the particle.
  20764. * The emission direction might be randomized.
  20765. */
  20766. export class ConeParticleEmitter implements IParticleEmitterType {
  20767. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  20768. directionRandomizer: number;
  20769. private _radius;
  20770. private _angle;
  20771. private _height;
  20772. /**
  20773. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  20774. */
  20775. radiusRange: number;
  20776. /**
  20777. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  20778. */
  20779. heightRange: number;
  20780. /**
  20781. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  20782. */
  20783. emitFromSpawnPointOnly: boolean;
  20784. /**
  20785. * Gets or sets the radius of the emission cone
  20786. */
  20787. radius: number;
  20788. /**
  20789. * Gets or sets the angle of the emission cone
  20790. */
  20791. angle: number;
  20792. private _buildHeight;
  20793. /**
  20794. * Creates a new instance ConeParticleEmitter
  20795. * @param radius the radius of the emission cone (1 by default)
  20796. * @param angle the cone base angle (PI by default)
  20797. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  20798. */
  20799. constructor(radius?: number, angle?: number,
  20800. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  20801. directionRandomizer?: number);
  20802. /**
  20803. * Called by the particle System when the direction is computed for the created particle.
  20804. * @param worldMatrix is the world matrix of the particle system
  20805. * @param directionToUpdate is the direction vector to update with the result
  20806. * @param particle is the particle we are computed the direction for
  20807. */
  20808. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20809. /**
  20810. * Called by the particle System when the position is computed for the created particle.
  20811. * @param worldMatrix is the world matrix of the particle system
  20812. * @param positionToUpdate is the position vector to update with the result
  20813. * @param particle is the particle we are computed the position for
  20814. */
  20815. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20816. /**
  20817. * Clones the current emitter and returns a copy of it
  20818. * @returns the new emitter
  20819. */
  20820. clone(): ConeParticleEmitter;
  20821. /**
  20822. * Called by the GPUParticleSystem to setup the update shader
  20823. * @param effect defines the update shader
  20824. */
  20825. applyToShader(effect: Effect): void;
  20826. /**
  20827. * Returns a string to use to update the GPU particles update shader
  20828. * @returns a string containng the defines string
  20829. */
  20830. getEffectDefines(): string;
  20831. /**
  20832. * Returns the string "ConeParticleEmitter"
  20833. * @returns a string containing the class name
  20834. */
  20835. getClassName(): string;
  20836. /**
  20837. * Serializes the particle system to a JSON object.
  20838. * @returns the JSON object
  20839. */
  20840. serialize(): any;
  20841. /**
  20842. * Parse properties from a JSON object
  20843. * @param serializationObject defines the JSON object
  20844. */
  20845. parse(serializationObject: any): void;
  20846. }
  20847. }
  20848. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  20849. import { Vector3, Matrix } from "babylonjs/Maths/math";
  20850. import { Effect } from "babylonjs/Materials/effect";
  20851. import { Particle } from "babylonjs/Particles/particle";
  20852. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  20853. /**
  20854. * Particle emitter emitting particles from the inside of a cylinder.
  20855. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  20856. */
  20857. export class CylinderParticleEmitter implements IParticleEmitterType {
  20858. /**
  20859. * The radius of the emission cylinder.
  20860. */
  20861. radius: number;
  20862. /**
  20863. * The height of the emission cylinder.
  20864. */
  20865. height: number;
  20866. /**
  20867. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20868. */
  20869. radiusRange: number;
  20870. /**
  20871. * How much to randomize the particle direction [0-1].
  20872. */
  20873. directionRandomizer: number;
  20874. /**
  20875. * Creates a new instance CylinderParticleEmitter
  20876. * @param radius the radius of the emission cylinder (1 by default)
  20877. * @param height the height of the emission cylinder (1 by default)
  20878. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  20879. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  20880. */
  20881. constructor(
  20882. /**
  20883. * The radius of the emission cylinder.
  20884. */
  20885. radius?: number,
  20886. /**
  20887. * The height of the emission cylinder.
  20888. */
  20889. height?: number,
  20890. /**
  20891. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20892. */
  20893. radiusRange?: number,
  20894. /**
  20895. * How much to randomize the particle direction [0-1].
  20896. */
  20897. directionRandomizer?: number);
  20898. /**
  20899. * Called by the particle System when the direction is computed for the created particle.
  20900. * @param worldMatrix is the world matrix of the particle system
  20901. * @param directionToUpdate is the direction vector to update with the result
  20902. * @param particle is the particle we are computed the direction for
  20903. */
  20904. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20905. /**
  20906. * Called by the particle System when the position is computed for the created particle.
  20907. * @param worldMatrix is the world matrix of the particle system
  20908. * @param positionToUpdate is the position vector to update with the result
  20909. * @param particle is the particle we are computed the position for
  20910. */
  20911. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20912. /**
  20913. * Clones the current emitter and returns a copy of it
  20914. * @returns the new emitter
  20915. */
  20916. clone(): CylinderParticleEmitter;
  20917. /**
  20918. * Called by the GPUParticleSystem to setup the update shader
  20919. * @param effect defines the update shader
  20920. */
  20921. applyToShader(effect: Effect): void;
  20922. /**
  20923. * Returns a string to use to update the GPU particles update shader
  20924. * @returns a string containng the defines string
  20925. */
  20926. getEffectDefines(): string;
  20927. /**
  20928. * Returns the string "CylinderParticleEmitter"
  20929. * @returns a string containing the class name
  20930. */
  20931. getClassName(): string;
  20932. /**
  20933. * Serializes the particle system to a JSON object.
  20934. * @returns the JSON object
  20935. */
  20936. serialize(): any;
  20937. /**
  20938. * Parse properties from a JSON object
  20939. * @param serializationObject defines the JSON object
  20940. */
  20941. parse(serializationObject: any): void;
  20942. }
  20943. /**
  20944. * Particle emitter emitting particles from the inside of a cylinder.
  20945. * It emits the particles randomly between two vectors.
  20946. */
  20947. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  20948. /**
  20949. * The min limit of the emission direction.
  20950. */
  20951. direction1: Vector3;
  20952. /**
  20953. * The max limit of the emission direction.
  20954. */
  20955. direction2: Vector3;
  20956. /**
  20957. * Creates a new instance CylinderDirectedParticleEmitter
  20958. * @param radius the radius of the emission cylinder (1 by default)
  20959. * @param height the height of the emission cylinder (1 by default)
  20960. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  20961. * @param direction1 the min limit of the emission direction (up vector by default)
  20962. * @param direction2 the max limit of the emission direction (up vector by default)
  20963. */
  20964. constructor(radius?: number, height?: number, radiusRange?: number,
  20965. /**
  20966. * The min limit of the emission direction.
  20967. */
  20968. direction1?: Vector3,
  20969. /**
  20970. * The max limit of the emission direction.
  20971. */
  20972. direction2?: Vector3);
  20973. /**
  20974. * Called by the particle System when the direction is computed for the created particle.
  20975. * @param worldMatrix is the world matrix of the particle system
  20976. * @param directionToUpdate is the direction vector to update with the result
  20977. * @param particle is the particle we are computed the direction for
  20978. */
  20979. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20980. /**
  20981. * Clones the current emitter and returns a copy of it
  20982. * @returns the new emitter
  20983. */
  20984. clone(): CylinderDirectedParticleEmitter;
  20985. /**
  20986. * Called by the GPUParticleSystem to setup the update shader
  20987. * @param effect defines the update shader
  20988. */
  20989. applyToShader(effect: Effect): void;
  20990. /**
  20991. * Returns a string to use to update the GPU particles update shader
  20992. * @returns a string containng the defines string
  20993. */
  20994. getEffectDefines(): string;
  20995. /**
  20996. * Returns the string "CylinderDirectedParticleEmitter"
  20997. * @returns a string containing the class name
  20998. */
  20999. getClassName(): string;
  21000. /**
  21001. * Serializes the particle system to a JSON object.
  21002. * @returns the JSON object
  21003. */
  21004. serialize(): any;
  21005. /**
  21006. * Parse properties from a JSON object
  21007. * @param serializationObject defines the JSON object
  21008. */
  21009. parse(serializationObject: any): void;
  21010. }
  21011. }
  21012. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  21013. import { Vector3, Matrix } from "babylonjs/Maths/math";
  21014. import { Effect } from "babylonjs/Materials/effect";
  21015. import { Particle } from "babylonjs/Particles/particle";
  21016. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  21017. /**
  21018. * Particle emitter emitting particles from the inside of a hemisphere.
  21019. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  21020. */
  21021. export class HemisphericParticleEmitter implements IParticleEmitterType {
  21022. /**
  21023. * The radius of the emission hemisphere.
  21024. */
  21025. radius: number;
  21026. /**
  21027. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  21028. */
  21029. radiusRange: number;
  21030. /**
  21031. * How much to randomize the particle direction [0-1].
  21032. */
  21033. directionRandomizer: number;
  21034. /**
  21035. * Creates a new instance HemisphericParticleEmitter
  21036. * @param radius the radius of the emission hemisphere (1 by default)
  21037. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  21038. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  21039. */
  21040. constructor(
  21041. /**
  21042. * The radius of the emission hemisphere.
  21043. */
  21044. radius?: number,
  21045. /**
  21046. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  21047. */
  21048. radiusRange?: number,
  21049. /**
  21050. * How much to randomize the particle direction [0-1].
  21051. */
  21052. directionRandomizer?: number);
  21053. /**
  21054. * Called by the particle System when the direction is computed for the created particle.
  21055. * @param worldMatrix is the world matrix of the particle system
  21056. * @param directionToUpdate is the direction vector to update with the result
  21057. * @param particle is the particle we are computed the direction for
  21058. */
  21059. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  21060. /**
  21061. * Called by the particle System when the position is computed for the created particle.
  21062. * @param worldMatrix is the world matrix of the particle system
  21063. * @param positionToUpdate is the position vector to update with the result
  21064. * @param particle is the particle we are computed the position for
  21065. */
  21066. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  21067. /**
  21068. * Clones the current emitter and returns a copy of it
  21069. * @returns the new emitter
  21070. */
  21071. clone(): HemisphericParticleEmitter;
  21072. /**
  21073. * Called by the GPUParticleSystem to setup the update shader
  21074. * @param effect defines the update shader
  21075. */
  21076. applyToShader(effect: Effect): void;
  21077. /**
  21078. * Returns a string to use to update the GPU particles update shader
  21079. * @returns a string containng the defines string
  21080. */
  21081. getEffectDefines(): string;
  21082. /**
  21083. * Returns the string "HemisphericParticleEmitter"
  21084. * @returns a string containing the class name
  21085. */
  21086. getClassName(): string;
  21087. /**
  21088. * Serializes the particle system to a JSON object.
  21089. * @returns the JSON object
  21090. */
  21091. serialize(): any;
  21092. /**
  21093. * Parse properties from a JSON object
  21094. * @param serializationObject defines the JSON object
  21095. */
  21096. parse(serializationObject: any): void;
  21097. }
  21098. }
  21099. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  21100. import { Vector3, Matrix } from "babylonjs/Maths/math";
  21101. import { Effect } from "babylonjs/Materials/effect";
  21102. import { Particle } from "babylonjs/Particles/particle";
  21103. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  21104. /**
  21105. * Particle emitter emitting particles from a point.
  21106. * It emits the particles randomly between 2 given directions.
  21107. */
  21108. export class PointParticleEmitter implements IParticleEmitterType {
  21109. /**
  21110. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  21111. */
  21112. direction1: Vector3;
  21113. /**
  21114. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  21115. */
  21116. direction2: Vector3;
  21117. /**
  21118. * Creates a new instance PointParticleEmitter
  21119. */
  21120. constructor();
  21121. /**
  21122. * Called by the particle System when the direction is computed for the created particle.
  21123. * @param worldMatrix is the world matrix of the particle system
  21124. * @param directionToUpdate is the direction vector to update with the result
  21125. * @param particle is the particle we are computed the direction for
  21126. */
  21127. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  21128. /**
  21129. * Called by the particle System when the position is computed for the created particle.
  21130. * @param worldMatrix is the world matrix of the particle system
  21131. * @param positionToUpdate is the position vector to update with the result
  21132. * @param particle is the particle we are computed the position for
  21133. */
  21134. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  21135. /**
  21136. * Clones the current emitter and returns a copy of it
  21137. * @returns the new emitter
  21138. */
  21139. clone(): PointParticleEmitter;
  21140. /**
  21141. * Called by the GPUParticleSystem to setup the update shader
  21142. * @param effect defines the update shader
  21143. */
  21144. applyToShader(effect: Effect): void;
  21145. /**
  21146. * Returns a string to use to update the GPU particles update shader
  21147. * @returns a string containng the defines string
  21148. */
  21149. getEffectDefines(): string;
  21150. /**
  21151. * Returns the string "PointParticleEmitter"
  21152. * @returns a string containing the class name
  21153. */
  21154. getClassName(): string;
  21155. /**
  21156. * Serializes the particle system to a JSON object.
  21157. * @returns the JSON object
  21158. */
  21159. serialize(): any;
  21160. /**
  21161. * Parse properties from a JSON object
  21162. * @param serializationObject defines the JSON object
  21163. */
  21164. parse(serializationObject: any): void;
  21165. }
  21166. }
  21167. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  21168. import { Vector3, Matrix } from "babylonjs/Maths/math";
  21169. import { Effect } from "babylonjs/Materials/effect";
  21170. import { Particle } from "babylonjs/Particles/particle";
  21171. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  21172. /**
  21173. * Particle emitter emitting particles from the inside of a sphere.
  21174. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  21175. */
  21176. export class SphereParticleEmitter implements IParticleEmitterType {
  21177. /**
  21178. * The radius of the emission sphere.
  21179. */
  21180. radius: number;
  21181. /**
  21182. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  21183. */
  21184. radiusRange: number;
  21185. /**
  21186. * How much to randomize the particle direction [0-1].
  21187. */
  21188. directionRandomizer: number;
  21189. /**
  21190. * Creates a new instance SphereParticleEmitter
  21191. * @param radius the radius of the emission sphere (1 by default)
  21192. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  21193. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  21194. */
  21195. constructor(
  21196. /**
  21197. * The radius of the emission sphere.
  21198. */
  21199. radius?: number,
  21200. /**
  21201. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  21202. */
  21203. radiusRange?: number,
  21204. /**
  21205. * How much to randomize the particle direction [0-1].
  21206. */
  21207. directionRandomizer?: number);
  21208. /**
  21209. * Called by the particle System when the direction is computed for the created particle.
  21210. * @param worldMatrix is the world matrix of the particle system
  21211. * @param directionToUpdate is the direction vector to update with the result
  21212. * @param particle is the particle we are computed the direction for
  21213. */
  21214. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  21215. /**
  21216. * Called by the particle System when the position is computed for the created particle.
  21217. * @param worldMatrix is the world matrix of the particle system
  21218. * @param positionToUpdate is the position vector to update with the result
  21219. * @param particle is the particle we are computed the position for
  21220. */
  21221. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  21222. /**
  21223. * Clones the current emitter and returns a copy of it
  21224. * @returns the new emitter
  21225. */
  21226. clone(): SphereParticleEmitter;
  21227. /**
  21228. * Called by the GPUParticleSystem to setup the update shader
  21229. * @param effect defines the update shader
  21230. */
  21231. applyToShader(effect: Effect): void;
  21232. /**
  21233. * Returns a string to use to update the GPU particles update shader
  21234. * @returns a string containng the defines string
  21235. */
  21236. getEffectDefines(): string;
  21237. /**
  21238. * Returns the string "SphereParticleEmitter"
  21239. * @returns a string containing the class name
  21240. */
  21241. getClassName(): string;
  21242. /**
  21243. * Serializes the particle system to a JSON object.
  21244. * @returns the JSON object
  21245. */
  21246. serialize(): any;
  21247. /**
  21248. * Parse properties from a JSON object
  21249. * @param serializationObject defines the JSON object
  21250. */
  21251. parse(serializationObject: any): void;
  21252. }
  21253. /**
  21254. * Particle emitter emitting particles from the inside of a sphere.
  21255. * It emits the particles randomly between two vectors.
  21256. */
  21257. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  21258. /**
  21259. * The min limit of the emission direction.
  21260. */
  21261. direction1: Vector3;
  21262. /**
  21263. * The max limit of the emission direction.
  21264. */
  21265. direction2: Vector3;
  21266. /**
  21267. * Creates a new instance SphereDirectedParticleEmitter
  21268. * @param radius the radius of the emission sphere (1 by default)
  21269. * @param direction1 the min limit of the emission direction (up vector by default)
  21270. * @param direction2 the max limit of the emission direction (up vector by default)
  21271. */
  21272. constructor(radius?: number,
  21273. /**
  21274. * The min limit of the emission direction.
  21275. */
  21276. direction1?: Vector3,
  21277. /**
  21278. * The max limit of the emission direction.
  21279. */
  21280. direction2?: Vector3);
  21281. /**
  21282. * Called by the particle System when the direction is computed for the created particle.
  21283. * @param worldMatrix is the world matrix of the particle system
  21284. * @param directionToUpdate is the direction vector to update with the result
  21285. * @param particle is the particle we are computed the direction for
  21286. */
  21287. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  21288. /**
  21289. * Clones the current emitter and returns a copy of it
  21290. * @returns the new emitter
  21291. */
  21292. clone(): SphereDirectedParticleEmitter;
  21293. /**
  21294. * Called by the GPUParticleSystem to setup the update shader
  21295. * @param effect defines the update shader
  21296. */
  21297. applyToShader(effect: Effect): void;
  21298. /**
  21299. * Returns a string to use to update the GPU particles update shader
  21300. * @returns a string containng the defines string
  21301. */
  21302. getEffectDefines(): string;
  21303. /**
  21304. * Returns the string "SphereDirectedParticleEmitter"
  21305. * @returns a string containing the class name
  21306. */
  21307. getClassName(): string;
  21308. /**
  21309. * Serializes the particle system to a JSON object.
  21310. * @returns the JSON object
  21311. */
  21312. serialize(): any;
  21313. /**
  21314. * Parse properties from a JSON object
  21315. * @param serializationObject defines the JSON object
  21316. */
  21317. parse(serializationObject: any): void;
  21318. }
  21319. }
  21320. declare module "babylonjs/Particles/EmitterTypes/index" {
  21321. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  21322. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  21323. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  21324. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  21325. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  21326. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  21327. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  21328. }
  21329. declare module "babylonjs/Particles/IParticleSystem" {
  21330. import { Nullable } from "babylonjs/types";
  21331. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  21332. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21333. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21334. import { Texture } from "babylonjs/Materials/Textures/texture";
  21335. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  21336. import { Scene } from "babylonjs/scene";
  21337. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  21338. import { Animation } from "babylonjs/Animations/animation";
  21339. /**
  21340. * Interface representing a particle system in Babylon.js.
  21341. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  21342. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  21343. */
  21344. export interface IParticleSystem {
  21345. /**
  21346. * List of animations used by the particle system.
  21347. */
  21348. animations: Animation[];
  21349. /**
  21350. * The id of the Particle system.
  21351. */
  21352. id: string;
  21353. /**
  21354. * The name of the Particle system.
  21355. */
  21356. name: string;
  21357. /**
  21358. * The emitter represents the Mesh or position we are attaching the particle system to.
  21359. */
  21360. emitter: Nullable<AbstractMesh | Vector3>;
  21361. /**
  21362. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  21363. */
  21364. isBillboardBased: boolean;
  21365. /**
  21366. * The rendering group used by the Particle system to chose when to render.
  21367. */
  21368. renderingGroupId: number;
  21369. /**
  21370. * The layer mask we are rendering the particles through.
  21371. */
  21372. layerMask: number;
  21373. /**
  21374. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  21375. */
  21376. updateSpeed: number;
  21377. /**
  21378. * The amount of time the particle system is running (depends of the overall update speed).
  21379. */
  21380. targetStopDuration: number;
  21381. /**
  21382. * The texture used to render each particle. (this can be a spritesheet)
  21383. */
  21384. particleTexture: Nullable<Texture>;
  21385. /**
  21386. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  21387. */
  21388. blendMode: number;
  21389. /**
  21390. * Minimum life time of emitting particles.
  21391. */
  21392. minLifeTime: number;
  21393. /**
  21394. * Maximum life time of emitting particles.
  21395. */
  21396. maxLifeTime: number;
  21397. /**
  21398. * Minimum Size of emitting particles.
  21399. */
  21400. minSize: number;
  21401. /**
  21402. * Maximum Size of emitting particles.
  21403. */
  21404. maxSize: number;
  21405. /**
  21406. * Minimum scale of emitting particles on X axis.
  21407. */
  21408. minScaleX: number;
  21409. /**
  21410. * Maximum scale of emitting particles on X axis.
  21411. */
  21412. maxScaleX: number;
  21413. /**
  21414. * Minimum scale of emitting particles on Y axis.
  21415. */
  21416. minScaleY: number;
  21417. /**
  21418. * Maximum scale of emitting particles on Y axis.
  21419. */
  21420. maxScaleY: number;
  21421. /**
  21422. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  21423. */
  21424. color1: Color4;
  21425. /**
  21426. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  21427. */
  21428. color2: Color4;
  21429. /**
  21430. * Color the particle will have at the end of its lifetime.
  21431. */
  21432. colorDead: Color4;
  21433. /**
  21434. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  21435. */
  21436. emitRate: number;
  21437. /**
  21438. * You can use gravity if you want to give an orientation to your particles.
  21439. */
  21440. gravity: Vector3;
  21441. /**
  21442. * Minimum power of emitting particles.
  21443. */
  21444. minEmitPower: number;
  21445. /**
  21446. * Maximum power of emitting particles.
  21447. */
  21448. maxEmitPower: number;
  21449. /**
  21450. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  21451. */
  21452. minAngularSpeed: number;
  21453. /**
  21454. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  21455. */
  21456. maxAngularSpeed: number;
  21457. /**
  21458. * Gets or sets the minimal initial rotation in radians.
  21459. */
  21460. minInitialRotation: number;
  21461. /**
  21462. * Gets or sets the maximal initial rotation in radians.
  21463. */
  21464. maxInitialRotation: number;
  21465. /**
  21466. * The particle emitter type defines the emitter used by the particle system.
  21467. * It can be for example box, sphere, or cone...
  21468. */
  21469. particleEmitterType: Nullable<IParticleEmitterType>;
  21470. /**
  21471. * Defines the delay in milliseconds before starting the system (0 by default)
  21472. */
  21473. startDelay: number;
  21474. /**
  21475. * 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
  21476. */
  21477. preWarmCycles: number;
  21478. /**
  21479. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  21480. */
  21481. preWarmStepOffset: number;
  21482. /**
  21483. * 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)
  21484. */
  21485. spriteCellChangeSpeed: number;
  21486. /**
  21487. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  21488. */
  21489. startSpriteCellID: number;
  21490. /**
  21491. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  21492. */
  21493. endSpriteCellID: number;
  21494. /**
  21495. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  21496. */
  21497. spriteCellWidth: number;
  21498. /**
  21499. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  21500. */
  21501. spriteCellHeight: number;
  21502. /**
  21503. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  21504. */
  21505. spriteRandomStartCell: boolean;
  21506. /**
  21507. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  21508. */
  21509. isAnimationSheetEnabled: boolean;
  21510. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  21511. translationPivot: Vector2;
  21512. /**
  21513. * Gets or sets a texture used to add random noise to particle positions
  21514. */
  21515. noiseTexture: Nullable<BaseTexture>;
  21516. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  21517. noiseStrength: Vector3;
  21518. /**
  21519. * Gets or sets the billboard mode to use when isBillboardBased = true.
  21520. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  21521. */
  21522. billboardMode: number;
  21523. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  21524. limitVelocityDamping: number;
  21525. /**
  21526. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  21527. */
  21528. beginAnimationOnStart: boolean;
  21529. /**
  21530. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  21531. */
  21532. beginAnimationFrom: number;
  21533. /**
  21534. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  21535. */
  21536. beginAnimationTo: number;
  21537. /**
  21538. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  21539. */
  21540. beginAnimationLoop: boolean;
  21541. /**
  21542. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  21543. */
  21544. disposeOnStop: boolean;
  21545. /**
  21546. * Gets the maximum number of particles active at the same time.
  21547. * @returns The max number of active particles.
  21548. */
  21549. getCapacity(): number;
  21550. /**
  21551. * Gets if the system has been started. (Note: this will still be true after stop is called)
  21552. * @returns True if it has been started, otherwise false.
  21553. */
  21554. isStarted(): boolean;
  21555. /**
  21556. * Animates the particle system for this frame.
  21557. */
  21558. animate(): void;
  21559. /**
  21560. * Renders the particle system in its current state.
  21561. * @returns the current number of particles
  21562. */
  21563. render(): number;
  21564. /**
  21565. * Dispose the particle system and frees its associated resources.
  21566. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  21567. */
  21568. dispose(disposeTexture?: boolean): void;
  21569. /**
  21570. * Clones the particle system.
  21571. * @param name The name of the cloned object
  21572. * @param newEmitter The new emitter to use
  21573. * @returns the cloned particle system
  21574. */
  21575. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  21576. /**
  21577. * Serializes the particle system to a JSON object.
  21578. * @returns the JSON object
  21579. */
  21580. serialize(): any;
  21581. /**
  21582. * Rebuild the particle system
  21583. */
  21584. rebuild(): void;
  21585. /**
  21586. * Starts the particle system and begins to emit
  21587. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  21588. */
  21589. start(delay?: number): void;
  21590. /**
  21591. * Stops the particle system.
  21592. */
  21593. stop(): void;
  21594. /**
  21595. * Remove all active particles
  21596. */
  21597. reset(): void;
  21598. /**
  21599. * Is this system ready to be used/rendered
  21600. * @return true if the system is ready
  21601. */
  21602. isReady(): boolean;
  21603. /**
  21604. * Adds a new color gradient
  21605. * @param gradient defines the gradient to use (between 0 and 1)
  21606. * @param color1 defines the color to affect to the specified gradient
  21607. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  21608. * @returns the current particle system
  21609. */
  21610. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  21611. /**
  21612. * Remove a specific color gradient
  21613. * @param gradient defines the gradient to remove
  21614. * @returns the current particle system
  21615. */
  21616. removeColorGradient(gradient: number): IParticleSystem;
  21617. /**
  21618. * Adds a new size gradient
  21619. * @param gradient defines the gradient to use (between 0 and 1)
  21620. * @param factor defines the size factor to affect to the specified gradient
  21621. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21622. * @returns the current particle system
  21623. */
  21624. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21625. /**
  21626. * Remove a specific size gradient
  21627. * @param gradient defines the gradient to remove
  21628. * @returns the current particle system
  21629. */
  21630. removeSizeGradient(gradient: number): IParticleSystem;
  21631. /**
  21632. * Gets the current list of color gradients.
  21633. * You must use addColorGradient and removeColorGradient to udpate this list
  21634. * @returns the list of color gradients
  21635. */
  21636. getColorGradients(): Nullable<Array<ColorGradient>>;
  21637. /**
  21638. * Gets the current list of size gradients.
  21639. * You must use addSizeGradient and removeSizeGradient to udpate this list
  21640. * @returns the list of size gradients
  21641. */
  21642. getSizeGradients(): Nullable<Array<FactorGradient>>;
  21643. /**
  21644. * Gets the current list of angular speed gradients.
  21645. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  21646. * @returns the list of angular speed gradients
  21647. */
  21648. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  21649. /**
  21650. * Adds a new angular speed gradient
  21651. * @param gradient defines the gradient to use (between 0 and 1)
  21652. * @param factor defines the angular speed to affect to the specified gradient
  21653. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21654. * @returns the current particle system
  21655. */
  21656. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21657. /**
  21658. * Remove a specific angular speed gradient
  21659. * @param gradient defines the gradient to remove
  21660. * @returns the current particle system
  21661. */
  21662. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  21663. /**
  21664. * Gets the current list of velocity gradients.
  21665. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  21666. * @returns the list of velocity gradients
  21667. */
  21668. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  21669. /**
  21670. * Adds a new velocity gradient
  21671. * @param gradient defines the gradient to use (between 0 and 1)
  21672. * @param factor defines the velocity to affect to the specified gradient
  21673. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21674. * @returns the current particle system
  21675. */
  21676. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21677. /**
  21678. * Remove a specific velocity gradient
  21679. * @param gradient defines the gradient to remove
  21680. * @returns the current particle system
  21681. */
  21682. removeVelocityGradient(gradient: number): IParticleSystem;
  21683. /**
  21684. * Gets the current list of limit velocity gradients.
  21685. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  21686. * @returns the list of limit velocity gradients
  21687. */
  21688. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  21689. /**
  21690. * Adds a new limit velocity gradient
  21691. * @param gradient defines the gradient to use (between 0 and 1)
  21692. * @param factor defines the limit velocity to affect to the specified gradient
  21693. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21694. * @returns the current particle system
  21695. */
  21696. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21697. /**
  21698. * Remove a specific limit velocity gradient
  21699. * @param gradient defines the gradient to remove
  21700. * @returns the current particle system
  21701. */
  21702. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  21703. /**
  21704. * Adds a new drag gradient
  21705. * @param gradient defines the gradient to use (between 0 and 1)
  21706. * @param factor defines the drag to affect to the specified gradient
  21707. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21708. * @returns the current particle system
  21709. */
  21710. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21711. /**
  21712. * Remove a specific drag gradient
  21713. * @param gradient defines the gradient to remove
  21714. * @returns the current particle system
  21715. */
  21716. removeDragGradient(gradient: number): IParticleSystem;
  21717. /**
  21718. * Gets the current list of drag gradients.
  21719. * You must use addDragGradient and removeDragGradient to udpate this list
  21720. * @returns the list of drag gradients
  21721. */
  21722. getDragGradients(): Nullable<Array<FactorGradient>>;
  21723. /**
  21724. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  21725. * @param gradient defines the gradient to use (between 0 and 1)
  21726. * @param factor defines the emit rate to affect to the specified gradient
  21727. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21728. * @returns the current particle system
  21729. */
  21730. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21731. /**
  21732. * Remove a specific emit rate gradient
  21733. * @param gradient defines the gradient to remove
  21734. * @returns the current particle system
  21735. */
  21736. removeEmitRateGradient(gradient: number): IParticleSystem;
  21737. /**
  21738. * Gets the current list of emit rate gradients.
  21739. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  21740. * @returns the list of emit rate gradients
  21741. */
  21742. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  21743. /**
  21744. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  21745. * @param gradient defines the gradient to use (between 0 and 1)
  21746. * @param factor defines the start size to affect to the specified gradient
  21747. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21748. * @returns the current particle system
  21749. */
  21750. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21751. /**
  21752. * Remove a specific start size gradient
  21753. * @param gradient defines the gradient to remove
  21754. * @returns the current particle system
  21755. */
  21756. removeStartSizeGradient(gradient: number): IParticleSystem;
  21757. /**
  21758. * Gets the current list of start size gradients.
  21759. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  21760. * @returns the list of start size gradients
  21761. */
  21762. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  21763. /**
  21764. * Adds a new life time gradient
  21765. * @param gradient defines the gradient to use (between 0 and 1)
  21766. * @param factor defines the life time factor to affect to the specified gradient
  21767. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21768. * @returns the current particle system
  21769. */
  21770. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21771. /**
  21772. * Remove a specific life time gradient
  21773. * @param gradient defines the gradient to remove
  21774. * @returns the current particle system
  21775. */
  21776. removeLifeTimeGradient(gradient: number): IParticleSystem;
  21777. /**
  21778. * Gets the current list of life time gradients.
  21779. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  21780. * @returns the list of life time gradients
  21781. */
  21782. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  21783. /**
  21784. * Gets the current list of color gradients.
  21785. * You must use addColorGradient and removeColorGradient to udpate this list
  21786. * @returns the list of color gradients
  21787. */
  21788. getColorGradients(): Nullable<Array<ColorGradient>>;
  21789. /**
  21790. * Adds a new ramp gradient used to remap particle colors
  21791. * @param gradient defines the gradient to use (between 0 and 1)
  21792. * @param color defines the color to affect to the specified gradient
  21793. * @returns the current particle system
  21794. */
  21795. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  21796. /**
  21797. * Gets the current list of ramp gradients.
  21798. * You must use addRampGradient and removeRampGradient to udpate this list
  21799. * @returns the list of ramp gradients
  21800. */
  21801. getRampGradients(): Nullable<Array<Color3Gradient>>;
  21802. /** Gets or sets a boolean indicating that ramp gradients must be used
  21803. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  21804. */
  21805. useRampGradients: boolean;
  21806. /**
  21807. * Adds a new color remap gradient
  21808. * @param gradient defines the gradient to use (between 0 and 1)
  21809. * @param min defines the color remap minimal range
  21810. * @param max defines the color remap maximal range
  21811. * @returns the current particle system
  21812. */
  21813. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  21814. /**
  21815. * Gets the current list of color remap gradients.
  21816. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  21817. * @returns the list of color remap gradients
  21818. */
  21819. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  21820. /**
  21821. * Adds a new alpha remap gradient
  21822. * @param gradient defines the gradient to use (between 0 and 1)
  21823. * @param min defines the alpha remap minimal range
  21824. * @param max defines the alpha remap maximal range
  21825. * @returns the current particle system
  21826. */
  21827. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  21828. /**
  21829. * Gets the current list of alpha remap gradients.
  21830. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  21831. * @returns the list of alpha remap gradients
  21832. */
  21833. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  21834. /**
  21835. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  21836. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  21837. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  21838. * @returns the emitter
  21839. */
  21840. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  21841. /**
  21842. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  21843. * @param radius The radius of the hemisphere to emit from
  21844. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  21845. * @returns the emitter
  21846. */
  21847. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  21848. /**
  21849. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  21850. * @param radius The radius of the sphere to emit from
  21851. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  21852. * @returns the emitter
  21853. */
  21854. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  21855. /**
  21856. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  21857. * @param radius The radius of the sphere to emit from
  21858. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  21859. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  21860. * @returns the emitter
  21861. */
  21862. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  21863. /**
  21864. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  21865. * @param radius The radius of the emission cylinder
  21866. * @param height The height of the emission cylinder
  21867. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  21868. * @param directionRandomizer How much to randomize the particle direction [0-1]
  21869. * @returns the emitter
  21870. */
  21871. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  21872. /**
  21873. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  21874. * @param radius The radius of the cylinder to emit from
  21875. * @param height The height of the emission cylinder
  21876. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  21877. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  21878. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  21879. * @returns the emitter
  21880. */
  21881. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  21882. /**
  21883. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  21884. * @param radius The radius of the cone to emit from
  21885. * @param angle The base angle of the cone
  21886. * @returns the emitter
  21887. */
  21888. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  21889. /**
  21890. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  21891. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  21892. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  21893. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  21894. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  21895. * @returns the emitter
  21896. */
  21897. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  21898. /**
  21899. * Get hosting scene
  21900. * @returns the scene
  21901. */
  21902. getScene(): Scene;
  21903. }
  21904. }
  21905. declare module "babylonjs/Shaders/line.fragment" {
  21906. /** @hidden */
  21907. export var linePixelShader: {
  21908. name: string;
  21909. shader: string;
  21910. };
  21911. }
  21912. declare module "babylonjs/Shaders/line.vertex" {
  21913. /** @hidden */
  21914. export var lineVertexShader: {
  21915. name: string;
  21916. shader: string;
  21917. };
  21918. }
  21919. declare module "babylonjs/Rendering/edgesRenderer" {
  21920. import { Nullable } from "babylonjs/types";
  21921. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21922. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21923. import { Vector3 } from "babylonjs/Maths/math";
  21924. import { IDisposable } from "babylonjs/scene";
  21925. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  21926. import "babylonjs/Shaders/line.fragment";
  21927. import "babylonjs/Shaders/line.vertex";
  21928. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21929. module "babylonjs/Meshes/abstractMesh" {
  21930. interface AbstractMesh {
  21931. /**
  21932. * Gets the edgesRenderer associated with the mesh
  21933. */
  21934. edgesRenderer: Nullable<EdgesRenderer>;
  21935. }
  21936. }
  21937. module "babylonjs/Meshes/linesMesh" {
  21938. interface LinesMesh {
  21939. /**
  21940. * Enables the edge rendering mode on the mesh.
  21941. * This mode makes the mesh edges visible
  21942. * @param epsilon defines the maximal distance between two angles to detect a face
  21943. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  21944. * @returns the currentAbstractMesh
  21945. * @see https://www.babylonjs-playground.com/#19O9TU#0
  21946. */
  21947. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  21948. }
  21949. }
  21950. module "babylonjs/Meshes/linesMesh" {
  21951. interface InstancedLinesMesh {
  21952. /**
  21953. * Enables the edge rendering mode on the mesh.
  21954. * This mode makes the mesh edges visible
  21955. * @param epsilon defines the maximal distance between two angles to detect a face
  21956. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  21957. * @returns the current InstancedLinesMesh
  21958. * @see https://www.babylonjs-playground.com/#19O9TU#0
  21959. */
  21960. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  21961. }
  21962. }
  21963. /**
  21964. * Defines the minimum contract an Edges renderer should follow.
  21965. */
  21966. export interface IEdgesRenderer extends IDisposable {
  21967. /**
  21968. * Gets or sets a boolean indicating if the edgesRenderer is active
  21969. */
  21970. isEnabled: boolean;
  21971. /**
  21972. * Renders the edges of the attached mesh,
  21973. */
  21974. render(): void;
  21975. /**
  21976. * Checks wether or not the edges renderer is ready to render.
  21977. * @return true if ready, otherwise false.
  21978. */
  21979. isReady(): boolean;
  21980. }
  21981. /**
  21982. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  21983. */
  21984. export class EdgesRenderer implements IEdgesRenderer {
  21985. /**
  21986. * Define the size of the edges with an orthographic camera
  21987. */
  21988. edgesWidthScalerForOrthographic: number;
  21989. /**
  21990. * Define the size of the edges with a perspective camera
  21991. */
  21992. edgesWidthScalerForPerspective: number;
  21993. protected _source: AbstractMesh;
  21994. protected _linesPositions: number[];
  21995. protected _linesNormals: number[];
  21996. protected _linesIndices: number[];
  21997. protected _epsilon: number;
  21998. protected _indicesCount: number;
  21999. protected _lineShader: ShaderMaterial;
  22000. protected _ib: DataBuffer;
  22001. protected _buffers: {
  22002. [key: string]: Nullable<VertexBuffer>;
  22003. };
  22004. protected _checkVerticesInsteadOfIndices: boolean;
  22005. private _meshRebuildObserver;
  22006. private _meshDisposeObserver;
  22007. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  22008. isEnabled: boolean;
  22009. /**
  22010. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  22011. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  22012. * @param source Mesh used to create edges
  22013. * @param epsilon sum of angles in adjacency to check for edge
  22014. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  22015. * @param generateEdgesLines - should generate Lines or only prepare resources.
  22016. */
  22017. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  22018. protected _prepareRessources(): void;
  22019. /** @hidden */
  22020. _rebuild(): void;
  22021. /**
  22022. * Releases the required resources for the edges renderer
  22023. */
  22024. dispose(): void;
  22025. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  22026. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  22027. /**
  22028. * Checks if the pair of p0 and p1 is en edge
  22029. * @param faceIndex
  22030. * @param edge
  22031. * @param faceNormals
  22032. * @param p0
  22033. * @param p1
  22034. * @private
  22035. */
  22036. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  22037. /**
  22038. * push line into the position, normal and index buffer
  22039. * @protected
  22040. */
  22041. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  22042. /**
  22043. * Generates lines edges from adjacencjes
  22044. * @private
  22045. */
  22046. _generateEdgesLines(): void;
  22047. /**
  22048. * Checks wether or not the edges renderer is ready to render.
  22049. * @return true if ready, otherwise false.
  22050. */
  22051. isReady(): boolean;
  22052. /**
  22053. * Renders the edges of the attached mesh,
  22054. */
  22055. render(): void;
  22056. }
  22057. /**
  22058. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  22059. */
  22060. export class LineEdgesRenderer extends EdgesRenderer {
  22061. /**
  22062. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  22063. * @param source LineMesh used to generate edges
  22064. * @param epsilon not important (specified angle for edge detection)
  22065. * @param checkVerticesInsteadOfIndices not important for LineMesh
  22066. */
  22067. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  22068. /**
  22069. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  22070. */
  22071. _generateEdgesLines(): void;
  22072. }
  22073. }
  22074. declare module "babylonjs/Rendering/renderingGroup" {
  22075. import { SmartArray } from "babylonjs/Misc/smartArray";
  22076. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22077. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22078. import { Nullable } from "babylonjs/types";
  22079. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  22080. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  22081. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  22082. import { Material } from "babylonjs/Materials/material";
  22083. import { Scene } from "babylonjs/scene";
  22084. /**
  22085. * This represents the object necessary to create a rendering group.
  22086. * This is exclusively used and created by the rendering manager.
  22087. * To modify the behavior, you use the available helpers in your scene or meshes.
  22088. * @hidden
  22089. */
  22090. export class RenderingGroup {
  22091. index: number;
  22092. private static _zeroVector;
  22093. private _scene;
  22094. private _opaqueSubMeshes;
  22095. private _transparentSubMeshes;
  22096. private _alphaTestSubMeshes;
  22097. private _depthOnlySubMeshes;
  22098. private _particleSystems;
  22099. private _spriteManagers;
  22100. private _opaqueSortCompareFn;
  22101. private _alphaTestSortCompareFn;
  22102. private _transparentSortCompareFn;
  22103. private _renderOpaque;
  22104. private _renderAlphaTest;
  22105. private _renderTransparent;
  22106. /** @hidden */
  22107. _edgesRenderers: SmartArray<IEdgesRenderer>;
  22108. onBeforeTransparentRendering: () => void;
  22109. /**
  22110. * Set the opaque sort comparison function.
  22111. * If null the sub meshes will be render in the order they were created
  22112. */
  22113. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  22114. /**
  22115. * Set the alpha test sort comparison function.
  22116. * If null the sub meshes will be render in the order they were created
  22117. */
  22118. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  22119. /**
  22120. * Set the transparent sort comparison function.
  22121. * If null the sub meshes will be render in the order they were created
  22122. */
  22123. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  22124. /**
  22125. * Creates a new rendering group.
  22126. * @param index The rendering group index
  22127. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  22128. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  22129. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  22130. */
  22131. 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>);
  22132. /**
  22133. * Render all the sub meshes contained in the group.
  22134. * @param customRenderFunction Used to override the default render behaviour of the group.
  22135. * @returns true if rendered some submeshes.
  22136. */
  22137. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  22138. /**
  22139. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  22140. * @param subMeshes The submeshes to render
  22141. */
  22142. private renderOpaqueSorted;
  22143. /**
  22144. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  22145. * @param subMeshes The submeshes to render
  22146. */
  22147. private renderAlphaTestSorted;
  22148. /**
  22149. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  22150. * @param subMeshes The submeshes to render
  22151. */
  22152. private renderTransparentSorted;
  22153. /**
  22154. * Renders the submeshes in a specified order.
  22155. * @param subMeshes The submeshes to sort before render
  22156. * @param sortCompareFn The comparison function use to sort
  22157. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  22158. * @param transparent Specifies to activate blending if true
  22159. */
  22160. private static renderSorted;
  22161. /**
  22162. * Renders the submeshes in the order they were dispatched (no sort applied).
  22163. * @param subMeshes The submeshes to render
  22164. */
  22165. private static renderUnsorted;
  22166. /**
  22167. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  22168. * are rendered back to front if in the same alpha index.
  22169. *
  22170. * @param a The first submesh
  22171. * @param b The second submesh
  22172. * @returns The result of the comparison
  22173. */
  22174. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  22175. /**
  22176. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  22177. * are rendered back to front.
  22178. *
  22179. * @param a The first submesh
  22180. * @param b The second submesh
  22181. * @returns The result of the comparison
  22182. */
  22183. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  22184. /**
  22185. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  22186. * are rendered front to back (prevent overdraw).
  22187. *
  22188. * @param a The first submesh
  22189. * @param b The second submesh
  22190. * @returns The result of the comparison
  22191. */
  22192. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  22193. /**
  22194. * Resets the different lists of submeshes to prepare a new frame.
  22195. */
  22196. prepare(): void;
  22197. dispose(): void;
  22198. /**
  22199. * Inserts the submesh in its correct queue depending on its material.
  22200. * @param subMesh The submesh to dispatch
  22201. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  22202. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  22203. */
  22204. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  22205. dispatchSprites(spriteManager: ISpriteManager): void;
  22206. dispatchParticles(particleSystem: IParticleSystem): void;
  22207. private _renderParticles;
  22208. private _renderSprites;
  22209. }
  22210. }
  22211. declare module "babylonjs/Rendering/renderingManager" {
  22212. import { Nullable } from "babylonjs/types";
  22213. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22214. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22215. import { SmartArray } from "babylonjs/Misc/smartArray";
  22216. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  22217. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  22218. import { Material } from "babylonjs/Materials/material";
  22219. import { Scene } from "babylonjs/scene";
  22220. import { Camera } from "babylonjs/Cameras/camera";
  22221. /**
  22222. * Interface describing the different options available in the rendering manager
  22223. * regarding Auto Clear between groups.
  22224. */
  22225. export interface IRenderingManagerAutoClearSetup {
  22226. /**
  22227. * Defines whether or not autoclear is enable.
  22228. */
  22229. autoClear: boolean;
  22230. /**
  22231. * Defines whether or not to autoclear the depth buffer.
  22232. */
  22233. depth: boolean;
  22234. /**
  22235. * Defines whether or not to autoclear the stencil buffer.
  22236. */
  22237. stencil: boolean;
  22238. }
  22239. /**
  22240. * This class is used by the onRenderingGroupObservable
  22241. */
  22242. export class RenderingGroupInfo {
  22243. /**
  22244. * The Scene that being rendered
  22245. */
  22246. scene: Scene;
  22247. /**
  22248. * The camera currently used for the rendering pass
  22249. */
  22250. camera: Nullable<Camera>;
  22251. /**
  22252. * The ID of the renderingGroup being processed
  22253. */
  22254. renderingGroupId: number;
  22255. }
  22256. /**
  22257. * This is the manager responsible of all the rendering for meshes sprites and particles.
  22258. * It is enable to manage the different groups as well as the different necessary sort functions.
  22259. * This should not be used directly aside of the few static configurations
  22260. */
  22261. export class RenderingManager {
  22262. /**
  22263. * The max id used for rendering groups (not included)
  22264. */
  22265. static MAX_RENDERINGGROUPS: number;
  22266. /**
  22267. * The min id used for rendering groups (included)
  22268. */
  22269. static MIN_RENDERINGGROUPS: number;
  22270. /**
  22271. * Used to globally prevent autoclearing scenes.
  22272. */
  22273. static AUTOCLEAR: boolean;
  22274. /**
  22275. * @hidden
  22276. */
  22277. _useSceneAutoClearSetup: boolean;
  22278. private _scene;
  22279. private _renderingGroups;
  22280. private _depthStencilBufferAlreadyCleaned;
  22281. private _autoClearDepthStencil;
  22282. private _customOpaqueSortCompareFn;
  22283. private _customAlphaTestSortCompareFn;
  22284. private _customTransparentSortCompareFn;
  22285. private _renderingGroupInfo;
  22286. /**
  22287. * Instantiates a new rendering group for a particular scene
  22288. * @param scene Defines the scene the groups belongs to
  22289. */
  22290. constructor(scene: Scene);
  22291. private _clearDepthStencilBuffer;
  22292. /**
  22293. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  22294. * @hidden
  22295. */
  22296. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  22297. /**
  22298. * Resets the different information of the group to prepare a new frame
  22299. * @hidden
  22300. */
  22301. reset(): void;
  22302. /**
  22303. * Dispose and release the group and its associated resources.
  22304. * @hidden
  22305. */
  22306. dispose(): void;
  22307. /**
  22308. * Clear the info related to rendering groups preventing retention points during dispose.
  22309. */
  22310. freeRenderingGroups(): void;
  22311. private _prepareRenderingGroup;
  22312. /**
  22313. * Add a sprite manager to the rendering manager in order to render it this frame.
  22314. * @param spriteManager Define the sprite manager to render
  22315. */
  22316. dispatchSprites(spriteManager: ISpriteManager): void;
  22317. /**
  22318. * Add a particle system to the rendering manager in order to render it this frame.
  22319. * @param particleSystem Define the particle system to render
  22320. */
  22321. dispatchParticles(particleSystem: IParticleSystem): void;
  22322. /**
  22323. * Add a submesh to the manager in order to render it this frame
  22324. * @param subMesh The submesh to dispatch
  22325. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  22326. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  22327. */
  22328. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  22329. /**
  22330. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  22331. * This allowed control for front to back rendering or reversly depending of the special needs.
  22332. *
  22333. * @param renderingGroupId The rendering group id corresponding to its index
  22334. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  22335. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  22336. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  22337. */
  22338. 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;
  22339. /**
  22340. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  22341. *
  22342. * @param renderingGroupId The rendering group id corresponding to its index
  22343. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  22344. * @param depth Automatically clears depth between groups if true and autoClear is true.
  22345. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  22346. */
  22347. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  22348. /**
  22349. * Gets the current auto clear configuration for one rendering group of the rendering
  22350. * manager.
  22351. * @param index the rendering group index to get the information for
  22352. * @returns The auto clear setup for the requested rendering group
  22353. */
  22354. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  22355. }
  22356. }
  22357. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  22358. import { Observable } from "babylonjs/Misc/observable";
  22359. import { SmartArray } from "babylonjs/Misc/smartArray";
  22360. import { Nullable } from "babylonjs/types";
  22361. import { Camera } from "babylonjs/Cameras/camera";
  22362. import { Scene } from "babylonjs/scene";
  22363. import { Matrix, Vector3, Color4 } from "babylonjs/Maths/math";
  22364. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  22365. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22366. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22367. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  22368. import { Texture } from "babylonjs/Materials/Textures/texture";
  22369. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  22370. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  22371. import "babylonjs/Engines/Extensions/engine.renderTarget";
  22372. import { Engine } from "babylonjs/Engines/engine";
  22373. /**
  22374. * This Helps creating a texture that will be created from a camera in your scene.
  22375. * It is basically a dynamic texture that could be used to create special effects for instance.
  22376. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  22377. */
  22378. export class RenderTargetTexture extends Texture {
  22379. isCube: boolean;
  22380. /**
  22381. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  22382. */
  22383. static readonly REFRESHRATE_RENDER_ONCE: number;
  22384. /**
  22385. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  22386. */
  22387. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  22388. /**
  22389. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  22390. * the central point of your effect and can save a lot of performances.
  22391. */
  22392. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  22393. /**
  22394. * Use this predicate to dynamically define the list of mesh you want to render.
  22395. * If set, the renderList property will be overwritten.
  22396. */
  22397. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  22398. private _renderList;
  22399. /**
  22400. * Use this list to define the list of mesh you want to render.
  22401. */
  22402. renderList: Nullable<Array<AbstractMesh>>;
  22403. private _hookArray;
  22404. /**
  22405. * Define if particles should be rendered in your texture.
  22406. */
  22407. renderParticles: boolean;
  22408. /**
  22409. * Define if sprites should be rendered in your texture.
  22410. */
  22411. renderSprites: boolean;
  22412. /**
  22413. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  22414. */
  22415. coordinatesMode: number;
  22416. /**
  22417. * Define the camera used to render the texture.
  22418. */
  22419. activeCamera: Nullable<Camera>;
  22420. /**
  22421. * Override the render function of the texture with your own one.
  22422. */
  22423. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  22424. /**
  22425. * Define if camera post processes should be use while rendering the texture.
  22426. */
  22427. useCameraPostProcesses: boolean;
  22428. /**
  22429. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  22430. */
  22431. ignoreCameraViewport: boolean;
  22432. private _postProcessManager;
  22433. private _postProcesses;
  22434. private _resizeObserver;
  22435. /**
  22436. * An event triggered when the texture is unbind.
  22437. */
  22438. onBeforeBindObservable: Observable<RenderTargetTexture>;
  22439. /**
  22440. * An event triggered when the texture is unbind.
  22441. */
  22442. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  22443. private _onAfterUnbindObserver;
  22444. /**
  22445. * Set a after unbind callback in the texture.
  22446. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  22447. */
  22448. onAfterUnbind: () => void;
  22449. /**
  22450. * An event triggered before rendering the texture
  22451. */
  22452. onBeforeRenderObservable: Observable<number>;
  22453. private _onBeforeRenderObserver;
  22454. /**
  22455. * Set a before render callback in the texture.
  22456. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  22457. */
  22458. onBeforeRender: (faceIndex: number) => void;
  22459. /**
  22460. * An event triggered after rendering the texture
  22461. */
  22462. onAfterRenderObservable: Observable<number>;
  22463. private _onAfterRenderObserver;
  22464. /**
  22465. * Set a after render callback in the texture.
  22466. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  22467. */
  22468. onAfterRender: (faceIndex: number) => void;
  22469. /**
  22470. * An event triggered after the texture clear
  22471. */
  22472. onClearObservable: Observable<import("babylonjs/Engines/engine").Engine>;
  22473. private _onClearObserver;
  22474. /**
  22475. * Set a clear callback in the texture.
  22476. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  22477. */
  22478. onClear: (Engine: Engine) => void;
  22479. /**
  22480. * Define the clear color of the Render Target if it should be different from the scene.
  22481. */
  22482. clearColor: Color4;
  22483. protected _size: number | {
  22484. width: number;
  22485. height: number;
  22486. };
  22487. protected _initialSizeParameter: number | {
  22488. width: number;
  22489. height: number;
  22490. } | {
  22491. ratio: number;
  22492. };
  22493. protected _sizeRatio: Nullable<number>;
  22494. /** @hidden */
  22495. _generateMipMaps: boolean;
  22496. protected _renderingManager: RenderingManager;
  22497. /** @hidden */
  22498. _waitingRenderList: string[];
  22499. protected _doNotChangeAspectRatio: boolean;
  22500. protected _currentRefreshId: number;
  22501. protected _refreshRate: number;
  22502. protected _textureMatrix: Matrix;
  22503. protected _samples: number;
  22504. protected _renderTargetOptions: RenderTargetCreationOptions;
  22505. /**
  22506. * Gets render target creation options that were used.
  22507. */
  22508. readonly renderTargetOptions: RenderTargetCreationOptions;
  22509. protected _engine: Engine;
  22510. protected _onRatioRescale(): void;
  22511. /**
  22512. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  22513. * It must define where the camera used to render the texture is set
  22514. */
  22515. boundingBoxPosition: Vector3;
  22516. private _boundingBoxSize;
  22517. /**
  22518. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  22519. * When defined, the cubemap will switch to local mode
  22520. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  22521. * @example https://www.babylonjs-playground.com/#RNASML
  22522. */
  22523. boundingBoxSize: Vector3;
  22524. /**
  22525. * In case the RTT has been created with a depth texture, get the associated
  22526. * depth texture.
  22527. * Otherwise, return null.
  22528. */
  22529. depthStencilTexture: Nullable<InternalTexture>;
  22530. /**
  22531. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  22532. * or used a shadow, depth texture...
  22533. * @param name The friendly name of the texture
  22534. * @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)
  22535. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  22536. * @param generateMipMaps True if mip maps need to be generated after render.
  22537. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  22538. * @param type The type of the buffer in the RTT (int, half float, float...)
  22539. * @param isCube True if a cube texture needs to be created
  22540. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  22541. * @param generateDepthBuffer True to generate a depth buffer
  22542. * @param generateStencilBuffer True to generate a stencil buffer
  22543. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  22544. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  22545. * @param delayAllocation if the texture allocation should be delayed (default: false)
  22546. */
  22547. constructor(name: string, size: number | {
  22548. width: number;
  22549. height: number;
  22550. } | {
  22551. ratio: number;
  22552. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  22553. /**
  22554. * Creates a depth stencil texture.
  22555. * This is only available in WebGL 2 or with the depth texture extension available.
  22556. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  22557. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  22558. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  22559. */
  22560. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  22561. private _processSizeParameter;
  22562. /**
  22563. * Define the number of samples to use in case of MSAA.
  22564. * It defaults to one meaning no MSAA has been enabled.
  22565. */
  22566. samples: number;
  22567. /**
  22568. * Resets the refresh counter of the texture and start bak from scratch.
  22569. * Could be useful to regenerate the texture if it is setup to render only once.
  22570. */
  22571. resetRefreshCounter(): void;
  22572. /**
  22573. * Define the refresh rate of the texture or the rendering frequency.
  22574. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  22575. */
  22576. refreshRate: number;
  22577. /**
  22578. * Adds a post process to the render target rendering passes.
  22579. * @param postProcess define the post process to add
  22580. */
  22581. addPostProcess(postProcess: PostProcess): void;
  22582. /**
  22583. * Clear all the post processes attached to the render target
  22584. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  22585. */
  22586. clearPostProcesses(dispose?: boolean): void;
  22587. /**
  22588. * Remove one of the post process from the list of attached post processes to the texture
  22589. * @param postProcess define the post process to remove from the list
  22590. */
  22591. removePostProcess(postProcess: PostProcess): void;
  22592. /** @hidden */
  22593. _shouldRender(): boolean;
  22594. /**
  22595. * Gets the actual render size of the texture.
  22596. * @returns the width of the render size
  22597. */
  22598. getRenderSize(): number;
  22599. /**
  22600. * Gets the actual render width of the texture.
  22601. * @returns the width of the render size
  22602. */
  22603. getRenderWidth(): number;
  22604. /**
  22605. * Gets the actual render height of the texture.
  22606. * @returns the height of the render size
  22607. */
  22608. getRenderHeight(): number;
  22609. /**
  22610. * Get if the texture can be rescaled or not.
  22611. */
  22612. readonly canRescale: boolean;
  22613. /**
  22614. * Resize the texture using a ratio.
  22615. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  22616. */
  22617. scale(ratio: number): void;
  22618. /**
  22619. * Get the texture reflection matrix used to rotate/transform the reflection.
  22620. * @returns the reflection matrix
  22621. */
  22622. getReflectionTextureMatrix(): Matrix;
  22623. /**
  22624. * Resize the texture to a new desired size.
  22625. * Be carrefull as it will recreate all the data in the new texture.
  22626. * @param size Define the new size. It can be:
  22627. * - a number for squared texture,
  22628. * - an object containing { width: number, height: number }
  22629. * - or an object containing a ratio { ratio: number }
  22630. */
  22631. resize(size: number | {
  22632. width: number;
  22633. height: number;
  22634. } | {
  22635. ratio: number;
  22636. }): void;
  22637. /**
  22638. * Renders all the objects from the render list into the texture.
  22639. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  22640. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  22641. */
  22642. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  22643. private _bestReflectionRenderTargetDimension;
  22644. /**
  22645. * @hidden
  22646. * @param faceIndex face index to bind to if this is a cubetexture
  22647. */
  22648. _bindFrameBuffer(faceIndex?: number): void;
  22649. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  22650. private renderToTarget;
  22651. /**
  22652. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  22653. * This allowed control for front to back rendering or reversly depending of the special needs.
  22654. *
  22655. * @param renderingGroupId The rendering group id corresponding to its index
  22656. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  22657. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  22658. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  22659. */
  22660. 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;
  22661. /**
  22662. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  22663. *
  22664. * @param renderingGroupId The rendering group id corresponding to its index
  22665. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  22666. */
  22667. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  22668. /**
  22669. * Clones the texture.
  22670. * @returns the cloned texture
  22671. */
  22672. clone(): RenderTargetTexture;
  22673. /**
  22674. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  22675. * @returns The JSON representation of the texture
  22676. */
  22677. serialize(): any;
  22678. /**
  22679. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  22680. */
  22681. disposeFramebufferObjects(): void;
  22682. /**
  22683. * Dispose the texture and release its associated resources.
  22684. */
  22685. dispose(): void;
  22686. /** @hidden */
  22687. _rebuild(): void;
  22688. /**
  22689. * Clear the info related to rendering groups preventing retention point in material dispose.
  22690. */
  22691. freeRenderingGroups(): void;
  22692. /**
  22693. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  22694. * @returns the view count
  22695. */
  22696. getViewCount(): number;
  22697. }
  22698. }
  22699. declare module "babylonjs/Materials/material" {
  22700. import { IAnimatable } from "babylonjs/Misc/tools";
  22701. import { SmartArray } from "babylonjs/Misc/smartArray";
  22702. import { Observable } from "babylonjs/Misc/observable";
  22703. import { Nullable } from "babylonjs/types";
  22704. import { Scene } from "babylonjs/scene";
  22705. import { Matrix } from "babylonjs/Maths/math";
  22706. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  22707. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22708. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  22709. import { Effect } from "babylonjs/Materials/effect";
  22710. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22711. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  22712. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22713. import { IInspectable } from "babylonjs/Misc/iInspectable";
  22714. import { Mesh } from "babylonjs/Meshes/mesh";
  22715. import { Animation } from "babylonjs/Animations/animation";
  22716. /**
  22717. * Base class for the main features of a material in Babylon.js
  22718. */
  22719. export class Material implements IAnimatable {
  22720. /**
  22721. * Returns the triangle fill mode
  22722. */
  22723. static readonly TriangleFillMode: number;
  22724. /**
  22725. * Returns the wireframe mode
  22726. */
  22727. static readonly WireFrameFillMode: number;
  22728. /**
  22729. * Returns the point fill mode
  22730. */
  22731. static readonly PointFillMode: number;
  22732. /**
  22733. * Returns the point list draw mode
  22734. */
  22735. static readonly PointListDrawMode: number;
  22736. /**
  22737. * Returns the line list draw mode
  22738. */
  22739. static readonly LineListDrawMode: number;
  22740. /**
  22741. * Returns the line loop draw mode
  22742. */
  22743. static readonly LineLoopDrawMode: number;
  22744. /**
  22745. * Returns the line strip draw mode
  22746. */
  22747. static readonly LineStripDrawMode: number;
  22748. /**
  22749. * Returns the triangle strip draw mode
  22750. */
  22751. static readonly TriangleStripDrawMode: number;
  22752. /**
  22753. * Returns the triangle fan draw mode
  22754. */
  22755. static readonly TriangleFanDrawMode: number;
  22756. /**
  22757. * Stores the clock-wise side orientation
  22758. */
  22759. static readonly ClockWiseSideOrientation: number;
  22760. /**
  22761. * Stores the counter clock-wise side orientation
  22762. */
  22763. static readonly CounterClockWiseSideOrientation: number;
  22764. /**
  22765. * The dirty texture flag value
  22766. */
  22767. static readonly TextureDirtyFlag: number;
  22768. /**
  22769. * The dirty light flag value
  22770. */
  22771. static readonly LightDirtyFlag: number;
  22772. /**
  22773. * The dirty fresnel flag value
  22774. */
  22775. static readonly FresnelDirtyFlag: number;
  22776. /**
  22777. * The dirty attribute flag value
  22778. */
  22779. static readonly AttributesDirtyFlag: number;
  22780. /**
  22781. * The dirty misc flag value
  22782. */
  22783. static readonly MiscDirtyFlag: number;
  22784. /**
  22785. * The all dirty flag value
  22786. */
  22787. static readonly AllDirtyFlag: number;
  22788. /**
  22789. * The ID of the material
  22790. */
  22791. id: string;
  22792. /**
  22793. * Gets or sets the unique id of the material
  22794. */
  22795. uniqueId: number;
  22796. /**
  22797. * The name of the material
  22798. */
  22799. name: string;
  22800. /**
  22801. * Gets or sets user defined metadata
  22802. */
  22803. metadata: any;
  22804. /**
  22805. * For internal use only. Please do not use.
  22806. */
  22807. reservedDataStore: any;
  22808. /**
  22809. * Specifies if the ready state should be checked on each call
  22810. */
  22811. checkReadyOnEveryCall: boolean;
  22812. /**
  22813. * Specifies if the ready state should be checked once
  22814. */
  22815. checkReadyOnlyOnce: boolean;
  22816. /**
  22817. * The state of the material
  22818. */
  22819. state: string;
  22820. /**
  22821. * The alpha value of the material
  22822. */
  22823. protected _alpha: number;
  22824. /**
  22825. * List of inspectable custom properties (used by the Inspector)
  22826. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22827. */
  22828. inspectableCustomProperties: IInspectable[];
  22829. /**
  22830. * Sets the alpha value of the material
  22831. */
  22832. /**
  22833. * Gets the alpha value of the material
  22834. */
  22835. alpha: number;
  22836. /**
  22837. * Specifies if back face culling is enabled
  22838. */
  22839. protected _backFaceCulling: boolean;
  22840. /**
  22841. * Sets the back-face culling state
  22842. */
  22843. /**
  22844. * Gets the back-face culling state
  22845. */
  22846. backFaceCulling: boolean;
  22847. /**
  22848. * Stores the value for side orientation
  22849. */
  22850. sideOrientation: number;
  22851. /**
  22852. * Callback triggered when the material is compiled
  22853. */
  22854. onCompiled: Nullable<(effect: Effect) => void>;
  22855. /**
  22856. * Callback triggered when an error occurs
  22857. */
  22858. onError: Nullable<(effect: Effect, errors: string) => void>;
  22859. /**
  22860. * Callback triggered to get the render target textures
  22861. */
  22862. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  22863. /**
  22864. * Gets a boolean indicating that current material needs to register RTT
  22865. */
  22866. readonly hasRenderTargetTextures: boolean;
  22867. /**
  22868. * Specifies if the material should be serialized
  22869. */
  22870. doNotSerialize: boolean;
  22871. /**
  22872. * @hidden
  22873. */
  22874. _storeEffectOnSubMeshes: boolean;
  22875. /**
  22876. * Stores the animations for the material
  22877. */
  22878. animations: Nullable<Array<Animation>>;
  22879. /**
  22880. * An event triggered when the material is disposed
  22881. */
  22882. onDisposeObservable: Observable<Material>;
  22883. /**
  22884. * An observer which watches for dispose events
  22885. */
  22886. private _onDisposeObserver;
  22887. private _onUnBindObservable;
  22888. /**
  22889. * Called during a dispose event
  22890. */
  22891. onDispose: () => void;
  22892. private _onBindObservable;
  22893. /**
  22894. * An event triggered when the material is bound
  22895. */
  22896. readonly onBindObservable: Observable<AbstractMesh>;
  22897. /**
  22898. * An observer which watches for bind events
  22899. */
  22900. private _onBindObserver;
  22901. /**
  22902. * Called during a bind event
  22903. */
  22904. onBind: (Mesh: AbstractMesh) => void;
  22905. /**
  22906. * An event triggered when the material is unbound
  22907. */
  22908. readonly onUnBindObservable: Observable<Material>;
  22909. /**
  22910. * Stores the value of the alpha mode
  22911. */
  22912. private _alphaMode;
  22913. /**
  22914. * Sets the value of the alpha mode.
  22915. *
  22916. * | Value | Type | Description |
  22917. * | --- | --- | --- |
  22918. * | 0 | ALPHA_DISABLE | |
  22919. * | 1 | ALPHA_ADD | |
  22920. * | 2 | ALPHA_COMBINE | |
  22921. * | 3 | ALPHA_SUBTRACT | |
  22922. * | 4 | ALPHA_MULTIPLY | |
  22923. * | 5 | ALPHA_MAXIMIZED | |
  22924. * | 6 | ALPHA_ONEONE | |
  22925. * | 7 | ALPHA_PREMULTIPLIED | |
  22926. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  22927. * | 9 | ALPHA_INTERPOLATE | |
  22928. * | 10 | ALPHA_SCREENMODE | |
  22929. *
  22930. */
  22931. /**
  22932. * Gets the value of the alpha mode
  22933. */
  22934. alphaMode: number;
  22935. /**
  22936. * Stores the state of the need depth pre-pass value
  22937. */
  22938. private _needDepthPrePass;
  22939. /**
  22940. * Sets the need depth pre-pass value
  22941. */
  22942. /**
  22943. * Gets the depth pre-pass value
  22944. */
  22945. needDepthPrePass: boolean;
  22946. /**
  22947. * Specifies if depth writing should be disabled
  22948. */
  22949. disableDepthWrite: boolean;
  22950. /**
  22951. * Specifies if depth writing should be forced
  22952. */
  22953. forceDepthWrite: boolean;
  22954. /**
  22955. * Specifies if there should be a separate pass for culling
  22956. */
  22957. separateCullingPass: boolean;
  22958. /**
  22959. * Stores the state specifing if fog should be enabled
  22960. */
  22961. private _fogEnabled;
  22962. /**
  22963. * Sets the state for enabling fog
  22964. */
  22965. /**
  22966. * Gets the value of the fog enabled state
  22967. */
  22968. fogEnabled: boolean;
  22969. /**
  22970. * Stores the size of points
  22971. */
  22972. pointSize: number;
  22973. /**
  22974. * Stores the z offset value
  22975. */
  22976. zOffset: number;
  22977. /**
  22978. * Gets a value specifying if wireframe mode is enabled
  22979. */
  22980. /**
  22981. * Sets the state of wireframe mode
  22982. */
  22983. wireframe: boolean;
  22984. /**
  22985. * Gets the value specifying if point clouds are enabled
  22986. */
  22987. /**
  22988. * Sets the state of point cloud mode
  22989. */
  22990. pointsCloud: boolean;
  22991. /**
  22992. * Gets the material fill mode
  22993. */
  22994. /**
  22995. * Sets the material fill mode
  22996. */
  22997. fillMode: number;
  22998. /**
  22999. * @hidden
  23000. * Stores the effects for the material
  23001. */
  23002. _effect: Nullable<Effect>;
  23003. /**
  23004. * @hidden
  23005. * Specifies if the material was previously ready
  23006. */
  23007. _wasPreviouslyReady: boolean;
  23008. /**
  23009. * Specifies if uniform buffers should be used
  23010. */
  23011. private _useUBO;
  23012. /**
  23013. * Stores a reference to the scene
  23014. */
  23015. private _scene;
  23016. /**
  23017. * Stores the fill mode state
  23018. */
  23019. private _fillMode;
  23020. /**
  23021. * Specifies if the depth write state should be cached
  23022. */
  23023. private _cachedDepthWriteState;
  23024. /**
  23025. * Stores the uniform buffer
  23026. */
  23027. protected _uniformBuffer: UniformBuffer;
  23028. /** @hidden */
  23029. _indexInSceneMaterialArray: number;
  23030. /** @hidden */
  23031. meshMap: Nullable<{
  23032. [id: string]: AbstractMesh | undefined;
  23033. }>;
  23034. /**
  23035. * Creates a material instance
  23036. * @param name defines the name of the material
  23037. * @param scene defines the scene to reference
  23038. * @param doNotAdd specifies if the material should be added to the scene
  23039. */
  23040. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  23041. /**
  23042. * Returns a string representation of the current material
  23043. * @param fullDetails defines a boolean indicating which levels of logging is desired
  23044. * @returns a string with material information
  23045. */
  23046. toString(fullDetails?: boolean): string;
  23047. /**
  23048. * Gets the class name of the material
  23049. * @returns a string with the class name of the material
  23050. */
  23051. getClassName(): string;
  23052. /**
  23053. * Specifies if updates for the material been locked
  23054. */
  23055. readonly isFrozen: boolean;
  23056. /**
  23057. * Locks updates for the material
  23058. */
  23059. freeze(): void;
  23060. /**
  23061. * Unlocks updates for the material
  23062. */
  23063. unfreeze(): void;
  23064. /**
  23065. * Specifies if the material is ready to be used
  23066. * @param mesh defines the mesh to check
  23067. * @param useInstances specifies if instances should be used
  23068. * @returns a boolean indicating if the material is ready to be used
  23069. */
  23070. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  23071. /**
  23072. * Specifies that the submesh is ready to be used
  23073. * @param mesh defines the mesh to check
  23074. * @param subMesh defines which submesh to check
  23075. * @param useInstances specifies that instances should be used
  23076. * @returns a boolean indicating that the submesh is ready or not
  23077. */
  23078. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  23079. /**
  23080. * Returns the material effect
  23081. * @returns the effect associated with the material
  23082. */
  23083. getEffect(): Nullable<Effect>;
  23084. /**
  23085. * Returns the current scene
  23086. * @returns a Scene
  23087. */
  23088. getScene(): Scene;
  23089. /**
  23090. * Specifies if the material will require alpha blending
  23091. * @returns a boolean specifying if alpha blending is needed
  23092. */
  23093. needAlphaBlending(): boolean;
  23094. /**
  23095. * Specifies if the mesh will require alpha blending
  23096. * @param mesh defines the mesh to check
  23097. * @returns a boolean specifying if alpha blending is needed for the mesh
  23098. */
  23099. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  23100. /**
  23101. * Specifies if this material should be rendered in alpha test mode
  23102. * @returns a boolean specifying if an alpha test is needed.
  23103. */
  23104. needAlphaTesting(): boolean;
  23105. /**
  23106. * Gets the texture used for the alpha test
  23107. * @returns the texture to use for alpha testing
  23108. */
  23109. getAlphaTestTexture(): Nullable<BaseTexture>;
  23110. /**
  23111. * Marks the material to indicate that it needs to be re-calculated
  23112. */
  23113. markDirty(): void;
  23114. /** @hidden */
  23115. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  23116. /**
  23117. * Binds the material to the mesh
  23118. * @param world defines the world transformation matrix
  23119. * @param mesh defines the mesh to bind the material to
  23120. */
  23121. bind(world: Matrix, mesh?: Mesh): void;
  23122. /**
  23123. * Binds the submesh to the material
  23124. * @param world defines the world transformation matrix
  23125. * @param mesh defines the mesh containing the submesh
  23126. * @param subMesh defines the submesh to bind the material to
  23127. */
  23128. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  23129. /**
  23130. * Binds the world matrix to the material
  23131. * @param world defines the world transformation matrix
  23132. */
  23133. bindOnlyWorldMatrix(world: Matrix): void;
  23134. /**
  23135. * Binds the scene's uniform buffer to the effect.
  23136. * @param effect defines the effect to bind to the scene uniform buffer
  23137. * @param sceneUbo defines the uniform buffer storing scene data
  23138. */
  23139. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  23140. /**
  23141. * Binds the view matrix to the effect
  23142. * @param effect defines the effect to bind the view matrix to
  23143. */
  23144. bindView(effect: Effect): void;
  23145. /**
  23146. * Binds the view projection matrix to the effect
  23147. * @param effect defines the effect to bind the view projection matrix to
  23148. */
  23149. bindViewProjection(effect: Effect): void;
  23150. /**
  23151. * Specifies if material alpha testing should be turned on for the mesh
  23152. * @param mesh defines the mesh to check
  23153. */
  23154. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  23155. /**
  23156. * Processes to execute after binding the material to a mesh
  23157. * @param mesh defines the rendered mesh
  23158. */
  23159. protected _afterBind(mesh?: Mesh): void;
  23160. /**
  23161. * Unbinds the material from the mesh
  23162. */
  23163. unbind(): void;
  23164. /**
  23165. * Gets the active textures from the material
  23166. * @returns an array of textures
  23167. */
  23168. getActiveTextures(): BaseTexture[];
  23169. /**
  23170. * Specifies if the material uses a texture
  23171. * @param texture defines the texture to check against the material
  23172. * @returns a boolean specifying if the material uses the texture
  23173. */
  23174. hasTexture(texture: BaseTexture): boolean;
  23175. /**
  23176. * Makes a duplicate of the material, and gives it a new name
  23177. * @param name defines the new name for the duplicated material
  23178. * @returns the cloned material
  23179. */
  23180. clone(name: string): Nullable<Material>;
  23181. /**
  23182. * Gets the meshes bound to the material
  23183. * @returns an array of meshes bound to the material
  23184. */
  23185. getBindedMeshes(): AbstractMesh[];
  23186. /**
  23187. * Force shader compilation
  23188. * @param mesh defines the mesh associated with this material
  23189. * @param onCompiled defines a function to execute once the material is compiled
  23190. * @param options defines the options to configure the compilation
  23191. */
  23192. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  23193. clipPlane: boolean;
  23194. }>): void;
  23195. /**
  23196. * Force shader compilation
  23197. * @param mesh defines the mesh that will use this material
  23198. * @param options defines additional options for compiling the shaders
  23199. * @returns a promise that resolves when the compilation completes
  23200. */
  23201. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  23202. clipPlane: boolean;
  23203. }>): Promise<void>;
  23204. private static readonly _AllDirtyCallBack;
  23205. private static readonly _ImageProcessingDirtyCallBack;
  23206. private static readonly _TextureDirtyCallBack;
  23207. private static readonly _FresnelDirtyCallBack;
  23208. private static readonly _MiscDirtyCallBack;
  23209. private static readonly _LightsDirtyCallBack;
  23210. private static readonly _AttributeDirtyCallBack;
  23211. private static _FresnelAndMiscDirtyCallBack;
  23212. private static _TextureAndMiscDirtyCallBack;
  23213. private static readonly _DirtyCallbackArray;
  23214. private static readonly _RunDirtyCallBacks;
  23215. /**
  23216. * Marks a define in the material to indicate that it needs to be re-computed
  23217. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  23218. */
  23219. markAsDirty(flag: number): void;
  23220. /**
  23221. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  23222. * @param func defines a function which checks material defines against the submeshes
  23223. */
  23224. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  23225. /**
  23226. * Indicates that we need to re-calculated for all submeshes
  23227. */
  23228. protected _markAllSubMeshesAsAllDirty(): void;
  23229. /**
  23230. * Indicates that image processing needs to be re-calculated for all submeshes
  23231. */
  23232. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  23233. /**
  23234. * Indicates that textures need to be re-calculated for all submeshes
  23235. */
  23236. protected _markAllSubMeshesAsTexturesDirty(): void;
  23237. /**
  23238. * Indicates that fresnel needs to be re-calculated for all submeshes
  23239. */
  23240. protected _markAllSubMeshesAsFresnelDirty(): void;
  23241. /**
  23242. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  23243. */
  23244. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  23245. /**
  23246. * Indicates that lights need to be re-calculated for all submeshes
  23247. */
  23248. protected _markAllSubMeshesAsLightsDirty(): void;
  23249. /**
  23250. * Indicates that attributes need to be re-calculated for all submeshes
  23251. */
  23252. protected _markAllSubMeshesAsAttributesDirty(): void;
  23253. /**
  23254. * Indicates that misc needs to be re-calculated for all submeshes
  23255. */
  23256. protected _markAllSubMeshesAsMiscDirty(): void;
  23257. /**
  23258. * Indicates that textures and misc need to be re-calculated for all submeshes
  23259. */
  23260. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  23261. /**
  23262. * Disposes the material
  23263. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23264. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23265. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23266. */
  23267. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23268. /** @hidden */
  23269. private releaseVertexArrayObject;
  23270. /**
  23271. * Serializes this material
  23272. * @returns the serialized material object
  23273. */
  23274. serialize(): any;
  23275. /**
  23276. * Creates a material from parsed material data
  23277. * @param parsedMaterial defines parsed material data
  23278. * @param scene defines the hosting scene
  23279. * @param rootUrl defines the root URL to use to load textures
  23280. * @returns a new material
  23281. */
  23282. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  23283. }
  23284. }
  23285. declare module "babylonjs/Meshes/subMesh" {
  23286. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  23287. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  23288. import { Engine } from "babylonjs/Engines/engine";
  23289. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  23290. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23291. import { Effect } from "babylonjs/Materials/effect";
  23292. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  23293. import { Collider } from "babylonjs/Collisions/collider";
  23294. import { Material } from "babylonjs/Materials/material";
  23295. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  23296. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23297. import { Mesh } from "babylonjs/Meshes/mesh";
  23298. import { Ray } from "babylonjs/Culling/ray";
  23299. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  23300. /**
  23301. * Base class for submeshes
  23302. */
  23303. export class BaseSubMesh {
  23304. /** @hidden */
  23305. _materialDefines: Nullable<MaterialDefines>;
  23306. /** @hidden */
  23307. _materialEffect: Nullable<Effect>;
  23308. /**
  23309. * Gets associated effect
  23310. */
  23311. readonly effect: Nullable<Effect>;
  23312. /**
  23313. * Sets associated effect (effect used to render this submesh)
  23314. * @param effect defines the effect to associate with
  23315. * @param defines defines the set of defines used to compile this effect
  23316. */
  23317. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  23318. }
  23319. /**
  23320. * Defines a subdivision inside a mesh
  23321. */
  23322. export class SubMesh extends BaseSubMesh implements ICullable {
  23323. /** the material index to use */
  23324. materialIndex: number;
  23325. /** vertex index start */
  23326. verticesStart: number;
  23327. /** vertices count */
  23328. verticesCount: number;
  23329. /** index start */
  23330. indexStart: number;
  23331. /** indices count */
  23332. indexCount: number;
  23333. /** @hidden */
  23334. _linesIndexCount: number;
  23335. private _mesh;
  23336. private _renderingMesh;
  23337. private _boundingInfo;
  23338. private _linesIndexBuffer;
  23339. /** @hidden */
  23340. _lastColliderWorldVertices: Nullable<Vector3[]>;
  23341. /** @hidden */
  23342. _trianglePlanes: Plane[];
  23343. /** @hidden */
  23344. _lastColliderTransformMatrix: Nullable<Matrix>;
  23345. /** @hidden */
  23346. _renderId: number;
  23347. /** @hidden */
  23348. _alphaIndex: number;
  23349. /** @hidden */
  23350. _distanceToCamera: number;
  23351. /** @hidden */
  23352. _id: number;
  23353. private _currentMaterial;
  23354. /**
  23355. * Add a new submesh to a mesh
  23356. * @param materialIndex defines the material index to use
  23357. * @param verticesStart defines vertex index start
  23358. * @param verticesCount defines vertices count
  23359. * @param indexStart defines index start
  23360. * @param indexCount defines indices count
  23361. * @param mesh defines the parent mesh
  23362. * @param renderingMesh defines an optional rendering mesh
  23363. * @param createBoundingBox defines if bounding box should be created for this submesh
  23364. * @returns the new submesh
  23365. */
  23366. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  23367. /**
  23368. * Creates a new submesh
  23369. * @param materialIndex defines the material index to use
  23370. * @param verticesStart defines vertex index start
  23371. * @param verticesCount defines vertices count
  23372. * @param indexStart defines index start
  23373. * @param indexCount defines indices count
  23374. * @param mesh defines the parent mesh
  23375. * @param renderingMesh defines an optional rendering mesh
  23376. * @param createBoundingBox defines if bounding box should be created for this submesh
  23377. */
  23378. constructor(
  23379. /** the material index to use */
  23380. materialIndex: number,
  23381. /** vertex index start */
  23382. verticesStart: number,
  23383. /** vertices count */
  23384. verticesCount: number,
  23385. /** index start */
  23386. indexStart: number,
  23387. /** indices count */
  23388. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  23389. /**
  23390. * Returns true if this submesh covers the entire parent mesh
  23391. * @ignorenaming
  23392. */
  23393. readonly IsGlobal: boolean;
  23394. /**
  23395. * Returns the submesh BoudingInfo object
  23396. * @returns current bounding info (or mesh's one if the submesh is global)
  23397. */
  23398. getBoundingInfo(): BoundingInfo;
  23399. /**
  23400. * Sets the submesh BoundingInfo
  23401. * @param boundingInfo defines the new bounding info to use
  23402. * @returns the SubMesh
  23403. */
  23404. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  23405. /**
  23406. * Returns the mesh of the current submesh
  23407. * @return the parent mesh
  23408. */
  23409. getMesh(): AbstractMesh;
  23410. /**
  23411. * Returns the rendering mesh of the submesh
  23412. * @returns the rendering mesh (could be different from parent mesh)
  23413. */
  23414. getRenderingMesh(): Mesh;
  23415. /**
  23416. * Returns the submesh material
  23417. * @returns null or the current material
  23418. */
  23419. getMaterial(): Nullable<Material>;
  23420. /**
  23421. * Sets a new updated BoundingInfo object to the submesh
  23422. * @param data defines an optional position array to use to determine the bounding info
  23423. * @returns the SubMesh
  23424. */
  23425. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  23426. /** @hidden */
  23427. _checkCollision(collider: Collider): boolean;
  23428. /**
  23429. * Updates the submesh BoundingInfo
  23430. * @param world defines the world matrix to use to update the bounding info
  23431. * @returns the submesh
  23432. */
  23433. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  23434. /**
  23435. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  23436. * @param frustumPlanes defines the frustum planes
  23437. * @returns true if the submesh is intersecting with the frustum
  23438. */
  23439. isInFrustum(frustumPlanes: Plane[]): boolean;
  23440. /**
  23441. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  23442. * @param frustumPlanes defines the frustum planes
  23443. * @returns true if the submesh is inside the frustum
  23444. */
  23445. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  23446. /**
  23447. * Renders the submesh
  23448. * @param enableAlphaMode defines if alpha needs to be used
  23449. * @returns the submesh
  23450. */
  23451. render(enableAlphaMode: boolean): SubMesh;
  23452. /**
  23453. * @hidden
  23454. */
  23455. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  23456. /**
  23457. * Checks if the submesh intersects with a ray
  23458. * @param ray defines the ray to test
  23459. * @returns true is the passed ray intersects the submesh bounding box
  23460. */
  23461. canIntersects(ray: Ray): boolean;
  23462. /**
  23463. * Intersects current submesh with a ray
  23464. * @param ray defines the ray to test
  23465. * @param positions defines mesh's positions array
  23466. * @param indices defines mesh's indices array
  23467. * @param fastCheck defines if only bounding info should be used
  23468. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  23469. * @returns intersection info or null if no intersection
  23470. */
  23471. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  23472. /** @hidden */
  23473. private _intersectLines;
  23474. /** @hidden */
  23475. private _intersectUnIndexedLines;
  23476. /** @hidden */
  23477. private _intersectTriangles;
  23478. /** @hidden */
  23479. private _intersectUnIndexedTriangles;
  23480. /** @hidden */
  23481. _rebuild(): void;
  23482. /**
  23483. * Creates a new submesh from the passed mesh
  23484. * @param newMesh defines the new hosting mesh
  23485. * @param newRenderingMesh defines an optional rendering mesh
  23486. * @returns the new submesh
  23487. */
  23488. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  23489. /**
  23490. * Release associated resources
  23491. */
  23492. dispose(): void;
  23493. /**
  23494. * Gets the class name
  23495. * @returns the string "SubMesh".
  23496. */
  23497. getClassName(): string;
  23498. /**
  23499. * Creates a new submesh from indices data
  23500. * @param materialIndex the index of the main mesh material
  23501. * @param startIndex the index where to start the copy in the mesh indices array
  23502. * @param indexCount the number of indices to copy then from the startIndex
  23503. * @param mesh the main mesh to create the submesh from
  23504. * @param renderingMesh the optional rendering mesh
  23505. * @returns a new submesh
  23506. */
  23507. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  23508. }
  23509. }
  23510. declare module "babylonjs/Meshes/geometry" {
  23511. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  23512. import { Scene } from "babylonjs/scene";
  23513. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  23514. import { Engine } from "babylonjs/Engines/engine";
  23515. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  23516. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  23517. import { Effect } from "babylonjs/Materials/effect";
  23518. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23519. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  23520. import { Mesh } from "babylonjs/Meshes/mesh";
  23521. /**
  23522. * Class used to store geometry data (vertex buffers + index buffer)
  23523. */
  23524. export class Geometry implements IGetSetVerticesData {
  23525. /**
  23526. * Gets or sets the ID of the geometry
  23527. */
  23528. id: string;
  23529. /**
  23530. * Gets or sets the unique ID of the geometry
  23531. */
  23532. uniqueId: number;
  23533. /**
  23534. * Gets the delay loading state of the geometry (none by default which means not delayed)
  23535. */
  23536. delayLoadState: number;
  23537. /**
  23538. * Gets the file containing the data to load when running in delay load state
  23539. */
  23540. delayLoadingFile: Nullable<string>;
  23541. /**
  23542. * Callback called when the geometry is updated
  23543. */
  23544. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  23545. private _scene;
  23546. private _engine;
  23547. private _meshes;
  23548. private _totalVertices;
  23549. /** @hidden */
  23550. _indices: IndicesArray;
  23551. /** @hidden */
  23552. _vertexBuffers: {
  23553. [key: string]: VertexBuffer;
  23554. };
  23555. private _isDisposed;
  23556. private _extend;
  23557. private _boundingBias;
  23558. /** @hidden */
  23559. _delayInfo: Array<string>;
  23560. private _indexBuffer;
  23561. private _indexBufferIsUpdatable;
  23562. /** @hidden */
  23563. _boundingInfo: Nullable<BoundingInfo>;
  23564. /** @hidden */
  23565. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  23566. /** @hidden */
  23567. _softwareSkinningFrameId: number;
  23568. private _vertexArrayObjects;
  23569. private _updatable;
  23570. /** @hidden */
  23571. _positions: Nullable<Vector3[]>;
  23572. /**
  23573. * 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
  23574. */
  23575. /**
  23576. * 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
  23577. */
  23578. boundingBias: Vector2;
  23579. /**
  23580. * Static function used to attach a new empty geometry to a mesh
  23581. * @param mesh defines the mesh to attach the geometry to
  23582. * @returns the new Geometry
  23583. */
  23584. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  23585. /**
  23586. * Creates a new geometry
  23587. * @param id defines the unique ID
  23588. * @param scene defines the hosting scene
  23589. * @param vertexData defines the VertexData used to get geometry data
  23590. * @param updatable defines if geometry must be updatable (false by default)
  23591. * @param mesh defines the mesh that will be associated with the geometry
  23592. */
  23593. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  23594. /**
  23595. * Gets the current extend of the geometry
  23596. */
  23597. readonly extend: {
  23598. minimum: Vector3;
  23599. maximum: Vector3;
  23600. };
  23601. /**
  23602. * Gets the hosting scene
  23603. * @returns the hosting Scene
  23604. */
  23605. getScene(): Scene;
  23606. /**
  23607. * Gets the hosting engine
  23608. * @returns the hosting Engine
  23609. */
  23610. getEngine(): Engine;
  23611. /**
  23612. * Defines if the geometry is ready to use
  23613. * @returns true if the geometry is ready to be used
  23614. */
  23615. isReady(): boolean;
  23616. /**
  23617. * Gets a value indicating that the geometry should not be serialized
  23618. */
  23619. readonly doNotSerialize: boolean;
  23620. /** @hidden */
  23621. _rebuild(): void;
  23622. /**
  23623. * Affects all geometry data in one call
  23624. * @param vertexData defines the geometry data
  23625. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  23626. */
  23627. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  23628. /**
  23629. * Set specific vertex data
  23630. * @param kind defines the data kind (Position, normal, etc...)
  23631. * @param data defines the vertex data to use
  23632. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23633. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23634. */
  23635. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  23636. /**
  23637. * Removes a specific vertex data
  23638. * @param kind defines the data kind (Position, normal, etc...)
  23639. */
  23640. removeVerticesData(kind: string): void;
  23641. /**
  23642. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  23643. * @param buffer defines the vertex buffer to use
  23644. * @param totalVertices defines the total number of vertices for position kind (could be null)
  23645. */
  23646. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  23647. /**
  23648. * Update a specific vertex buffer
  23649. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  23650. * It will do nothing if the buffer is not updatable
  23651. * @param kind defines the data kind (Position, normal, etc...)
  23652. * @param data defines the data to use
  23653. * @param offset defines the offset in the target buffer where to store the data
  23654. * @param useBytes set to true if the offset is in bytes
  23655. */
  23656. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  23657. /**
  23658. * Update a specific vertex buffer
  23659. * This function will create a new buffer if the current one is not updatable
  23660. * @param kind defines the data kind (Position, normal, etc...)
  23661. * @param data defines the data to use
  23662. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  23663. */
  23664. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  23665. private _updateBoundingInfo;
  23666. /** @hidden */
  23667. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  23668. /**
  23669. * Gets total number of vertices
  23670. * @returns the total number of vertices
  23671. */
  23672. getTotalVertices(): number;
  23673. /**
  23674. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23675. * @param kind defines the data kind (Position, normal, etc...)
  23676. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23677. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23678. * @returns a float array containing vertex data
  23679. */
  23680. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23681. /**
  23682. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  23683. * @param kind defines the data kind (Position, normal, etc...)
  23684. * @returns true if the vertex buffer with the specified kind is updatable
  23685. */
  23686. isVertexBufferUpdatable(kind: string): boolean;
  23687. /**
  23688. * Gets a specific vertex buffer
  23689. * @param kind defines the data kind (Position, normal, etc...)
  23690. * @returns a VertexBuffer
  23691. */
  23692. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23693. /**
  23694. * Returns all vertex buffers
  23695. * @return an object holding all vertex buffers indexed by kind
  23696. */
  23697. getVertexBuffers(): Nullable<{
  23698. [key: string]: VertexBuffer;
  23699. }>;
  23700. /**
  23701. * Gets a boolean indicating if specific vertex buffer is present
  23702. * @param kind defines the data kind (Position, normal, etc...)
  23703. * @returns true if data is present
  23704. */
  23705. isVerticesDataPresent(kind: string): boolean;
  23706. /**
  23707. * Gets a list of all attached data kinds (Position, normal, etc...)
  23708. * @returns a list of string containing all kinds
  23709. */
  23710. getVerticesDataKinds(): string[];
  23711. /**
  23712. * Update index buffer
  23713. * @param indices defines the indices to store in the index buffer
  23714. * @param offset defines the offset in the target buffer where to store the data
  23715. * @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)
  23716. */
  23717. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  23718. /**
  23719. * Creates a new index buffer
  23720. * @param indices defines the indices to store in the index buffer
  23721. * @param totalVertices defines the total number of vertices (could be null)
  23722. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23723. */
  23724. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  23725. /**
  23726. * Return the total number of indices
  23727. * @returns the total number of indices
  23728. */
  23729. getTotalIndices(): number;
  23730. /**
  23731. * Gets the index buffer array
  23732. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23733. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23734. * @returns the index buffer array
  23735. */
  23736. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23737. /**
  23738. * Gets the index buffer
  23739. * @return the index buffer
  23740. */
  23741. getIndexBuffer(): Nullable<DataBuffer>;
  23742. /** @hidden */
  23743. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  23744. /**
  23745. * Release the associated resources for a specific mesh
  23746. * @param mesh defines the source mesh
  23747. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  23748. */
  23749. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  23750. /**
  23751. * Apply current geometry to a given mesh
  23752. * @param mesh defines the mesh to apply geometry to
  23753. */
  23754. applyToMesh(mesh: Mesh): void;
  23755. private _updateExtend;
  23756. private _applyToMesh;
  23757. private notifyUpdate;
  23758. /**
  23759. * Load the geometry if it was flagged as delay loaded
  23760. * @param scene defines the hosting scene
  23761. * @param onLoaded defines a callback called when the geometry is loaded
  23762. */
  23763. load(scene: Scene, onLoaded?: () => void): void;
  23764. private _queueLoad;
  23765. /**
  23766. * Invert the geometry to move from a right handed system to a left handed one.
  23767. */
  23768. toLeftHanded(): void;
  23769. /** @hidden */
  23770. _resetPointsArrayCache(): void;
  23771. /** @hidden */
  23772. _generatePointsArray(): boolean;
  23773. /**
  23774. * Gets a value indicating if the geometry is disposed
  23775. * @returns true if the geometry was disposed
  23776. */
  23777. isDisposed(): boolean;
  23778. private _disposeVertexArrayObjects;
  23779. /**
  23780. * Free all associated resources
  23781. */
  23782. dispose(): void;
  23783. /**
  23784. * Clone the current geometry into a new geometry
  23785. * @param id defines the unique ID of the new geometry
  23786. * @returns a new geometry object
  23787. */
  23788. copy(id: string): Geometry;
  23789. /**
  23790. * Serialize the current geometry info (and not the vertices data) into a JSON object
  23791. * @return a JSON representation of the current geometry data (without the vertices data)
  23792. */
  23793. serialize(): any;
  23794. private toNumberArray;
  23795. /**
  23796. * Serialize all vertices data into a JSON oject
  23797. * @returns a JSON representation of the current geometry data
  23798. */
  23799. serializeVerticeData(): any;
  23800. /**
  23801. * Extracts a clone of a mesh geometry
  23802. * @param mesh defines the source mesh
  23803. * @param id defines the unique ID of the new geometry object
  23804. * @returns the new geometry object
  23805. */
  23806. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  23807. /**
  23808. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  23809. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23810. * Be aware Math.random() could cause collisions, but:
  23811. * "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"
  23812. * @returns a string containing a new GUID
  23813. */
  23814. static RandomId(): string;
  23815. /** @hidden */
  23816. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  23817. private static _CleanMatricesWeights;
  23818. /**
  23819. * Create a new geometry from persisted data (Using .babylon file format)
  23820. * @param parsedVertexData defines the persisted data
  23821. * @param scene defines the hosting scene
  23822. * @param rootUrl defines the root url to use to load assets (like delayed data)
  23823. * @returns the new geometry object
  23824. */
  23825. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  23826. }
  23827. }
  23828. declare module "babylonjs/Meshes/mesh.vertexData" {
  23829. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  23830. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  23831. import { Geometry } from "babylonjs/Meshes/geometry";
  23832. import { Mesh } from "babylonjs/Meshes/mesh";
  23833. /**
  23834. * Define an interface for all classes that will get and set the data on vertices
  23835. */
  23836. export interface IGetSetVerticesData {
  23837. /**
  23838. * Gets a boolean indicating if specific vertex data is present
  23839. * @param kind defines the vertex data kind to use
  23840. * @returns true is data kind is present
  23841. */
  23842. isVerticesDataPresent(kind: string): boolean;
  23843. /**
  23844. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23845. * @param kind defines the data kind (Position, normal, etc...)
  23846. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23847. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23848. * @returns a float array containing vertex data
  23849. */
  23850. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23851. /**
  23852. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23853. * @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.
  23854. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23855. * @returns the indices array or an empty array if the mesh has no geometry
  23856. */
  23857. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23858. /**
  23859. * Set specific vertex data
  23860. * @param kind defines the data kind (Position, normal, etc...)
  23861. * @param data defines the vertex data to use
  23862. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23863. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23864. */
  23865. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  23866. /**
  23867. * Update a specific associated vertex buffer
  23868. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23869. * - VertexBuffer.PositionKind
  23870. * - VertexBuffer.UVKind
  23871. * - VertexBuffer.UV2Kind
  23872. * - VertexBuffer.UV3Kind
  23873. * - VertexBuffer.UV4Kind
  23874. * - VertexBuffer.UV5Kind
  23875. * - VertexBuffer.UV6Kind
  23876. * - VertexBuffer.ColorKind
  23877. * - VertexBuffer.MatricesIndicesKind
  23878. * - VertexBuffer.MatricesIndicesExtraKind
  23879. * - VertexBuffer.MatricesWeightsKind
  23880. * - VertexBuffer.MatricesWeightsExtraKind
  23881. * @param data defines the data source
  23882. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23883. * @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)
  23884. */
  23885. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  23886. /**
  23887. * Creates a new index buffer
  23888. * @param indices defines the indices to store in the index buffer
  23889. * @param totalVertices defines the total number of vertices (could be null)
  23890. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23891. */
  23892. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  23893. }
  23894. /**
  23895. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  23896. */
  23897. export class VertexData {
  23898. /**
  23899. * Mesh side orientation : usually the external or front surface
  23900. */
  23901. static readonly FRONTSIDE: number;
  23902. /**
  23903. * Mesh side orientation : usually the internal or back surface
  23904. */
  23905. static readonly BACKSIDE: number;
  23906. /**
  23907. * Mesh side orientation : both internal and external or front and back surfaces
  23908. */
  23909. static readonly DOUBLESIDE: number;
  23910. /**
  23911. * Mesh side orientation : by default, `FRONTSIDE`
  23912. */
  23913. static readonly DEFAULTSIDE: number;
  23914. /**
  23915. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  23916. */
  23917. positions: Nullable<FloatArray>;
  23918. /**
  23919. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  23920. */
  23921. normals: Nullable<FloatArray>;
  23922. /**
  23923. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  23924. */
  23925. tangents: Nullable<FloatArray>;
  23926. /**
  23927. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23928. */
  23929. uvs: Nullable<FloatArray>;
  23930. /**
  23931. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23932. */
  23933. uvs2: Nullable<FloatArray>;
  23934. /**
  23935. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23936. */
  23937. uvs3: Nullable<FloatArray>;
  23938. /**
  23939. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23940. */
  23941. uvs4: Nullable<FloatArray>;
  23942. /**
  23943. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23944. */
  23945. uvs5: Nullable<FloatArray>;
  23946. /**
  23947. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23948. */
  23949. uvs6: Nullable<FloatArray>;
  23950. /**
  23951. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  23952. */
  23953. colors: Nullable<FloatArray>;
  23954. /**
  23955. * 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).
  23956. */
  23957. matricesIndices: Nullable<FloatArray>;
  23958. /**
  23959. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  23960. */
  23961. matricesWeights: Nullable<FloatArray>;
  23962. /**
  23963. * An array extending the number of possible indices
  23964. */
  23965. matricesIndicesExtra: Nullable<FloatArray>;
  23966. /**
  23967. * An array extending the number of possible weights when the number of indices is extended
  23968. */
  23969. matricesWeightsExtra: Nullable<FloatArray>;
  23970. /**
  23971. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  23972. */
  23973. indices: Nullable<IndicesArray>;
  23974. /**
  23975. * Uses the passed data array to set the set the values for the specified kind of data
  23976. * @param data a linear array of floating numbers
  23977. * @param kind the type of data that is being set, eg positions, colors etc
  23978. */
  23979. set(data: FloatArray, kind: string): void;
  23980. /**
  23981. * Associates the vertexData to the passed Mesh.
  23982. * Sets it as updatable or not (default `false`)
  23983. * @param mesh the mesh the vertexData is applied to
  23984. * @param updatable when used and having the value true allows new data to update the vertexData
  23985. * @returns the VertexData
  23986. */
  23987. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  23988. /**
  23989. * Associates the vertexData to the passed Geometry.
  23990. * Sets it as updatable or not (default `false`)
  23991. * @param geometry the geometry the vertexData is applied to
  23992. * @param updatable when used and having the value true allows new data to update the vertexData
  23993. * @returns VertexData
  23994. */
  23995. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  23996. /**
  23997. * Updates the associated mesh
  23998. * @param mesh the mesh to be updated
  23999. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  24000. * @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
  24001. * @returns VertexData
  24002. */
  24003. updateMesh(mesh: Mesh): VertexData;
  24004. /**
  24005. * Updates the associated geometry
  24006. * @param geometry the geometry to be updated
  24007. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  24008. * @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
  24009. * @returns VertexData.
  24010. */
  24011. updateGeometry(geometry: Geometry): VertexData;
  24012. private _applyTo;
  24013. private _update;
  24014. /**
  24015. * Transforms each position and each normal of the vertexData according to the passed Matrix
  24016. * @param matrix the transforming matrix
  24017. * @returns the VertexData
  24018. */
  24019. transform(matrix: Matrix): VertexData;
  24020. /**
  24021. * Merges the passed VertexData into the current one
  24022. * @param other the VertexData to be merged into the current one
  24023. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  24024. * @returns the modified VertexData
  24025. */
  24026. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  24027. private _mergeElement;
  24028. private _validate;
  24029. /**
  24030. * Serializes the VertexData
  24031. * @returns a serialized object
  24032. */
  24033. serialize(): any;
  24034. /**
  24035. * Extracts the vertexData from a mesh
  24036. * @param mesh the mesh from which to extract the VertexData
  24037. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  24038. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  24039. * @returns the object VertexData associated to the passed mesh
  24040. */
  24041. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  24042. /**
  24043. * Extracts the vertexData from the geometry
  24044. * @param geometry the geometry from which to extract the VertexData
  24045. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  24046. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  24047. * @returns the object VertexData associated to the passed mesh
  24048. */
  24049. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  24050. private static _ExtractFrom;
  24051. /**
  24052. * Creates the VertexData for a Ribbon
  24053. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  24054. * * pathArray array of paths, each of which an array of successive Vector3
  24055. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  24056. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  24057. * * 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
  24058. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24059. * * 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)
  24060. * * 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)
  24061. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  24062. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  24063. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  24064. * @returns the VertexData of the ribbon
  24065. */
  24066. static CreateRibbon(options: {
  24067. pathArray: Vector3[][];
  24068. closeArray?: boolean;
  24069. closePath?: boolean;
  24070. offset?: number;
  24071. sideOrientation?: number;
  24072. frontUVs?: Vector4;
  24073. backUVs?: Vector4;
  24074. invertUV?: boolean;
  24075. uvs?: Vector2[];
  24076. colors?: Color4[];
  24077. }): VertexData;
  24078. /**
  24079. * Creates the VertexData for a box
  24080. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24081. * * size sets the width, height and depth of the box to the value of size, optional default 1
  24082. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  24083. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  24084. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  24085. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  24086. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  24087. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24088. * * 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)
  24089. * * 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)
  24090. * @returns the VertexData of the box
  24091. */
  24092. static CreateBox(options: {
  24093. size?: number;
  24094. width?: number;
  24095. height?: number;
  24096. depth?: number;
  24097. faceUV?: Vector4[];
  24098. faceColors?: Color4[];
  24099. sideOrientation?: number;
  24100. frontUVs?: Vector4;
  24101. backUVs?: Vector4;
  24102. }): VertexData;
  24103. /**
  24104. * Creates the VertexData for a tiled box
  24105. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24106. * * faceTiles sets the pattern, tile size and number of tiles for a face
  24107. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  24108. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  24109. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24110. * @returns the VertexData of the box
  24111. */
  24112. static CreateTiledBox(options: {
  24113. pattern?: number;
  24114. width?: number;
  24115. height?: number;
  24116. depth?: number;
  24117. tileSize?: number;
  24118. tileWidth?: number;
  24119. tileHeight?: number;
  24120. alignHorizontal?: number;
  24121. alignVertical?: number;
  24122. faceUV?: Vector4[];
  24123. faceColors?: Color4[];
  24124. sideOrientation?: number;
  24125. }): VertexData;
  24126. /**
  24127. * Creates the VertexData for a tiled plane
  24128. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24129. * * pattern a limited pattern arrangement depending on the number
  24130. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  24131. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  24132. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  24133. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24134. * * 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)
  24135. * * 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)
  24136. * @returns the VertexData of the tiled plane
  24137. */
  24138. static CreateTiledPlane(options: {
  24139. pattern?: number;
  24140. tileSize?: number;
  24141. tileWidth?: number;
  24142. tileHeight?: number;
  24143. size?: number;
  24144. width?: number;
  24145. height?: number;
  24146. alignHorizontal?: number;
  24147. alignVertical?: number;
  24148. sideOrientation?: number;
  24149. frontUVs?: Vector4;
  24150. backUVs?: Vector4;
  24151. }): VertexData;
  24152. /**
  24153. * Creates the VertexData for an ellipsoid, defaults to a sphere
  24154. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24155. * * segments sets the number of horizontal strips optional, default 32
  24156. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  24157. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  24158. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  24159. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  24160. * * 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
  24161. * * 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
  24162. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24163. * * 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)
  24164. * * 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)
  24165. * @returns the VertexData of the ellipsoid
  24166. */
  24167. static CreateSphere(options: {
  24168. segments?: number;
  24169. diameter?: number;
  24170. diameterX?: number;
  24171. diameterY?: number;
  24172. diameterZ?: number;
  24173. arc?: number;
  24174. slice?: number;
  24175. sideOrientation?: number;
  24176. frontUVs?: Vector4;
  24177. backUVs?: Vector4;
  24178. }): VertexData;
  24179. /**
  24180. * Creates the VertexData for a cylinder, cone or prism
  24181. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24182. * * height sets the height (y direction) of the cylinder, optional, default 2
  24183. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  24184. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  24185. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  24186. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  24187. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  24188. * * 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
  24189. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  24190. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  24191. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  24192. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  24193. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24194. * * 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)
  24195. * * 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)
  24196. * @returns the VertexData of the cylinder, cone or prism
  24197. */
  24198. static CreateCylinder(options: {
  24199. height?: number;
  24200. diameterTop?: number;
  24201. diameterBottom?: number;
  24202. diameter?: number;
  24203. tessellation?: number;
  24204. subdivisions?: number;
  24205. arc?: number;
  24206. faceColors?: Color4[];
  24207. faceUV?: Vector4[];
  24208. hasRings?: boolean;
  24209. enclose?: boolean;
  24210. sideOrientation?: number;
  24211. frontUVs?: Vector4;
  24212. backUVs?: Vector4;
  24213. }): VertexData;
  24214. /**
  24215. * Creates the VertexData for a torus
  24216. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24217. * * diameter the diameter of the torus, optional default 1
  24218. * * thickness the diameter of the tube forming the torus, optional default 0.5
  24219. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  24220. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24221. * * 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)
  24222. * * 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)
  24223. * @returns the VertexData of the torus
  24224. */
  24225. static CreateTorus(options: {
  24226. diameter?: number;
  24227. thickness?: number;
  24228. tessellation?: number;
  24229. sideOrientation?: number;
  24230. frontUVs?: Vector4;
  24231. backUVs?: Vector4;
  24232. }): VertexData;
  24233. /**
  24234. * Creates the VertexData of the LineSystem
  24235. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  24236. * - lines an array of lines, each line being an array of successive Vector3
  24237. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  24238. * @returns the VertexData of the LineSystem
  24239. */
  24240. static CreateLineSystem(options: {
  24241. lines: Vector3[][];
  24242. colors?: Nullable<Color4[][]>;
  24243. }): VertexData;
  24244. /**
  24245. * Create the VertexData for a DashedLines
  24246. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  24247. * - points an array successive Vector3
  24248. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  24249. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  24250. * - dashNb the intended total number of dashes, optional, default 200
  24251. * @returns the VertexData for the DashedLines
  24252. */
  24253. static CreateDashedLines(options: {
  24254. points: Vector3[];
  24255. dashSize?: number;
  24256. gapSize?: number;
  24257. dashNb?: number;
  24258. }): VertexData;
  24259. /**
  24260. * Creates the VertexData for a Ground
  24261. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  24262. * - width the width (x direction) of the ground, optional, default 1
  24263. * - height the height (z direction) of the ground, optional, default 1
  24264. * - subdivisions the number of subdivisions per side, optional, default 1
  24265. * @returns the VertexData of the Ground
  24266. */
  24267. static CreateGround(options: {
  24268. width?: number;
  24269. height?: number;
  24270. subdivisions?: number;
  24271. subdivisionsX?: number;
  24272. subdivisionsY?: number;
  24273. }): VertexData;
  24274. /**
  24275. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  24276. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  24277. * * xmin the ground minimum X coordinate, optional, default -1
  24278. * * zmin the ground minimum Z coordinate, optional, default -1
  24279. * * xmax the ground maximum X coordinate, optional, default 1
  24280. * * zmax the ground maximum Z coordinate, optional, default 1
  24281. * * 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}
  24282. * * 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}
  24283. * @returns the VertexData of the TiledGround
  24284. */
  24285. static CreateTiledGround(options: {
  24286. xmin: number;
  24287. zmin: number;
  24288. xmax: number;
  24289. zmax: number;
  24290. subdivisions?: {
  24291. w: number;
  24292. h: number;
  24293. };
  24294. precision?: {
  24295. w: number;
  24296. h: number;
  24297. };
  24298. }): VertexData;
  24299. /**
  24300. * Creates the VertexData of the Ground designed from a heightmap
  24301. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  24302. * * width the width (x direction) of the ground
  24303. * * height the height (z direction) of the ground
  24304. * * subdivisions the number of subdivisions per side
  24305. * * minHeight the minimum altitude on the ground, optional, default 0
  24306. * * maxHeight the maximum altitude on the ground, optional default 1
  24307. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  24308. * * buffer the array holding the image color data
  24309. * * bufferWidth the width of image
  24310. * * bufferHeight the height of image
  24311. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  24312. * @returns the VertexData of the Ground designed from a heightmap
  24313. */
  24314. static CreateGroundFromHeightMap(options: {
  24315. width: number;
  24316. height: number;
  24317. subdivisions: number;
  24318. minHeight: number;
  24319. maxHeight: number;
  24320. colorFilter: Color3;
  24321. buffer: Uint8Array;
  24322. bufferWidth: number;
  24323. bufferHeight: number;
  24324. alphaFilter: number;
  24325. }): VertexData;
  24326. /**
  24327. * Creates the VertexData for a Plane
  24328. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  24329. * * size sets the width and height of the plane to the value of size, optional default 1
  24330. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  24331. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  24332. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24333. * * 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)
  24334. * * 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)
  24335. * @returns the VertexData of the box
  24336. */
  24337. static CreatePlane(options: {
  24338. size?: number;
  24339. width?: number;
  24340. height?: number;
  24341. sideOrientation?: number;
  24342. frontUVs?: Vector4;
  24343. backUVs?: Vector4;
  24344. }): VertexData;
  24345. /**
  24346. * Creates the VertexData of the Disc or regular Polygon
  24347. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  24348. * * radius the radius of the disc, optional default 0.5
  24349. * * tessellation the number of polygon sides, optional, default 64
  24350. * * 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
  24351. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24352. * * 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)
  24353. * * 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)
  24354. * @returns the VertexData of the box
  24355. */
  24356. static CreateDisc(options: {
  24357. radius?: number;
  24358. tessellation?: number;
  24359. arc?: number;
  24360. sideOrientation?: number;
  24361. frontUVs?: Vector4;
  24362. backUVs?: Vector4;
  24363. }): VertexData;
  24364. /**
  24365. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  24366. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  24367. * @param polygon a mesh built from polygonTriangulation.build()
  24368. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24369. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  24370. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  24371. * @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)
  24372. * @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)
  24373. * @returns the VertexData of the Polygon
  24374. */
  24375. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  24376. /**
  24377. * Creates the VertexData of the IcoSphere
  24378. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  24379. * * radius the radius of the IcoSphere, optional default 1
  24380. * * radiusX allows stretching in the x direction, optional, default radius
  24381. * * radiusY allows stretching in the y direction, optional, default radius
  24382. * * radiusZ allows stretching in the z direction, optional, default radius
  24383. * * flat when true creates a flat shaded mesh, optional, default true
  24384. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  24385. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24386. * * 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)
  24387. * * 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)
  24388. * @returns the VertexData of the IcoSphere
  24389. */
  24390. static CreateIcoSphere(options: {
  24391. radius?: number;
  24392. radiusX?: number;
  24393. radiusY?: number;
  24394. radiusZ?: number;
  24395. flat?: boolean;
  24396. subdivisions?: number;
  24397. sideOrientation?: number;
  24398. frontUVs?: Vector4;
  24399. backUVs?: Vector4;
  24400. }): VertexData;
  24401. /**
  24402. * Creates the VertexData for a Polyhedron
  24403. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  24404. * * type provided types are:
  24405. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  24406. * * 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)
  24407. * * size the size of the IcoSphere, optional default 1
  24408. * * sizeX allows stretching in the x direction, optional, default size
  24409. * * sizeY allows stretching in the y direction, optional, default size
  24410. * * sizeZ allows stretching in the z direction, optional, default size
  24411. * * 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
  24412. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  24413. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  24414. * * flat when true creates a flat shaded mesh, optional, default true
  24415. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  24416. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24417. * * 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)
  24418. * * 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)
  24419. * @returns the VertexData of the Polyhedron
  24420. */
  24421. static CreatePolyhedron(options: {
  24422. type?: number;
  24423. size?: number;
  24424. sizeX?: number;
  24425. sizeY?: number;
  24426. sizeZ?: number;
  24427. custom?: any;
  24428. faceUV?: Vector4[];
  24429. faceColors?: Color4[];
  24430. flat?: boolean;
  24431. sideOrientation?: number;
  24432. frontUVs?: Vector4;
  24433. backUVs?: Vector4;
  24434. }): VertexData;
  24435. /**
  24436. * Creates the VertexData for a TorusKnot
  24437. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  24438. * * radius the radius of the torus knot, optional, default 2
  24439. * * tube the thickness of the tube, optional, default 0.5
  24440. * * radialSegments the number of sides on each tube segments, optional, default 32
  24441. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  24442. * * p the number of windings around the z axis, optional, default 2
  24443. * * q the number of windings around the x axis, optional, default 3
  24444. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24445. * * 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)
  24446. * * 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)
  24447. * @returns the VertexData of the Torus Knot
  24448. */
  24449. static CreateTorusKnot(options: {
  24450. radius?: number;
  24451. tube?: number;
  24452. radialSegments?: number;
  24453. tubularSegments?: number;
  24454. p?: number;
  24455. q?: number;
  24456. sideOrientation?: number;
  24457. frontUVs?: Vector4;
  24458. backUVs?: Vector4;
  24459. }): VertexData;
  24460. /**
  24461. * Compute normals for given positions and indices
  24462. * @param positions an array of vertex positions, [...., x, y, z, ......]
  24463. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  24464. * @param normals an array of vertex normals, [...., x, y, z, ......]
  24465. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  24466. * * facetNormals : optional array of facet normals (vector3)
  24467. * * facetPositions : optional array of facet positions (vector3)
  24468. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  24469. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  24470. * * bInfo : optional bounding info, required for facetPartitioning computation
  24471. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  24472. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  24473. * * useRightHandedSystem: optional boolean to for right handed system computation
  24474. * * depthSort : optional boolean to enable the facet depth sort computation
  24475. * * distanceTo : optional Vector3 to compute the facet depth from this location
  24476. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  24477. */
  24478. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  24479. facetNormals?: any;
  24480. facetPositions?: any;
  24481. facetPartitioning?: any;
  24482. ratio?: number;
  24483. bInfo?: any;
  24484. bbSize?: Vector3;
  24485. subDiv?: any;
  24486. useRightHandedSystem?: boolean;
  24487. depthSort?: boolean;
  24488. distanceTo?: Vector3;
  24489. depthSortedFacets?: any;
  24490. }): void;
  24491. /** @hidden */
  24492. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  24493. /**
  24494. * Applies VertexData created from the imported parameters to the geometry
  24495. * @param parsedVertexData the parsed data from an imported file
  24496. * @param geometry the geometry to apply the VertexData to
  24497. */
  24498. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  24499. }
  24500. }
  24501. declare module "babylonjs/Meshes/Builders/discBuilder" {
  24502. import { Nullable } from "babylonjs/types";
  24503. import { Scene } from "babylonjs/scene";
  24504. import { Vector4 } from "babylonjs/Maths/math";
  24505. import { Mesh } from "babylonjs/Meshes/mesh";
  24506. /**
  24507. * Class containing static functions to help procedurally build meshes
  24508. */
  24509. export class DiscBuilder {
  24510. /**
  24511. * Creates a plane polygonal mesh. By default, this is a disc
  24512. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  24513. * * 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
  24514. * * 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
  24515. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24516. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  24517. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24518. * @param name defines the name of the mesh
  24519. * @param options defines the options used to create the mesh
  24520. * @param scene defines the hosting scene
  24521. * @returns the plane polygonal mesh
  24522. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  24523. */
  24524. static CreateDisc(name: string, options: {
  24525. radius?: number;
  24526. tessellation?: number;
  24527. arc?: number;
  24528. updatable?: boolean;
  24529. sideOrientation?: number;
  24530. frontUVs?: Vector4;
  24531. backUVs?: Vector4;
  24532. }, scene?: Nullable<Scene>): Mesh;
  24533. }
  24534. }
  24535. declare module "babylonjs/Particles/solidParticleSystem" {
  24536. import { Vector3 } from "babylonjs/Maths/math";
  24537. import { Mesh } from "babylonjs/Meshes/mesh";
  24538. import { Scene, IDisposable } from "babylonjs/scene";
  24539. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  24540. /**
  24541. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  24542. *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.
  24543. * The SPS is also a particle system. It provides some methods to manage the particles.
  24544. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  24545. *
  24546. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  24547. */
  24548. export class SolidParticleSystem implements IDisposable {
  24549. /**
  24550. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  24551. * Example : var p = SPS.particles[i];
  24552. */
  24553. particles: SolidParticle[];
  24554. /**
  24555. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  24556. */
  24557. nbParticles: number;
  24558. /**
  24559. * If the particles must ever face the camera (default false). Useful for planar particles.
  24560. */
  24561. billboard: boolean;
  24562. /**
  24563. * Recompute normals when adding a shape
  24564. */
  24565. recomputeNormals: boolean;
  24566. /**
  24567. * This a counter ofr your own usage. It's not set by any SPS functions.
  24568. */
  24569. counter: number;
  24570. /**
  24571. * The SPS name. This name is also given to the underlying mesh.
  24572. */
  24573. name: string;
  24574. /**
  24575. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  24576. */
  24577. mesh: Mesh;
  24578. /**
  24579. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  24580. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  24581. */
  24582. vars: any;
  24583. /**
  24584. * This array is populated when the SPS is set as 'pickable'.
  24585. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  24586. * Each element of this array is an object `{idx: int, faceId: int}`.
  24587. * `idx` is the picked particle index in the `SPS.particles` array
  24588. * `faceId` is the picked face index counted within this particle.
  24589. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  24590. */
  24591. pickedParticles: {
  24592. idx: number;
  24593. faceId: number;
  24594. }[];
  24595. /**
  24596. * This array is populated when `enableDepthSort` is set to true.
  24597. * Each element of this array is an instance of the class DepthSortedParticle.
  24598. */
  24599. depthSortedParticles: DepthSortedParticle[];
  24600. /**
  24601. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  24602. * @hidden
  24603. */
  24604. _bSphereOnly: boolean;
  24605. /**
  24606. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  24607. * @hidden
  24608. */
  24609. _bSphereRadiusFactor: number;
  24610. private _scene;
  24611. private _positions;
  24612. private _indices;
  24613. private _normals;
  24614. private _colors;
  24615. private _uvs;
  24616. private _indices32;
  24617. private _positions32;
  24618. private _normals32;
  24619. private _fixedNormal32;
  24620. private _colors32;
  24621. private _uvs32;
  24622. private _index;
  24623. private _updatable;
  24624. private _pickable;
  24625. private _isVisibilityBoxLocked;
  24626. private _alwaysVisible;
  24627. private _depthSort;
  24628. private _shapeCounter;
  24629. private _copy;
  24630. private _color;
  24631. private _computeParticleColor;
  24632. private _computeParticleTexture;
  24633. private _computeParticleRotation;
  24634. private _computeParticleVertex;
  24635. private _computeBoundingBox;
  24636. private _depthSortParticles;
  24637. private _camera;
  24638. private _mustUnrotateFixedNormals;
  24639. private _particlesIntersect;
  24640. private _needs32Bits;
  24641. /**
  24642. * Creates a SPS (Solid Particle System) object.
  24643. * @param name (String) is the SPS name, this will be the underlying mesh name.
  24644. * @param scene (Scene) is the scene in which the SPS is added.
  24645. * @param options defines the options of the sps e.g.
  24646. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  24647. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  24648. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  24649. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  24650. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  24651. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  24652. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  24653. */
  24654. constructor(name: string, scene: Scene, options?: {
  24655. updatable?: boolean;
  24656. isPickable?: boolean;
  24657. enableDepthSort?: boolean;
  24658. particleIntersection?: boolean;
  24659. boundingSphereOnly?: boolean;
  24660. bSphereRadiusFactor?: number;
  24661. });
  24662. /**
  24663. * Builds the SPS underlying mesh. Returns a standard Mesh.
  24664. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  24665. * @returns the created mesh
  24666. */
  24667. buildMesh(): Mesh;
  24668. /**
  24669. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  24670. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  24671. * Thus the particles generated from `digest()` have their property `position` set yet.
  24672. * @param mesh ( Mesh ) is the mesh to be digested
  24673. * @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
  24674. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  24675. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  24676. * @returns the current SPS
  24677. */
  24678. digest(mesh: Mesh, options?: {
  24679. facetNb?: number;
  24680. number?: number;
  24681. delta?: number;
  24682. }): SolidParticleSystem;
  24683. private _unrotateFixedNormals;
  24684. private _resetCopy;
  24685. private _meshBuilder;
  24686. private _posToShape;
  24687. private _uvsToShapeUV;
  24688. private _addParticle;
  24689. /**
  24690. * Adds some particles to the SPS from the model shape. Returns the shape id.
  24691. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  24692. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  24693. * @param nb (positive integer) the number of particles to be created from this model
  24694. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  24695. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  24696. * @returns the number of shapes in the system
  24697. */
  24698. addShape(mesh: Mesh, nb: number, options?: {
  24699. positionFunction?: any;
  24700. vertexFunction?: any;
  24701. }): number;
  24702. private _rebuildParticle;
  24703. /**
  24704. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  24705. * @returns the SPS.
  24706. */
  24707. rebuildMesh(): SolidParticleSystem;
  24708. /**
  24709. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  24710. * This method calls `updateParticle()` for each particle of the SPS.
  24711. * For an animated SPS, it is usually called within the render loop.
  24712. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  24713. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  24714. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  24715. * @returns the SPS.
  24716. */
  24717. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  24718. /**
  24719. * Disposes the SPS.
  24720. */
  24721. dispose(): void;
  24722. /**
  24723. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  24724. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24725. * @returns the SPS.
  24726. */
  24727. refreshVisibleSize(): SolidParticleSystem;
  24728. /**
  24729. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  24730. * @param size the size (float) of the visibility box
  24731. * note : this doesn't lock the SPS mesh bounding box.
  24732. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24733. */
  24734. setVisibilityBox(size: number): void;
  24735. /**
  24736. * Gets whether the SPS as always visible or not
  24737. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24738. */
  24739. /**
  24740. * Sets the SPS as always visible or not
  24741. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24742. */
  24743. isAlwaysVisible: boolean;
  24744. /**
  24745. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24746. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24747. */
  24748. /**
  24749. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24750. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24751. */
  24752. isVisibilityBoxLocked: boolean;
  24753. /**
  24754. * Tells to `setParticles()` to compute the particle rotations or not.
  24755. * Default value : true. The SPS is faster when it's set to false.
  24756. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24757. */
  24758. /**
  24759. * Gets if `setParticles()` computes the particle rotations or not.
  24760. * Default value : true. The SPS is faster when it's set to false.
  24761. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24762. */
  24763. computeParticleRotation: boolean;
  24764. /**
  24765. * Tells to `setParticles()` to compute the particle colors or not.
  24766. * Default value : true. The SPS is faster when it's set to false.
  24767. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24768. */
  24769. /**
  24770. * Gets if `setParticles()` computes the particle colors or not.
  24771. * Default value : true. The SPS is faster when it's set to false.
  24772. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24773. */
  24774. computeParticleColor: boolean;
  24775. /**
  24776. * Gets if `setParticles()` computes the particle textures or not.
  24777. * Default value : true. The SPS is faster when it's set to false.
  24778. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  24779. */
  24780. computeParticleTexture: boolean;
  24781. /**
  24782. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  24783. * Default value : false. The SPS is faster when it's set to false.
  24784. * Note : the particle custom vertex positions aren't stored values.
  24785. */
  24786. /**
  24787. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  24788. * Default value : false. The SPS is faster when it's set to false.
  24789. * Note : the particle custom vertex positions aren't stored values.
  24790. */
  24791. computeParticleVertex: boolean;
  24792. /**
  24793. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  24794. */
  24795. /**
  24796. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  24797. */
  24798. computeBoundingBox: boolean;
  24799. /**
  24800. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  24801. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24802. * Default : `true`
  24803. */
  24804. /**
  24805. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  24806. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24807. * Default : `true`
  24808. */
  24809. depthSortParticles: boolean;
  24810. /**
  24811. * This function does nothing. It may be overwritten to set all the particle first values.
  24812. * The SPS doesn't call this function, you may have to call it by your own.
  24813. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24814. */
  24815. initParticles(): void;
  24816. /**
  24817. * This function does nothing. It may be overwritten to recycle a particle.
  24818. * The SPS doesn't call this function, you may have to call it by your own.
  24819. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24820. * @param particle The particle to recycle
  24821. * @returns the recycled particle
  24822. */
  24823. recycleParticle(particle: SolidParticle): SolidParticle;
  24824. /**
  24825. * Updates a particle : this function should be overwritten by the user.
  24826. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  24827. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24828. * @example : just set a particle position or velocity and recycle conditions
  24829. * @param particle The particle to update
  24830. * @returns the updated particle
  24831. */
  24832. updateParticle(particle: SolidParticle): SolidParticle;
  24833. /**
  24834. * Updates a vertex of a particle : it can be overwritten by the user.
  24835. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  24836. * @param particle the current particle
  24837. * @param vertex the current index of the current particle
  24838. * @param pt the index of the current vertex in the particle shape
  24839. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  24840. * @example : just set a vertex particle position
  24841. * @returns the updated vertex
  24842. */
  24843. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  24844. /**
  24845. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  24846. * This does nothing and may be overwritten by the user.
  24847. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24848. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24849. * @param update the boolean update value actually passed to setParticles()
  24850. */
  24851. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24852. /**
  24853. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  24854. * This will be passed three parameters.
  24855. * This does nothing and may be overwritten by the user.
  24856. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24857. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24858. * @param update the boolean update value actually passed to setParticles()
  24859. */
  24860. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24861. }
  24862. }
  24863. declare module "babylonjs/Particles/solidParticle" {
  24864. import { Nullable } from "babylonjs/types";
  24865. import { Color4, Vector3, Matrix, Quaternion, Vector4, Plane } from "babylonjs/Maths/math";
  24866. import { Mesh } from "babylonjs/Meshes/mesh";
  24867. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24868. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  24869. /**
  24870. * Represents one particle of a solid particle system.
  24871. */
  24872. export class SolidParticle {
  24873. /**
  24874. * particle global index
  24875. */
  24876. idx: number;
  24877. /**
  24878. * The color of the particle
  24879. */
  24880. color: Nullable<Color4>;
  24881. /**
  24882. * The world space position of the particle.
  24883. */
  24884. position: Vector3;
  24885. /**
  24886. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  24887. */
  24888. rotation: Vector3;
  24889. /**
  24890. * The world space rotation quaternion of the particle.
  24891. */
  24892. rotationQuaternion: Nullable<Quaternion>;
  24893. /**
  24894. * The scaling of the particle.
  24895. */
  24896. scaling: Vector3;
  24897. /**
  24898. * The uvs of the particle.
  24899. */
  24900. uvs: Vector4;
  24901. /**
  24902. * The current speed of the particle.
  24903. */
  24904. velocity: Vector3;
  24905. /**
  24906. * The pivot point in the particle local space.
  24907. */
  24908. pivot: Vector3;
  24909. /**
  24910. * Must the particle be translated from its pivot point in its local space ?
  24911. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  24912. * Default : false
  24913. */
  24914. translateFromPivot: boolean;
  24915. /**
  24916. * Is the particle active or not ?
  24917. */
  24918. alive: boolean;
  24919. /**
  24920. * Is the particle visible or not ?
  24921. */
  24922. isVisible: boolean;
  24923. /**
  24924. * Index of this particle in the global "positions" array (Internal use)
  24925. * @hidden
  24926. */
  24927. _pos: number;
  24928. /**
  24929. * @hidden Index of this particle in the global "indices" array (Internal use)
  24930. */
  24931. _ind: number;
  24932. /**
  24933. * @hidden ModelShape of this particle (Internal use)
  24934. */
  24935. _model: ModelShape;
  24936. /**
  24937. * ModelShape id of this particle
  24938. */
  24939. shapeId: number;
  24940. /**
  24941. * Index of the particle in its shape id (Internal use)
  24942. */
  24943. idxInShape: number;
  24944. /**
  24945. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  24946. */
  24947. _modelBoundingInfo: BoundingInfo;
  24948. /**
  24949. * @hidden Particle BoundingInfo object (Internal use)
  24950. */
  24951. _boundingInfo: BoundingInfo;
  24952. /**
  24953. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  24954. */
  24955. _sps: SolidParticleSystem;
  24956. /**
  24957. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  24958. */
  24959. _stillInvisible: boolean;
  24960. /**
  24961. * @hidden Last computed particle rotation matrix
  24962. */
  24963. _rotationMatrix: number[];
  24964. /**
  24965. * Parent particle Id, if any.
  24966. * Default null.
  24967. */
  24968. parentId: Nullable<number>;
  24969. /**
  24970. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  24971. * The possible values are :
  24972. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24973. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24974. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24975. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24976. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24977. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  24978. * */
  24979. cullingStrategy: number;
  24980. /**
  24981. * @hidden Internal global position in the SPS.
  24982. */
  24983. _globalPosition: Vector3;
  24984. /**
  24985. * Creates a Solid Particle object.
  24986. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  24987. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  24988. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  24989. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  24990. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  24991. * @param shapeId (integer) is the model shape identifier in the SPS.
  24992. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  24993. * @param sps defines the sps it is associated to
  24994. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  24995. */
  24996. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  24997. /**
  24998. * Legacy support, changed scale to scaling
  24999. */
  25000. /**
  25001. * Legacy support, changed scale to scaling
  25002. */
  25003. scale: Vector3;
  25004. /**
  25005. * Legacy support, changed quaternion to rotationQuaternion
  25006. */
  25007. /**
  25008. * Legacy support, changed quaternion to rotationQuaternion
  25009. */
  25010. quaternion: Nullable<Quaternion>;
  25011. /**
  25012. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  25013. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  25014. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  25015. * @returns true if it intersects
  25016. */
  25017. intersectsMesh(target: Mesh | SolidParticle): boolean;
  25018. /**
  25019. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  25020. * A particle is in the frustum if its bounding box intersects the frustum
  25021. * @param frustumPlanes defines the frustum to test
  25022. * @returns true if the particle is in the frustum planes
  25023. */
  25024. isInFrustum(frustumPlanes: Plane[]): boolean;
  25025. /**
  25026. * get the rotation matrix of the particle
  25027. * @hidden
  25028. */
  25029. getRotationMatrix(m: Matrix): void;
  25030. }
  25031. /**
  25032. * Represents the shape of the model used by one particle of a solid particle system.
  25033. * SPS internal tool, don't use it manually.
  25034. */
  25035. export class ModelShape {
  25036. /**
  25037. * The shape id
  25038. * @hidden
  25039. */
  25040. shapeID: number;
  25041. /**
  25042. * flat array of model positions (internal use)
  25043. * @hidden
  25044. */
  25045. _shape: Vector3[];
  25046. /**
  25047. * flat array of model UVs (internal use)
  25048. * @hidden
  25049. */
  25050. _shapeUV: number[];
  25051. /**
  25052. * length of the shape in the model indices array (internal use)
  25053. * @hidden
  25054. */
  25055. _indicesLength: number;
  25056. /**
  25057. * Custom position function (internal use)
  25058. * @hidden
  25059. */
  25060. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  25061. /**
  25062. * Custom vertex function (internal use)
  25063. * @hidden
  25064. */
  25065. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  25066. /**
  25067. * 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.
  25068. * SPS internal tool, don't use it manually.
  25069. * @hidden
  25070. */
  25071. 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>);
  25072. }
  25073. /**
  25074. * Represents a Depth Sorted Particle in the solid particle system.
  25075. */
  25076. export class DepthSortedParticle {
  25077. /**
  25078. * Index of the particle in the "indices" array
  25079. */
  25080. ind: number;
  25081. /**
  25082. * Length of the particle shape in the "indices" array
  25083. */
  25084. indicesLength: number;
  25085. /**
  25086. * Squared distance from the particle to the camera
  25087. */
  25088. sqDistance: number;
  25089. }
  25090. }
  25091. declare module "babylonjs/Collisions/meshCollisionData" {
  25092. import { Collider } from "babylonjs/Collisions/collider";
  25093. import { Vector3 } from "babylonjs/Maths/math";
  25094. import { Nullable } from "babylonjs/types";
  25095. import { Observer } from "babylonjs/Misc/observable";
  25096. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25097. /**
  25098. * @hidden
  25099. */
  25100. export class _MeshCollisionData {
  25101. _checkCollisions: boolean;
  25102. _collisionMask: number;
  25103. _collisionGroup: number;
  25104. _collider: Nullable<Collider>;
  25105. _oldPositionForCollisions: Vector3;
  25106. _diffPositionForCollisions: Vector3;
  25107. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  25108. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  25109. }
  25110. }
  25111. declare module "babylonjs/Meshes/abstractMesh" {
  25112. import { Observable } from "babylonjs/Misc/observable";
  25113. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  25114. import { Camera } from "babylonjs/Cameras/camera";
  25115. import { Scene, IDisposable } from "babylonjs/scene";
  25116. import { Matrix, Vector3, Color3, Color4, Plane, Vector2 } from "babylonjs/Maths/math";
  25117. import { Node } from "babylonjs/node";
  25118. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  25119. import { TransformNode } from "babylonjs/Meshes/transformNode";
  25120. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25121. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  25122. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  25123. import { Material } from "babylonjs/Materials/material";
  25124. import { Light } from "babylonjs/Lights/light";
  25125. import { Skeleton } from "babylonjs/Bones/skeleton";
  25126. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  25127. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  25128. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  25129. import { Ray } from "babylonjs/Culling/ray";
  25130. import { Collider } from "babylonjs/Collisions/collider";
  25131. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  25132. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  25133. /** @hidden */
  25134. class _FacetDataStorage {
  25135. facetPositions: Vector3[];
  25136. facetNormals: Vector3[];
  25137. facetPartitioning: number[][];
  25138. facetNb: number;
  25139. partitioningSubdivisions: number;
  25140. partitioningBBoxRatio: number;
  25141. facetDataEnabled: boolean;
  25142. facetParameters: any;
  25143. bbSize: Vector3;
  25144. subDiv: {
  25145. max: number;
  25146. X: number;
  25147. Y: number;
  25148. Z: number;
  25149. };
  25150. facetDepthSort: boolean;
  25151. facetDepthSortEnabled: boolean;
  25152. depthSortedIndices: IndicesArray;
  25153. depthSortedFacets: {
  25154. ind: number;
  25155. sqDistance: number;
  25156. }[];
  25157. facetDepthSortFunction: (f1: {
  25158. ind: number;
  25159. sqDistance: number;
  25160. }, f2: {
  25161. ind: number;
  25162. sqDistance: number;
  25163. }) => number;
  25164. facetDepthSortFrom: Vector3;
  25165. facetDepthSortOrigin: Vector3;
  25166. invertedMatrix: Matrix;
  25167. }
  25168. /**
  25169. * @hidden
  25170. **/
  25171. class _InternalAbstractMeshDataInfo {
  25172. _hasVertexAlpha: boolean;
  25173. _useVertexColors: boolean;
  25174. _numBoneInfluencers: number;
  25175. _applyFog: boolean;
  25176. _receiveShadows: boolean;
  25177. _facetData: _FacetDataStorage;
  25178. _visibility: number;
  25179. _skeleton: Nullable<Skeleton>;
  25180. _layerMask: number;
  25181. _computeBonesUsingShaders: boolean;
  25182. _isActive: boolean;
  25183. _onlyForInstances: boolean;
  25184. _isActiveIntermediate: boolean;
  25185. _onlyForInstancesIntermediate: boolean;
  25186. }
  25187. /**
  25188. * Class used to store all common mesh properties
  25189. */
  25190. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  25191. /** No occlusion */
  25192. static OCCLUSION_TYPE_NONE: number;
  25193. /** Occlusion set to optimisitic */
  25194. static OCCLUSION_TYPE_OPTIMISTIC: number;
  25195. /** Occlusion set to strict */
  25196. static OCCLUSION_TYPE_STRICT: number;
  25197. /** Use an accurante occlusion algorithm */
  25198. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  25199. /** Use a conservative occlusion algorithm */
  25200. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  25201. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  25202. * Test order :
  25203. * Is the bounding sphere outside the frustum ?
  25204. * If not, are the bounding box vertices outside the frustum ?
  25205. * It not, then the cullable object is in the frustum.
  25206. */
  25207. static readonly CULLINGSTRATEGY_STANDARD: number;
  25208. /** Culling strategy : Bounding Sphere Only.
  25209. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  25210. * It's also less accurate than the standard because some not visible objects can still be selected.
  25211. * Test : is the bounding sphere outside the frustum ?
  25212. * If not, then the cullable object is in the frustum.
  25213. */
  25214. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  25215. /** Culling strategy : Optimistic Inclusion.
  25216. * This in an inclusion test first, then the standard exclusion test.
  25217. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  25218. * 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.
  25219. * Anyway, it's as accurate as the standard strategy.
  25220. * Test :
  25221. * Is the cullable object bounding sphere center in the frustum ?
  25222. * If not, apply the default culling strategy.
  25223. */
  25224. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  25225. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  25226. * This in an inclusion test first, then the bounding sphere only exclusion test.
  25227. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  25228. * 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.
  25229. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  25230. * Test :
  25231. * Is the cullable object bounding sphere center in the frustum ?
  25232. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  25233. */
  25234. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  25235. /**
  25236. * No billboard
  25237. */
  25238. static readonly BILLBOARDMODE_NONE: number;
  25239. /** Billboard on X axis */
  25240. static readonly BILLBOARDMODE_X: number;
  25241. /** Billboard on Y axis */
  25242. static readonly BILLBOARDMODE_Y: number;
  25243. /** Billboard on Z axis */
  25244. static readonly BILLBOARDMODE_Z: number;
  25245. /** Billboard on all axes */
  25246. static readonly BILLBOARDMODE_ALL: number;
  25247. /** @hidden */
  25248. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  25249. /**
  25250. * The culling strategy to use to check whether the mesh must be rendered or not.
  25251. * This value can be changed at any time and will be used on the next render mesh selection.
  25252. * The possible values are :
  25253. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25254. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25255. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25256. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25257. * Please read each static variable documentation to get details about the culling process.
  25258. * */
  25259. cullingStrategy: number;
  25260. /**
  25261. * Gets the number of facets in the mesh
  25262. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25263. */
  25264. readonly facetNb: number;
  25265. /**
  25266. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  25267. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25268. */
  25269. partitioningSubdivisions: number;
  25270. /**
  25271. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  25272. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  25273. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25274. */
  25275. partitioningBBoxRatio: number;
  25276. /**
  25277. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  25278. * Works only for updatable meshes.
  25279. * Doesn't work with multi-materials
  25280. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25281. */
  25282. mustDepthSortFacets: boolean;
  25283. /**
  25284. * The location (Vector3) where the facet depth sort must be computed from.
  25285. * By default, the active camera position.
  25286. * Used only when facet depth sort is enabled
  25287. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25288. */
  25289. facetDepthSortFrom: Vector3;
  25290. /**
  25291. * gets a boolean indicating if facetData is enabled
  25292. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25293. */
  25294. readonly isFacetDataEnabled: boolean;
  25295. /** @hidden */
  25296. _updateNonUniformScalingState(value: boolean): boolean;
  25297. /**
  25298. * An event triggered when this mesh collides with another one
  25299. */
  25300. onCollideObservable: Observable<AbstractMesh>;
  25301. /** Set a function to call when this mesh collides with another one */
  25302. onCollide: () => void;
  25303. /**
  25304. * An event triggered when the collision's position changes
  25305. */
  25306. onCollisionPositionChangeObservable: Observable<Vector3>;
  25307. /** Set a function to call when the collision's position changes */
  25308. onCollisionPositionChange: () => void;
  25309. /**
  25310. * An event triggered when material is changed
  25311. */
  25312. onMaterialChangedObservable: Observable<AbstractMesh>;
  25313. /**
  25314. * Gets or sets the orientation for POV movement & rotation
  25315. */
  25316. definedFacingForward: boolean;
  25317. /** @hidden */
  25318. _occlusionQuery: Nullable<WebGLQuery>;
  25319. /** @hidden */
  25320. _renderingGroup: Nullable<RenderingGroup>;
  25321. /**
  25322. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25323. */
  25324. /**
  25325. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25326. */
  25327. visibility: number;
  25328. /** Gets or sets the alpha index used to sort transparent meshes
  25329. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  25330. */
  25331. alphaIndex: number;
  25332. /**
  25333. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  25334. */
  25335. isVisible: boolean;
  25336. /**
  25337. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  25338. */
  25339. isPickable: boolean;
  25340. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  25341. showSubMeshesBoundingBox: boolean;
  25342. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  25343. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  25344. */
  25345. isBlocker: boolean;
  25346. /**
  25347. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  25348. */
  25349. enablePointerMoveEvents: boolean;
  25350. /**
  25351. * Specifies the rendering group id for this mesh (0 by default)
  25352. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  25353. */
  25354. renderingGroupId: number;
  25355. private _material;
  25356. /** Gets or sets current material */
  25357. material: Nullable<Material>;
  25358. /**
  25359. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  25360. * @see http://doc.babylonjs.com/babylon101/shadows
  25361. */
  25362. receiveShadows: boolean;
  25363. /** Defines color to use when rendering outline */
  25364. outlineColor: Color3;
  25365. /** Define width to use when rendering outline */
  25366. outlineWidth: number;
  25367. /** Defines color to use when rendering overlay */
  25368. overlayColor: Color3;
  25369. /** Defines alpha to use when rendering overlay */
  25370. overlayAlpha: number;
  25371. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  25372. hasVertexAlpha: boolean;
  25373. /** 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) */
  25374. useVertexColors: boolean;
  25375. /**
  25376. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  25377. */
  25378. computeBonesUsingShaders: boolean;
  25379. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  25380. numBoneInfluencers: number;
  25381. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  25382. applyFog: boolean;
  25383. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  25384. useOctreeForRenderingSelection: boolean;
  25385. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  25386. useOctreeForPicking: boolean;
  25387. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  25388. useOctreeForCollisions: boolean;
  25389. /**
  25390. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  25391. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  25392. */
  25393. layerMask: number;
  25394. /**
  25395. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  25396. */
  25397. alwaysSelectAsActiveMesh: boolean;
  25398. /**
  25399. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  25400. */
  25401. doNotSyncBoundingInfo: boolean;
  25402. /**
  25403. * Gets or sets the current action manager
  25404. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25405. */
  25406. actionManager: Nullable<AbstractActionManager>;
  25407. private _meshCollisionData;
  25408. /**
  25409. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  25410. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25411. */
  25412. ellipsoid: Vector3;
  25413. /**
  25414. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  25415. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25416. */
  25417. ellipsoidOffset: Vector3;
  25418. /**
  25419. * Gets or sets a collision mask used to mask collisions (default is -1).
  25420. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25421. */
  25422. collisionMask: number;
  25423. /**
  25424. * Gets or sets the current collision group mask (-1 by default).
  25425. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25426. */
  25427. collisionGroup: number;
  25428. /**
  25429. * Defines edge width used when edgesRenderer is enabled
  25430. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25431. */
  25432. edgesWidth: number;
  25433. /**
  25434. * Defines edge color used when edgesRenderer is enabled
  25435. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25436. */
  25437. edgesColor: Color4;
  25438. /** @hidden */
  25439. _edgesRenderer: Nullable<IEdgesRenderer>;
  25440. /** @hidden */
  25441. _masterMesh: Nullable<AbstractMesh>;
  25442. /** @hidden */
  25443. _boundingInfo: Nullable<BoundingInfo>;
  25444. /** @hidden */
  25445. _renderId: number;
  25446. /**
  25447. * Gets or sets the list of subMeshes
  25448. * @see http://doc.babylonjs.com/how_to/multi_materials
  25449. */
  25450. subMeshes: SubMesh[];
  25451. /** @hidden */
  25452. _intersectionsInProgress: AbstractMesh[];
  25453. /** @hidden */
  25454. _unIndexed: boolean;
  25455. /** @hidden */
  25456. _lightSources: Light[];
  25457. /** Gets the list of lights affecting that mesh */
  25458. readonly lightSources: Light[];
  25459. /** @hidden */
  25460. readonly _positions: Nullable<Vector3[]>;
  25461. /** @hidden */
  25462. _waitingData: {
  25463. lods: Nullable<any>;
  25464. actions: Nullable<any>;
  25465. freezeWorldMatrix: Nullable<boolean>;
  25466. };
  25467. /** @hidden */
  25468. _bonesTransformMatrices: Nullable<Float32Array>;
  25469. /**
  25470. * Gets or sets a skeleton to apply skining transformations
  25471. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25472. */
  25473. skeleton: Nullable<Skeleton>;
  25474. /**
  25475. * An event triggered when the mesh is rebuilt.
  25476. */
  25477. onRebuildObservable: Observable<AbstractMesh>;
  25478. /**
  25479. * Creates a new AbstractMesh
  25480. * @param name defines the name of the mesh
  25481. * @param scene defines the hosting scene
  25482. */
  25483. constructor(name: string, scene?: Nullable<Scene>);
  25484. /**
  25485. * Returns the string "AbstractMesh"
  25486. * @returns "AbstractMesh"
  25487. */
  25488. getClassName(): string;
  25489. /**
  25490. * Gets a string representation of the current mesh
  25491. * @param fullDetails defines a boolean indicating if full details must be included
  25492. * @returns a string representation of the current mesh
  25493. */
  25494. toString(fullDetails?: boolean): string;
  25495. /**
  25496. * @hidden
  25497. */
  25498. protected _getEffectiveParent(): Nullable<Node>;
  25499. /** @hidden */
  25500. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25501. /** @hidden */
  25502. _rebuild(): void;
  25503. /** @hidden */
  25504. _resyncLightSources(): void;
  25505. /** @hidden */
  25506. _resyncLighSource(light: Light): void;
  25507. /** @hidden */
  25508. _unBindEffect(): void;
  25509. /** @hidden */
  25510. _removeLightSource(light: Light): void;
  25511. private _markSubMeshesAsDirty;
  25512. /** @hidden */
  25513. _markSubMeshesAsLightDirty(): void;
  25514. /** @hidden */
  25515. _markSubMeshesAsAttributesDirty(): void;
  25516. /** @hidden */
  25517. _markSubMeshesAsMiscDirty(): void;
  25518. /**
  25519. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  25520. */
  25521. scaling: Vector3;
  25522. /**
  25523. * Returns true if the mesh is blocked. Implemented by child classes
  25524. */
  25525. readonly isBlocked: boolean;
  25526. /**
  25527. * Returns the mesh itself by default. Implemented by child classes
  25528. * @param camera defines the camera to use to pick the right LOD level
  25529. * @returns the currentAbstractMesh
  25530. */
  25531. getLOD(camera: Camera): Nullable<AbstractMesh>;
  25532. /**
  25533. * Returns 0 by default. Implemented by child classes
  25534. * @returns an integer
  25535. */
  25536. getTotalVertices(): number;
  25537. /**
  25538. * Returns a positive integer : the total number of indices in this mesh geometry.
  25539. * @returns the numner of indices or zero if the mesh has no geometry.
  25540. */
  25541. getTotalIndices(): number;
  25542. /**
  25543. * Returns null by default. Implemented by child classes
  25544. * @returns null
  25545. */
  25546. getIndices(): Nullable<IndicesArray>;
  25547. /**
  25548. * Returns the array of the requested vertex data kind. Implemented by child classes
  25549. * @param kind defines the vertex data kind to use
  25550. * @returns null
  25551. */
  25552. getVerticesData(kind: string): Nullable<FloatArray>;
  25553. /**
  25554. * Sets the vertex data of the mesh geometry for the requested `kind`.
  25555. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  25556. * Note that a new underlying VertexBuffer object is created each call.
  25557. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  25558. * @param kind defines vertex data kind:
  25559. * * VertexBuffer.PositionKind
  25560. * * VertexBuffer.UVKind
  25561. * * VertexBuffer.UV2Kind
  25562. * * VertexBuffer.UV3Kind
  25563. * * VertexBuffer.UV4Kind
  25564. * * VertexBuffer.UV5Kind
  25565. * * VertexBuffer.UV6Kind
  25566. * * VertexBuffer.ColorKind
  25567. * * VertexBuffer.MatricesIndicesKind
  25568. * * VertexBuffer.MatricesIndicesExtraKind
  25569. * * VertexBuffer.MatricesWeightsKind
  25570. * * VertexBuffer.MatricesWeightsExtraKind
  25571. * @param data defines the data source
  25572. * @param updatable defines if the data must be flagged as updatable (or static)
  25573. * @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
  25574. * @returns the current mesh
  25575. */
  25576. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25577. /**
  25578. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  25579. * If the mesh has no geometry, it is simply returned as it is.
  25580. * @param kind defines vertex data kind:
  25581. * * VertexBuffer.PositionKind
  25582. * * VertexBuffer.UVKind
  25583. * * VertexBuffer.UV2Kind
  25584. * * VertexBuffer.UV3Kind
  25585. * * VertexBuffer.UV4Kind
  25586. * * VertexBuffer.UV5Kind
  25587. * * VertexBuffer.UV6Kind
  25588. * * VertexBuffer.ColorKind
  25589. * * VertexBuffer.MatricesIndicesKind
  25590. * * VertexBuffer.MatricesIndicesExtraKind
  25591. * * VertexBuffer.MatricesWeightsKind
  25592. * * VertexBuffer.MatricesWeightsExtraKind
  25593. * @param data defines the data source
  25594. * @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
  25595. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  25596. * @returns the current mesh
  25597. */
  25598. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25599. /**
  25600. * Sets the mesh indices,
  25601. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  25602. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  25603. * @param totalVertices Defines the total number of vertices
  25604. * @returns the current mesh
  25605. */
  25606. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  25607. /**
  25608. * Gets a boolean indicating if specific vertex data is present
  25609. * @param kind defines the vertex data kind to use
  25610. * @returns true is data kind is present
  25611. */
  25612. isVerticesDataPresent(kind: string): boolean;
  25613. /**
  25614. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  25615. * @returns a BoundingInfo
  25616. */
  25617. getBoundingInfo(): BoundingInfo;
  25618. /**
  25619. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  25620. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  25621. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  25622. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  25623. * @returns the current mesh
  25624. */
  25625. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  25626. /**
  25627. * Overwrite the current bounding info
  25628. * @param boundingInfo defines the new bounding info
  25629. * @returns the current mesh
  25630. */
  25631. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  25632. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  25633. readonly useBones: boolean;
  25634. /** @hidden */
  25635. _preActivate(): void;
  25636. /** @hidden */
  25637. _preActivateForIntermediateRendering(renderId: number): void;
  25638. /** @hidden */
  25639. _activate(renderId: number, intermediateRendering: boolean): boolean;
  25640. /** @hidden */
  25641. _postActivate(): void;
  25642. /** @hidden */
  25643. _freeze(): void;
  25644. /** @hidden */
  25645. _unFreeze(): void;
  25646. /**
  25647. * Gets the current world matrix
  25648. * @returns a Matrix
  25649. */
  25650. getWorldMatrix(): Matrix;
  25651. /** @hidden */
  25652. _getWorldMatrixDeterminant(): number;
  25653. /**
  25654. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  25655. */
  25656. readonly isAnInstance: boolean;
  25657. /**
  25658. * Perform relative position change from the point of view of behind the front of the mesh.
  25659. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25660. * Supports definition of mesh facing forward or backward
  25661. * @param amountRight defines the distance on the right axis
  25662. * @param amountUp defines the distance on the up axis
  25663. * @param amountForward defines the distance on the forward axis
  25664. * @returns the current mesh
  25665. */
  25666. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  25667. /**
  25668. * Calculate relative position change from the point of view of behind the front of the mesh.
  25669. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25670. * Supports definition of mesh facing forward or backward
  25671. * @param amountRight defines the distance on the right axis
  25672. * @param amountUp defines the distance on the up axis
  25673. * @param amountForward defines the distance on the forward axis
  25674. * @returns the new displacement vector
  25675. */
  25676. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  25677. /**
  25678. * Perform relative rotation change from the point of view of behind the front of the mesh.
  25679. * Supports definition of mesh facing forward or backward
  25680. * @param flipBack defines the flip
  25681. * @param twirlClockwise defines the twirl
  25682. * @param tiltRight defines the tilt
  25683. * @returns the current mesh
  25684. */
  25685. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  25686. /**
  25687. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  25688. * Supports definition of mesh facing forward or backward.
  25689. * @param flipBack defines the flip
  25690. * @param twirlClockwise defines the twirl
  25691. * @param tiltRight defines the tilt
  25692. * @returns the new rotation vector
  25693. */
  25694. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  25695. /**
  25696. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25697. * This means the mesh underlying bounding box and sphere are recomputed.
  25698. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25699. * @returns the current mesh
  25700. */
  25701. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  25702. /** @hidden */
  25703. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  25704. /** @hidden */
  25705. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  25706. /** @hidden */
  25707. _updateBoundingInfo(): AbstractMesh;
  25708. /** @hidden */
  25709. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  25710. /** @hidden */
  25711. protected _afterComputeWorldMatrix(): void;
  25712. /** @hidden */
  25713. readonly _effectiveMesh: AbstractMesh;
  25714. /**
  25715. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25716. * A mesh is in the frustum if its bounding box intersects the frustum
  25717. * @param frustumPlanes defines the frustum to test
  25718. * @returns true if the mesh is in the frustum planes
  25719. */
  25720. isInFrustum(frustumPlanes: Plane[]): boolean;
  25721. /**
  25722. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  25723. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  25724. * @param frustumPlanes defines the frustum to test
  25725. * @returns true if the mesh is completely in the frustum planes
  25726. */
  25727. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25728. /**
  25729. * True if the mesh intersects another mesh or a SolidParticle object
  25730. * @param mesh defines a target mesh or SolidParticle to test
  25731. * @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)
  25732. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  25733. * @returns true if there is an intersection
  25734. */
  25735. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  25736. /**
  25737. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  25738. * @param point defines the point to test
  25739. * @returns true if there is an intersection
  25740. */
  25741. intersectsPoint(point: Vector3): boolean;
  25742. /**
  25743. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  25744. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25745. */
  25746. checkCollisions: boolean;
  25747. /**
  25748. * Gets Collider object used to compute collisions (not physics)
  25749. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25750. */
  25751. readonly collider: Nullable<Collider>;
  25752. /**
  25753. * Move the mesh using collision engine
  25754. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25755. * @param displacement defines the requested displacement vector
  25756. * @returns the current mesh
  25757. */
  25758. moveWithCollisions(displacement: Vector3): AbstractMesh;
  25759. private _onCollisionPositionChange;
  25760. /** @hidden */
  25761. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  25762. /** @hidden */
  25763. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  25764. /** @hidden */
  25765. _checkCollision(collider: Collider): AbstractMesh;
  25766. /** @hidden */
  25767. _generatePointsArray(): boolean;
  25768. /**
  25769. * Checks if the passed Ray intersects with the mesh
  25770. * @param ray defines the ray to use
  25771. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  25772. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25773. * @returns the picking info
  25774. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  25775. */
  25776. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  25777. /**
  25778. * Clones the current mesh
  25779. * @param name defines the mesh name
  25780. * @param newParent defines the new mesh parent
  25781. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  25782. * @returns the new mesh
  25783. */
  25784. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  25785. /**
  25786. * Disposes all the submeshes of the current meshnp
  25787. * @returns the current mesh
  25788. */
  25789. releaseSubMeshes(): AbstractMesh;
  25790. /**
  25791. * Releases resources associated with this abstract mesh.
  25792. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25793. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25794. */
  25795. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25796. /**
  25797. * Adds the passed mesh as a child to the current mesh
  25798. * @param mesh defines the child mesh
  25799. * @returns the current mesh
  25800. */
  25801. addChild(mesh: AbstractMesh): AbstractMesh;
  25802. /**
  25803. * Removes the passed mesh from the current mesh children list
  25804. * @param mesh defines the child mesh
  25805. * @returns the current mesh
  25806. */
  25807. removeChild(mesh: AbstractMesh): AbstractMesh;
  25808. /** @hidden */
  25809. private _initFacetData;
  25810. /**
  25811. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  25812. * This method can be called within the render loop.
  25813. * 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
  25814. * @returns the current mesh
  25815. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25816. */
  25817. updateFacetData(): AbstractMesh;
  25818. /**
  25819. * Returns the facetLocalNormals array.
  25820. * The normals are expressed in the mesh local spac
  25821. * @returns an array of Vector3
  25822. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25823. */
  25824. getFacetLocalNormals(): Vector3[];
  25825. /**
  25826. * Returns the facetLocalPositions array.
  25827. * The facet positions are expressed in the mesh local space
  25828. * @returns an array of Vector3
  25829. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25830. */
  25831. getFacetLocalPositions(): Vector3[];
  25832. /**
  25833. * Returns the facetLocalPartioning array
  25834. * @returns an array of array of numbers
  25835. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25836. */
  25837. getFacetLocalPartitioning(): number[][];
  25838. /**
  25839. * Returns the i-th facet position in the world system.
  25840. * This method allocates a new Vector3 per call
  25841. * @param i defines the facet index
  25842. * @returns a new Vector3
  25843. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25844. */
  25845. getFacetPosition(i: number): Vector3;
  25846. /**
  25847. * Sets the reference Vector3 with the i-th facet position in the world system
  25848. * @param i defines the facet index
  25849. * @param ref defines the target vector
  25850. * @returns the current mesh
  25851. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25852. */
  25853. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  25854. /**
  25855. * Returns the i-th facet normal in the world system.
  25856. * This method allocates a new Vector3 per call
  25857. * @param i defines the facet index
  25858. * @returns a new Vector3
  25859. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25860. */
  25861. getFacetNormal(i: number): Vector3;
  25862. /**
  25863. * Sets the reference Vector3 with the i-th facet normal in the world system
  25864. * @param i defines the facet index
  25865. * @param ref defines the target vector
  25866. * @returns the current mesh
  25867. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25868. */
  25869. getFacetNormalToRef(i: number, ref: Vector3): this;
  25870. /**
  25871. * 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)
  25872. * @param x defines x coordinate
  25873. * @param y defines y coordinate
  25874. * @param z defines z coordinate
  25875. * @returns the array of facet indexes
  25876. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25877. */
  25878. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  25879. /**
  25880. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  25881. * @param projected sets as the (x,y,z) world projection on the facet
  25882. * @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
  25883. * @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
  25884. * @param x defines x coordinate
  25885. * @param y defines y coordinate
  25886. * @param z defines z coordinate
  25887. * @returns the face index if found (or null instead)
  25888. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25889. */
  25890. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25891. /**
  25892. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  25893. * @param projected sets as the (x,y,z) local projection on the facet
  25894. * @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
  25895. * @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
  25896. * @param x defines x coordinate
  25897. * @param y defines y coordinate
  25898. * @param z defines z coordinate
  25899. * @returns the face index if found (or null instead)
  25900. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25901. */
  25902. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25903. /**
  25904. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  25905. * @returns the parameters
  25906. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25907. */
  25908. getFacetDataParameters(): any;
  25909. /**
  25910. * Disables the feature FacetData and frees the related memory
  25911. * @returns the current mesh
  25912. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25913. */
  25914. disableFacetData(): AbstractMesh;
  25915. /**
  25916. * Updates the AbstractMesh indices array
  25917. * @param indices defines the data source
  25918. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25919. * @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)
  25920. * @returns the current mesh
  25921. */
  25922. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25923. /**
  25924. * Creates new normals data for the mesh
  25925. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  25926. * @returns the current mesh
  25927. */
  25928. createNormals(updatable: boolean): AbstractMesh;
  25929. /**
  25930. * Align the mesh with a normal
  25931. * @param normal defines the normal to use
  25932. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  25933. * @returns the current mesh
  25934. */
  25935. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  25936. /** @hidden */
  25937. _checkOcclusionQuery(): boolean;
  25938. /**
  25939. * Disables the mesh edge rendering mode
  25940. * @returns the currentAbstractMesh
  25941. */
  25942. disableEdgesRendering(): AbstractMesh;
  25943. /**
  25944. * Enables the edge rendering mode on the mesh.
  25945. * This mode makes the mesh edges visible
  25946. * @param epsilon defines the maximal distance between two angles to detect a face
  25947. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  25948. * @returns the currentAbstractMesh
  25949. * @see https://www.babylonjs-playground.com/#19O9TU#0
  25950. */
  25951. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  25952. }
  25953. }
  25954. declare module "babylonjs/Actions/actionEvent" {
  25955. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25956. import { Nullable } from "babylonjs/types";
  25957. import { Sprite } from "babylonjs/Sprites/sprite";
  25958. import { Scene } from "babylonjs/scene";
  25959. import { Vector2 } from "babylonjs/Maths/math";
  25960. /**
  25961. * Interface used to define ActionEvent
  25962. */
  25963. export interface IActionEvent {
  25964. /** The mesh or sprite that triggered the action */
  25965. source: any;
  25966. /** The X mouse cursor position at the time of the event */
  25967. pointerX: number;
  25968. /** The Y mouse cursor position at the time of the event */
  25969. pointerY: number;
  25970. /** The mesh that is currently pointed at (can be null) */
  25971. meshUnderPointer: Nullable<AbstractMesh>;
  25972. /** the original (browser) event that triggered the ActionEvent */
  25973. sourceEvent?: any;
  25974. /** additional data for the event */
  25975. additionalData?: any;
  25976. }
  25977. /**
  25978. * ActionEvent is the event being sent when an action is triggered.
  25979. */
  25980. export class ActionEvent implements IActionEvent {
  25981. /** The mesh or sprite that triggered the action */
  25982. source: any;
  25983. /** The X mouse cursor position at the time of the event */
  25984. pointerX: number;
  25985. /** The Y mouse cursor position at the time of the event */
  25986. pointerY: number;
  25987. /** The mesh that is currently pointed at (can be null) */
  25988. meshUnderPointer: Nullable<AbstractMesh>;
  25989. /** the original (browser) event that triggered the ActionEvent */
  25990. sourceEvent?: any;
  25991. /** additional data for the event */
  25992. additionalData?: any;
  25993. /**
  25994. * Creates a new ActionEvent
  25995. * @param source The mesh or sprite that triggered the action
  25996. * @param pointerX The X mouse cursor position at the time of the event
  25997. * @param pointerY The Y mouse cursor position at the time of the event
  25998. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  25999. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  26000. * @param additionalData additional data for the event
  26001. */
  26002. constructor(
  26003. /** The mesh or sprite that triggered the action */
  26004. source: any,
  26005. /** The X mouse cursor position at the time of the event */
  26006. pointerX: number,
  26007. /** The Y mouse cursor position at the time of the event */
  26008. pointerY: number,
  26009. /** The mesh that is currently pointed at (can be null) */
  26010. meshUnderPointer: Nullable<AbstractMesh>,
  26011. /** the original (browser) event that triggered the ActionEvent */
  26012. sourceEvent?: any,
  26013. /** additional data for the event */
  26014. additionalData?: any);
  26015. /**
  26016. * Helper function to auto-create an ActionEvent from a source mesh.
  26017. * @param source The source mesh that triggered the event
  26018. * @param evt The original (browser) event
  26019. * @param additionalData additional data for the event
  26020. * @returns the new ActionEvent
  26021. */
  26022. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  26023. /**
  26024. * Helper function to auto-create an ActionEvent from a source sprite
  26025. * @param source The source sprite that triggered the event
  26026. * @param scene Scene associated with the sprite
  26027. * @param evt The original (browser) event
  26028. * @param additionalData additional data for the event
  26029. * @returns the new ActionEvent
  26030. */
  26031. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  26032. /**
  26033. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  26034. * @param scene the scene where the event occurred
  26035. * @param evt The original (browser) event
  26036. * @returns the new ActionEvent
  26037. */
  26038. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  26039. /**
  26040. * Helper function to auto-create an ActionEvent from a primitive
  26041. * @param prim defines the target primitive
  26042. * @param pointerPos defines the pointer position
  26043. * @param evt The original (browser) event
  26044. * @param additionalData additional data for the event
  26045. * @returns the new ActionEvent
  26046. */
  26047. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  26048. }
  26049. }
  26050. declare module "babylonjs/Actions/abstractActionManager" {
  26051. import { IDisposable } from "babylonjs/scene";
  26052. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  26053. import { IAction } from "babylonjs/Actions/action";
  26054. import { Nullable } from "babylonjs/types";
  26055. /**
  26056. * Abstract class used to decouple action Manager from scene and meshes.
  26057. * Do not instantiate.
  26058. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26059. */
  26060. export abstract class AbstractActionManager implements IDisposable {
  26061. /** Gets the list of active triggers */
  26062. static Triggers: {
  26063. [key: string]: number;
  26064. };
  26065. /** Gets the cursor to use when hovering items */
  26066. hoverCursor: string;
  26067. /** Gets the list of actions */
  26068. actions: IAction[];
  26069. /**
  26070. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  26071. */
  26072. isRecursive: boolean;
  26073. /**
  26074. * Releases all associated resources
  26075. */
  26076. abstract dispose(): void;
  26077. /**
  26078. * Does this action manager has pointer triggers
  26079. */
  26080. abstract readonly hasPointerTriggers: boolean;
  26081. /**
  26082. * Does this action manager has pick triggers
  26083. */
  26084. abstract readonly hasPickTriggers: boolean;
  26085. /**
  26086. * Process a specific trigger
  26087. * @param trigger defines the trigger to process
  26088. * @param evt defines the event details to be processed
  26089. */
  26090. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  26091. /**
  26092. * Does this action manager handles actions of any of the given triggers
  26093. * @param triggers defines the triggers to be tested
  26094. * @return a boolean indicating whether one (or more) of the triggers is handled
  26095. */
  26096. abstract hasSpecificTriggers(triggers: number[]): boolean;
  26097. /**
  26098. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  26099. * speed.
  26100. * @param triggerA defines the trigger to be tested
  26101. * @param triggerB defines the trigger to be tested
  26102. * @return a boolean indicating whether one (or more) of the triggers is handled
  26103. */
  26104. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  26105. /**
  26106. * Does this action manager handles actions of a given trigger
  26107. * @param trigger defines the trigger to be tested
  26108. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  26109. * @return whether the trigger is handled
  26110. */
  26111. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  26112. /**
  26113. * Serialize this manager to a JSON object
  26114. * @param name defines the property name to store this manager
  26115. * @returns a JSON representation of this manager
  26116. */
  26117. abstract serialize(name: string): any;
  26118. /**
  26119. * Registers an action to this action manager
  26120. * @param action defines the action to be registered
  26121. * @return the action amended (prepared) after registration
  26122. */
  26123. abstract registerAction(action: IAction): Nullable<IAction>;
  26124. /**
  26125. * Unregisters an action to this action manager
  26126. * @param action defines the action to be unregistered
  26127. * @return a boolean indicating whether the action has been unregistered
  26128. */
  26129. abstract unregisterAction(action: IAction): Boolean;
  26130. /**
  26131. * Does exist one action manager with at least one trigger
  26132. **/
  26133. static readonly HasTriggers: boolean;
  26134. /**
  26135. * Does exist one action manager with at least one pick trigger
  26136. **/
  26137. static readonly HasPickTriggers: boolean;
  26138. /**
  26139. * Does exist one action manager that handles actions of a given trigger
  26140. * @param trigger defines the trigger to be tested
  26141. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  26142. **/
  26143. static HasSpecificTrigger(trigger: number): boolean;
  26144. }
  26145. }
  26146. declare module "babylonjs/node" {
  26147. import { Scene } from "babylonjs/scene";
  26148. import { Nullable } from "babylonjs/types";
  26149. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  26150. import { Engine } from "babylonjs/Engines/engine";
  26151. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  26152. import { Observable } from "babylonjs/Misc/observable";
  26153. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  26154. import { IInspectable } from "babylonjs/Misc/iInspectable";
  26155. import { Animatable } from "babylonjs/Animations/animatable";
  26156. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  26157. import { Animation } from "babylonjs/Animations/animation";
  26158. import { AnimationRange } from "babylonjs/Animations/animationRange";
  26159. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26160. /**
  26161. * Defines how a node can be built from a string name.
  26162. */
  26163. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  26164. /**
  26165. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  26166. */
  26167. export class Node implements IBehaviorAware<Node> {
  26168. /** @hidden */
  26169. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  26170. private static _NodeConstructors;
  26171. /**
  26172. * Add a new node constructor
  26173. * @param type defines the type name of the node to construct
  26174. * @param constructorFunc defines the constructor function
  26175. */
  26176. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  26177. /**
  26178. * Returns a node constructor based on type name
  26179. * @param type defines the type name
  26180. * @param name defines the new node name
  26181. * @param scene defines the hosting scene
  26182. * @param options defines optional options to transmit to constructors
  26183. * @returns the new constructor or null
  26184. */
  26185. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  26186. /**
  26187. * Gets or sets the name of the node
  26188. */
  26189. name: string;
  26190. /**
  26191. * Gets or sets the id of the node
  26192. */
  26193. id: string;
  26194. /**
  26195. * Gets or sets the unique id of the node
  26196. */
  26197. uniqueId: number;
  26198. /**
  26199. * Gets or sets a string used to store user defined state for the node
  26200. */
  26201. state: string;
  26202. /**
  26203. * Gets or sets an object used to store user defined information for the node
  26204. */
  26205. metadata: any;
  26206. /**
  26207. * For internal use only. Please do not use.
  26208. */
  26209. reservedDataStore: any;
  26210. /**
  26211. * List of inspectable custom properties (used by the Inspector)
  26212. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  26213. */
  26214. inspectableCustomProperties: IInspectable[];
  26215. /**
  26216. * Gets or sets a boolean used to define if the node must be serialized
  26217. */
  26218. doNotSerialize: boolean;
  26219. /** @hidden */
  26220. _isDisposed: boolean;
  26221. /**
  26222. * Gets a list of Animations associated with the node
  26223. */
  26224. animations: import("babylonjs/Animations/animation").Animation[];
  26225. protected _ranges: {
  26226. [name: string]: Nullable<AnimationRange>;
  26227. };
  26228. /**
  26229. * Callback raised when the node is ready to be used
  26230. */
  26231. onReady: Nullable<(node: Node) => void>;
  26232. private _isEnabled;
  26233. private _isParentEnabled;
  26234. private _isReady;
  26235. /** @hidden */
  26236. _currentRenderId: number;
  26237. private _parentUpdateId;
  26238. /** @hidden */
  26239. _childUpdateId: number;
  26240. /** @hidden */
  26241. _waitingParentId: Nullable<string>;
  26242. /** @hidden */
  26243. _scene: Scene;
  26244. /** @hidden */
  26245. _cache: any;
  26246. private _parentNode;
  26247. private _children;
  26248. /** @hidden */
  26249. _worldMatrix: Matrix;
  26250. /** @hidden */
  26251. _worldMatrixDeterminant: number;
  26252. /** @hidden */
  26253. _worldMatrixDeterminantIsDirty: boolean;
  26254. /** @hidden */
  26255. private _sceneRootNodesIndex;
  26256. /**
  26257. * Gets a boolean indicating if the node has been disposed
  26258. * @returns true if the node was disposed
  26259. */
  26260. isDisposed(): boolean;
  26261. /**
  26262. * Gets or sets the parent of the node (without keeping the current position in the scene)
  26263. * @see https://doc.babylonjs.com/how_to/parenting
  26264. */
  26265. parent: Nullable<Node>;
  26266. private addToSceneRootNodes;
  26267. private removeFromSceneRootNodes;
  26268. private _animationPropertiesOverride;
  26269. /**
  26270. * Gets or sets the animation properties override
  26271. */
  26272. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  26273. /**
  26274. * Gets a string idenfifying the name of the class
  26275. * @returns "Node" string
  26276. */
  26277. getClassName(): string;
  26278. /** @hidden */
  26279. readonly _isNode: boolean;
  26280. /**
  26281. * An event triggered when the mesh is disposed
  26282. */
  26283. onDisposeObservable: Observable<Node>;
  26284. private _onDisposeObserver;
  26285. /**
  26286. * Sets a callback that will be raised when the node will be disposed
  26287. */
  26288. onDispose: () => void;
  26289. /**
  26290. * Creates a new Node
  26291. * @param name the name and id to be given to this node
  26292. * @param scene the scene this node will be added to
  26293. * @param addToRootNodes the node will be added to scene.rootNodes
  26294. */
  26295. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  26296. /**
  26297. * Gets the scene of the node
  26298. * @returns a scene
  26299. */
  26300. getScene(): Scene;
  26301. /**
  26302. * Gets the engine of the node
  26303. * @returns a Engine
  26304. */
  26305. getEngine(): Engine;
  26306. private _behaviors;
  26307. /**
  26308. * Attach a behavior to the node
  26309. * @see http://doc.babylonjs.com/features/behaviour
  26310. * @param behavior defines the behavior to attach
  26311. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  26312. * @returns the current Node
  26313. */
  26314. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  26315. /**
  26316. * Remove an attached behavior
  26317. * @see http://doc.babylonjs.com/features/behaviour
  26318. * @param behavior defines the behavior to attach
  26319. * @returns the current Node
  26320. */
  26321. removeBehavior(behavior: Behavior<Node>): Node;
  26322. /**
  26323. * Gets the list of attached behaviors
  26324. * @see http://doc.babylonjs.com/features/behaviour
  26325. */
  26326. readonly behaviors: Behavior<Node>[];
  26327. /**
  26328. * Gets an attached behavior by name
  26329. * @param name defines the name of the behavior to look for
  26330. * @see http://doc.babylonjs.com/features/behaviour
  26331. * @returns null if behavior was not found else the requested behavior
  26332. */
  26333. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  26334. /**
  26335. * Returns the latest update of the World matrix
  26336. * @returns a Matrix
  26337. */
  26338. getWorldMatrix(): Matrix;
  26339. /** @hidden */
  26340. _getWorldMatrixDeterminant(): number;
  26341. /**
  26342. * Returns directly the latest state of the mesh World matrix.
  26343. * A Matrix is returned.
  26344. */
  26345. readonly worldMatrixFromCache: Matrix;
  26346. /** @hidden */
  26347. _initCache(): void;
  26348. /** @hidden */
  26349. updateCache(force?: boolean): void;
  26350. /** @hidden */
  26351. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26352. /** @hidden */
  26353. _updateCache(ignoreParentClass?: boolean): void;
  26354. /** @hidden */
  26355. _isSynchronized(): boolean;
  26356. /** @hidden */
  26357. _markSyncedWithParent(): void;
  26358. /** @hidden */
  26359. isSynchronizedWithParent(): boolean;
  26360. /** @hidden */
  26361. isSynchronized(): boolean;
  26362. /**
  26363. * Is this node ready to be used/rendered
  26364. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26365. * @return true if the node is ready
  26366. */
  26367. isReady(completeCheck?: boolean): boolean;
  26368. /**
  26369. * Is this node enabled?
  26370. * 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
  26371. * @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
  26372. * @return whether this node (and its parent) is enabled
  26373. */
  26374. isEnabled(checkAncestors?: boolean): boolean;
  26375. /** @hidden */
  26376. protected _syncParentEnabledState(): void;
  26377. /**
  26378. * Set the enabled state of this node
  26379. * @param value defines the new enabled state
  26380. */
  26381. setEnabled(value: boolean): void;
  26382. /**
  26383. * Is this node a descendant of the given node?
  26384. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  26385. * @param ancestor defines the parent node to inspect
  26386. * @returns a boolean indicating if this node is a descendant of the given node
  26387. */
  26388. isDescendantOf(ancestor: Node): boolean;
  26389. /** @hidden */
  26390. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  26391. /**
  26392. * Will return all nodes that have this node as ascendant
  26393. * @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
  26394. * @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
  26395. * @return all children nodes of all types
  26396. */
  26397. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  26398. /**
  26399. * Get all child-meshes of this node
  26400. * @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)
  26401. * @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
  26402. * @returns an array of AbstractMesh
  26403. */
  26404. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  26405. /**
  26406. * Get all direct children of this node
  26407. * @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
  26408. * @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)
  26409. * @returns an array of Node
  26410. */
  26411. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  26412. /** @hidden */
  26413. _setReady(state: boolean): void;
  26414. /**
  26415. * Get an animation by name
  26416. * @param name defines the name of the animation to look for
  26417. * @returns null if not found else the requested animation
  26418. */
  26419. getAnimationByName(name: string): Nullable<Animation>;
  26420. /**
  26421. * Creates an animation range for this node
  26422. * @param name defines the name of the range
  26423. * @param from defines the starting key
  26424. * @param to defines the end key
  26425. */
  26426. createAnimationRange(name: string, from: number, to: number): void;
  26427. /**
  26428. * Delete a specific animation range
  26429. * @param name defines the name of the range to delete
  26430. * @param deleteFrames defines if animation frames from the range must be deleted as well
  26431. */
  26432. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26433. /**
  26434. * Get an animation range by name
  26435. * @param name defines the name of the animation range to look for
  26436. * @returns null if not found else the requested animation range
  26437. */
  26438. getAnimationRange(name: string): Nullable<AnimationRange>;
  26439. /**
  26440. * Gets the list of all animation ranges defined on this node
  26441. * @returns an array
  26442. */
  26443. getAnimationRanges(): Nullable<AnimationRange>[];
  26444. /**
  26445. * Will start the animation sequence
  26446. * @param name defines the range frames for animation sequence
  26447. * @param loop defines if the animation should loop (false by default)
  26448. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  26449. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  26450. * @returns the object created for this animation. If range does not exist, it will return null
  26451. */
  26452. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  26453. /**
  26454. * Serialize animation ranges into a JSON compatible object
  26455. * @returns serialization object
  26456. */
  26457. serializeAnimationRanges(): any;
  26458. /**
  26459. * Computes the world matrix of the node
  26460. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26461. * @returns the world matrix
  26462. */
  26463. computeWorldMatrix(force?: boolean): Matrix;
  26464. /**
  26465. * Releases resources associated with this node.
  26466. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26467. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26468. */
  26469. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26470. /**
  26471. * Parse animation range data from a serialization object and store them into a given node
  26472. * @param node defines where to store the animation ranges
  26473. * @param parsedNode defines the serialization object to read data from
  26474. * @param scene defines the hosting scene
  26475. */
  26476. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  26477. /**
  26478. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  26479. * @param includeDescendants Include bounding info from descendants as well (true by default)
  26480. * @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
  26481. * @returns the new bounding vectors
  26482. */
  26483. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  26484. min: Vector3;
  26485. max: Vector3;
  26486. };
  26487. }
  26488. }
  26489. declare module "babylonjs/Animations/animation" {
  26490. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  26491. import { Vector3, Quaternion, Vector2, Color3, Size, Matrix } from "babylonjs/Maths/math";
  26492. import { Nullable } from "babylonjs/types";
  26493. import { Scene } from "babylonjs/scene";
  26494. import { IAnimatable } from "babylonjs/Misc/tools";
  26495. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  26496. import { AnimationRange } from "babylonjs/Animations/animationRange";
  26497. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  26498. import { Node } from "babylonjs/node";
  26499. import { Animatable } from "babylonjs/Animations/animatable";
  26500. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  26501. /**
  26502. * @hidden
  26503. */
  26504. export class _IAnimationState {
  26505. key: number;
  26506. repeatCount: number;
  26507. workValue?: any;
  26508. loopMode?: number;
  26509. offsetValue?: any;
  26510. highLimitValue?: any;
  26511. }
  26512. /**
  26513. * Class used to store any kind of animation
  26514. */
  26515. export class Animation {
  26516. /**Name of the animation */
  26517. name: string;
  26518. /**Property to animate */
  26519. targetProperty: string;
  26520. /**The frames per second of the animation */
  26521. framePerSecond: number;
  26522. /**The data type of the animation */
  26523. dataType: number;
  26524. /**The loop mode of the animation */
  26525. loopMode?: number | undefined;
  26526. /**Specifies if blending should be enabled */
  26527. enableBlending?: boolean | undefined;
  26528. /**
  26529. * Use matrix interpolation instead of using direct key value when animating matrices
  26530. */
  26531. static AllowMatricesInterpolation: boolean;
  26532. /**
  26533. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  26534. */
  26535. static AllowMatrixDecomposeForInterpolation: boolean;
  26536. /**
  26537. * Stores the key frames of the animation
  26538. */
  26539. private _keys;
  26540. /**
  26541. * Stores the easing function of the animation
  26542. */
  26543. private _easingFunction;
  26544. /**
  26545. * @hidden Internal use only
  26546. */
  26547. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  26548. /**
  26549. * The set of event that will be linked to this animation
  26550. */
  26551. private _events;
  26552. /**
  26553. * Stores an array of target property paths
  26554. */
  26555. targetPropertyPath: string[];
  26556. /**
  26557. * Stores the blending speed of the animation
  26558. */
  26559. blendingSpeed: number;
  26560. /**
  26561. * Stores the animation ranges for the animation
  26562. */
  26563. private _ranges;
  26564. /**
  26565. * @hidden Internal use
  26566. */
  26567. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  26568. /**
  26569. * Sets up an animation
  26570. * @param property The property to animate
  26571. * @param animationType The animation type to apply
  26572. * @param framePerSecond The frames per second of the animation
  26573. * @param easingFunction The easing function used in the animation
  26574. * @returns The created animation
  26575. */
  26576. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  26577. /**
  26578. * Create and start an animation on a node
  26579. * @param name defines the name of the global animation that will be run on all nodes
  26580. * @param node defines the root node where the animation will take place
  26581. * @param targetProperty defines property to animate
  26582. * @param framePerSecond defines the number of frame per second yo use
  26583. * @param totalFrame defines the number of frames in total
  26584. * @param from defines the initial value
  26585. * @param to defines the final value
  26586. * @param loopMode defines which loop mode you want to use (off by default)
  26587. * @param easingFunction defines the easing function to use (linear by default)
  26588. * @param onAnimationEnd defines the callback to call when animation end
  26589. * @returns the animatable created for this animation
  26590. */
  26591. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26592. /**
  26593. * Create and start an animation on a node and its descendants
  26594. * @param name defines the name of the global animation that will be run on all nodes
  26595. * @param node defines the root node where the animation will take place
  26596. * @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
  26597. * @param targetProperty defines property to animate
  26598. * @param framePerSecond defines the number of frame per second to use
  26599. * @param totalFrame defines the number of frames in total
  26600. * @param from defines the initial value
  26601. * @param to defines the final value
  26602. * @param loopMode defines which loop mode you want to use (off by default)
  26603. * @param easingFunction defines the easing function to use (linear by default)
  26604. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26605. * @returns the list of animatables created for all nodes
  26606. * @example https://www.babylonjs-playground.com/#MH0VLI
  26607. */
  26608. 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[]>;
  26609. /**
  26610. * Creates a new animation, merges it with the existing animations and starts it
  26611. * @param name Name of the animation
  26612. * @param node Node which contains the scene that begins the animations
  26613. * @param targetProperty Specifies which property to animate
  26614. * @param framePerSecond The frames per second of the animation
  26615. * @param totalFrame The total number of frames
  26616. * @param from The frame at the beginning of the animation
  26617. * @param to The frame at the end of the animation
  26618. * @param loopMode Specifies the loop mode of the animation
  26619. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  26620. * @param onAnimationEnd Callback to run once the animation is complete
  26621. * @returns Nullable animation
  26622. */
  26623. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26624. /**
  26625. * Transition property of an host to the target Value
  26626. * @param property The property to transition
  26627. * @param targetValue The target Value of the property
  26628. * @param host The object where the property to animate belongs
  26629. * @param scene Scene used to run the animation
  26630. * @param frameRate Framerate (in frame/s) to use
  26631. * @param transition The transition type we want to use
  26632. * @param duration The duration of the animation, in milliseconds
  26633. * @param onAnimationEnd Callback trigger at the end of the animation
  26634. * @returns Nullable animation
  26635. */
  26636. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  26637. /**
  26638. * Return the array of runtime animations currently using this animation
  26639. */
  26640. readonly runtimeAnimations: RuntimeAnimation[];
  26641. /**
  26642. * Specifies if any of the runtime animations are currently running
  26643. */
  26644. readonly hasRunningRuntimeAnimations: boolean;
  26645. /**
  26646. * Initializes the animation
  26647. * @param name Name of the animation
  26648. * @param targetProperty Property to animate
  26649. * @param framePerSecond The frames per second of the animation
  26650. * @param dataType The data type of the animation
  26651. * @param loopMode The loop mode of the animation
  26652. * @param enableBlending Specifies if blending should be enabled
  26653. */
  26654. constructor(
  26655. /**Name of the animation */
  26656. name: string,
  26657. /**Property to animate */
  26658. targetProperty: string,
  26659. /**The frames per second of the animation */
  26660. framePerSecond: number,
  26661. /**The data type of the animation */
  26662. dataType: number,
  26663. /**The loop mode of the animation */
  26664. loopMode?: number | undefined,
  26665. /**Specifies if blending should be enabled */
  26666. enableBlending?: boolean | undefined);
  26667. /**
  26668. * Converts the animation to a string
  26669. * @param fullDetails support for multiple levels of logging within scene loading
  26670. * @returns String form of the animation
  26671. */
  26672. toString(fullDetails?: boolean): string;
  26673. /**
  26674. * Add an event to this animation
  26675. * @param event Event to add
  26676. */
  26677. addEvent(event: AnimationEvent): void;
  26678. /**
  26679. * Remove all events found at the given frame
  26680. * @param frame The frame to remove events from
  26681. */
  26682. removeEvents(frame: number): void;
  26683. /**
  26684. * Retrieves all the events from the animation
  26685. * @returns Events from the animation
  26686. */
  26687. getEvents(): AnimationEvent[];
  26688. /**
  26689. * Creates an animation range
  26690. * @param name Name of the animation range
  26691. * @param from Starting frame of the animation range
  26692. * @param to Ending frame of the animation
  26693. */
  26694. createRange(name: string, from: number, to: number): void;
  26695. /**
  26696. * Deletes an animation range by name
  26697. * @param name Name of the animation range to delete
  26698. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  26699. */
  26700. deleteRange(name: string, deleteFrames?: boolean): void;
  26701. /**
  26702. * Gets the animation range by name, or null if not defined
  26703. * @param name Name of the animation range
  26704. * @returns Nullable animation range
  26705. */
  26706. getRange(name: string): Nullable<AnimationRange>;
  26707. /**
  26708. * Gets the key frames from the animation
  26709. * @returns The key frames of the animation
  26710. */
  26711. getKeys(): Array<IAnimationKey>;
  26712. /**
  26713. * Gets the highest frame rate of the animation
  26714. * @returns Highest frame rate of the animation
  26715. */
  26716. getHighestFrame(): number;
  26717. /**
  26718. * Gets the easing function of the animation
  26719. * @returns Easing function of the animation
  26720. */
  26721. getEasingFunction(): IEasingFunction;
  26722. /**
  26723. * Sets the easing function of the animation
  26724. * @param easingFunction A custom mathematical formula for animation
  26725. */
  26726. setEasingFunction(easingFunction: EasingFunction): void;
  26727. /**
  26728. * Interpolates a scalar linearly
  26729. * @param startValue Start value of the animation curve
  26730. * @param endValue End value of the animation curve
  26731. * @param gradient Scalar amount to interpolate
  26732. * @returns Interpolated scalar value
  26733. */
  26734. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  26735. /**
  26736. * Interpolates a scalar cubically
  26737. * @param startValue Start value of the animation curve
  26738. * @param outTangent End tangent of the animation
  26739. * @param endValue End value of the animation curve
  26740. * @param inTangent Start tangent of the animation curve
  26741. * @param gradient Scalar amount to interpolate
  26742. * @returns Interpolated scalar value
  26743. */
  26744. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  26745. /**
  26746. * Interpolates a quaternion using a spherical linear interpolation
  26747. * @param startValue Start value of the animation curve
  26748. * @param endValue End value of the animation curve
  26749. * @param gradient Scalar amount to interpolate
  26750. * @returns Interpolated quaternion value
  26751. */
  26752. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  26753. /**
  26754. * Interpolates a quaternion cubically
  26755. * @param startValue Start value of the animation curve
  26756. * @param outTangent End tangent of the animation curve
  26757. * @param endValue End value of the animation curve
  26758. * @param inTangent Start tangent of the animation curve
  26759. * @param gradient Scalar amount to interpolate
  26760. * @returns Interpolated quaternion value
  26761. */
  26762. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  26763. /**
  26764. * Interpolates a Vector3 linearl
  26765. * @param startValue Start value of the animation curve
  26766. * @param endValue End value of the animation curve
  26767. * @param gradient Scalar amount to interpolate
  26768. * @returns Interpolated scalar value
  26769. */
  26770. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  26771. /**
  26772. * Interpolates a Vector3 cubically
  26773. * @param startValue Start value of the animation curve
  26774. * @param outTangent End tangent of the animation
  26775. * @param endValue End value of the animation curve
  26776. * @param inTangent Start tangent of the animation curve
  26777. * @param gradient Scalar amount to interpolate
  26778. * @returns InterpolatedVector3 value
  26779. */
  26780. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  26781. /**
  26782. * Interpolates a Vector2 linearly
  26783. * @param startValue Start value of the animation curve
  26784. * @param endValue End value of the animation curve
  26785. * @param gradient Scalar amount to interpolate
  26786. * @returns Interpolated Vector2 value
  26787. */
  26788. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  26789. /**
  26790. * Interpolates a Vector2 cubically
  26791. * @param startValue Start value of the animation curve
  26792. * @param outTangent End tangent of the animation
  26793. * @param endValue End value of the animation curve
  26794. * @param inTangent Start tangent of the animation curve
  26795. * @param gradient Scalar amount to interpolate
  26796. * @returns Interpolated Vector2 value
  26797. */
  26798. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  26799. /**
  26800. * Interpolates a size linearly
  26801. * @param startValue Start value of the animation curve
  26802. * @param endValue End value of the animation curve
  26803. * @param gradient Scalar amount to interpolate
  26804. * @returns Interpolated Size value
  26805. */
  26806. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  26807. /**
  26808. * Interpolates a Color3 linearly
  26809. * @param startValue Start value of the animation curve
  26810. * @param endValue End value of the animation curve
  26811. * @param gradient Scalar amount to interpolate
  26812. * @returns Interpolated Color3 value
  26813. */
  26814. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  26815. /**
  26816. * @hidden Internal use only
  26817. */
  26818. _getKeyValue(value: any): any;
  26819. /**
  26820. * @hidden Internal use only
  26821. */
  26822. _interpolate(currentFrame: number, state: _IAnimationState): any;
  26823. /**
  26824. * Defines the function to use to interpolate matrices
  26825. * @param startValue defines the start matrix
  26826. * @param endValue defines the end matrix
  26827. * @param gradient defines the gradient between both matrices
  26828. * @param result defines an optional target matrix where to store the interpolation
  26829. * @returns the interpolated matrix
  26830. */
  26831. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  26832. /**
  26833. * Makes a copy of the animation
  26834. * @returns Cloned animation
  26835. */
  26836. clone(): Animation;
  26837. /**
  26838. * Sets the key frames of the animation
  26839. * @param values The animation key frames to set
  26840. */
  26841. setKeys(values: Array<IAnimationKey>): void;
  26842. /**
  26843. * Serializes the animation to an object
  26844. * @returns Serialized object
  26845. */
  26846. serialize(): any;
  26847. /**
  26848. * Float animation type
  26849. */
  26850. private static _ANIMATIONTYPE_FLOAT;
  26851. /**
  26852. * Vector3 animation type
  26853. */
  26854. private static _ANIMATIONTYPE_VECTOR3;
  26855. /**
  26856. * Quaternion animation type
  26857. */
  26858. private static _ANIMATIONTYPE_QUATERNION;
  26859. /**
  26860. * Matrix animation type
  26861. */
  26862. private static _ANIMATIONTYPE_MATRIX;
  26863. /**
  26864. * Color3 animation type
  26865. */
  26866. private static _ANIMATIONTYPE_COLOR3;
  26867. /**
  26868. * Vector2 animation type
  26869. */
  26870. private static _ANIMATIONTYPE_VECTOR2;
  26871. /**
  26872. * Size animation type
  26873. */
  26874. private static _ANIMATIONTYPE_SIZE;
  26875. /**
  26876. * Relative Loop Mode
  26877. */
  26878. private static _ANIMATIONLOOPMODE_RELATIVE;
  26879. /**
  26880. * Cycle Loop Mode
  26881. */
  26882. private static _ANIMATIONLOOPMODE_CYCLE;
  26883. /**
  26884. * Constant Loop Mode
  26885. */
  26886. private static _ANIMATIONLOOPMODE_CONSTANT;
  26887. /**
  26888. * Get the float animation type
  26889. */
  26890. static readonly ANIMATIONTYPE_FLOAT: number;
  26891. /**
  26892. * Get the Vector3 animation type
  26893. */
  26894. static readonly ANIMATIONTYPE_VECTOR3: number;
  26895. /**
  26896. * Get the Vector2 animation type
  26897. */
  26898. static readonly ANIMATIONTYPE_VECTOR2: number;
  26899. /**
  26900. * Get the Size animation type
  26901. */
  26902. static readonly ANIMATIONTYPE_SIZE: number;
  26903. /**
  26904. * Get the Quaternion animation type
  26905. */
  26906. static readonly ANIMATIONTYPE_QUATERNION: number;
  26907. /**
  26908. * Get the Matrix animation type
  26909. */
  26910. static readonly ANIMATIONTYPE_MATRIX: number;
  26911. /**
  26912. * Get the Color3 animation type
  26913. */
  26914. static readonly ANIMATIONTYPE_COLOR3: number;
  26915. /**
  26916. * Get the Relative Loop Mode
  26917. */
  26918. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  26919. /**
  26920. * Get the Cycle Loop Mode
  26921. */
  26922. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  26923. /**
  26924. * Get the Constant Loop Mode
  26925. */
  26926. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  26927. /** @hidden */
  26928. static _UniversalLerp(left: any, right: any, amount: number): any;
  26929. /**
  26930. * Parses an animation object and creates an animation
  26931. * @param parsedAnimation Parsed animation object
  26932. * @returns Animation object
  26933. */
  26934. static Parse(parsedAnimation: any): Animation;
  26935. /**
  26936. * Appends the serialized animations from the source animations
  26937. * @param source Source containing the animations
  26938. * @param destination Target to store the animations
  26939. */
  26940. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  26941. }
  26942. }
  26943. declare module "babylonjs/Materials/Textures/baseTexture" {
  26944. import { Observable } from "babylonjs/Misc/observable";
  26945. import { IAnimatable } from "babylonjs/Misc/tools";
  26946. import { Nullable } from "babylonjs/types";
  26947. import { Scene } from "babylonjs/scene";
  26948. import { Matrix, ISize } from "babylonjs/Maths/math";
  26949. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  26950. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26951. /**
  26952. * Base class of all the textures in babylon.
  26953. * It groups all the common properties the materials, post process, lights... might need
  26954. * in order to make a correct use of the texture.
  26955. */
  26956. export class BaseTexture implements IAnimatable {
  26957. /**
  26958. * Default anisotropic filtering level for the application.
  26959. * It is set to 4 as a good tradeoff between perf and quality.
  26960. */
  26961. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  26962. /**
  26963. * Gets or sets the unique id of the texture
  26964. */
  26965. uniqueId: number;
  26966. /**
  26967. * Define the name of the texture.
  26968. */
  26969. name: string;
  26970. /**
  26971. * Gets or sets an object used to store user defined information.
  26972. */
  26973. metadata: any;
  26974. /**
  26975. * For internal use only. Please do not use.
  26976. */
  26977. reservedDataStore: any;
  26978. private _hasAlpha;
  26979. /**
  26980. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  26981. */
  26982. hasAlpha: boolean;
  26983. /**
  26984. * Defines if the alpha value should be determined via the rgb values.
  26985. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  26986. */
  26987. getAlphaFromRGB: boolean;
  26988. /**
  26989. * Intensity or strength of the texture.
  26990. * It is commonly used by materials to fine tune the intensity of the texture
  26991. */
  26992. level: number;
  26993. /**
  26994. * Define the UV chanel to use starting from 0 and defaulting to 0.
  26995. * This is part of the texture as textures usually maps to one uv set.
  26996. */
  26997. coordinatesIndex: number;
  26998. private _coordinatesMode;
  26999. /**
  27000. * How a texture is mapped.
  27001. *
  27002. * | Value | Type | Description |
  27003. * | ----- | ----------------------------------- | ----------- |
  27004. * | 0 | EXPLICIT_MODE | |
  27005. * | 1 | SPHERICAL_MODE | |
  27006. * | 2 | PLANAR_MODE | |
  27007. * | 3 | CUBIC_MODE | |
  27008. * | 4 | PROJECTION_MODE | |
  27009. * | 5 | SKYBOX_MODE | |
  27010. * | 6 | INVCUBIC_MODE | |
  27011. * | 7 | EQUIRECTANGULAR_MODE | |
  27012. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  27013. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  27014. */
  27015. coordinatesMode: number;
  27016. /**
  27017. * | Value | Type | Description |
  27018. * | ----- | ------------------ | ----------- |
  27019. * | 0 | CLAMP_ADDRESSMODE | |
  27020. * | 1 | WRAP_ADDRESSMODE | |
  27021. * | 2 | MIRROR_ADDRESSMODE | |
  27022. */
  27023. wrapU: number;
  27024. /**
  27025. * | Value | Type | Description |
  27026. * | ----- | ------------------ | ----------- |
  27027. * | 0 | CLAMP_ADDRESSMODE | |
  27028. * | 1 | WRAP_ADDRESSMODE | |
  27029. * | 2 | MIRROR_ADDRESSMODE | |
  27030. */
  27031. wrapV: number;
  27032. /**
  27033. * | Value | Type | Description |
  27034. * | ----- | ------------------ | ----------- |
  27035. * | 0 | CLAMP_ADDRESSMODE | |
  27036. * | 1 | WRAP_ADDRESSMODE | |
  27037. * | 2 | MIRROR_ADDRESSMODE | |
  27038. */
  27039. wrapR: number;
  27040. /**
  27041. * With compliant hardware and browser (supporting anisotropic filtering)
  27042. * this defines the level of anisotropic filtering in the texture.
  27043. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  27044. */
  27045. anisotropicFilteringLevel: number;
  27046. /**
  27047. * Define if the texture is a cube texture or if false a 2d texture.
  27048. */
  27049. isCube: boolean;
  27050. /**
  27051. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  27052. */
  27053. is3D: boolean;
  27054. /**
  27055. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  27056. * HDR texture are usually stored in linear space.
  27057. * This only impacts the PBR and Background materials
  27058. */
  27059. gammaSpace: boolean;
  27060. /**
  27061. * Gets whether or not the texture contains RGBD data.
  27062. */
  27063. readonly isRGBD: boolean;
  27064. /**
  27065. * Is Z inverted in the texture (useful in a cube texture).
  27066. */
  27067. invertZ: boolean;
  27068. /**
  27069. * Are mip maps generated for this texture or not.
  27070. */
  27071. readonly noMipmap: boolean;
  27072. /**
  27073. * @hidden
  27074. */
  27075. lodLevelInAlpha: boolean;
  27076. /**
  27077. * With prefiltered texture, defined the offset used during the prefiltering steps.
  27078. */
  27079. lodGenerationOffset: number;
  27080. /**
  27081. * With prefiltered texture, defined the scale used during the prefiltering steps.
  27082. */
  27083. lodGenerationScale: number;
  27084. /**
  27085. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  27086. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  27087. * average roughness values.
  27088. */
  27089. linearSpecularLOD: boolean;
  27090. /**
  27091. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  27092. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  27093. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  27094. */
  27095. irradianceTexture: Nullable<BaseTexture>;
  27096. /**
  27097. * Define if the texture is a render target.
  27098. */
  27099. isRenderTarget: boolean;
  27100. /**
  27101. * Define the unique id of the texture in the scene.
  27102. */
  27103. readonly uid: string;
  27104. /**
  27105. * Return a string representation of the texture.
  27106. * @returns the texture as a string
  27107. */
  27108. toString(): string;
  27109. /**
  27110. * Get the class name of the texture.
  27111. * @returns "BaseTexture"
  27112. */
  27113. getClassName(): string;
  27114. /**
  27115. * Define the list of animation attached to the texture.
  27116. */
  27117. animations: import("babylonjs/Animations/animation").Animation[];
  27118. /**
  27119. * An event triggered when the texture is disposed.
  27120. */
  27121. onDisposeObservable: Observable<BaseTexture>;
  27122. private _onDisposeObserver;
  27123. /**
  27124. * Callback triggered when the texture has been disposed.
  27125. * Kept for back compatibility, you can use the onDisposeObservable instead.
  27126. */
  27127. onDispose: () => void;
  27128. /**
  27129. * Define the current state of the loading sequence when in delayed load mode.
  27130. */
  27131. delayLoadState: number;
  27132. private _scene;
  27133. /** @hidden */
  27134. _texture: Nullable<InternalTexture>;
  27135. private _uid;
  27136. /**
  27137. * Define if the texture is preventinga material to render or not.
  27138. * If not and the texture is not ready, the engine will use a default black texture instead.
  27139. */
  27140. readonly isBlocking: boolean;
  27141. /**
  27142. * Instantiates a new BaseTexture.
  27143. * Base class of all the textures in babylon.
  27144. * It groups all the common properties the materials, post process, lights... might need
  27145. * in order to make a correct use of the texture.
  27146. * @param scene Define the scene the texture blongs to
  27147. */
  27148. constructor(scene: Nullable<Scene>);
  27149. /**
  27150. * Get the scene the texture belongs to.
  27151. * @returns the scene or null if undefined
  27152. */
  27153. getScene(): Nullable<Scene>;
  27154. /**
  27155. * Get the texture transform matrix used to offset tile the texture for istance.
  27156. * @returns the transformation matrix
  27157. */
  27158. getTextureMatrix(): Matrix;
  27159. /**
  27160. * Get the texture reflection matrix used to rotate/transform the reflection.
  27161. * @returns the reflection matrix
  27162. */
  27163. getReflectionTextureMatrix(): Matrix;
  27164. /**
  27165. * Get the underlying lower level texture from Babylon.
  27166. * @returns the insternal texture
  27167. */
  27168. getInternalTexture(): Nullable<InternalTexture>;
  27169. /**
  27170. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  27171. * @returns true if ready or not blocking
  27172. */
  27173. isReadyOrNotBlocking(): boolean;
  27174. /**
  27175. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  27176. * @returns true if fully ready
  27177. */
  27178. isReady(): boolean;
  27179. private _cachedSize;
  27180. /**
  27181. * Get the size of the texture.
  27182. * @returns the texture size.
  27183. */
  27184. getSize(): ISize;
  27185. /**
  27186. * Get the base size of the texture.
  27187. * It can be different from the size if the texture has been resized for POT for instance
  27188. * @returns the base size
  27189. */
  27190. getBaseSize(): ISize;
  27191. /**
  27192. * Update the sampling mode of the texture.
  27193. * Default is Trilinear mode.
  27194. *
  27195. * | Value | Type | Description |
  27196. * | ----- | ------------------ | ----------- |
  27197. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  27198. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  27199. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  27200. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  27201. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  27202. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  27203. * | 7 | NEAREST_LINEAR | |
  27204. * | 8 | NEAREST_NEAREST | |
  27205. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  27206. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  27207. * | 11 | LINEAR_LINEAR | |
  27208. * | 12 | LINEAR_NEAREST | |
  27209. *
  27210. * > _mag_: magnification filter (close to the viewer)
  27211. * > _min_: minification filter (far from the viewer)
  27212. * > _mip_: filter used between mip map levels
  27213. *@param samplingMode Define the new sampling mode of the texture
  27214. */
  27215. updateSamplingMode(samplingMode: number): void;
  27216. /**
  27217. * Scales the texture if is `canRescale()`
  27218. * @param ratio the resize factor we want to use to rescale
  27219. */
  27220. scale(ratio: number): void;
  27221. /**
  27222. * Get if the texture can rescale.
  27223. */
  27224. readonly canRescale: boolean;
  27225. /** @hidden */
  27226. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  27227. /** @hidden */
  27228. _rebuild(): void;
  27229. /**
  27230. * Triggers the load sequence in delayed load mode.
  27231. */
  27232. delayLoad(): void;
  27233. /**
  27234. * Clones the texture.
  27235. * @returns the cloned texture
  27236. */
  27237. clone(): Nullable<BaseTexture>;
  27238. /**
  27239. * Get the texture underlying type (INT, FLOAT...)
  27240. */
  27241. readonly textureType: number;
  27242. /**
  27243. * Get the texture underlying format (RGB, RGBA...)
  27244. */
  27245. readonly textureFormat: number;
  27246. /**
  27247. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  27248. * This will returns an RGBA array buffer containing either in values (0-255) or
  27249. * float values (0-1) depending of the underlying buffer type.
  27250. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  27251. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  27252. * @param buffer defines a user defined buffer to fill with data (can be null)
  27253. * @returns The Array buffer containing the pixels data.
  27254. */
  27255. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  27256. /**
  27257. * Release and destroy the underlying lower level texture aka internalTexture.
  27258. */
  27259. releaseInternalTexture(): void;
  27260. /**
  27261. * Get the polynomial representation of the texture data.
  27262. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  27263. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  27264. */
  27265. sphericalPolynomial: Nullable<SphericalPolynomial>;
  27266. /** @hidden */
  27267. readonly _lodTextureHigh: Nullable<BaseTexture>;
  27268. /** @hidden */
  27269. readonly _lodTextureMid: Nullable<BaseTexture>;
  27270. /** @hidden */
  27271. readonly _lodTextureLow: Nullable<BaseTexture>;
  27272. /**
  27273. * Dispose the texture and release its associated resources.
  27274. */
  27275. dispose(): void;
  27276. /**
  27277. * Serialize the texture into a JSON representation that can be parsed later on.
  27278. * @returns the JSON representation of the texture
  27279. */
  27280. serialize(): any;
  27281. /**
  27282. * Helper function to be called back once a list of texture contains only ready textures.
  27283. * @param textures Define the list of textures to wait for
  27284. * @param callback Define the callback triggered once the entire list will be ready
  27285. */
  27286. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  27287. }
  27288. }
  27289. declare module "babylonjs/Materials/uniformBuffer" {
  27290. import { Nullable, FloatArray } from "babylonjs/types";
  27291. import { Matrix, Vector3, Color3, Vector4 } from "babylonjs/Maths/math";
  27292. import { Engine } from "babylonjs/Engines/engine";
  27293. import { Effect } from "babylonjs/Materials/effect";
  27294. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27295. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  27296. /**
  27297. * Uniform buffer objects.
  27298. *
  27299. * Handles blocks of uniform on the GPU.
  27300. *
  27301. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  27302. *
  27303. * For more information, please refer to :
  27304. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  27305. */
  27306. export class UniformBuffer {
  27307. private _engine;
  27308. private _buffer;
  27309. private _data;
  27310. private _bufferData;
  27311. private _dynamic?;
  27312. private _uniformLocations;
  27313. private _uniformSizes;
  27314. private _uniformLocationPointer;
  27315. private _needSync;
  27316. private _noUBO;
  27317. private _currentEffect;
  27318. private static _MAX_UNIFORM_SIZE;
  27319. private static _tempBuffer;
  27320. /**
  27321. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  27322. * This is dynamic to allow compat with webgl 1 and 2.
  27323. * You will need to pass the name of the uniform as well as the value.
  27324. */
  27325. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  27326. /**
  27327. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  27328. * This is dynamic to allow compat with webgl 1 and 2.
  27329. * You will need to pass the name of the uniform as well as the value.
  27330. */
  27331. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  27332. /**
  27333. * Lambda to Update a single float in a uniform buffer.
  27334. * This is dynamic to allow compat with webgl 1 and 2.
  27335. * You will need to pass the name of the uniform as well as the value.
  27336. */
  27337. updateFloat: (name: string, x: number) => void;
  27338. /**
  27339. * Lambda to Update a vec2 of float in a uniform buffer.
  27340. * This is dynamic to allow compat with webgl 1 and 2.
  27341. * You will need to pass the name of the uniform as well as the value.
  27342. */
  27343. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  27344. /**
  27345. * Lambda to Update a vec3 of float in a uniform buffer.
  27346. * This is dynamic to allow compat with webgl 1 and 2.
  27347. * You will need to pass the name of the uniform as well as the value.
  27348. */
  27349. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  27350. /**
  27351. * Lambda to Update a vec4 of float in a uniform buffer.
  27352. * This is dynamic to allow compat with webgl 1 and 2.
  27353. * You will need to pass the name of the uniform as well as the value.
  27354. */
  27355. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  27356. /**
  27357. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  27358. * This is dynamic to allow compat with webgl 1 and 2.
  27359. * You will need to pass the name of the uniform as well as the value.
  27360. */
  27361. updateMatrix: (name: string, mat: Matrix) => void;
  27362. /**
  27363. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  27364. * This is dynamic to allow compat with webgl 1 and 2.
  27365. * You will need to pass the name of the uniform as well as the value.
  27366. */
  27367. updateVector3: (name: string, vector: Vector3) => void;
  27368. /**
  27369. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  27370. * This is dynamic to allow compat with webgl 1 and 2.
  27371. * You will need to pass the name of the uniform as well as the value.
  27372. */
  27373. updateVector4: (name: string, vector: Vector4) => void;
  27374. /**
  27375. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  27376. * This is dynamic to allow compat with webgl 1 and 2.
  27377. * You will need to pass the name of the uniform as well as the value.
  27378. */
  27379. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  27380. /**
  27381. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  27382. * This is dynamic to allow compat with webgl 1 and 2.
  27383. * You will need to pass the name of the uniform as well as the value.
  27384. */
  27385. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  27386. /**
  27387. * Instantiates a new Uniform buffer objects.
  27388. *
  27389. * Handles blocks of uniform on the GPU.
  27390. *
  27391. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  27392. *
  27393. * For more information, please refer to :
  27394. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  27395. * @param engine Define the engine the buffer is associated with
  27396. * @param data Define the data contained in the buffer
  27397. * @param dynamic Define if the buffer is updatable
  27398. */
  27399. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  27400. /**
  27401. * Indicates if the buffer is using the WebGL2 UBO implementation,
  27402. * or just falling back on setUniformXXX calls.
  27403. */
  27404. readonly useUbo: boolean;
  27405. /**
  27406. * Indicates if the WebGL underlying uniform buffer is in sync
  27407. * with the javascript cache data.
  27408. */
  27409. readonly isSync: boolean;
  27410. /**
  27411. * Indicates if the WebGL underlying uniform buffer is dynamic.
  27412. * Also, a dynamic UniformBuffer will disable cache verification and always
  27413. * update the underlying WebGL uniform buffer to the GPU.
  27414. * @returns if Dynamic, otherwise false
  27415. */
  27416. isDynamic(): boolean;
  27417. /**
  27418. * The data cache on JS side.
  27419. * @returns the underlying data as a float array
  27420. */
  27421. getData(): Float32Array;
  27422. /**
  27423. * The underlying WebGL Uniform buffer.
  27424. * @returns the webgl buffer
  27425. */
  27426. getBuffer(): Nullable<DataBuffer>;
  27427. /**
  27428. * std140 layout specifies how to align data within an UBO structure.
  27429. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  27430. * for specs.
  27431. */
  27432. private _fillAlignment;
  27433. /**
  27434. * Adds an uniform in the buffer.
  27435. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  27436. * for the layout to be correct !
  27437. * @param name Name of the uniform, as used in the uniform block in the shader.
  27438. * @param size Data size, or data directly.
  27439. */
  27440. addUniform(name: string, size: number | number[]): void;
  27441. /**
  27442. * Adds a Matrix 4x4 to the uniform buffer.
  27443. * @param name Name of the uniform, as used in the uniform block in the shader.
  27444. * @param mat A 4x4 matrix.
  27445. */
  27446. addMatrix(name: string, mat: Matrix): void;
  27447. /**
  27448. * Adds a vec2 to the uniform buffer.
  27449. * @param name Name of the uniform, as used in the uniform block in the shader.
  27450. * @param x Define the x component value of the vec2
  27451. * @param y Define the y component value of the vec2
  27452. */
  27453. addFloat2(name: string, x: number, y: number): void;
  27454. /**
  27455. * Adds a vec3 to the uniform buffer.
  27456. * @param name Name of the uniform, as used in the uniform block in the shader.
  27457. * @param x Define the x component value of the vec3
  27458. * @param y Define the y component value of the vec3
  27459. * @param z Define the z component value of the vec3
  27460. */
  27461. addFloat3(name: string, x: number, y: number, z: number): void;
  27462. /**
  27463. * Adds a vec3 to the uniform buffer.
  27464. * @param name Name of the uniform, as used in the uniform block in the shader.
  27465. * @param color Define the vec3 from a Color
  27466. */
  27467. addColor3(name: string, color: Color3): void;
  27468. /**
  27469. * Adds a vec4 to the uniform buffer.
  27470. * @param name Name of the uniform, as used in the uniform block in the shader.
  27471. * @param color Define the rgb components from a Color
  27472. * @param alpha Define the a component of the vec4
  27473. */
  27474. addColor4(name: string, color: Color3, alpha: number): void;
  27475. /**
  27476. * Adds a vec3 to the uniform buffer.
  27477. * @param name Name of the uniform, as used in the uniform block in the shader.
  27478. * @param vector Define the vec3 components from a Vector
  27479. */
  27480. addVector3(name: string, vector: Vector3): void;
  27481. /**
  27482. * Adds a Matrix 3x3 to the uniform buffer.
  27483. * @param name Name of the uniform, as used in the uniform block in the shader.
  27484. */
  27485. addMatrix3x3(name: string): void;
  27486. /**
  27487. * Adds a Matrix 2x2 to the uniform buffer.
  27488. * @param name Name of the uniform, as used in the uniform block in the shader.
  27489. */
  27490. addMatrix2x2(name: string): void;
  27491. /**
  27492. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  27493. */
  27494. create(): void;
  27495. /** @hidden */
  27496. _rebuild(): void;
  27497. /**
  27498. * Updates the WebGL Uniform Buffer on the GPU.
  27499. * If the `dynamic` flag is set to true, no cache comparison is done.
  27500. * Otherwise, the buffer will be updated only if the cache differs.
  27501. */
  27502. update(): void;
  27503. /**
  27504. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  27505. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  27506. * @param data Define the flattened data
  27507. * @param size Define the size of the data.
  27508. */
  27509. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  27510. private _updateMatrix3x3ForUniform;
  27511. private _updateMatrix3x3ForEffect;
  27512. private _updateMatrix2x2ForEffect;
  27513. private _updateMatrix2x2ForUniform;
  27514. private _updateFloatForEffect;
  27515. private _updateFloatForUniform;
  27516. private _updateFloat2ForEffect;
  27517. private _updateFloat2ForUniform;
  27518. private _updateFloat3ForEffect;
  27519. private _updateFloat3ForUniform;
  27520. private _updateFloat4ForEffect;
  27521. private _updateFloat4ForUniform;
  27522. private _updateMatrixForEffect;
  27523. private _updateMatrixForUniform;
  27524. private _updateVector3ForEffect;
  27525. private _updateVector3ForUniform;
  27526. private _updateVector4ForEffect;
  27527. private _updateVector4ForUniform;
  27528. private _updateColor3ForEffect;
  27529. private _updateColor3ForUniform;
  27530. private _updateColor4ForEffect;
  27531. private _updateColor4ForUniform;
  27532. /**
  27533. * Sets a sampler uniform on the effect.
  27534. * @param name Define the name of the sampler.
  27535. * @param texture Define the texture to set in the sampler
  27536. */
  27537. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  27538. /**
  27539. * Directly updates the value of the uniform in the cache AND on the GPU.
  27540. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  27541. * @param data Define the flattened data
  27542. */
  27543. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  27544. /**
  27545. * Binds this uniform buffer to an effect.
  27546. * @param effect Define the effect to bind the buffer to
  27547. * @param name Name of the uniform block in the shader.
  27548. */
  27549. bindToEffect(effect: Effect, name: string): void;
  27550. /**
  27551. * Disposes the uniform buffer.
  27552. */
  27553. dispose(): void;
  27554. }
  27555. }
  27556. declare module "babylonjs/Audio/analyser" {
  27557. import { Scene } from "babylonjs/scene";
  27558. /**
  27559. * Class used to work with sound analyzer using fast fourier transform (FFT)
  27560. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27561. */
  27562. export class Analyser {
  27563. /**
  27564. * Gets or sets the smoothing
  27565. * @ignorenaming
  27566. */
  27567. SMOOTHING: number;
  27568. /**
  27569. * Gets or sets the FFT table size
  27570. * @ignorenaming
  27571. */
  27572. FFT_SIZE: number;
  27573. /**
  27574. * Gets or sets the bar graph amplitude
  27575. * @ignorenaming
  27576. */
  27577. BARGRAPHAMPLITUDE: number;
  27578. /**
  27579. * Gets or sets the position of the debug canvas
  27580. * @ignorenaming
  27581. */
  27582. DEBUGCANVASPOS: {
  27583. x: number;
  27584. y: number;
  27585. };
  27586. /**
  27587. * Gets or sets the debug canvas size
  27588. * @ignorenaming
  27589. */
  27590. DEBUGCANVASSIZE: {
  27591. width: number;
  27592. height: number;
  27593. };
  27594. private _byteFreqs;
  27595. private _byteTime;
  27596. private _floatFreqs;
  27597. private _webAudioAnalyser;
  27598. private _debugCanvas;
  27599. private _debugCanvasContext;
  27600. private _scene;
  27601. private _registerFunc;
  27602. private _audioEngine;
  27603. /**
  27604. * Creates a new analyser
  27605. * @param scene defines hosting scene
  27606. */
  27607. constructor(scene: Scene);
  27608. /**
  27609. * Get the number of data values you will have to play with for the visualization
  27610. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  27611. * @returns a number
  27612. */
  27613. getFrequencyBinCount(): number;
  27614. /**
  27615. * Gets the current frequency data as a byte array
  27616. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  27617. * @returns a Uint8Array
  27618. */
  27619. getByteFrequencyData(): Uint8Array;
  27620. /**
  27621. * Gets the current waveform as a byte array
  27622. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  27623. * @returns a Uint8Array
  27624. */
  27625. getByteTimeDomainData(): Uint8Array;
  27626. /**
  27627. * Gets the current frequency data as a float array
  27628. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  27629. * @returns a Float32Array
  27630. */
  27631. getFloatFrequencyData(): Float32Array;
  27632. /**
  27633. * Renders the debug canvas
  27634. */
  27635. drawDebugCanvas(): void;
  27636. /**
  27637. * Stops rendering the debug canvas and removes it
  27638. */
  27639. stopDebugCanvas(): void;
  27640. /**
  27641. * Connects two audio nodes
  27642. * @param inputAudioNode defines first node to connect
  27643. * @param outputAudioNode defines second node to connect
  27644. */
  27645. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  27646. /**
  27647. * Releases all associated resources
  27648. */
  27649. dispose(): void;
  27650. }
  27651. }
  27652. declare module "babylonjs/Audio/audioEngine" {
  27653. import { IDisposable } from "babylonjs/scene";
  27654. import { Analyser } from "babylonjs/Audio/analyser";
  27655. import { Nullable } from "babylonjs/types";
  27656. import { Observable } from "babylonjs/Misc/observable";
  27657. /**
  27658. * This represents an audio engine and it is responsible
  27659. * to play, synchronize and analyse sounds throughout the application.
  27660. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27661. */
  27662. export interface IAudioEngine extends IDisposable {
  27663. /**
  27664. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27665. */
  27666. readonly canUseWebAudio: boolean;
  27667. /**
  27668. * Gets the current AudioContext if available.
  27669. */
  27670. readonly audioContext: Nullable<AudioContext>;
  27671. /**
  27672. * The master gain node defines the global audio volume of your audio engine.
  27673. */
  27674. readonly masterGain: GainNode;
  27675. /**
  27676. * Gets whether or not mp3 are supported by your browser.
  27677. */
  27678. readonly isMP3supported: boolean;
  27679. /**
  27680. * Gets whether or not ogg are supported by your browser.
  27681. */
  27682. readonly isOGGsupported: boolean;
  27683. /**
  27684. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27685. * @ignoreNaming
  27686. */
  27687. WarnedWebAudioUnsupported: boolean;
  27688. /**
  27689. * Defines if the audio engine relies on a custom unlocked button.
  27690. * In this case, the embedded button will not be displayed.
  27691. */
  27692. useCustomUnlockedButton: boolean;
  27693. /**
  27694. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  27695. */
  27696. readonly unlocked: boolean;
  27697. /**
  27698. * Event raised when audio has been unlocked on the browser.
  27699. */
  27700. onAudioUnlockedObservable: Observable<AudioEngine>;
  27701. /**
  27702. * Event raised when audio has been locked on the browser.
  27703. */
  27704. onAudioLockedObservable: Observable<AudioEngine>;
  27705. /**
  27706. * Flags the audio engine in Locked state.
  27707. * This happens due to new browser policies preventing audio to autoplay.
  27708. */
  27709. lock(): void;
  27710. /**
  27711. * Unlocks the audio engine once a user action has been done on the dom.
  27712. * This is helpful to resume play once browser policies have been satisfied.
  27713. */
  27714. unlock(): void;
  27715. }
  27716. /**
  27717. * This represents the default audio engine used in babylon.
  27718. * It is responsible to play, synchronize and analyse sounds throughout the application.
  27719. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27720. */
  27721. export class AudioEngine implements IAudioEngine {
  27722. private _audioContext;
  27723. private _audioContextInitialized;
  27724. private _muteButton;
  27725. private _hostElement;
  27726. /**
  27727. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27728. */
  27729. canUseWebAudio: boolean;
  27730. /**
  27731. * The master gain node defines the global audio volume of your audio engine.
  27732. */
  27733. masterGain: GainNode;
  27734. /**
  27735. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27736. * @ignoreNaming
  27737. */
  27738. WarnedWebAudioUnsupported: boolean;
  27739. /**
  27740. * Gets whether or not mp3 are supported by your browser.
  27741. */
  27742. isMP3supported: boolean;
  27743. /**
  27744. * Gets whether or not ogg are supported by your browser.
  27745. */
  27746. isOGGsupported: boolean;
  27747. /**
  27748. * Gets whether audio has been unlocked on the device.
  27749. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  27750. * a user interaction has happened.
  27751. */
  27752. unlocked: boolean;
  27753. /**
  27754. * Defines if the audio engine relies on a custom unlocked button.
  27755. * In this case, the embedded button will not be displayed.
  27756. */
  27757. useCustomUnlockedButton: boolean;
  27758. /**
  27759. * Event raised when audio has been unlocked on the browser.
  27760. */
  27761. onAudioUnlockedObservable: Observable<AudioEngine>;
  27762. /**
  27763. * Event raised when audio has been locked on the browser.
  27764. */
  27765. onAudioLockedObservable: Observable<AudioEngine>;
  27766. /**
  27767. * Gets the current AudioContext if available.
  27768. */
  27769. readonly audioContext: Nullable<AudioContext>;
  27770. private _connectedAnalyser;
  27771. /**
  27772. * Instantiates a new audio engine.
  27773. *
  27774. * There should be only one per page as some browsers restrict the number
  27775. * of audio contexts you can create.
  27776. * @param hostElement defines the host element where to display the mute icon if necessary
  27777. */
  27778. constructor(hostElement?: Nullable<HTMLElement>);
  27779. /**
  27780. * Flags the audio engine in Locked state.
  27781. * This happens due to new browser policies preventing audio to autoplay.
  27782. */
  27783. lock(): void;
  27784. /**
  27785. * Unlocks the audio engine once a user action has been done on the dom.
  27786. * This is helpful to resume play once browser policies have been satisfied.
  27787. */
  27788. unlock(): void;
  27789. private _resumeAudioContext;
  27790. private _initializeAudioContext;
  27791. private _tryToRun;
  27792. private _triggerRunningState;
  27793. private _triggerSuspendedState;
  27794. private _displayMuteButton;
  27795. private _moveButtonToTopLeft;
  27796. private _onResize;
  27797. private _hideMuteButton;
  27798. /**
  27799. * Destroy and release the resources associated with the audio ccontext.
  27800. */
  27801. dispose(): void;
  27802. /**
  27803. * Gets the global volume sets on the master gain.
  27804. * @returns the global volume if set or -1 otherwise
  27805. */
  27806. getGlobalVolume(): number;
  27807. /**
  27808. * Sets the global volume of your experience (sets on the master gain).
  27809. * @param newVolume Defines the new global volume of the application
  27810. */
  27811. setGlobalVolume(newVolume: number): void;
  27812. /**
  27813. * Connect the audio engine to an audio analyser allowing some amazing
  27814. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  27815. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  27816. * @param analyser The analyser to connect to the engine
  27817. */
  27818. connectToAnalyser(analyser: Analyser): void;
  27819. }
  27820. }
  27821. declare module "babylonjs/Loading/loadingScreen" {
  27822. /**
  27823. * Interface used to present a loading screen while loading a scene
  27824. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27825. */
  27826. export interface ILoadingScreen {
  27827. /**
  27828. * Function called to display the loading screen
  27829. */
  27830. displayLoadingUI: () => void;
  27831. /**
  27832. * Function called to hide the loading screen
  27833. */
  27834. hideLoadingUI: () => void;
  27835. /**
  27836. * Gets or sets the color to use for the background
  27837. */
  27838. loadingUIBackgroundColor: string;
  27839. /**
  27840. * Gets or sets the text to display while loading
  27841. */
  27842. loadingUIText: string;
  27843. }
  27844. /**
  27845. * Class used for the default loading screen
  27846. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27847. */
  27848. export class DefaultLoadingScreen implements ILoadingScreen {
  27849. private _renderingCanvas;
  27850. private _loadingText;
  27851. private _loadingDivBackgroundColor;
  27852. private _loadingDiv;
  27853. private _loadingTextDiv;
  27854. /** Gets or sets the logo url to use for the default loading screen */
  27855. static DefaultLogoUrl: string;
  27856. /** Gets or sets the spinner url to use for the default loading screen */
  27857. static DefaultSpinnerUrl: string;
  27858. /**
  27859. * Creates a new default loading screen
  27860. * @param _renderingCanvas defines the canvas used to render the scene
  27861. * @param _loadingText defines the default text to display
  27862. * @param _loadingDivBackgroundColor defines the default background color
  27863. */
  27864. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  27865. /**
  27866. * Function called to display the loading screen
  27867. */
  27868. displayLoadingUI(): void;
  27869. /**
  27870. * Function called to hide the loading screen
  27871. */
  27872. hideLoadingUI(): void;
  27873. /**
  27874. * Gets or sets the text to display while loading
  27875. */
  27876. loadingUIText: string;
  27877. /**
  27878. * Gets or sets the color to use for the background
  27879. */
  27880. loadingUIBackgroundColor: string;
  27881. private _resizeLoadingUI;
  27882. }
  27883. }
  27884. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  27885. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  27886. import { Engine } from "babylonjs/Engines/engine";
  27887. import { Nullable } from "babylonjs/types";
  27888. /** @hidden */
  27889. export class WebGLPipelineContext implements IPipelineContext {
  27890. engine: Engine;
  27891. program: Nullable<WebGLProgram>;
  27892. context?: WebGLRenderingContext;
  27893. vertexShader?: WebGLShader;
  27894. fragmentShader?: WebGLShader;
  27895. isParallelCompiled: boolean;
  27896. onCompiled?: () => void;
  27897. transformFeedback?: WebGLTransformFeedback | null;
  27898. readonly isAsync: boolean;
  27899. readonly isReady: boolean;
  27900. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  27901. }
  27902. }
  27903. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  27904. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  27905. /** @hidden */
  27906. export class WebGLDataBuffer extends DataBuffer {
  27907. private _buffer;
  27908. constructor(resource: WebGLBuffer);
  27909. readonly underlyingResource: any;
  27910. }
  27911. }
  27912. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  27913. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  27914. /** @hidden */
  27915. export class WebGL2ShaderProcessor implements IShaderProcessor {
  27916. attributeProcessor(attribute: string): string;
  27917. varyingProcessor(varying: string, isFragment: boolean): string;
  27918. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  27919. }
  27920. }
  27921. declare module "babylonjs/Materials/Textures/videoTexture" {
  27922. import { Observable } from "babylonjs/Misc/observable";
  27923. import { Nullable } from "babylonjs/types";
  27924. import { Scene } from "babylonjs/scene";
  27925. import { Texture } from "babylonjs/Materials/Textures/texture";
  27926. /**
  27927. * Settings for finer control over video usage
  27928. */
  27929. export interface VideoTextureSettings {
  27930. /**
  27931. * Applies `autoplay` to video, if specified
  27932. */
  27933. autoPlay?: boolean;
  27934. /**
  27935. * Applies `loop` to video, if specified
  27936. */
  27937. loop?: boolean;
  27938. /**
  27939. * Automatically updates internal texture from video at every frame in the render loop
  27940. */
  27941. autoUpdateTexture: boolean;
  27942. /**
  27943. * Image src displayed during the video loading or until the user interacts with the video.
  27944. */
  27945. poster?: string;
  27946. }
  27947. /**
  27948. * If you want to display a video in your scene, this is the special texture for that.
  27949. * This special texture works similar to other textures, with the exception of a few parameters.
  27950. * @see https://doc.babylonjs.com/how_to/video_texture
  27951. */
  27952. export class VideoTexture extends Texture {
  27953. /**
  27954. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  27955. */
  27956. readonly autoUpdateTexture: boolean;
  27957. /**
  27958. * The video instance used by the texture internally
  27959. */
  27960. readonly video: HTMLVideoElement;
  27961. private _onUserActionRequestedObservable;
  27962. /**
  27963. * Event triggerd when a dom action is required by the user to play the video.
  27964. * This happens due to recent changes in browser policies preventing video to auto start.
  27965. */
  27966. readonly onUserActionRequestedObservable: Observable<Texture>;
  27967. private _generateMipMaps;
  27968. private _engine;
  27969. private _stillImageCaptured;
  27970. private _displayingPosterTexture;
  27971. private _settings;
  27972. private _createInternalTextureOnEvent;
  27973. /**
  27974. * Creates a video texture.
  27975. * If you want to display a video in your scene, this is the special texture for that.
  27976. * This special texture works similar to other textures, with the exception of a few parameters.
  27977. * @see https://doc.babylonjs.com/how_to/video_texture
  27978. * @param name optional name, will detect from video source, if not defined
  27979. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  27980. * @param scene is obviously the current scene.
  27981. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  27982. * @param invertY is false by default but can be used to invert video on Y axis
  27983. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  27984. * @param settings allows finer control over video usage
  27985. */
  27986. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  27987. private _getName;
  27988. private _getVideo;
  27989. private _createInternalTexture;
  27990. private reset;
  27991. /**
  27992. * @hidden Internal method to initiate `update`.
  27993. */
  27994. _rebuild(): void;
  27995. /**
  27996. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  27997. */
  27998. update(): void;
  27999. /**
  28000. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  28001. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  28002. */
  28003. updateTexture(isVisible: boolean): void;
  28004. protected _updateInternalTexture: () => void;
  28005. /**
  28006. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  28007. * @param url New url.
  28008. */
  28009. updateURL(url: string): void;
  28010. /**
  28011. * Dispose the texture and release its associated resources.
  28012. */
  28013. dispose(): void;
  28014. /**
  28015. * Creates a video texture straight from a stream.
  28016. * @param scene Define the scene the texture should be created in
  28017. * @param stream Define the stream the texture should be created from
  28018. * @returns The created video texture as a promise
  28019. */
  28020. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  28021. /**
  28022. * Creates a video texture straight from your WebCam video feed.
  28023. * @param scene Define the scene the texture should be created in
  28024. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  28025. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  28026. * @returns The created video texture as a promise
  28027. */
  28028. static CreateFromWebCamAsync(scene: Scene, constraints: {
  28029. minWidth: number;
  28030. maxWidth: number;
  28031. minHeight: number;
  28032. maxHeight: number;
  28033. deviceId: string;
  28034. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  28035. /**
  28036. * Creates a video texture straight from your WebCam video feed.
  28037. * @param scene Define the scene the texture should be created in
  28038. * @param onReady Define a callback to triggered once the texture will be ready
  28039. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  28040. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  28041. */
  28042. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  28043. minWidth: number;
  28044. maxWidth: number;
  28045. minHeight: number;
  28046. maxHeight: number;
  28047. deviceId: string;
  28048. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  28049. }
  28050. }
  28051. declare module "babylonjs/Engines/engine" {
  28052. import { Observable } from "babylonjs/Misc/observable";
  28053. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  28054. import { ICustomAnimationFrameRequester, PerfCounter, IFileRequest } from "babylonjs/Misc/tools";
  28055. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  28056. import { Camera } from "babylonjs/Cameras/camera";
  28057. import { Scene } from "babylonjs/scene";
  28058. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  28059. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  28060. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  28061. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  28062. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  28063. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28064. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28065. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  28066. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  28067. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  28068. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  28069. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  28070. import { WebRequest } from "babylonjs/Misc/webRequest";
  28071. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  28072. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  28073. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  28074. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  28075. import { Material } from "babylonjs/Materials/material";
  28076. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  28077. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  28078. /**
  28079. * Interface for attribute information associated with buffer instanciation
  28080. */
  28081. export class InstancingAttributeInfo {
  28082. /**
  28083. * Index/offset of the attribute in the vertex shader
  28084. */
  28085. index: number;
  28086. /**
  28087. * size of the attribute, 1, 2, 3 or 4
  28088. */
  28089. attributeSize: number;
  28090. /**
  28091. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  28092. * default is FLOAT
  28093. */
  28094. attribyteType: number;
  28095. /**
  28096. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  28097. */
  28098. normalized: boolean;
  28099. /**
  28100. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  28101. */
  28102. offset: number;
  28103. /**
  28104. * Name of the GLSL attribute, for debugging purpose only
  28105. */
  28106. attributeName: string;
  28107. }
  28108. /**
  28109. * Define options used to create a depth texture
  28110. */
  28111. export class DepthTextureCreationOptions {
  28112. /** Specifies whether or not a stencil should be allocated in the texture */
  28113. generateStencil?: boolean;
  28114. /** Specifies whether or not bilinear filtering is enable on the texture */
  28115. bilinearFiltering?: boolean;
  28116. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  28117. comparisonFunction?: number;
  28118. /** Specifies if the created texture is a cube texture */
  28119. isCube?: boolean;
  28120. }
  28121. /**
  28122. * Class used to describe the capabilities of the engine relatively to the current browser
  28123. */
  28124. export class EngineCapabilities {
  28125. /** Maximum textures units per fragment shader */
  28126. maxTexturesImageUnits: number;
  28127. /** Maximum texture units per vertex shader */
  28128. maxVertexTextureImageUnits: number;
  28129. /** Maximum textures units in the entire pipeline */
  28130. maxCombinedTexturesImageUnits: number;
  28131. /** Maximum texture size */
  28132. maxTextureSize: number;
  28133. /** Maximum cube texture size */
  28134. maxCubemapTextureSize: number;
  28135. /** Maximum render texture size */
  28136. maxRenderTextureSize: number;
  28137. /** Maximum number of vertex attributes */
  28138. maxVertexAttribs: number;
  28139. /** Maximum number of varyings */
  28140. maxVaryingVectors: number;
  28141. /** Maximum number of uniforms per vertex shader */
  28142. maxVertexUniformVectors: number;
  28143. /** Maximum number of uniforms per fragment shader */
  28144. maxFragmentUniformVectors: number;
  28145. /** Defines if standard derivates (dx/dy) are supported */
  28146. standardDerivatives: boolean;
  28147. /** Defines if s3tc texture compression is supported */
  28148. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  28149. /** Defines if pvrtc texture compression is supported */
  28150. pvrtc: any;
  28151. /** Defines if etc1 texture compression is supported */
  28152. etc1: any;
  28153. /** Defines if etc2 texture compression is supported */
  28154. etc2: any;
  28155. /** Defines if astc texture compression is supported */
  28156. astc: any;
  28157. /** Defines if float textures are supported */
  28158. textureFloat: boolean;
  28159. /** Defines if vertex array objects are supported */
  28160. vertexArrayObject: boolean;
  28161. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  28162. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  28163. /** Gets the maximum level of anisotropy supported */
  28164. maxAnisotropy: number;
  28165. /** Defines if instancing is supported */
  28166. instancedArrays: boolean;
  28167. /** Defines if 32 bits indices are supported */
  28168. uintIndices: boolean;
  28169. /** Defines if high precision shaders are supported */
  28170. highPrecisionShaderSupported: boolean;
  28171. /** Defines if depth reading in the fragment shader is supported */
  28172. fragmentDepthSupported: boolean;
  28173. /** Defines if float texture linear filtering is supported*/
  28174. textureFloatLinearFiltering: boolean;
  28175. /** Defines if rendering to float textures is supported */
  28176. textureFloatRender: boolean;
  28177. /** Defines if half float textures are supported*/
  28178. textureHalfFloat: boolean;
  28179. /** Defines if half float texture linear filtering is supported*/
  28180. textureHalfFloatLinearFiltering: boolean;
  28181. /** Defines if rendering to half float textures is supported */
  28182. textureHalfFloatRender: boolean;
  28183. /** Defines if textureLOD shader command is supported */
  28184. textureLOD: boolean;
  28185. /** Defines if draw buffers extension is supported */
  28186. drawBuffersExtension: boolean;
  28187. /** Defines if depth textures are supported */
  28188. depthTextureExtension: boolean;
  28189. /** Defines if float color buffer are supported */
  28190. colorBufferFloat: boolean;
  28191. /** Gets disjoint timer query extension (null if not supported) */
  28192. timerQuery: EXT_disjoint_timer_query;
  28193. /** Defines if timestamp can be used with timer query */
  28194. canUseTimestampForTimerQuery: boolean;
  28195. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  28196. multiview: any;
  28197. /** Function used to let the system compiles shaders in background */
  28198. parallelShaderCompile: {
  28199. COMPLETION_STATUS_KHR: number;
  28200. };
  28201. }
  28202. /** Interface defining initialization parameters for Engine class */
  28203. export interface EngineOptions extends WebGLContextAttributes {
  28204. /**
  28205. * Defines if the engine should no exceed a specified device ratio
  28206. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  28207. */
  28208. limitDeviceRatio?: number;
  28209. /**
  28210. * Defines if webvr should be enabled automatically
  28211. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28212. */
  28213. autoEnableWebVR?: boolean;
  28214. /**
  28215. * Defines if webgl2 should be turned off even if supported
  28216. * @see http://doc.babylonjs.com/features/webgl2
  28217. */
  28218. disableWebGL2Support?: boolean;
  28219. /**
  28220. * Defines if webaudio should be initialized as well
  28221. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28222. */
  28223. audioEngine?: boolean;
  28224. /**
  28225. * Defines if animations should run using a deterministic lock step
  28226. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28227. */
  28228. deterministicLockstep?: boolean;
  28229. /** Defines the maximum steps to use with deterministic lock step mode */
  28230. lockstepMaxSteps?: number;
  28231. /**
  28232. * Defines that engine should ignore context lost events
  28233. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  28234. */
  28235. doNotHandleContextLost?: boolean;
  28236. /**
  28237. * Defines that engine should ignore modifying touch action attribute and style
  28238. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  28239. */
  28240. doNotHandleTouchAction?: boolean;
  28241. /**
  28242. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  28243. */
  28244. useHighPrecisionFloats?: boolean;
  28245. }
  28246. /**
  28247. * Defines the interface used by display changed events
  28248. */
  28249. export interface IDisplayChangedEventArgs {
  28250. /** Gets the vrDisplay object (if any) */
  28251. vrDisplay: Nullable<any>;
  28252. /** Gets a boolean indicating if webVR is supported */
  28253. vrSupported: boolean;
  28254. }
  28255. /**
  28256. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  28257. */
  28258. export class Engine {
  28259. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  28260. static ExceptionList: ({
  28261. key: string;
  28262. capture: string;
  28263. captureConstraint: number;
  28264. targets: string[];
  28265. } | {
  28266. key: string;
  28267. capture: null;
  28268. captureConstraint: null;
  28269. targets: string[];
  28270. })[];
  28271. /** Gets the list of created engines */
  28272. static readonly Instances: Engine[];
  28273. /**
  28274. * Gets the latest created engine
  28275. */
  28276. static readonly LastCreatedEngine: Nullable<Engine>;
  28277. /**
  28278. * Gets the latest created scene
  28279. */
  28280. static readonly LastCreatedScene: Nullable<Scene>;
  28281. /**
  28282. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  28283. * @param flag defines which part of the materials must be marked as dirty
  28284. * @param predicate defines a predicate used to filter which materials should be affected
  28285. */
  28286. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  28287. /** @hidden */
  28288. static _TextureLoaders: IInternalTextureLoader[];
  28289. /** Defines that alpha blending is disabled */
  28290. static readonly ALPHA_DISABLE: number;
  28291. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  28292. static readonly ALPHA_ADD: number;
  28293. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  28294. static readonly ALPHA_COMBINE: number;
  28295. /** Defines that alpha blending to DEST - SRC * DEST */
  28296. static readonly ALPHA_SUBTRACT: number;
  28297. /** Defines that alpha blending to SRC * DEST */
  28298. static readonly ALPHA_MULTIPLY: number;
  28299. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  28300. static readonly ALPHA_MAXIMIZED: number;
  28301. /** Defines that alpha blending to SRC + DEST */
  28302. static readonly ALPHA_ONEONE: number;
  28303. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  28304. static readonly ALPHA_PREMULTIPLIED: number;
  28305. /**
  28306. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  28307. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  28308. */
  28309. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  28310. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  28311. static readonly ALPHA_INTERPOLATE: number;
  28312. /**
  28313. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  28314. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  28315. */
  28316. static readonly ALPHA_SCREENMODE: number;
  28317. /** Defines that the ressource is not delayed*/
  28318. static readonly DELAYLOADSTATE_NONE: number;
  28319. /** Defines that the ressource was successfully delay loaded */
  28320. static readonly DELAYLOADSTATE_LOADED: number;
  28321. /** Defines that the ressource is currently delay loading */
  28322. static readonly DELAYLOADSTATE_LOADING: number;
  28323. /** Defines that the ressource is delayed and has not started loading */
  28324. static readonly DELAYLOADSTATE_NOTLOADED: number;
  28325. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  28326. static readonly NEVER: number;
  28327. /** 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 */
  28328. static readonly ALWAYS: number;
  28329. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  28330. static readonly LESS: number;
  28331. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  28332. static readonly EQUAL: number;
  28333. /** 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 */
  28334. static readonly LEQUAL: number;
  28335. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  28336. static readonly GREATER: number;
  28337. /** 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 */
  28338. static readonly GEQUAL: number;
  28339. /** 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 */
  28340. static readonly NOTEQUAL: number;
  28341. /** Passed to stencilOperation to specify that stencil value must be kept */
  28342. static readonly KEEP: number;
  28343. /** Passed to stencilOperation to specify that stencil value must be replaced */
  28344. static readonly REPLACE: number;
  28345. /** Passed to stencilOperation to specify that stencil value must be incremented */
  28346. static readonly INCR: number;
  28347. /** Passed to stencilOperation to specify that stencil value must be decremented */
  28348. static readonly DECR: number;
  28349. /** Passed to stencilOperation to specify that stencil value must be inverted */
  28350. static readonly INVERT: number;
  28351. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  28352. static readonly INCR_WRAP: number;
  28353. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  28354. static readonly DECR_WRAP: number;
  28355. /** Texture is not repeating outside of 0..1 UVs */
  28356. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  28357. /** Texture is repeating outside of 0..1 UVs */
  28358. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  28359. /** Texture is repeating and mirrored */
  28360. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  28361. /** ALPHA */
  28362. static readonly TEXTUREFORMAT_ALPHA: number;
  28363. /** LUMINANCE */
  28364. static readonly TEXTUREFORMAT_LUMINANCE: number;
  28365. /** LUMINANCE_ALPHA */
  28366. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  28367. /** RGB */
  28368. static readonly TEXTUREFORMAT_RGB: number;
  28369. /** RGBA */
  28370. static readonly TEXTUREFORMAT_RGBA: number;
  28371. /** RED */
  28372. static readonly TEXTUREFORMAT_RED: number;
  28373. /** RED (2nd reference) */
  28374. static readonly TEXTUREFORMAT_R: number;
  28375. /** RG */
  28376. static readonly TEXTUREFORMAT_RG: number;
  28377. /** RED_INTEGER */
  28378. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  28379. /** RED_INTEGER (2nd reference) */
  28380. static readonly TEXTUREFORMAT_R_INTEGER: number;
  28381. /** RG_INTEGER */
  28382. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  28383. /** RGB_INTEGER */
  28384. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  28385. /** RGBA_INTEGER */
  28386. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  28387. /** UNSIGNED_BYTE */
  28388. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  28389. /** UNSIGNED_BYTE (2nd reference) */
  28390. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  28391. /** FLOAT */
  28392. static readonly TEXTURETYPE_FLOAT: number;
  28393. /** HALF_FLOAT */
  28394. static readonly TEXTURETYPE_HALF_FLOAT: number;
  28395. /** BYTE */
  28396. static readonly TEXTURETYPE_BYTE: number;
  28397. /** SHORT */
  28398. static readonly TEXTURETYPE_SHORT: number;
  28399. /** UNSIGNED_SHORT */
  28400. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  28401. /** INT */
  28402. static readonly TEXTURETYPE_INT: number;
  28403. /** UNSIGNED_INT */
  28404. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  28405. /** UNSIGNED_SHORT_4_4_4_4 */
  28406. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  28407. /** UNSIGNED_SHORT_5_5_5_1 */
  28408. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  28409. /** UNSIGNED_SHORT_5_6_5 */
  28410. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  28411. /** UNSIGNED_INT_2_10_10_10_REV */
  28412. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  28413. /** UNSIGNED_INT_24_8 */
  28414. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  28415. /** UNSIGNED_INT_10F_11F_11F_REV */
  28416. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  28417. /** UNSIGNED_INT_5_9_9_9_REV */
  28418. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  28419. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  28420. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  28421. /** nearest is mag = nearest and min = nearest and mip = linear */
  28422. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  28423. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28424. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  28425. /** Trilinear is mag = linear and min = linear and mip = linear */
  28426. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  28427. /** nearest is mag = nearest and min = nearest and mip = linear */
  28428. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  28429. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28430. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  28431. /** Trilinear is mag = linear and min = linear and mip = linear */
  28432. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  28433. /** mag = nearest and min = nearest and mip = nearest */
  28434. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  28435. /** mag = nearest and min = linear and mip = nearest */
  28436. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  28437. /** mag = nearest and min = linear and mip = linear */
  28438. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  28439. /** mag = nearest and min = linear and mip = none */
  28440. static readonly TEXTURE_NEAREST_LINEAR: number;
  28441. /** mag = nearest and min = nearest and mip = none */
  28442. static readonly TEXTURE_NEAREST_NEAREST: number;
  28443. /** mag = linear and min = nearest and mip = nearest */
  28444. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  28445. /** mag = linear and min = nearest and mip = linear */
  28446. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  28447. /** mag = linear and min = linear and mip = none */
  28448. static readonly TEXTURE_LINEAR_LINEAR: number;
  28449. /** mag = linear and min = nearest and mip = none */
  28450. static readonly TEXTURE_LINEAR_NEAREST: number;
  28451. /** Explicit coordinates mode */
  28452. static readonly TEXTURE_EXPLICIT_MODE: number;
  28453. /** Spherical coordinates mode */
  28454. static readonly TEXTURE_SPHERICAL_MODE: number;
  28455. /** Planar coordinates mode */
  28456. static readonly TEXTURE_PLANAR_MODE: number;
  28457. /** Cubic coordinates mode */
  28458. static readonly TEXTURE_CUBIC_MODE: number;
  28459. /** Projection coordinates mode */
  28460. static readonly TEXTURE_PROJECTION_MODE: number;
  28461. /** Skybox coordinates mode */
  28462. static readonly TEXTURE_SKYBOX_MODE: number;
  28463. /** Inverse Cubic coordinates mode */
  28464. static readonly TEXTURE_INVCUBIC_MODE: number;
  28465. /** Equirectangular coordinates mode */
  28466. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  28467. /** Equirectangular Fixed coordinates mode */
  28468. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  28469. /** Equirectangular Fixed Mirrored coordinates mode */
  28470. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  28471. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  28472. static readonly SCALEMODE_FLOOR: number;
  28473. /** Defines that texture rescaling will look for the nearest power of 2 size */
  28474. static readonly SCALEMODE_NEAREST: number;
  28475. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  28476. static readonly SCALEMODE_CEILING: number;
  28477. /**
  28478. * Returns the current npm package of the sdk
  28479. */
  28480. static readonly NpmPackage: string;
  28481. /**
  28482. * Returns the current version of the framework
  28483. */
  28484. static readonly Version: string;
  28485. /**
  28486. * Returns a string describing the current engine
  28487. */
  28488. readonly description: string;
  28489. /**
  28490. * Gets or sets the epsilon value used by collision engine
  28491. */
  28492. static CollisionsEpsilon: number;
  28493. /**
  28494. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28495. */
  28496. static ShadersRepository: string;
  28497. /**
  28498. * Method called to create the default loading screen.
  28499. * This can be overriden in your own app.
  28500. * @param canvas The rendering canvas element
  28501. * @returns The loading screen
  28502. */
  28503. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  28504. /**
  28505. * Method called to create the default rescale post process on each engine.
  28506. */
  28507. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  28508. /** @hidden */
  28509. _shaderProcessor: IShaderProcessor;
  28510. /**
  28511. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  28512. */
  28513. forcePOTTextures: boolean;
  28514. /**
  28515. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  28516. */
  28517. isFullscreen: boolean;
  28518. /**
  28519. * Gets a boolean indicating if the pointer is currently locked
  28520. */
  28521. isPointerLock: boolean;
  28522. /**
  28523. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  28524. */
  28525. cullBackFaces: boolean;
  28526. /**
  28527. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  28528. */
  28529. renderEvenInBackground: boolean;
  28530. /**
  28531. * Gets or sets a boolean indicating that cache can be kept between frames
  28532. */
  28533. preventCacheWipeBetweenFrames: boolean;
  28534. /**
  28535. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  28536. **/
  28537. enableOfflineSupport: boolean;
  28538. /**
  28539. * 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)
  28540. **/
  28541. disableManifestCheck: boolean;
  28542. /**
  28543. * Gets the list of created scenes
  28544. */
  28545. scenes: Scene[];
  28546. /**
  28547. * Event raised when a new scene is created
  28548. */
  28549. onNewSceneAddedObservable: Observable<Scene>;
  28550. /**
  28551. * Gets the list of created postprocesses
  28552. */
  28553. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  28554. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  28555. validateShaderPrograms: boolean;
  28556. /**
  28557. * Observable event triggered each time the rendering canvas is resized
  28558. */
  28559. onResizeObservable: Observable<Engine>;
  28560. /**
  28561. * Observable event triggered each time the canvas loses focus
  28562. */
  28563. onCanvasBlurObservable: Observable<Engine>;
  28564. /**
  28565. * Observable event triggered each time the canvas gains focus
  28566. */
  28567. onCanvasFocusObservable: Observable<Engine>;
  28568. /**
  28569. * Observable event triggered each time the canvas receives pointerout event
  28570. */
  28571. onCanvasPointerOutObservable: Observable<PointerEvent>;
  28572. /**
  28573. * Observable event triggered before each texture is initialized
  28574. */
  28575. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  28576. /**
  28577. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  28578. */
  28579. disableUniformBuffers: boolean;
  28580. /** @hidden */
  28581. _uniformBuffers: UniformBuffer[];
  28582. /**
  28583. * Gets a boolean indicating that the engine supports uniform buffers
  28584. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28585. */
  28586. readonly supportsUniformBuffers: boolean;
  28587. /**
  28588. * Observable raised when the engine begins a new frame
  28589. */
  28590. onBeginFrameObservable: Observable<Engine>;
  28591. /**
  28592. * If set, will be used to request the next animation frame for the render loop
  28593. */
  28594. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  28595. /**
  28596. * Observable raised when the engine ends the current frame
  28597. */
  28598. onEndFrameObservable: Observable<Engine>;
  28599. /**
  28600. * Observable raised when the engine is about to compile a shader
  28601. */
  28602. onBeforeShaderCompilationObservable: Observable<Engine>;
  28603. /**
  28604. * Observable raised when the engine has jsut compiled a shader
  28605. */
  28606. onAfterShaderCompilationObservable: Observable<Engine>;
  28607. /** @hidden */
  28608. _gl: WebGLRenderingContext;
  28609. private _renderingCanvas;
  28610. private _windowIsBackground;
  28611. private _webGLVersion;
  28612. protected _highPrecisionShadersAllowed: boolean;
  28613. /** @hidden */
  28614. readonly _shouldUseHighPrecisionShader: boolean;
  28615. /**
  28616. * Gets a boolean indicating that only power of 2 textures are supported
  28617. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  28618. */
  28619. readonly needPOTTextures: boolean;
  28620. /** @hidden */
  28621. _badOS: boolean;
  28622. /** @hidden */
  28623. _badDesktopOS: boolean;
  28624. /**
  28625. * Gets the audio engine
  28626. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28627. * @ignorenaming
  28628. */
  28629. static audioEngine: IAudioEngine;
  28630. /**
  28631. * Default AudioEngine factory responsible of creating the Audio Engine.
  28632. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  28633. */
  28634. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  28635. /**
  28636. * Default offline support factory responsible of creating a tool used to store data locally.
  28637. * By default, this will create a Database object if the workload has been embedded.
  28638. */
  28639. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  28640. private _onFocus;
  28641. private _onBlur;
  28642. private _onCanvasPointerOut;
  28643. private _onCanvasBlur;
  28644. private _onCanvasFocus;
  28645. private _onFullscreenChange;
  28646. private _onPointerLockChange;
  28647. private _hardwareScalingLevel;
  28648. /** @hidden */
  28649. _caps: EngineCapabilities;
  28650. private _pointerLockRequested;
  28651. private _isStencilEnable;
  28652. private _colorWrite;
  28653. private _loadingScreen;
  28654. /** @hidden */
  28655. _drawCalls: PerfCounter;
  28656. private _glVersion;
  28657. private _glRenderer;
  28658. private _glVendor;
  28659. private _videoTextureSupported;
  28660. private _renderingQueueLaunched;
  28661. private _activeRenderLoops;
  28662. private _deterministicLockstep;
  28663. private _lockstepMaxSteps;
  28664. /**
  28665. * Observable signaled when a context lost event is raised
  28666. */
  28667. onContextLostObservable: Observable<Engine>;
  28668. /**
  28669. * Observable signaled when a context restored event is raised
  28670. */
  28671. onContextRestoredObservable: Observable<Engine>;
  28672. private _onContextLost;
  28673. private _onContextRestored;
  28674. private _contextWasLost;
  28675. /** @hidden */
  28676. _doNotHandleContextLost: boolean;
  28677. /**
  28678. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  28679. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  28680. */
  28681. doNotHandleContextLost: boolean;
  28682. private _performanceMonitor;
  28683. private _fps;
  28684. private _deltaTime;
  28685. /**
  28686. * Turn this value on if you want to pause FPS computation when in background
  28687. */
  28688. disablePerformanceMonitorInBackground: boolean;
  28689. /**
  28690. * Gets the performance monitor attached to this engine
  28691. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  28692. */
  28693. readonly performanceMonitor: PerformanceMonitor;
  28694. /**
  28695. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  28696. */
  28697. disableVertexArrayObjects: boolean;
  28698. /** @hidden */
  28699. protected _depthCullingState: _DepthCullingState;
  28700. /** @hidden */
  28701. protected _stencilState: _StencilState;
  28702. /** @hidden */
  28703. protected _alphaState: _AlphaState;
  28704. /** @hidden */
  28705. protected _alphaMode: number;
  28706. /** @hidden */
  28707. _internalTexturesCache: InternalTexture[];
  28708. /** @hidden */
  28709. protected _activeChannel: number;
  28710. private _currentTextureChannel;
  28711. /** @hidden */
  28712. protected _boundTexturesCache: {
  28713. [key: string]: Nullable<InternalTexture>;
  28714. };
  28715. /** @hidden */
  28716. protected _currentEffect: Nullable<Effect>;
  28717. /** @hidden */
  28718. protected _currentProgram: Nullable<WebGLProgram>;
  28719. private _compiledEffects;
  28720. private _vertexAttribArraysEnabled;
  28721. /** @hidden */
  28722. protected _cachedViewport: Nullable<Viewport>;
  28723. private _cachedVertexArrayObject;
  28724. /** @hidden */
  28725. protected _cachedVertexBuffers: any;
  28726. /** @hidden */
  28727. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  28728. /** @hidden */
  28729. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  28730. /** @hidden */
  28731. _currentRenderTarget: Nullable<InternalTexture>;
  28732. private _uintIndicesCurrentlySet;
  28733. private _currentBoundBuffer;
  28734. /** @hidden */
  28735. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  28736. private _currentBufferPointers;
  28737. private _currentInstanceLocations;
  28738. private _currentInstanceBuffers;
  28739. private _textureUnits;
  28740. /** @hidden */
  28741. _workingCanvas: Nullable<HTMLCanvasElement>;
  28742. /** @hidden */
  28743. _workingContext: Nullable<CanvasRenderingContext2D>;
  28744. private _rescalePostProcess;
  28745. private _dummyFramebuffer;
  28746. private _externalData;
  28747. /** @hidden */
  28748. _bindedRenderFunction: any;
  28749. private _vaoRecordInProgress;
  28750. private _mustWipeVertexAttributes;
  28751. private _emptyTexture;
  28752. private _emptyCubeTexture;
  28753. private _emptyTexture3D;
  28754. /** @hidden */
  28755. _frameHandler: number;
  28756. private _nextFreeTextureSlots;
  28757. private _maxSimultaneousTextures;
  28758. private _activeRequests;
  28759. private _texturesSupported;
  28760. /** @hidden */
  28761. _textureFormatInUse: Nullable<string>;
  28762. /**
  28763. * Gets the list of texture formats supported
  28764. */
  28765. readonly texturesSupported: Array<string>;
  28766. /**
  28767. * Gets the list of texture formats in use
  28768. */
  28769. readonly textureFormatInUse: Nullable<string>;
  28770. /**
  28771. * Gets the current viewport
  28772. */
  28773. readonly currentViewport: Nullable<Viewport>;
  28774. /**
  28775. * Gets the default empty texture
  28776. */
  28777. readonly emptyTexture: InternalTexture;
  28778. /**
  28779. * Gets the default empty 3D texture
  28780. */
  28781. readonly emptyTexture3D: InternalTexture;
  28782. /**
  28783. * Gets the default empty cube texture
  28784. */
  28785. readonly emptyCubeTexture: InternalTexture;
  28786. /**
  28787. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  28788. */
  28789. readonly premultipliedAlpha: boolean;
  28790. /**
  28791. * Creates a new engine
  28792. * @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
  28793. * @param antialias defines enable antialiasing (default: false)
  28794. * @param options defines further options to be sent to the getContext() function
  28795. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  28796. */
  28797. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  28798. /**
  28799. * Initializes a webVR display and starts listening to display change events
  28800. * The onVRDisplayChangedObservable will be notified upon these changes
  28801. * @returns The onVRDisplayChangedObservable
  28802. */
  28803. initWebVR(): Observable<IDisplayChangedEventArgs>;
  28804. /** @hidden */
  28805. _prepareVRComponent(): void;
  28806. /** @hidden */
  28807. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  28808. /** @hidden */
  28809. _submitVRFrame(): void;
  28810. /**
  28811. * Call this function to leave webVR mode
  28812. * Will do nothing if webVR is not supported or if there is no webVR device
  28813. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28814. */
  28815. disableVR(): void;
  28816. /**
  28817. * Gets a boolean indicating that the system is in VR mode and is presenting
  28818. * @returns true if VR mode is engaged
  28819. */
  28820. isVRPresenting(): boolean;
  28821. /** @hidden */
  28822. _requestVRFrame(): void;
  28823. private _disableTouchAction;
  28824. private _rebuildInternalTextures;
  28825. private _rebuildEffects;
  28826. /**
  28827. * Gets a boolean indicating if all created effects are ready
  28828. * @returns true if all effects are ready
  28829. */
  28830. areAllEffectsReady(): boolean;
  28831. private _rebuildBuffers;
  28832. private _initGLContext;
  28833. /**
  28834. * Gets version of the current webGL context
  28835. */
  28836. readonly webGLVersion: number;
  28837. /**
  28838. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  28839. */
  28840. readonly isStencilEnable: boolean;
  28841. /** @hidden */
  28842. _prepareWorkingCanvas(): void;
  28843. /**
  28844. * Reset the texture cache to empty state
  28845. */
  28846. resetTextureCache(): void;
  28847. /**
  28848. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  28849. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28850. * @returns true if engine is in deterministic lock step mode
  28851. */
  28852. isDeterministicLockStep(): boolean;
  28853. /**
  28854. * Gets the max steps when engine is running in deterministic lock step
  28855. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28856. * @returns the max steps
  28857. */
  28858. getLockstepMaxSteps(): number;
  28859. /**
  28860. * Gets an object containing information about the current webGL context
  28861. * @returns an object containing the vender, the renderer and the version of the current webGL context
  28862. */
  28863. getGlInfo(): {
  28864. vendor: string;
  28865. renderer: string;
  28866. version: string;
  28867. };
  28868. /**
  28869. * Gets current aspect ratio
  28870. * @param camera defines the camera to use to get the aspect ratio
  28871. * @param useScreen defines if screen size must be used (or the current render target if any)
  28872. * @returns a number defining the aspect ratio
  28873. */
  28874. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  28875. /**
  28876. * Gets current screen aspect ratio
  28877. * @returns a number defining the aspect ratio
  28878. */
  28879. getScreenAspectRatio(): number;
  28880. /**
  28881. * Gets the current render width
  28882. * @param useScreen defines if screen size must be used (or the current render target if any)
  28883. * @returns a number defining the current render width
  28884. */
  28885. getRenderWidth(useScreen?: boolean): number;
  28886. /**
  28887. * Gets the current render height
  28888. * @param useScreen defines if screen size must be used (or the current render target if any)
  28889. * @returns a number defining the current render height
  28890. */
  28891. getRenderHeight(useScreen?: boolean): number;
  28892. /**
  28893. * Gets the HTML canvas attached with the current webGL context
  28894. * @returns a HTML canvas
  28895. */
  28896. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  28897. /**
  28898. * Gets the client rect of the HTML canvas attached with the current webGL context
  28899. * @returns a client rectanglee
  28900. */
  28901. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  28902. /**
  28903. * Defines the hardware scaling level.
  28904. * By default the hardware scaling level is computed from the window device ratio.
  28905. * 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.
  28906. * @param level defines the level to use
  28907. */
  28908. setHardwareScalingLevel(level: number): void;
  28909. /**
  28910. * Gets the current hardware scaling level.
  28911. * By default the hardware scaling level is computed from the window device ratio.
  28912. * 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.
  28913. * @returns a number indicating the current hardware scaling level
  28914. */
  28915. getHardwareScalingLevel(): number;
  28916. /**
  28917. * Gets the list of loaded textures
  28918. * @returns an array containing all loaded textures
  28919. */
  28920. getLoadedTexturesCache(): InternalTexture[];
  28921. /**
  28922. * Gets the object containing all engine capabilities
  28923. * @returns the EngineCapabilities object
  28924. */
  28925. getCaps(): EngineCapabilities;
  28926. /**
  28927. * Gets the current depth function
  28928. * @returns a number defining the depth function
  28929. */
  28930. getDepthFunction(): Nullable<number>;
  28931. /**
  28932. * Sets the current depth function
  28933. * @param depthFunc defines the function to use
  28934. */
  28935. setDepthFunction(depthFunc: number): void;
  28936. /**
  28937. * Sets the current depth function to GREATER
  28938. */
  28939. setDepthFunctionToGreater(): void;
  28940. /**
  28941. * Sets the current depth function to GEQUAL
  28942. */
  28943. setDepthFunctionToGreaterOrEqual(): void;
  28944. /**
  28945. * Sets the current depth function to LESS
  28946. */
  28947. setDepthFunctionToLess(): void;
  28948. private _cachedStencilBuffer;
  28949. private _cachedStencilFunction;
  28950. private _cachedStencilMask;
  28951. private _cachedStencilOperationPass;
  28952. private _cachedStencilOperationFail;
  28953. private _cachedStencilOperationDepthFail;
  28954. private _cachedStencilReference;
  28955. /**
  28956. * Caches the the state of the stencil buffer
  28957. */
  28958. cacheStencilState(): void;
  28959. /**
  28960. * Restores the state of the stencil buffer
  28961. */
  28962. restoreStencilState(): void;
  28963. /**
  28964. * Sets the current depth function to LEQUAL
  28965. */
  28966. setDepthFunctionToLessOrEqual(): void;
  28967. /**
  28968. * Gets a boolean indicating if stencil buffer is enabled
  28969. * @returns the current stencil buffer state
  28970. */
  28971. getStencilBuffer(): boolean;
  28972. /**
  28973. * Enable or disable the stencil buffer
  28974. * @param enable defines if the stencil buffer must be enabled or disabled
  28975. */
  28976. setStencilBuffer(enable: boolean): void;
  28977. /**
  28978. * Gets the current stencil mask
  28979. * @returns a number defining the new stencil mask to use
  28980. */
  28981. getStencilMask(): number;
  28982. /**
  28983. * Sets the current stencil mask
  28984. * @param mask defines the new stencil mask to use
  28985. */
  28986. setStencilMask(mask: number): void;
  28987. /**
  28988. * Gets the current stencil function
  28989. * @returns a number defining the stencil function to use
  28990. */
  28991. getStencilFunction(): number;
  28992. /**
  28993. * Gets the current stencil reference value
  28994. * @returns a number defining the stencil reference value to use
  28995. */
  28996. getStencilFunctionReference(): number;
  28997. /**
  28998. * Gets the current stencil mask
  28999. * @returns a number defining the stencil mask to use
  29000. */
  29001. getStencilFunctionMask(): number;
  29002. /**
  29003. * Sets the current stencil function
  29004. * @param stencilFunc defines the new stencil function to use
  29005. */
  29006. setStencilFunction(stencilFunc: number): void;
  29007. /**
  29008. * Sets the current stencil reference
  29009. * @param reference defines the new stencil reference to use
  29010. */
  29011. setStencilFunctionReference(reference: number): void;
  29012. /**
  29013. * Sets the current stencil mask
  29014. * @param mask defines the new stencil mask to use
  29015. */
  29016. setStencilFunctionMask(mask: number): void;
  29017. /**
  29018. * Gets the current stencil operation when stencil fails
  29019. * @returns a number defining stencil operation to use when stencil fails
  29020. */
  29021. getStencilOperationFail(): number;
  29022. /**
  29023. * Gets the current stencil operation when depth fails
  29024. * @returns a number defining stencil operation to use when depth fails
  29025. */
  29026. getStencilOperationDepthFail(): number;
  29027. /**
  29028. * Gets the current stencil operation when stencil passes
  29029. * @returns a number defining stencil operation to use when stencil passes
  29030. */
  29031. getStencilOperationPass(): number;
  29032. /**
  29033. * Sets the stencil operation to use when stencil fails
  29034. * @param operation defines the stencil operation to use when stencil fails
  29035. */
  29036. setStencilOperationFail(operation: number): void;
  29037. /**
  29038. * Sets the stencil operation to use when depth fails
  29039. * @param operation defines the stencil operation to use when depth fails
  29040. */
  29041. setStencilOperationDepthFail(operation: number): void;
  29042. /**
  29043. * Sets the stencil operation to use when stencil passes
  29044. * @param operation defines the stencil operation to use when stencil passes
  29045. */
  29046. setStencilOperationPass(operation: number): void;
  29047. /**
  29048. * Sets a boolean indicating if the dithering state is enabled or disabled
  29049. * @param value defines the dithering state
  29050. */
  29051. setDitheringState(value: boolean): void;
  29052. /**
  29053. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  29054. * @param value defines the rasterizer state
  29055. */
  29056. setRasterizerState(value: boolean): void;
  29057. /**
  29058. * stop executing a render loop function and remove it from the execution array
  29059. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  29060. */
  29061. stopRenderLoop(renderFunction?: () => void): void;
  29062. /** @hidden */
  29063. _renderLoop(): void;
  29064. /**
  29065. * Register and execute a render loop. The engine can have more than one render function
  29066. * @param renderFunction defines the function to continuously execute
  29067. */
  29068. runRenderLoop(renderFunction: () => void): void;
  29069. /**
  29070. * Toggle full screen mode
  29071. * @param requestPointerLock defines if a pointer lock should be requested from the user
  29072. */
  29073. switchFullscreen(requestPointerLock: boolean): void;
  29074. /**
  29075. * Enters full screen mode
  29076. * @param requestPointerLock defines if a pointer lock should be requested from the user
  29077. */
  29078. enterFullscreen(requestPointerLock: boolean): void;
  29079. /**
  29080. * Exits full screen mode
  29081. */
  29082. exitFullscreen(): void;
  29083. /**
  29084. * Enters Pointerlock mode
  29085. */
  29086. enterPointerlock(): void;
  29087. /**
  29088. * Exits Pointerlock mode
  29089. */
  29090. exitPointerlock(): void;
  29091. /**
  29092. * Clear the current render buffer or the current render target (if any is set up)
  29093. * @param color defines the color to use
  29094. * @param backBuffer defines if the back buffer must be cleared
  29095. * @param depth defines if the depth buffer must be cleared
  29096. * @param stencil defines if the stencil buffer must be cleared
  29097. */
  29098. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  29099. /**
  29100. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  29101. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  29102. * @param y defines the y-coordinate of the corner of the clear rectangle
  29103. * @param width defines the width of the clear rectangle
  29104. * @param height defines the height of the clear rectangle
  29105. * @param clearColor defines the clear color
  29106. */
  29107. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  29108. /**
  29109. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  29110. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  29111. * @param y defines the y-coordinate of the corner of the clear rectangle
  29112. * @param width defines the width of the clear rectangle
  29113. * @param height defines the height of the clear rectangle
  29114. */
  29115. enableScissor(x: number, y: number, width: number, height: number): void;
  29116. /**
  29117. * Disable previously set scissor test rectangle
  29118. */
  29119. disableScissor(): void;
  29120. private _viewportCached;
  29121. /** @hidden */
  29122. _viewport(x: number, y: number, width: number, height: number): void;
  29123. /**
  29124. * Set the WebGL's viewport
  29125. * @param viewport defines the viewport element to be used
  29126. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  29127. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  29128. */
  29129. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  29130. /**
  29131. * Directly set the WebGL Viewport
  29132. * @param x defines the x coordinate of the viewport (in screen space)
  29133. * @param y defines the y coordinate of the viewport (in screen space)
  29134. * @param width defines the width of the viewport (in screen space)
  29135. * @param height defines the height of the viewport (in screen space)
  29136. * @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
  29137. */
  29138. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  29139. /**
  29140. * Begin a new frame
  29141. */
  29142. beginFrame(): void;
  29143. /**
  29144. * Enf the current frame
  29145. */
  29146. endFrame(): void;
  29147. /**
  29148. * Resize the view according to the canvas' size
  29149. */
  29150. resize(): void;
  29151. /**
  29152. * Force a specific size of the canvas
  29153. * @param width defines the new canvas' width
  29154. * @param height defines the new canvas' height
  29155. */
  29156. setSize(width: number, height: number): void;
  29157. /**
  29158. * Binds the frame buffer to the specified texture.
  29159. * @param texture The texture to render to or null for the default canvas
  29160. * @param faceIndex The face of the texture to render to in case of cube texture
  29161. * @param requiredWidth The width of the target to render to
  29162. * @param requiredHeight The height of the target to render to
  29163. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  29164. * @param depthStencilTexture The depth stencil texture to use to render
  29165. * @param lodLevel defines le lod level to bind to the frame buffer
  29166. */
  29167. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  29168. /** @hidden */
  29169. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  29170. /**
  29171. * Unbind the current render target texture from the webGL context
  29172. * @param texture defines the render target texture to unbind
  29173. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  29174. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  29175. */
  29176. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  29177. /**
  29178. * Force the mipmap generation for the given render target texture
  29179. * @param texture defines the render target texture to use
  29180. */
  29181. generateMipMapsForCubemap(texture: InternalTexture): void;
  29182. /**
  29183. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  29184. */
  29185. flushFramebuffer(): void;
  29186. /**
  29187. * Unbind the current render target and bind the default framebuffer
  29188. */
  29189. restoreDefaultFramebuffer(): void;
  29190. /**
  29191. * Create an uniform buffer
  29192. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29193. * @param elements defines the content of the uniform buffer
  29194. * @returns the webGL uniform buffer
  29195. */
  29196. createUniformBuffer(elements: FloatArray): DataBuffer;
  29197. /**
  29198. * Create a dynamic uniform buffer
  29199. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29200. * @param elements defines the content of the uniform buffer
  29201. * @returns the webGL uniform buffer
  29202. */
  29203. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  29204. /**
  29205. * Update an existing uniform buffer
  29206. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29207. * @param uniformBuffer defines the target uniform buffer
  29208. * @param elements defines the content to update
  29209. * @param offset defines the offset in the uniform buffer where update should start
  29210. * @param count defines the size of the data to update
  29211. */
  29212. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  29213. private _resetVertexBufferBinding;
  29214. /**
  29215. * Creates a vertex buffer
  29216. * @param data the data for the vertex buffer
  29217. * @returns the new WebGL static buffer
  29218. */
  29219. createVertexBuffer(data: DataArray): DataBuffer;
  29220. /**
  29221. * Creates a dynamic vertex buffer
  29222. * @param data the data for the dynamic vertex buffer
  29223. * @returns the new WebGL dynamic buffer
  29224. */
  29225. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  29226. /**
  29227. * Update a dynamic index buffer
  29228. * @param indexBuffer defines the target index buffer
  29229. * @param indices defines the data to update
  29230. * @param offset defines the offset in the target index buffer where update should start
  29231. */
  29232. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  29233. /**
  29234. * Updates a dynamic vertex buffer.
  29235. * @param vertexBuffer the vertex buffer to update
  29236. * @param data the data used to update the vertex buffer
  29237. * @param byteOffset the byte offset of the data
  29238. * @param byteLength the byte length of the data
  29239. */
  29240. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  29241. private _resetIndexBufferBinding;
  29242. /**
  29243. * Creates a new index buffer
  29244. * @param indices defines the content of the index buffer
  29245. * @param updatable defines if the index buffer must be updatable
  29246. * @returns a new webGL buffer
  29247. */
  29248. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  29249. /**
  29250. * Bind a webGL buffer to the webGL context
  29251. * @param buffer defines the buffer to bind
  29252. */
  29253. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  29254. /**
  29255. * Bind an uniform buffer to the current webGL context
  29256. * @param buffer defines the buffer to bind
  29257. */
  29258. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  29259. /**
  29260. * Bind a buffer to the current webGL context at a given location
  29261. * @param buffer defines the buffer to bind
  29262. * @param location defines the index where to bind the buffer
  29263. */
  29264. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  29265. /**
  29266. * Bind a specific block at a given index in a specific shader program
  29267. * @param pipelineContext defines the pipeline context to use
  29268. * @param blockName defines the block name
  29269. * @param index defines the index where to bind the block
  29270. */
  29271. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  29272. private bindIndexBuffer;
  29273. private bindBuffer;
  29274. /**
  29275. * update the bound buffer with the given data
  29276. * @param data defines the data to update
  29277. */
  29278. updateArrayBuffer(data: Float32Array): void;
  29279. private _vertexAttribPointer;
  29280. private _bindIndexBufferWithCache;
  29281. private _bindVertexBuffersAttributes;
  29282. /**
  29283. * Records a vertex array object
  29284. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29285. * @param vertexBuffers defines the list of vertex buffers to store
  29286. * @param indexBuffer defines the index buffer to store
  29287. * @param effect defines the effect to store
  29288. * @returns the new vertex array object
  29289. */
  29290. recordVertexArrayObject(vertexBuffers: {
  29291. [key: string]: VertexBuffer;
  29292. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  29293. /**
  29294. * Bind a specific vertex array object
  29295. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29296. * @param vertexArrayObject defines the vertex array object to bind
  29297. * @param indexBuffer defines the index buffer to bind
  29298. */
  29299. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  29300. /**
  29301. * Bind webGl buffers directly to the webGL context
  29302. * @param vertexBuffer defines the vertex buffer to bind
  29303. * @param indexBuffer defines the index buffer to bind
  29304. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  29305. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  29306. * @param effect defines the effect associated with the vertex buffer
  29307. */
  29308. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  29309. private _unbindVertexArrayObject;
  29310. /**
  29311. * Bind a list of vertex buffers to the webGL context
  29312. * @param vertexBuffers defines the list of vertex buffers to bind
  29313. * @param indexBuffer defines the index buffer to bind
  29314. * @param effect defines the effect associated with the vertex buffers
  29315. */
  29316. bindBuffers(vertexBuffers: {
  29317. [key: string]: Nullable<VertexBuffer>;
  29318. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  29319. /**
  29320. * Unbind all instance attributes
  29321. */
  29322. unbindInstanceAttributes(): void;
  29323. /**
  29324. * Release and free the memory of a vertex array object
  29325. * @param vao defines the vertex array object to delete
  29326. */
  29327. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  29328. /** @hidden */
  29329. _releaseBuffer(buffer: DataBuffer): boolean;
  29330. /**
  29331. * Creates a webGL buffer to use with instanciation
  29332. * @param capacity defines the size of the buffer
  29333. * @returns the webGL buffer
  29334. */
  29335. createInstancesBuffer(capacity: number): DataBuffer;
  29336. /**
  29337. * Delete a webGL buffer used with instanciation
  29338. * @param buffer defines the webGL buffer to delete
  29339. */
  29340. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  29341. /**
  29342. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  29343. * @param instancesBuffer defines the webGL buffer to update and bind
  29344. * @param data defines the data to store in the buffer
  29345. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  29346. */
  29347. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  29348. /**
  29349. * Apply all cached states (depth, culling, stencil and alpha)
  29350. */
  29351. applyStates(): void;
  29352. /**
  29353. * Send a draw order
  29354. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29355. * @param indexStart defines the starting index
  29356. * @param indexCount defines the number of index to draw
  29357. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29358. */
  29359. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  29360. /**
  29361. * Draw a list of points
  29362. * @param verticesStart defines the index of first vertex to draw
  29363. * @param verticesCount defines the count of vertices to draw
  29364. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29365. */
  29366. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29367. /**
  29368. * Draw a list of unindexed primitives
  29369. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29370. * @param verticesStart defines the index of first vertex to draw
  29371. * @param verticesCount defines the count of vertices to draw
  29372. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29373. */
  29374. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29375. /**
  29376. * Draw a list of indexed primitives
  29377. * @param fillMode defines the primitive to use
  29378. * @param indexStart defines the starting index
  29379. * @param indexCount defines the number of index to draw
  29380. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29381. */
  29382. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  29383. /**
  29384. * Draw a list of unindexed primitives
  29385. * @param fillMode defines the primitive to use
  29386. * @param verticesStart defines the index of first vertex to draw
  29387. * @param verticesCount defines the count of vertices to draw
  29388. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29389. */
  29390. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29391. private _drawMode;
  29392. /** @hidden */
  29393. _releaseEffect(effect: Effect): void;
  29394. /** @hidden */
  29395. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  29396. /**
  29397. * Create a new effect (used to store vertex/fragment shaders)
  29398. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  29399. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  29400. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  29401. * @param samplers defines an array of string used to represent textures
  29402. * @param defines defines the string containing the defines to use to compile the shaders
  29403. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  29404. * @param onCompiled defines a function to call when the effect creation is successful
  29405. * @param onError defines a function to call when the effect creation has failed
  29406. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  29407. * @returns the new Effect
  29408. */
  29409. 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;
  29410. private _compileShader;
  29411. private _compileRawShader;
  29412. /**
  29413. * Directly creates a webGL program
  29414. * @param pipelineContext defines the pipeline context to attach to
  29415. * @param vertexCode defines the vertex shader code to use
  29416. * @param fragmentCode defines the fragment shader code to use
  29417. * @param context defines the webGL context to use (if not set, the current one will be used)
  29418. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29419. * @returns the new webGL program
  29420. */
  29421. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29422. /**
  29423. * Creates a webGL program
  29424. * @param pipelineContext defines the pipeline context to attach to
  29425. * @param vertexCode defines the vertex shader code to use
  29426. * @param fragmentCode defines the fragment shader code to use
  29427. * @param defines defines the string containing the defines to use to compile the shaders
  29428. * @param context defines the webGL context to use (if not set, the current one will be used)
  29429. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29430. * @returns the new webGL program
  29431. */
  29432. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29433. /**
  29434. * Creates a new pipeline context
  29435. * @returns the new pipeline
  29436. */
  29437. createPipelineContext(): WebGLPipelineContext;
  29438. private _createShaderProgram;
  29439. private _finalizePipelineContext;
  29440. /** @hidden */
  29441. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  29442. /** @hidden */
  29443. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  29444. /** @hidden */
  29445. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  29446. /**
  29447. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  29448. * @param pipelineContext defines the pipeline context to use
  29449. * @param uniformsNames defines the list of uniform names
  29450. * @returns an array of webGL uniform locations
  29451. */
  29452. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  29453. /**
  29454. * Gets the lsit of active attributes for a given webGL program
  29455. * @param pipelineContext defines the pipeline context to use
  29456. * @param attributesNames defines the list of attribute names to get
  29457. * @returns an array of indices indicating the offset of each attribute
  29458. */
  29459. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  29460. /**
  29461. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  29462. * @param effect defines the effect to activate
  29463. */
  29464. enableEffect(effect: Nullable<Effect>): void;
  29465. /**
  29466. * Set the value of an uniform to an array of int32
  29467. * @param uniform defines the webGL uniform location where to store the value
  29468. * @param array defines the array of int32 to store
  29469. */
  29470. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29471. /**
  29472. * Set the value of an uniform to an array of int32 (stored as vec2)
  29473. * @param uniform defines the webGL uniform location where to store the value
  29474. * @param array defines the array of int32 to store
  29475. */
  29476. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29477. /**
  29478. * Set the value of an uniform to an array of int32 (stored as vec3)
  29479. * @param uniform defines the webGL uniform location where to store the value
  29480. * @param array defines the array of int32 to store
  29481. */
  29482. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29483. /**
  29484. * Set the value of an uniform to an array of int32 (stored as vec4)
  29485. * @param uniform defines the webGL uniform location where to store the value
  29486. * @param array defines the array of int32 to store
  29487. */
  29488. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29489. /**
  29490. * Set the value of an uniform to an array of float32
  29491. * @param uniform defines the webGL uniform location where to store the value
  29492. * @param array defines the array of float32 to store
  29493. */
  29494. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29495. /**
  29496. * Set the value of an uniform to an array of float32 (stored as vec2)
  29497. * @param uniform defines the webGL uniform location where to store the value
  29498. * @param array defines the array of float32 to store
  29499. */
  29500. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29501. /**
  29502. * Set the value of an uniform to an array of float32 (stored as vec3)
  29503. * @param uniform defines the webGL uniform location where to store the value
  29504. * @param array defines the array of float32 to store
  29505. */
  29506. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29507. /**
  29508. * Set the value of an uniform to an array of float32 (stored as vec4)
  29509. * @param uniform defines the webGL uniform location where to store the value
  29510. * @param array defines the array of float32 to store
  29511. */
  29512. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29513. /**
  29514. * Set the value of an uniform to an array of number
  29515. * @param uniform defines the webGL uniform location where to store the value
  29516. * @param array defines the array of number to store
  29517. */
  29518. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29519. /**
  29520. * Set the value of an uniform to an array of number (stored as vec2)
  29521. * @param uniform defines the webGL uniform location where to store the value
  29522. * @param array defines the array of number to store
  29523. */
  29524. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29525. /**
  29526. * Set the value of an uniform to an array of number (stored as vec3)
  29527. * @param uniform defines the webGL uniform location where to store the value
  29528. * @param array defines the array of number to store
  29529. */
  29530. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29531. /**
  29532. * Set the value of an uniform to an array of number (stored as vec4)
  29533. * @param uniform defines the webGL uniform location where to store the value
  29534. * @param array defines the array of number to store
  29535. */
  29536. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29537. /**
  29538. * Set the value of an uniform to an array of float32 (stored as matrices)
  29539. * @param uniform defines the webGL uniform location where to store the value
  29540. * @param matrices defines the array of float32 to store
  29541. */
  29542. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  29543. /**
  29544. * Set the value of an uniform to a matrix
  29545. * @param uniform defines the webGL uniform location where to store the value
  29546. * @param matrix defines the matrix to store
  29547. */
  29548. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  29549. /**
  29550. * Set the value of an uniform to a matrix (3x3)
  29551. * @param uniform defines the webGL uniform location where to store the value
  29552. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  29553. */
  29554. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29555. /**
  29556. * Set the value of an uniform to a matrix (2x2)
  29557. * @param uniform defines the webGL uniform location where to store the value
  29558. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  29559. */
  29560. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29561. /**
  29562. * Set the value of an uniform to a number (int)
  29563. * @param uniform defines the webGL uniform location where to store the value
  29564. * @param value defines the int number to store
  29565. */
  29566. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29567. /**
  29568. * Set the value of an uniform to a number (float)
  29569. * @param uniform defines the webGL uniform location where to store the value
  29570. * @param value defines the float number to store
  29571. */
  29572. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29573. /**
  29574. * Set the value of an uniform to a vec2
  29575. * @param uniform defines the webGL uniform location where to store the value
  29576. * @param x defines the 1st component of the value
  29577. * @param y defines the 2nd component of the value
  29578. */
  29579. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  29580. /**
  29581. * Set the value of an uniform to a vec3
  29582. * @param uniform defines the webGL uniform location where to store the value
  29583. * @param x defines the 1st component of the value
  29584. * @param y defines the 2nd component of the value
  29585. * @param z defines the 3rd component of the value
  29586. */
  29587. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  29588. /**
  29589. * Set the value of an uniform to a boolean
  29590. * @param uniform defines the webGL uniform location where to store the value
  29591. * @param bool defines the boolean to store
  29592. */
  29593. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  29594. /**
  29595. * Set the value of an uniform to a vec4
  29596. * @param uniform defines the webGL uniform location where to store the value
  29597. * @param x defines the 1st component of the value
  29598. * @param y defines the 2nd component of the value
  29599. * @param z defines the 3rd component of the value
  29600. * @param w defines the 4th component of the value
  29601. */
  29602. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  29603. /**
  29604. * Set the value of an uniform to a Color3
  29605. * @param uniform defines the webGL uniform location where to store the value
  29606. * @param color3 defines the color to store
  29607. */
  29608. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  29609. /**
  29610. * Set the value of an uniform to a Color3 and an alpha value
  29611. * @param uniform defines the webGL uniform location where to store the value
  29612. * @param color3 defines the color to store
  29613. * @param alpha defines the alpha component to store
  29614. */
  29615. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  29616. /**
  29617. * Sets a Color4 on a uniform variable
  29618. * @param uniform defines the uniform location
  29619. * @param color4 defines the value to be set
  29620. */
  29621. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  29622. /**
  29623. * Set various states to the webGL context
  29624. * @param culling defines backface culling state
  29625. * @param zOffset defines the value to apply to zOffset (0 by default)
  29626. * @param force defines if states must be applied even if cache is up to date
  29627. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  29628. */
  29629. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  29630. /**
  29631. * Set the z offset to apply to current rendering
  29632. * @param value defines the offset to apply
  29633. */
  29634. setZOffset(value: number): void;
  29635. /**
  29636. * Gets the current value of the zOffset
  29637. * @returns the current zOffset state
  29638. */
  29639. getZOffset(): number;
  29640. /**
  29641. * Enable or disable depth buffering
  29642. * @param enable defines the state to set
  29643. */
  29644. setDepthBuffer(enable: boolean): void;
  29645. /**
  29646. * Gets a boolean indicating if depth writing is enabled
  29647. * @returns the current depth writing state
  29648. */
  29649. getDepthWrite(): boolean;
  29650. /**
  29651. * Enable or disable depth writing
  29652. * @param enable defines the state to set
  29653. */
  29654. setDepthWrite(enable: boolean): void;
  29655. /**
  29656. * Enable or disable color writing
  29657. * @param enable defines the state to set
  29658. */
  29659. setColorWrite(enable: boolean): void;
  29660. /**
  29661. * Gets a boolean indicating if color writing is enabled
  29662. * @returns the current color writing state
  29663. */
  29664. getColorWrite(): boolean;
  29665. /**
  29666. * Sets alpha constants used by some alpha blending modes
  29667. * @param r defines the red component
  29668. * @param g defines the green component
  29669. * @param b defines the blue component
  29670. * @param a defines the alpha component
  29671. */
  29672. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  29673. /**
  29674. * Sets the current alpha mode
  29675. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  29676. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  29677. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29678. */
  29679. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  29680. /**
  29681. * Gets the current alpha mode
  29682. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29683. * @returns the current alpha mode
  29684. */
  29685. getAlphaMode(): number;
  29686. /**
  29687. * Clears the list of texture accessible through engine.
  29688. * This can help preventing texture load conflict due to name collision.
  29689. */
  29690. clearInternalTexturesCache(): void;
  29691. /**
  29692. * Force the entire cache to be cleared
  29693. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  29694. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  29695. */
  29696. wipeCaches(bruteForce?: boolean): void;
  29697. /**
  29698. * Set the compressed texture format to use, based on the formats you have, and the formats
  29699. * supported by the hardware / browser.
  29700. *
  29701. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  29702. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  29703. * to API arguments needed to compressed textures. This puts the burden on the container
  29704. * generator to house the arcane code for determining these for current & future formats.
  29705. *
  29706. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  29707. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  29708. *
  29709. * Note: The result of this call is not taken into account when a texture is base64.
  29710. *
  29711. * @param formatsAvailable defines the list of those format families you have created
  29712. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  29713. *
  29714. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  29715. * @returns The extension selected.
  29716. */
  29717. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  29718. /** @hidden */
  29719. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  29720. min: number;
  29721. mag: number;
  29722. };
  29723. /** @hidden */
  29724. _createTexture(): WebGLTexture;
  29725. /**
  29726. * Usually called from Texture.ts.
  29727. * Passed information to create a WebGLTexture
  29728. * @param urlArg defines a value which contains one of the following:
  29729. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  29730. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  29731. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  29732. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  29733. * @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)
  29734. * @param scene needed for loading to the correct scene
  29735. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  29736. * @param onLoad optional callback to be called upon successful completion
  29737. * @param onError optional callback to be called upon failure
  29738. * @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
  29739. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  29740. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  29741. * @param forcedExtension defines the extension to use to pick the right loader
  29742. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  29743. * @returns a InternalTexture for assignment back into BABYLON.Texture
  29744. */
  29745. 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;
  29746. /**
  29747. * @hidden
  29748. * Rescales a texture
  29749. * @param source input texutre
  29750. * @param destination destination texture
  29751. * @param scene scene to use to render the resize
  29752. * @param internalFormat format to use when resizing
  29753. * @param onComplete callback to be called when resize has completed
  29754. */
  29755. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  29756. private _unpackFlipYCached;
  29757. /**
  29758. * In case you are sharing the context with other applications, it might
  29759. * be interested to not cache the unpack flip y state to ensure a consistent
  29760. * value would be set.
  29761. */
  29762. enableUnpackFlipYCached: boolean;
  29763. /** @hidden */
  29764. _unpackFlipY(value: boolean): void;
  29765. /** @hidden */
  29766. _getUnpackAlignement(): number;
  29767. /**
  29768. * Creates a dynamic texture
  29769. * @param width defines the width of the texture
  29770. * @param height defines the height of the texture
  29771. * @param generateMipMaps defines if the engine should generate the mip levels
  29772. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  29773. * @returns the dynamic texture inside an InternalTexture
  29774. */
  29775. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  29776. /**
  29777. * Update the sampling mode of a given texture
  29778. * @param samplingMode defines the required sampling mode
  29779. * @param texture defines the texture to update
  29780. */
  29781. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  29782. /**
  29783. * Update the content of a dynamic texture
  29784. * @param texture defines the texture to update
  29785. * @param canvas defines the canvas containing the source
  29786. * @param invertY defines if data must be stored with Y axis inverted
  29787. * @param premulAlpha defines if alpha is stored as premultiplied
  29788. * @param format defines the format of the data
  29789. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  29790. */
  29791. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  29792. /**
  29793. * Update a video texture
  29794. * @param texture defines the texture to update
  29795. * @param video defines the video element to use
  29796. * @param invertY defines if data must be stored with Y axis inverted
  29797. */
  29798. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29799. /**
  29800. * Updates a depth texture Comparison Mode and Function.
  29801. * If the comparison Function is equal to 0, the mode will be set to none.
  29802. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  29803. * @param texture The texture to set the comparison function for
  29804. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  29805. */
  29806. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  29807. /** @hidden */
  29808. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  29809. width: number;
  29810. height: number;
  29811. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  29812. /**
  29813. * Creates a depth stencil texture.
  29814. * This is only available in WebGL 2 or with the depth texture extension available.
  29815. * @param size The size of face edge in the texture.
  29816. * @param options The options defining the texture.
  29817. * @returns The texture
  29818. */
  29819. createDepthStencilTexture(size: number | {
  29820. width: number;
  29821. height: number;
  29822. }, options: DepthTextureCreationOptions): InternalTexture;
  29823. /**
  29824. * Creates a depth stencil texture.
  29825. * This is only available in WebGL 2 or with the depth texture extension available.
  29826. * @param size The size of face edge in the texture.
  29827. * @param options The options defining the texture.
  29828. * @returns The texture
  29829. */
  29830. private _createDepthStencilTexture;
  29831. /**
  29832. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  29833. * @param renderTarget The render target to set the frame buffer for
  29834. */
  29835. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  29836. /**
  29837. * Creates a new render target texture
  29838. * @param size defines the size of the texture
  29839. * @param options defines the options used to create the texture
  29840. * @returns a new render target texture stored in an InternalTexture
  29841. */
  29842. createRenderTargetTexture(size: number | {
  29843. width: number;
  29844. height: number;
  29845. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  29846. /** @hidden */
  29847. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  29848. /**
  29849. * Updates the sample count of a render target texture
  29850. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  29851. * @param texture defines the texture to update
  29852. * @param samples defines the sample count to set
  29853. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  29854. */
  29855. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  29856. /** @hidden */
  29857. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29858. /** @hidden */
  29859. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  29860. /** @hidden */
  29861. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29862. /** @hidden */
  29863. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  29864. /**
  29865. * @hidden
  29866. */
  29867. _setCubeMapTextureParams(loadMipmap: boolean): void;
  29868. private _prepareWebGLTextureContinuation;
  29869. private _prepareWebGLTexture;
  29870. /** @hidden */
  29871. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  29872. /** @hidden */
  29873. _releaseFramebufferObjects(texture: InternalTexture): void;
  29874. /** @hidden */
  29875. _releaseTexture(texture: InternalTexture): void;
  29876. private setProgram;
  29877. private _boundUniforms;
  29878. /**
  29879. * Binds an effect to the webGL context
  29880. * @param effect defines the effect to bind
  29881. */
  29882. bindSamplers(effect: Effect): void;
  29883. private _activateCurrentTexture;
  29884. /** @hidden */
  29885. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  29886. /** @hidden */
  29887. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  29888. /**
  29889. * Sets a texture to the webGL context from a postprocess
  29890. * @param channel defines the channel to use
  29891. * @param postProcess defines the source postprocess
  29892. */
  29893. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  29894. /**
  29895. * Binds the output of the passed in post process to the texture channel specified
  29896. * @param channel The channel the texture should be bound to
  29897. * @param postProcess The post process which's output should be bound
  29898. */
  29899. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  29900. /**
  29901. * Unbind all textures from the webGL context
  29902. */
  29903. unbindAllTextures(): void;
  29904. /**
  29905. * Sets a texture to the according uniform.
  29906. * @param channel The texture channel
  29907. * @param uniform The uniform to set
  29908. * @param texture The texture to apply
  29909. */
  29910. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  29911. /**
  29912. * Sets a depth stencil texture from a render target to the according uniform.
  29913. * @param channel The texture channel
  29914. * @param uniform The uniform to set
  29915. * @param texture The render target texture containing the depth stencil texture to apply
  29916. */
  29917. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  29918. private _bindSamplerUniformToChannel;
  29919. private _getTextureWrapMode;
  29920. private _setTexture;
  29921. /**
  29922. * Sets an array of texture to the webGL context
  29923. * @param channel defines the channel where the texture array must be set
  29924. * @param uniform defines the associated uniform location
  29925. * @param textures defines the array of textures to bind
  29926. */
  29927. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  29928. /** @hidden */
  29929. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  29930. private _setTextureParameterFloat;
  29931. private _setTextureParameterInteger;
  29932. /**
  29933. * Reads pixels from the current frame buffer. Please note that this function can be slow
  29934. * @param x defines the x coordinate of the rectangle where pixels must be read
  29935. * @param y defines the y coordinate of the rectangle where pixels must be read
  29936. * @param width defines the width of the rectangle where pixels must be read
  29937. * @param height defines the height of the rectangle where pixels must be read
  29938. * @returns a Uint8Array containing RGBA colors
  29939. */
  29940. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  29941. /**
  29942. * Add an externaly attached data from its key.
  29943. * This method call will fail and return false, if such key already exists.
  29944. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  29945. * @param key the unique key that identifies the data
  29946. * @param data the data object to associate to the key for this Engine instance
  29947. * @return true if no such key were already present and the data was added successfully, false otherwise
  29948. */
  29949. addExternalData<T>(key: string, data: T): boolean;
  29950. /**
  29951. * Get an externaly attached data from its key
  29952. * @param key the unique key that identifies the data
  29953. * @return the associated data, if present (can be null), or undefined if not present
  29954. */
  29955. getExternalData<T>(key: string): T;
  29956. /**
  29957. * Get an externaly attached data from its key, create it using a factory if it's not already present
  29958. * @param key the unique key that identifies the data
  29959. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  29960. * @return the associated data, can be null if the factory returned null.
  29961. */
  29962. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  29963. /**
  29964. * Remove an externaly attached data from the Engine instance
  29965. * @param key the unique key that identifies the data
  29966. * @return true if the data was successfully removed, false if it doesn't exist
  29967. */
  29968. removeExternalData(key: string): boolean;
  29969. /**
  29970. * Unbind all vertex attributes from the webGL context
  29971. */
  29972. unbindAllAttributes(): void;
  29973. /**
  29974. * 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
  29975. */
  29976. releaseEffects(): void;
  29977. /**
  29978. * Dispose and release all associated resources
  29979. */
  29980. dispose(): void;
  29981. /**
  29982. * Display the loading screen
  29983. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29984. */
  29985. displayLoadingUI(): void;
  29986. /**
  29987. * Hide the loading screen
  29988. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29989. */
  29990. hideLoadingUI(): void;
  29991. /**
  29992. * Gets the current loading screen object
  29993. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29994. */
  29995. /**
  29996. * Sets the current loading screen object
  29997. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29998. */
  29999. loadingScreen: ILoadingScreen;
  30000. /**
  30001. * Sets the current loading screen text
  30002. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30003. */
  30004. loadingUIText: string;
  30005. /**
  30006. * Sets the current loading screen background color
  30007. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30008. */
  30009. loadingUIBackgroundColor: string;
  30010. /**
  30011. * Attach a new callback raised when context lost event is fired
  30012. * @param callback defines the callback to call
  30013. */
  30014. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30015. /**
  30016. * Attach a new callback raised when context restored event is fired
  30017. * @param callback defines the callback to call
  30018. */
  30019. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30020. /**
  30021. * Gets the source code of the vertex shader associated with a specific webGL program
  30022. * @param program defines the program to use
  30023. * @returns a string containing the source code of the vertex shader associated with the program
  30024. */
  30025. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  30026. /**
  30027. * Gets the source code of the fragment shader associated with a specific webGL program
  30028. * @param program defines the program to use
  30029. * @returns a string containing the source code of the fragment shader associated with the program
  30030. */
  30031. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  30032. /**
  30033. * Get the current error code of the webGL context
  30034. * @returns the error code
  30035. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  30036. */
  30037. getError(): number;
  30038. /**
  30039. * Gets the current framerate
  30040. * @returns a number representing the framerate
  30041. */
  30042. getFps(): number;
  30043. /**
  30044. * Gets the time spent between current and previous frame
  30045. * @returns a number representing the delta time in ms
  30046. */
  30047. getDeltaTime(): number;
  30048. private _measureFps;
  30049. /** @hidden */
  30050. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  30051. private _canRenderToFloatFramebuffer;
  30052. private _canRenderToHalfFloatFramebuffer;
  30053. private _canRenderToFramebuffer;
  30054. /** @hidden */
  30055. _getWebGLTextureType(type: number): number;
  30056. /** @hidden */
  30057. _getInternalFormat(format: number): number;
  30058. /** @hidden */
  30059. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  30060. /** @hidden */
  30061. _getRGBAMultiSampleBufferFormat(type: number): number;
  30062. /** @hidden */
  30063. _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;
  30064. /** @hidden */
  30065. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  30066. /**
  30067. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  30068. * @returns true if the engine can be created
  30069. * @ignorenaming
  30070. */
  30071. static isSupported(): boolean;
  30072. }
  30073. }
  30074. declare module "babylonjs/Materials/effect" {
  30075. import { Observable } from "babylonjs/Misc/observable";
  30076. import { Nullable } from "babylonjs/types";
  30077. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  30078. import { IDisposable } from "babylonjs/scene";
  30079. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30080. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30081. import { Engine } from "babylonjs/Engines/engine";
  30082. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30083. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30084. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30085. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30086. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30087. /**
  30088. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  30089. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  30090. */
  30091. export class EffectFallbacks {
  30092. private _defines;
  30093. private _currentRank;
  30094. private _maxRank;
  30095. private _mesh;
  30096. /**
  30097. * Removes the fallback from the bound mesh.
  30098. */
  30099. unBindMesh(): void;
  30100. /**
  30101. * Adds a fallback on the specified property.
  30102. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  30103. * @param define The name of the define in the shader
  30104. */
  30105. addFallback(rank: number, define: string): void;
  30106. /**
  30107. * Sets the mesh to use CPU skinning when needing to fallback.
  30108. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  30109. * @param mesh The mesh to use the fallbacks.
  30110. */
  30111. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  30112. /**
  30113. * Checks to see if more fallbacks are still availible.
  30114. */
  30115. readonly isMoreFallbacks: boolean;
  30116. /**
  30117. * Removes the defines that should be removed when falling back.
  30118. * @param currentDefines defines the current define statements for the shader.
  30119. * @param effect defines the current effect we try to compile
  30120. * @returns The resulting defines with defines of the current rank removed.
  30121. */
  30122. reduce(currentDefines: string, effect: Effect): string;
  30123. }
  30124. /**
  30125. * Options to be used when creating an effect.
  30126. */
  30127. export class EffectCreationOptions {
  30128. /**
  30129. * Atrributes that will be used in the shader.
  30130. */
  30131. attributes: string[];
  30132. /**
  30133. * Uniform varible names that will be set in the shader.
  30134. */
  30135. uniformsNames: string[];
  30136. /**
  30137. * Uniform buffer varible names that will be set in the shader.
  30138. */
  30139. uniformBuffersNames: string[];
  30140. /**
  30141. * Sampler texture variable names that will be set in the shader.
  30142. */
  30143. samplers: string[];
  30144. /**
  30145. * Define statements that will be set in the shader.
  30146. */
  30147. defines: any;
  30148. /**
  30149. * Possible fallbacks for this effect to improve performance when needed.
  30150. */
  30151. fallbacks: Nullable<EffectFallbacks>;
  30152. /**
  30153. * Callback that will be called when the shader is compiled.
  30154. */
  30155. onCompiled: Nullable<(effect: Effect) => void>;
  30156. /**
  30157. * Callback that will be called if an error occurs during shader compilation.
  30158. */
  30159. onError: Nullable<(effect: Effect, errors: string) => void>;
  30160. /**
  30161. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30162. */
  30163. indexParameters: any;
  30164. /**
  30165. * Max number of lights that can be used in the shader.
  30166. */
  30167. maxSimultaneousLights: number;
  30168. /**
  30169. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  30170. */
  30171. transformFeedbackVaryings: Nullable<string[]>;
  30172. }
  30173. /**
  30174. * Effect containing vertex and fragment shader that can be executed on an object.
  30175. */
  30176. export class Effect implements IDisposable {
  30177. /**
  30178. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30179. */
  30180. static ShadersRepository: string;
  30181. /**
  30182. * Name of the effect.
  30183. */
  30184. name: any;
  30185. /**
  30186. * String container all the define statements that should be set on the shader.
  30187. */
  30188. defines: string;
  30189. /**
  30190. * Callback that will be called when the shader is compiled.
  30191. */
  30192. onCompiled: Nullable<(effect: Effect) => void>;
  30193. /**
  30194. * Callback that will be called if an error occurs during shader compilation.
  30195. */
  30196. onError: Nullable<(effect: Effect, errors: string) => void>;
  30197. /**
  30198. * Callback that will be called when effect is bound.
  30199. */
  30200. onBind: Nullable<(effect: Effect) => void>;
  30201. /**
  30202. * Unique ID of the effect.
  30203. */
  30204. uniqueId: number;
  30205. /**
  30206. * Observable that will be called when the shader is compiled.
  30207. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30208. */
  30209. onCompileObservable: Observable<Effect>;
  30210. /**
  30211. * Observable that will be called if an error occurs during shader compilation.
  30212. */
  30213. onErrorObservable: Observable<Effect>;
  30214. /** @hidden */
  30215. _onBindObservable: Nullable<Observable<Effect>>;
  30216. /**
  30217. * Observable that will be called when effect is bound.
  30218. */
  30219. readonly onBindObservable: Observable<Effect>;
  30220. /** @hidden */
  30221. _bonesComputationForcedToCPU: boolean;
  30222. private static _uniqueIdSeed;
  30223. private _engine;
  30224. private _uniformBuffersNames;
  30225. private _uniformsNames;
  30226. private _samplerList;
  30227. private _samplers;
  30228. private _isReady;
  30229. private _compilationError;
  30230. private _attributesNames;
  30231. private _attributes;
  30232. private _uniforms;
  30233. /**
  30234. * Key for the effect.
  30235. * @hidden
  30236. */
  30237. _key: string;
  30238. private _indexParameters;
  30239. private _fallbacks;
  30240. private _vertexSourceCode;
  30241. private _fragmentSourceCode;
  30242. private _vertexSourceCodeOverride;
  30243. private _fragmentSourceCodeOverride;
  30244. private _transformFeedbackVaryings;
  30245. /**
  30246. * Compiled shader to webGL program.
  30247. * @hidden
  30248. */
  30249. _pipelineContext: Nullable<IPipelineContext>;
  30250. private _valueCache;
  30251. private static _baseCache;
  30252. /**
  30253. * Instantiates an effect.
  30254. * An effect can be used to create/manage/execute vertex and fragment shaders.
  30255. * @param baseName Name of the effect.
  30256. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  30257. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  30258. * @param samplers List of sampler variables that will be passed to the shader.
  30259. * @param engine Engine to be used to render the effect
  30260. * @param defines Define statements to be added to the shader.
  30261. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  30262. * @param onCompiled Callback that will be called when the shader is compiled.
  30263. * @param onError Callback that will be called if an error occurs during shader compilation.
  30264. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30265. */
  30266. 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);
  30267. private _useFinalCode;
  30268. /**
  30269. * Unique key for this effect
  30270. */
  30271. readonly key: string;
  30272. /**
  30273. * If the effect has been compiled and prepared.
  30274. * @returns if the effect is compiled and prepared.
  30275. */
  30276. isReady(): boolean;
  30277. /**
  30278. * The engine the effect was initialized with.
  30279. * @returns the engine.
  30280. */
  30281. getEngine(): Engine;
  30282. /**
  30283. * The pipeline context for this effect
  30284. * @returns the associated pipeline context
  30285. */
  30286. getPipelineContext(): Nullable<IPipelineContext>;
  30287. /**
  30288. * The set of names of attribute variables for the shader.
  30289. * @returns An array of attribute names.
  30290. */
  30291. getAttributesNames(): string[];
  30292. /**
  30293. * Returns the attribute at the given index.
  30294. * @param index The index of the attribute.
  30295. * @returns The location of the attribute.
  30296. */
  30297. getAttributeLocation(index: number): number;
  30298. /**
  30299. * Returns the attribute based on the name of the variable.
  30300. * @param name of the attribute to look up.
  30301. * @returns the attribute location.
  30302. */
  30303. getAttributeLocationByName(name: string): number;
  30304. /**
  30305. * The number of attributes.
  30306. * @returns the numnber of attributes.
  30307. */
  30308. getAttributesCount(): number;
  30309. /**
  30310. * Gets the index of a uniform variable.
  30311. * @param uniformName of the uniform to look up.
  30312. * @returns the index.
  30313. */
  30314. getUniformIndex(uniformName: string): number;
  30315. /**
  30316. * Returns the attribute based on the name of the variable.
  30317. * @param uniformName of the uniform to look up.
  30318. * @returns the location of the uniform.
  30319. */
  30320. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  30321. /**
  30322. * Returns an array of sampler variable names
  30323. * @returns The array of sampler variable neames.
  30324. */
  30325. getSamplers(): string[];
  30326. /**
  30327. * The error from the last compilation.
  30328. * @returns the error string.
  30329. */
  30330. getCompilationError(): string;
  30331. /**
  30332. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  30333. * @param func The callback to be used.
  30334. */
  30335. executeWhenCompiled(func: (effect: Effect) => void): void;
  30336. private _checkIsReady;
  30337. /** @hidden */
  30338. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  30339. /** @hidden */
  30340. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  30341. /** @hidden */
  30342. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  30343. /**
  30344. * Recompiles the webGL program
  30345. * @param vertexSourceCode The source code for the vertex shader.
  30346. * @param fragmentSourceCode The source code for the fragment shader.
  30347. * @param onCompiled Callback called when completed.
  30348. * @param onError Callback called on error.
  30349. * @hidden
  30350. */
  30351. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30352. /**
  30353. * Prepares the effect
  30354. * @hidden
  30355. */
  30356. _prepareEffect(): void;
  30357. /**
  30358. * Checks if the effect is supported. (Must be called after compilation)
  30359. */
  30360. readonly isSupported: boolean;
  30361. /**
  30362. * Binds a texture to the engine to be used as output of the shader.
  30363. * @param channel Name of the output variable.
  30364. * @param texture Texture to bind.
  30365. * @hidden
  30366. */
  30367. _bindTexture(channel: string, texture: InternalTexture): void;
  30368. /**
  30369. * Sets a texture on the engine to be used in the shader.
  30370. * @param channel Name of the sampler variable.
  30371. * @param texture Texture to set.
  30372. */
  30373. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30374. /**
  30375. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30376. * @param channel Name of the sampler variable.
  30377. * @param texture Texture to set.
  30378. */
  30379. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30380. /**
  30381. * Sets an array of textures on the engine to be used in the shader.
  30382. * @param channel Name of the variable.
  30383. * @param textures Textures to set.
  30384. */
  30385. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30386. /**
  30387. * 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)
  30388. * @param channel Name of the sampler variable.
  30389. * @param postProcess Post process to get the input texture from.
  30390. */
  30391. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30392. /**
  30393. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30394. * 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)
  30395. * @param channel Name of the sampler variable.
  30396. * @param postProcess Post process to get the output texture from.
  30397. */
  30398. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30399. /** @hidden */
  30400. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  30401. /** @hidden */
  30402. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30403. /** @hidden */
  30404. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30405. /** @hidden */
  30406. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30407. /**
  30408. * Binds a buffer to a uniform.
  30409. * @param buffer Buffer to bind.
  30410. * @param name Name of the uniform variable to bind to.
  30411. */
  30412. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30413. /**
  30414. * Binds block to a uniform.
  30415. * @param blockName Name of the block to bind.
  30416. * @param index Index to bind.
  30417. */
  30418. bindUniformBlock(blockName: string, index: number): void;
  30419. /**
  30420. * Sets an interger value on a uniform variable.
  30421. * @param uniformName Name of the variable.
  30422. * @param value Value to be set.
  30423. * @returns this effect.
  30424. */
  30425. setInt(uniformName: string, value: number): Effect;
  30426. /**
  30427. * Sets an int array on a uniform variable.
  30428. * @param uniformName Name of the variable.
  30429. * @param array array to be set.
  30430. * @returns this effect.
  30431. */
  30432. setIntArray(uniformName: string, array: Int32Array): Effect;
  30433. /**
  30434. * 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)
  30435. * @param uniformName Name of the variable.
  30436. * @param array array to be set.
  30437. * @returns this effect.
  30438. */
  30439. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30440. /**
  30441. * 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)
  30442. * @param uniformName Name of the variable.
  30443. * @param array array to be set.
  30444. * @returns this effect.
  30445. */
  30446. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30447. /**
  30448. * 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)
  30449. * @param uniformName Name of the variable.
  30450. * @param array array to be set.
  30451. * @returns this effect.
  30452. */
  30453. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30454. /**
  30455. * Sets an float array on a uniform variable.
  30456. * @param uniformName Name of the variable.
  30457. * @param array array to be set.
  30458. * @returns this effect.
  30459. */
  30460. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30461. /**
  30462. * 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)
  30463. * @param uniformName Name of the variable.
  30464. * @param array array to be set.
  30465. * @returns this effect.
  30466. */
  30467. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30468. /**
  30469. * 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)
  30470. * @param uniformName Name of the variable.
  30471. * @param array array to be set.
  30472. * @returns this effect.
  30473. */
  30474. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30475. /**
  30476. * 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)
  30477. * @param uniformName Name of the variable.
  30478. * @param array array to be set.
  30479. * @returns this effect.
  30480. */
  30481. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30482. /**
  30483. * Sets an array on a uniform variable.
  30484. * @param uniformName Name of the variable.
  30485. * @param array array to be set.
  30486. * @returns this effect.
  30487. */
  30488. setArray(uniformName: string, array: number[]): Effect;
  30489. /**
  30490. * 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)
  30491. * @param uniformName Name of the variable.
  30492. * @param array array to be set.
  30493. * @returns this effect.
  30494. */
  30495. setArray2(uniformName: string, array: number[]): Effect;
  30496. /**
  30497. * 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)
  30498. * @param uniformName Name of the variable.
  30499. * @param array array to be set.
  30500. * @returns this effect.
  30501. */
  30502. setArray3(uniformName: string, array: number[]): Effect;
  30503. /**
  30504. * 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)
  30505. * @param uniformName Name of the variable.
  30506. * @param array array to be set.
  30507. * @returns this effect.
  30508. */
  30509. setArray4(uniformName: string, array: number[]): Effect;
  30510. /**
  30511. * Sets matrices on a uniform variable.
  30512. * @param uniformName Name of the variable.
  30513. * @param matrices matrices to be set.
  30514. * @returns this effect.
  30515. */
  30516. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30517. /**
  30518. * Sets matrix on a uniform variable.
  30519. * @param uniformName Name of the variable.
  30520. * @param matrix matrix to be set.
  30521. * @returns this effect.
  30522. */
  30523. setMatrix(uniformName: string, matrix: Matrix): Effect;
  30524. /**
  30525. * 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)
  30526. * @param uniformName Name of the variable.
  30527. * @param matrix matrix to be set.
  30528. * @returns this effect.
  30529. */
  30530. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30531. /**
  30532. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30533. * @param uniformName Name of the variable.
  30534. * @param matrix matrix to be set.
  30535. * @returns this effect.
  30536. */
  30537. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30538. /**
  30539. * Sets a float on a uniform variable.
  30540. * @param uniformName Name of the variable.
  30541. * @param value value to be set.
  30542. * @returns this effect.
  30543. */
  30544. setFloat(uniformName: string, value: number): Effect;
  30545. /**
  30546. * Sets a boolean on a uniform variable.
  30547. * @param uniformName Name of the variable.
  30548. * @param bool value to be set.
  30549. * @returns this effect.
  30550. */
  30551. setBool(uniformName: string, bool: boolean): Effect;
  30552. /**
  30553. * Sets a Vector2 on a uniform variable.
  30554. * @param uniformName Name of the variable.
  30555. * @param vector2 vector2 to be set.
  30556. * @returns this effect.
  30557. */
  30558. setVector2(uniformName: string, vector2: Vector2): Effect;
  30559. /**
  30560. * Sets a float2 on a uniform variable.
  30561. * @param uniformName Name of the variable.
  30562. * @param x First float in float2.
  30563. * @param y Second float in float2.
  30564. * @returns this effect.
  30565. */
  30566. setFloat2(uniformName: string, x: number, y: number): Effect;
  30567. /**
  30568. * Sets a Vector3 on a uniform variable.
  30569. * @param uniformName Name of the variable.
  30570. * @param vector3 Value to be set.
  30571. * @returns this effect.
  30572. */
  30573. setVector3(uniformName: string, vector3: Vector3): Effect;
  30574. /**
  30575. * Sets a float3 on a uniform variable.
  30576. * @param uniformName Name of the variable.
  30577. * @param x First float in float3.
  30578. * @param y Second float in float3.
  30579. * @param z Third float in float3.
  30580. * @returns this effect.
  30581. */
  30582. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30583. /**
  30584. * Sets a Vector4 on a uniform variable.
  30585. * @param uniformName Name of the variable.
  30586. * @param vector4 Value to be set.
  30587. * @returns this effect.
  30588. */
  30589. setVector4(uniformName: string, vector4: Vector4): Effect;
  30590. /**
  30591. * Sets a float4 on a uniform variable.
  30592. * @param uniformName Name of the variable.
  30593. * @param x First float in float4.
  30594. * @param y Second float in float4.
  30595. * @param z Third float in float4.
  30596. * @param w Fourth float in float4.
  30597. * @returns this effect.
  30598. */
  30599. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30600. /**
  30601. * Sets a Color3 on a uniform variable.
  30602. * @param uniformName Name of the variable.
  30603. * @param color3 Value to be set.
  30604. * @returns this effect.
  30605. */
  30606. setColor3(uniformName: string, color3: Color3): Effect;
  30607. /**
  30608. * Sets a Color4 on a uniform variable.
  30609. * @param uniformName Name of the variable.
  30610. * @param color3 Value to be set.
  30611. * @param alpha Alpha value to be set.
  30612. * @returns this effect.
  30613. */
  30614. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  30615. /**
  30616. * Sets a Color4 on a uniform variable
  30617. * @param uniformName defines the name of the variable
  30618. * @param color4 defines the value to be set
  30619. * @returns this effect.
  30620. */
  30621. setDirectColor4(uniformName: string, color4: Color4): Effect;
  30622. /** Release all associated resources */
  30623. dispose(): void;
  30624. /**
  30625. * This function will add a new shader to the shader store
  30626. * @param name the name of the shader
  30627. * @param pixelShader optional pixel shader content
  30628. * @param vertexShader optional vertex shader content
  30629. */
  30630. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30631. /**
  30632. * Store of each shader (The can be looked up using effect.key)
  30633. */
  30634. static ShadersStore: {
  30635. [key: string]: string;
  30636. };
  30637. /**
  30638. * Store of each included file for a shader (The can be looked up using effect.key)
  30639. */
  30640. static IncludesShadersStore: {
  30641. [key: string]: string;
  30642. };
  30643. /**
  30644. * Resets the cache of effects.
  30645. */
  30646. static ResetCache(): void;
  30647. }
  30648. }
  30649. declare module "babylonjs/Materials/colorCurves" {
  30650. import { Effect } from "babylonjs/Materials/effect";
  30651. /**
  30652. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30653. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30654. * 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;
  30655. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30656. */
  30657. export class ColorCurves {
  30658. private _dirty;
  30659. private _tempColor;
  30660. private _globalCurve;
  30661. private _highlightsCurve;
  30662. private _midtonesCurve;
  30663. private _shadowsCurve;
  30664. private _positiveCurve;
  30665. private _negativeCurve;
  30666. private _globalHue;
  30667. private _globalDensity;
  30668. private _globalSaturation;
  30669. private _globalExposure;
  30670. /**
  30671. * Gets the global Hue value.
  30672. * 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).
  30673. */
  30674. /**
  30675. * Sets the global Hue value.
  30676. * 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).
  30677. */
  30678. globalHue: number;
  30679. /**
  30680. * Gets the global Density value.
  30681. * 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.
  30682. * Values less than zero provide a filter of opposite hue.
  30683. */
  30684. /**
  30685. * Sets the global Density value.
  30686. * 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.
  30687. * Values less than zero provide a filter of opposite hue.
  30688. */
  30689. globalDensity: number;
  30690. /**
  30691. * Gets the global Saturation value.
  30692. * 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.
  30693. */
  30694. /**
  30695. * Sets the global Saturation value.
  30696. * 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.
  30697. */
  30698. globalSaturation: number;
  30699. /**
  30700. * Gets the global Exposure value.
  30701. * 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.
  30702. */
  30703. /**
  30704. * Sets the global Exposure value.
  30705. * 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.
  30706. */
  30707. globalExposure: number;
  30708. private _highlightsHue;
  30709. private _highlightsDensity;
  30710. private _highlightsSaturation;
  30711. private _highlightsExposure;
  30712. /**
  30713. * Gets the highlights Hue value.
  30714. * 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).
  30715. */
  30716. /**
  30717. * Sets the highlights Hue value.
  30718. * 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).
  30719. */
  30720. highlightsHue: number;
  30721. /**
  30722. * Gets the highlights Density value.
  30723. * 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.
  30724. * Values less than zero provide a filter of opposite hue.
  30725. */
  30726. /**
  30727. * Sets the highlights Density value.
  30728. * 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.
  30729. * Values less than zero provide a filter of opposite hue.
  30730. */
  30731. highlightsDensity: number;
  30732. /**
  30733. * Gets the highlights Saturation value.
  30734. * 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.
  30735. */
  30736. /**
  30737. * Sets the highlights Saturation value.
  30738. * 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.
  30739. */
  30740. highlightsSaturation: number;
  30741. /**
  30742. * Gets the highlights Exposure value.
  30743. * 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.
  30744. */
  30745. /**
  30746. * Sets the highlights Exposure value.
  30747. * 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.
  30748. */
  30749. highlightsExposure: number;
  30750. private _midtonesHue;
  30751. private _midtonesDensity;
  30752. private _midtonesSaturation;
  30753. private _midtonesExposure;
  30754. /**
  30755. * Gets the midtones Hue value.
  30756. * 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).
  30757. */
  30758. /**
  30759. * Sets the midtones Hue value.
  30760. * 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).
  30761. */
  30762. midtonesHue: number;
  30763. /**
  30764. * Gets the midtones Density value.
  30765. * 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.
  30766. * Values less than zero provide a filter of opposite hue.
  30767. */
  30768. /**
  30769. * Sets the midtones Density value.
  30770. * 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.
  30771. * Values less than zero provide a filter of opposite hue.
  30772. */
  30773. midtonesDensity: number;
  30774. /**
  30775. * Gets the midtones Saturation value.
  30776. * 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.
  30777. */
  30778. /**
  30779. * Sets the midtones Saturation value.
  30780. * 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.
  30781. */
  30782. midtonesSaturation: number;
  30783. /**
  30784. * Gets the midtones Exposure value.
  30785. * 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.
  30786. */
  30787. /**
  30788. * Sets the midtones Exposure value.
  30789. * 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.
  30790. */
  30791. midtonesExposure: number;
  30792. private _shadowsHue;
  30793. private _shadowsDensity;
  30794. private _shadowsSaturation;
  30795. private _shadowsExposure;
  30796. /**
  30797. * Gets the shadows Hue value.
  30798. * 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).
  30799. */
  30800. /**
  30801. * Sets the shadows Hue value.
  30802. * 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).
  30803. */
  30804. shadowsHue: number;
  30805. /**
  30806. * Gets the shadows Density value.
  30807. * 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.
  30808. * Values less than zero provide a filter of opposite hue.
  30809. */
  30810. /**
  30811. * Sets the shadows Density value.
  30812. * 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.
  30813. * Values less than zero provide a filter of opposite hue.
  30814. */
  30815. shadowsDensity: number;
  30816. /**
  30817. * Gets the shadows Saturation value.
  30818. * 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.
  30819. */
  30820. /**
  30821. * Sets the shadows Saturation value.
  30822. * 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.
  30823. */
  30824. shadowsSaturation: number;
  30825. /**
  30826. * Gets the shadows Exposure value.
  30827. * 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.
  30828. */
  30829. /**
  30830. * Sets the shadows Exposure value.
  30831. * 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.
  30832. */
  30833. shadowsExposure: number;
  30834. /**
  30835. * Returns the class name
  30836. * @returns The class name
  30837. */
  30838. getClassName(): string;
  30839. /**
  30840. * Binds the color curves to the shader.
  30841. * @param colorCurves The color curve to bind
  30842. * @param effect The effect to bind to
  30843. * @param positiveUniform The positive uniform shader parameter
  30844. * @param neutralUniform The neutral uniform shader parameter
  30845. * @param negativeUniform The negative uniform shader parameter
  30846. */
  30847. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  30848. /**
  30849. * Prepare the list of uniforms associated with the ColorCurves effects.
  30850. * @param uniformsList The list of uniforms used in the effect
  30851. */
  30852. static PrepareUniforms(uniformsList: string[]): void;
  30853. /**
  30854. * Returns color grading data based on a hue, density, saturation and exposure value.
  30855. * @param filterHue The hue of the color filter.
  30856. * @param filterDensity The density of the color filter.
  30857. * @param saturation The saturation.
  30858. * @param exposure The exposure.
  30859. * @param result The result data container.
  30860. */
  30861. private getColorGradingDataToRef;
  30862. /**
  30863. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  30864. * @param value The input slider value in range [-100,100].
  30865. * @returns Adjusted value.
  30866. */
  30867. private static applyColorGradingSliderNonlinear;
  30868. /**
  30869. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  30870. * @param hue The hue (H) input.
  30871. * @param saturation The saturation (S) input.
  30872. * @param brightness The brightness (B) input.
  30873. * @result An RGBA color represented as Vector4.
  30874. */
  30875. private static fromHSBToRef;
  30876. /**
  30877. * Returns a value clamped between min and max
  30878. * @param value The value to clamp
  30879. * @param min The minimum of value
  30880. * @param max The maximum of value
  30881. * @returns The clamped value.
  30882. */
  30883. private static clamp;
  30884. /**
  30885. * Clones the current color curve instance.
  30886. * @return The cloned curves
  30887. */
  30888. clone(): ColorCurves;
  30889. /**
  30890. * Serializes the current color curve instance to a json representation.
  30891. * @return a JSON representation
  30892. */
  30893. serialize(): any;
  30894. /**
  30895. * Parses the color curve from a json representation.
  30896. * @param source the JSON source to parse
  30897. * @return The parsed curves
  30898. */
  30899. static Parse(source: any): ColorCurves;
  30900. }
  30901. }
  30902. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  30903. import { Observable } from "babylonjs/Misc/observable";
  30904. import { Nullable } from "babylonjs/types";
  30905. import { Color4 } from "babylonjs/Maths/math";
  30906. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30907. import { Effect } from "babylonjs/Materials/effect";
  30908. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30909. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  30910. /**
  30911. * Interface to follow in your material defines to integrate easily the
  30912. * Image proccessing functions.
  30913. * @hidden
  30914. */
  30915. export interface IImageProcessingConfigurationDefines {
  30916. IMAGEPROCESSING: boolean;
  30917. VIGNETTE: boolean;
  30918. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30919. VIGNETTEBLENDMODEOPAQUE: boolean;
  30920. TONEMAPPING: boolean;
  30921. TONEMAPPING_ACES: boolean;
  30922. CONTRAST: boolean;
  30923. EXPOSURE: boolean;
  30924. COLORCURVES: boolean;
  30925. COLORGRADING: boolean;
  30926. COLORGRADING3D: boolean;
  30927. SAMPLER3DGREENDEPTH: boolean;
  30928. SAMPLER3DBGRMAP: boolean;
  30929. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30930. }
  30931. /**
  30932. * @hidden
  30933. */
  30934. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  30935. IMAGEPROCESSING: boolean;
  30936. VIGNETTE: boolean;
  30937. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30938. VIGNETTEBLENDMODEOPAQUE: boolean;
  30939. TONEMAPPING: boolean;
  30940. TONEMAPPING_ACES: boolean;
  30941. CONTRAST: boolean;
  30942. COLORCURVES: boolean;
  30943. COLORGRADING: boolean;
  30944. COLORGRADING3D: boolean;
  30945. SAMPLER3DGREENDEPTH: boolean;
  30946. SAMPLER3DBGRMAP: boolean;
  30947. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30948. EXPOSURE: boolean;
  30949. constructor();
  30950. }
  30951. /**
  30952. * This groups together the common properties used for image processing either in direct forward pass
  30953. * or through post processing effect depending on the use of the image processing pipeline in your scene
  30954. * or not.
  30955. */
  30956. export class ImageProcessingConfiguration {
  30957. /**
  30958. * Default tone mapping applied in BabylonJS.
  30959. */
  30960. static readonly TONEMAPPING_STANDARD: number;
  30961. /**
  30962. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  30963. * to other engines rendering to increase portability.
  30964. */
  30965. static readonly TONEMAPPING_ACES: number;
  30966. /**
  30967. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  30968. */
  30969. colorCurves: Nullable<ColorCurves>;
  30970. private _colorCurvesEnabled;
  30971. /**
  30972. * Gets wether the color curves effect is enabled.
  30973. */
  30974. /**
  30975. * Sets wether the color curves effect is enabled.
  30976. */
  30977. colorCurvesEnabled: boolean;
  30978. private _colorGradingTexture;
  30979. /**
  30980. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30981. */
  30982. /**
  30983. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30984. */
  30985. colorGradingTexture: Nullable<BaseTexture>;
  30986. private _colorGradingEnabled;
  30987. /**
  30988. * Gets wether the color grading effect is enabled.
  30989. */
  30990. /**
  30991. * Sets wether the color grading effect is enabled.
  30992. */
  30993. colorGradingEnabled: boolean;
  30994. private _colorGradingWithGreenDepth;
  30995. /**
  30996. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  30997. */
  30998. /**
  30999. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  31000. */
  31001. colorGradingWithGreenDepth: boolean;
  31002. private _colorGradingBGR;
  31003. /**
  31004. * Gets wether the color grading texture contains BGR values.
  31005. */
  31006. /**
  31007. * Sets wether the color grading texture contains BGR values.
  31008. */
  31009. colorGradingBGR: boolean;
  31010. /** @hidden */
  31011. _exposure: number;
  31012. /**
  31013. * Gets the Exposure used in the effect.
  31014. */
  31015. /**
  31016. * Sets the Exposure used in the effect.
  31017. */
  31018. exposure: number;
  31019. private _toneMappingEnabled;
  31020. /**
  31021. * Gets wether the tone mapping effect is enabled.
  31022. */
  31023. /**
  31024. * Sets wether the tone mapping effect is enabled.
  31025. */
  31026. toneMappingEnabled: boolean;
  31027. private _toneMappingType;
  31028. /**
  31029. * Gets the type of tone mapping effect.
  31030. */
  31031. /**
  31032. * Sets the type of tone mapping effect used in BabylonJS.
  31033. */
  31034. toneMappingType: number;
  31035. protected _contrast: number;
  31036. /**
  31037. * Gets the contrast used in the effect.
  31038. */
  31039. /**
  31040. * Sets the contrast used in the effect.
  31041. */
  31042. contrast: number;
  31043. /**
  31044. * Vignette stretch size.
  31045. */
  31046. vignetteStretch: number;
  31047. /**
  31048. * Vignette centre X Offset.
  31049. */
  31050. vignetteCentreX: number;
  31051. /**
  31052. * Vignette centre Y Offset.
  31053. */
  31054. vignetteCentreY: number;
  31055. /**
  31056. * Vignette weight or intensity of the vignette effect.
  31057. */
  31058. vignetteWeight: number;
  31059. /**
  31060. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  31061. * if vignetteEnabled is set to true.
  31062. */
  31063. vignetteColor: Color4;
  31064. /**
  31065. * Camera field of view used by the Vignette effect.
  31066. */
  31067. vignetteCameraFov: number;
  31068. private _vignetteBlendMode;
  31069. /**
  31070. * Gets the vignette blend mode allowing different kind of effect.
  31071. */
  31072. /**
  31073. * Sets the vignette blend mode allowing different kind of effect.
  31074. */
  31075. vignetteBlendMode: number;
  31076. private _vignetteEnabled;
  31077. /**
  31078. * Gets wether the vignette effect is enabled.
  31079. */
  31080. /**
  31081. * Sets wether the vignette effect is enabled.
  31082. */
  31083. vignetteEnabled: boolean;
  31084. private _applyByPostProcess;
  31085. /**
  31086. * Gets wether the image processing is applied through a post process or not.
  31087. */
  31088. /**
  31089. * Sets wether the image processing is applied through a post process or not.
  31090. */
  31091. applyByPostProcess: boolean;
  31092. private _isEnabled;
  31093. /**
  31094. * Gets wether the image processing is enabled or not.
  31095. */
  31096. /**
  31097. * Sets wether the image processing is enabled or not.
  31098. */
  31099. isEnabled: boolean;
  31100. /**
  31101. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  31102. */
  31103. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  31104. /**
  31105. * Method called each time the image processing information changes requires to recompile the effect.
  31106. */
  31107. protected _updateParameters(): void;
  31108. /**
  31109. * Gets the current class name.
  31110. * @return "ImageProcessingConfiguration"
  31111. */
  31112. getClassName(): string;
  31113. /**
  31114. * Prepare the list of uniforms associated with the Image Processing effects.
  31115. * @param uniforms The list of uniforms used in the effect
  31116. * @param defines the list of defines currently in use
  31117. */
  31118. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  31119. /**
  31120. * Prepare the list of samplers associated with the Image Processing effects.
  31121. * @param samplersList The list of uniforms used in the effect
  31122. * @param defines the list of defines currently in use
  31123. */
  31124. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  31125. /**
  31126. * Prepare the list of defines associated to the shader.
  31127. * @param defines the list of defines to complete
  31128. * @param forPostProcess Define if we are currently in post process mode or not
  31129. */
  31130. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  31131. /**
  31132. * Returns true if all the image processing information are ready.
  31133. * @returns True if ready, otherwise, false
  31134. */
  31135. isReady(): boolean;
  31136. /**
  31137. * Binds the image processing to the shader.
  31138. * @param effect The effect to bind to
  31139. * @param aspectRatio Define the current aspect ratio of the effect
  31140. */
  31141. bind(effect: Effect, aspectRatio?: number): void;
  31142. /**
  31143. * Clones the current image processing instance.
  31144. * @return The cloned image processing
  31145. */
  31146. clone(): ImageProcessingConfiguration;
  31147. /**
  31148. * Serializes the current image processing instance to a json representation.
  31149. * @return a JSON representation
  31150. */
  31151. serialize(): any;
  31152. /**
  31153. * Parses the image processing from a json representation.
  31154. * @param source the JSON source to parse
  31155. * @return The parsed image processing
  31156. */
  31157. static Parse(source: any): ImageProcessingConfiguration;
  31158. private static _VIGNETTEMODE_MULTIPLY;
  31159. private static _VIGNETTEMODE_OPAQUE;
  31160. /**
  31161. * Used to apply the vignette as a mix with the pixel color.
  31162. */
  31163. static readonly VIGNETTEMODE_MULTIPLY: number;
  31164. /**
  31165. * Used to apply the vignette as a replacement of the pixel color.
  31166. */
  31167. static readonly VIGNETTEMODE_OPAQUE: number;
  31168. }
  31169. }
  31170. declare module "babylonjs/Materials/fresnelParameters" {
  31171. import { Color3 } from "babylonjs/Maths/math";
  31172. /**
  31173. * This represents all the required information to add a fresnel effect on a material:
  31174. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31175. */
  31176. export class FresnelParameters {
  31177. private _isEnabled;
  31178. /**
  31179. * Define if the fresnel effect is enable or not.
  31180. */
  31181. isEnabled: boolean;
  31182. /**
  31183. * Define the color used on edges (grazing angle)
  31184. */
  31185. leftColor: Color3;
  31186. /**
  31187. * Define the color used on center
  31188. */
  31189. rightColor: Color3;
  31190. /**
  31191. * Define bias applied to computed fresnel term
  31192. */
  31193. bias: number;
  31194. /**
  31195. * Defined the power exponent applied to fresnel term
  31196. */
  31197. power: number;
  31198. /**
  31199. * Clones the current fresnel and its valuues
  31200. * @returns a clone fresnel configuration
  31201. */
  31202. clone(): FresnelParameters;
  31203. /**
  31204. * Serializes the current fresnel parameters to a JSON representation.
  31205. * @return the JSON serialization
  31206. */
  31207. serialize(): any;
  31208. /**
  31209. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  31210. * @param parsedFresnelParameters Define the JSON representation
  31211. * @returns the parsed parameters
  31212. */
  31213. static Parse(parsedFresnelParameters: any): FresnelParameters;
  31214. }
  31215. }
  31216. declare module "babylonjs/Misc/decorators" {
  31217. import { Nullable } from "babylonjs/types";
  31218. import { Scene } from "babylonjs/scene";
  31219. import { IAnimatable } from "babylonjs/Misc/tools";
  31220. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  31221. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31222. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31223. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31224. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31225. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31226. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31227. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31228. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31229. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31230. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31231. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31232. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31233. /**
  31234. * Decorator used to define property that can be serialized as reference to a camera
  31235. * @param sourceName defines the name of the property to decorate
  31236. */
  31237. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31238. /**
  31239. * Class used to help serialization objects
  31240. */
  31241. export class SerializationHelper {
  31242. /** @hidden */
  31243. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  31244. /** @hidden */
  31245. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  31246. /** @hidden */
  31247. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  31248. /** @hidden */
  31249. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  31250. /**
  31251. * Appends the serialized animations from the source animations
  31252. * @param source Source containing the animations
  31253. * @param destination Target to store the animations
  31254. */
  31255. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  31256. /**
  31257. * Static function used to serialized a specific entity
  31258. * @param entity defines the entity to serialize
  31259. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  31260. * @returns a JSON compatible object representing the serialization of the entity
  31261. */
  31262. static Serialize<T>(entity: T, serializationObject?: any): any;
  31263. /**
  31264. * Creates a new entity from a serialization data object
  31265. * @param creationFunction defines a function used to instanciated the new entity
  31266. * @param source defines the source serialization data
  31267. * @param scene defines the hosting scene
  31268. * @param rootUrl defines the root url for resources
  31269. * @returns a new entity
  31270. */
  31271. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  31272. /**
  31273. * Clones an object
  31274. * @param creationFunction defines the function used to instanciate the new object
  31275. * @param source defines the source object
  31276. * @returns the cloned object
  31277. */
  31278. static Clone<T>(creationFunction: () => T, source: T): T;
  31279. /**
  31280. * Instanciates a new object based on a source one (some data will be shared between both object)
  31281. * @param creationFunction defines the function used to instanciate the new object
  31282. * @param source defines the source object
  31283. * @returns the new object
  31284. */
  31285. static Instanciate<T>(creationFunction: () => T, source: T): T;
  31286. }
  31287. }
  31288. declare module "babylonjs/Cameras/camera" {
  31289. import { SmartArray } from "babylonjs/Misc/smartArray";
  31290. import { Observable } from "babylonjs/Misc/observable";
  31291. import { Nullable } from "babylonjs/types";
  31292. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  31293. import { Scene } from "babylonjs/scene";
  31294. import { Matrix, Vector3, Viewport } from "babylonjs/Maths/math";
  31295. import { Node } from "babylonjs/node";
  31296. import { Mesh } from "babylonjs/Meshes/mesh";
  31297. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31298. import { ICullable } from "babylonjs/Culling/boundingInfo";
  31299. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31300. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31301. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  31302. import { Ray } from "babylonjs/Culling/ray";
  31303. /**
  31304. * This is the base class of all the camera used in the application.
  31305. * @see http://doc.babylonjs.com/features/cameras
  31306. */
  31307. export class Camera extends Node {
  31308. /** @hidden */
  31309. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  31310. /**
  31311. * This is the default projection mode used by the cameras.
  31312. * It helps recreating a feeling of perspective and better appreciate depth.
  31313. * This is the best way to simulate real life cameras.
  31314. */
  31315. static readonly PERSPECTIVE_CAMERA: number;
  31316. /**
  31317. * This helps creating camera with an orthographic mode.
  31318. * 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.
  31319. */
  31320. static readonly ORTHOGRAPHIC_CAMERA: number;
  31321. /**
  31322. * This is the default FOV mode for perspective cameras.
  31323. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  31324. */
  31325. static readonly FOVMODE_VERTICAL_FIXED: number;
  31326. /**
  31327. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  31328. */
  31329. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  31330. /**
  31331. * This specifies ther is no need for a camera rig.
  31332. * Basically only one eye is rendered corresponding to the camera.
  31333. */
  31334. static readonly RIG_MODE_NONE: number;
  31335. /**
  31336. * Simulates a camera Rig with one blue eye and one red eye.
  31337. * This can be use with 3d blue and red glasses.
  31338. */
  31339. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  31340. /**
  31341. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  31342. */
  31343. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  31344. /**
  31345. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  31346. */
  31347. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  31348. /**
  31349. * Defines that both eyes of the camera will be rendered over under each other.
  31350. */
  31351. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  31352. /**
  31353. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  31354. */
  31355. static readonly RIG_MODE_VR: number;
  31356. /**
  31357. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  31358. */
  31359. static readonly RIG_MODE_WEBVR: number;
  31360. /**
  31361. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  31362. */
  31363. static readonly RIG_MODE_CUSTOM: number;
  31364. /**
  31365. * Defines if by default attaching controls should prevent the default javascript event to continue.
  31366. */
  31367. static ForceAttachControlToAlwaysPreventDefault: boolean;
  31368. /**
  31369. * Define the input manager associated with the camera.
  31370. */
  31371. inputs: CameraInputsManager<Camera>;
  31372. /** @hidden */
  31373. _position: Vector3;
  31374. /**
  31375. * Define the current local position of the camera in the scene
  31376. */
  31377. position: Vector3;
  31378. /**
  31379. * The vector the camera should consider as up.
  31380. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  31381. */
  31382. upVector: Vector3;
  31383. /**
  31384. * Define the current limit on the left side for an orthographic camera
  31385. * In scene unit
  31386. */
  31387. orthoLeft: Nullable<number>;
  31388. /**
  31389. * Define the current limit on the right side for an orthographic camera
  31390. * In scene unit
  31391. */
  31392. orthoRight: Nullable<number>;
  31393. /**
  31394. * Define the current limit on the bottom side for an orthographic camera
  31395. * In scene unit
  31396. */
  31397. orthoBottom: Nullable<number>;
  31398. /**
  31399. * Define the current limit on the top side for an orthographic camera
  31400. * In scene unit
  31401. */
  31402. orthoTop: Nullable<number>;
  31403. /**
  31404. * Field Of View is set in Radians. (default is 0.8)
  31405. */
  31406. fov: number;
  31407. /**
  31408. * Define the minimum distance the camera can see from.
  31409. * This is important to note that the depth buffer are not infinite and the closer it starts
  31410. * the more your scene might encounter depth fighting issue.
  31411. */
  31412. minZ: number;
  31413. /**
  31414. * Define the maximum distance the camera can see to.
  31415. * This is important to note that the depth buffer are not infinite and the further it end
  31416. * the more your scene might encounter depth fighting issue.
  31417. */
  31418. maxZ: number;
  31419. /**
  31420. * Define the default inertia of the camera.
  31421. * This helps giving a smooth feeling to the camera movement.
  31422. */
  31423. inertia: number;
  31424. /**
  31425. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  31426. */
  31427. mode: number;
  31428. /**
  31429. * Define wether the camera is intermediate.
  31430. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  31431. */
  31432. isIntermediate: boolean;
  31433. /**
  31434. * Define the viewport of the camera.
  31435. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  31436. */
  31437. viewport: Viewport;
  31438. /**
  31439. * Restricts the camera to viewing objects with the same layerMask.
  31440. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  31441. */
  31442. layerMask: number;
  31443. /**
  31444. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  31445. */
  31446. fovMode: number;
  31447. /**
  31448. * Rig mode of the camera.
  31449. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  31450. * This is normally controlled byt the camera themselves as internal use.
  31451. */
  31452. cameraRigMode: number;
  31453. /**
  31454. * Defines the distance between both "eyes" in case of a RIG
  31455. */
  31456. interaxialDistance: number;
  31457. /**
  31458. * Defines if stereoscopic rendering is done side by side or over under.
  31459. */
  31460. isStereoscopicSideBySide: boolean;
  31461. /**
  31462. * 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
  31463. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  31464. * else in the scene.
  31465. */
  31466. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  31467. /**
  31468. * When set, the camera will render to this render target instead of the default canvas
  31469. */
  31470. outputRenderTarget: Nullable<RenderTargetTexture>;
  31471. /**
  31472. * Observable triggered when the camera view matrix has changed.
  31473. */
  31474. onViewMatrixChangedObservable: Observable<Camera>;
  31475. /**
  31476. * Observable triggered when the camera Projection matrix has changed.
  31477. */
  31478. onProjectionMatrixChangedObservable: Observable<Camera>;
  31479. /**
  31480. * Observable triggered when the inputs have been processed.
  31481. */
  31482. onAfterCheckInputsObservable: Observable<Camera>;
  31483. /**
  31484. * Observable triggered when reset has been called and applied to the camera.
  31485. */
  31486. onRestoreStateObservable: Observable<Camera>;
  31487. /** @hidden */
  31488. _cameraRigParams: any;
  31489. /** @hidden */
  31490. _rigCameras: Camera[];
  31491. /** @hidden */
  31492. _rigPostProcess: Nullable<PostProcess>;
  31493. protected _webvrViewMatrix: Matrix;
  31494. /** @hidden */
  31495. _skipRendering: boolean;
  31496. /** @hidden */
  31497. _projectionMatrix: Matrix;
  31498. /** @hidden */
  31499. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  31500. /** @hidden */
  31501. _activeMeshes: SmartArray<AbstractMesh>;
  31502. protected _globalPosition: Vector3;
  31503. /** @hidden */
  31504. _computedViewMatrix: Matrix;
  31505. private _doNotComputeProjectionMatrix;
  31506. private _transformMatrix;
  31507. private _frustumPlanes;
  31508. private _refreshFrustumPlanes;
  31509. private _storedFov;
  31510. private _stateStored;
  31511. /**
  31512. * Instantiates a new camera object.
  31513. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  31514. * @see http://doc.babylonjs.com/features/cameras
  31515. * @param name Defines the name of the camera in the scene
  31516. * @param position Defines the position of the camera
  31517. * @param scene Defines the scene the camera belongs too
  31518. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  31519. */
  31520. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  31521. /**
  31522. * Store current camera state (fov, position, etc..)
  31523. * @returns the camera
  31524. */
  31525. storeState(): Camera;
  31526. /**
  31527. * Restores the camera state values if it has been stored. You must call storeState() first
  31528. */
  31529. protected _restoreStateValues(): boolean;
  31530. /**
  31531. * Restored camera state. You must call storeState() first.
  31532. * @returns true if restored and false otherwise
  31533. */
  31534. restoreState(): boolean;
  31535. /**
  31536. * Gets the class name of the camera.
  31537. * @returns the class name
  31538. */
  31539. getClassName(): string;
  31540. /** @hidden */
  31541. readonly _isCamera: boolean;
  31542. /**
  31543. * Gets a string representation of the camera useful for debug purpose.
  31544. * @param fullDetails Defines that a more verboe level of logging is required
  31545. * @returns the string representation
  31546. */
  31547. toString(fullDetails?: boolean): string;
  31548. /**
  31549. * Gets the current world space position of the camera.
  31550. */
  31551. readonly globalPosition: Vector3;
  31552. /**
  31553. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  31554. * @returns the active meshe list
  31555. */
  31556. getActiveMeshes(): SmartArray<AbstractMesh>;
  31557. /**
  31558. * Check wether a mesh is part of the current active mesh list of the camera
  31559. * @param mesh Defines the mesh to check
  31560. * @returns true if active, false otherwise
  31561. */
  31562. isActiveMesh(mesh: Mesh): boolean;
  31563. /**
  31564. * Is this camera ready to be used/rendered
  31565. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  31566. * @return true if the camera is ready
  31567. */
  31568. isReady(completeCheck?: boolean): boolean;
  31569. /** @hidden */
  31570. _initCache(): void;
  31571. /** @hidden */
  31572. _updateCache(ignoreParentClass?: boolean): void;
  31573. /** @hidden */
  31574. _isSynchronized(): boolean;
  31575. /** @hidden */
  31576. _isSynchronizedViewMatrix(): boolean;
  31577. /** @hidden */
  31578. _isSynchronizedProjectionMatrix(): boolean;
  31579. /**
  31580. * Attach the input controls to a specific dom element to get the input from.
  31581. * @param element Defines the element the controls should be listened from
  31582. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  31583. */
  31584. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31585. /**
  31586. * Detach the current controls from the specified dom element.
  31587. * @param element Defines the element to stop listening the inputs from
  31588. */
  31589. detachControl(element: HTMLElement): void;
  31590. /**
  31591. * Update the camera state according to the different inputs gathered during the frame.
  31592. */
  31593. update(): void;
  31594. /** @hidden */
  31595. _checkInputs(): void;
  31596. /** @hidden */
  31597. readonly rigCameras: Camera[];
  31598. /**
  31599. * Gets the post process used by the rig cameras
  31600. */
  31601. readonly rigPostProcess: Nullable<PostProcess>;
  31602. /**
  31603. * Internal, gets the first post proces.
  31604. * @returns the first post process to be run on this camera.
  31605. */
  31606. _getFirstPostProcess(): Nullable<PostProcess>;
  31607. private _cascadePostProcessesToRigCams;
  31608. /**
  31609. * Attach a post process to the camera.
  31610. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31611. * @param postProcess The post process to attach to the camera
  31612. * @param insertAt The position of the post process in case several of them are in use in the scene
  31613. * @returns the position the post process has been inserted at
  31614. */
  31615. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  31616. /**
  31617. * Detach a post process to the camera.
  31618. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31619. * @param postProcess The post process to detach from the camera
  31620. */
  31621. detachPostProcess(postProcess: PostProcess): void;
  31622. /**
  31623. * Gets the current world matrix of the camera
  31624. */
  31625. getWorldMatrix(): Matrix;
  31626. /** @hidden */
  31627. _getViewMatrix(): Matrix;
  31628. /**
  31629. * Gets the current view matrix of the camera.
  31630. * @param force forces the camera to recompute the matrix without looking at the cached state
  31631. * @returns the view matrix
  31632. */
  31633. getViewMatrix(force?: boolean): Matrix;
  31634. /**
  31635. * Freeze the projection matrix.
  31636. * It will prevent the cache check of the camera projection compute and can speed up perf
  31637. * if no parameter of the camera are meant to change
  31638. * @param projection Defines manually a projection if necessary
  31639. */
  31640. freezeProjectionMatrix(projection?: Matrix): void;
  31641. /**
  31642. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  31643. */
  31644. unfreezeProjectionMatrix(): void;
  31645. /**
  31646. * Gets the current projection matrix of the camera.
  31647. * @param force forces the camera to recompute the matrix without looking at the cached state
  31648. * @returns the projection matrix
  31649. */
  31650. getProjectionMatrix(force?: boolean): Matrix;
  31651. /**
  31652. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  31653. * @returns a Matrix
  31654. */
  31655. getTransformationMatrix(): Matrix;
  31656. private _updateFrustumPlanes;
  31657. /**
  31658. * Checks if a cullable object (mesh...) is in the camera frustum
  31659. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  31660. * @param target The object to check
  31661. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  31662. * @returns true if the object is in frustum otherwise false
  31663. */
  31664. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  31665. /**
  31666. * Checks if a cullable object (mesh...) is in the camera frustum
  31667. * Unlike isInFrustum this cheks the full bounding box
  31668. * @param target The object to check
  31669. * @returns true if the object is in frustum otherwise false
  31670. */
  31671. isCompletelyInFrustum(target: ICullable): boolean;
  31672. /**
  31673. * Gets a ray in the forward direction from the camera.
  31674. * @param length Defines the length of the ray to create
  31675. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  31676. * @param origin Defines the start point of the ray which defaults to the camera position
  31677. * @returns the forward ray
  31678. */
  31679. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  31680. /**
  31681. * Releases resources associated with this node.
  31682. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  31683. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  31684. */
  31685. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  31686. /** @hidden */
  31687. _isLeftCamera: boolean;
  31688. /**
  31689. * Gets the left camera of a rig setup in case of Rigged Camera
  31690. */
  31691. readonly isLeftCamera: boolean;
  31692. /** @hidden */
  31693. _isRightCamera: boolean;
  31694. /**
  31695. * Gets the right camera of a rig setup in case of Rigged Camera
  31696. */
  31697. readonly isRightCamera: boolean;
  31698. /**
  31699. * Gets the left camera of a rig setup in case of Rigged Camera
  31700. */
  31701. readonly leftCamera: Nullable<FreeCamera>;
  31702. /**
  31703. * Gets the right camera of a rig setup in case of Rigged Camera
  31704. */
  31705. readonly rightCamera: Nullable<FreeCamera>;
  31706. /**
  31707. * Gets the left camera target of a rig setup in case of Rigged Camera
  31708. * @returns the target position
  31709. */
  31710. getLeftTarget(): Nullable<Vector3>;
  31711. /**
  31712. * Gets the right camera target of a rig setup in case of Rigged Camera
  31713. * @returns the target position
  31714. */
  31715. getRightTarget(): Nullable<Vector3>;
  31716. /**
  31717. * @hidden
  31718. */
  31719. setCameraRigMode(mode: number, rigParams: any): void;
  31720. /** @hidden */
  31721. static _setStereoscopicRigMode(camera: Camera): void;
  31722. /** @hidden */
  31723. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  31724. /** @hidden */
  31725. static _setVRRigMode(camera: Camera, rigParams: any): void;
  31726. /** @hidden */
  31727. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  31728. /** @hidden */
  31729. _getVRProjectionMatrix(): Matrix;
  31730. protected _updateCameraRotationMatrix(): void;
  31731. protected _updateWebVRCameraRotationMatrix(): void;
  31732. /**
  31733. * This function MUST be overwritten by the different WebVR cameras available.
  31734. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31735. * @hidden
  31736. */
  31737. _getWebVRProjectionMatrix(): Matrix;
  31738. /**
  31739. * This function MUST be overwritten by the different WebVR cameras available.
  31740. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31741. * @hidden
  31742. */
  31743. _getWebVRViewMatrix(): Matrix;
  31744. /** @hidden */
  31745. setCameraRigParameter(name: string, value: any): void;
  31746. /**
  31747. * needs to be overridden by children so sub has required properties to be copied
  31748. * @hidden
  31749. */
  31750. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  31751. /**
  31752. * May need to be overridden by children
  31753. * @hidden
  31754. */
  31755. _updateRigCameras(): void;
  31756. /** @hidden */
  31757. _setupInputs(): void;
  31758. /**
  31759. * Serialiaze the camera setup to a json represention
  31760. * @returns the JSON representation
  31761. */
  31762. serialize(): any;
  31763. /**
  31764. * Clones the current camera.
  31765. * @param name The cloned camera name
  31766. * @returns the cloned camera
  31767. */
  31768. clone(name: string): Camera;
  31769. /**
  31770. * Gets the direction of the camera relative to a given local axis.
  31771. * @param localAxis Defines the reference axis to provide a relative direction.
  31772. * @return the direction
  31773. */
  31774. getDirection(localAxis: Vector3): Vector3;
  31775. /**
  31776. * Gets the direction of the camera relative to a given local axis into a passed vector.
  31777. * @param localAxis Defines the reference axis to provide a relative direction.
  31778. * @param result Defines the vector to store the result in
  31779. */
  31780. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  31781. /**
  31782. * Gets a camera constructor for a given camera type
  31783. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  31784. * @param name The name of the camera the result will be able to instantiate
  31785. * @param scene The scene the result will construct the camera in
  31786. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  31787. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  31788. * @returns a factory method to construc the camera
  31789. */
  31790. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  31791. /**
  31792. * Compute the world matrix of the camera.
  31793. * @returns the camera workd matrix
  31794. */
  31795. computeWorldMatrix(): Matrix;
  31796. /**
  31797. * Parse a JSON and creates the camera from the parsed information
  31798. * @param parsedCamera The JSON to parse
  31799. * @param scene The scene to instantiate the camera in
  31800. * @returns the newly constructed camera
  31801. */
  31802. static Parse(parsedCamera: any, scene: Scene): Camera;
  31803. }
  31804. }
  31805. declare module "babylonjs/Misc/tools" {
  31806. import { FloatArray, IndicesArray, Nullable } from "babylonjs/types";
  31807. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  31808. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31809. import { Observable } from "babylonjs/Misc/observable";
  31810. import { DomManagement } from "babylonjs/Misc/domManagement";
  31811. import { WebRequest } from "babylonjs/Misc/webRequest";
  31812. import { Camera } from "babylonjs/Cameras/camera";
  31813. import { Engine } from "babylonjs/Engines/engine";
  31814. import { Animation } from "babylonjs/Animations/animation";
  31815. /**
  31816. * Interface for any object that can request an animation frame
  31817. */
  31818. export interface ICustomAnimationFrameRequester {
  31819. /**
  31820. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31821. */
  31822. renderFunction?: Function;
  31823. /**
  31824. * Called to request the next frame to render to
  31825. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31826. */
  31827. requestAnimationFrame: Function;
  31828. /**
  31829. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31830. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31831. */
  31832. requestID?: number;
  31833. }
  31834. /**
  31835. * Interface containing an array of animations
  31836. */
  31837. export interface IAnimatable {
  31838. /**
  31839. * Array of animations
  31840. */
  31841. animations: Nullable<Array<Animation>>;
  31842. }
  31843. /** Interface used by value gradients (color, factor, ...) */
  31844. export interface IValueGradient {
  31845. /**
  31846. * Gets or sets the gradient value (between 0 and 1)
  31847. */
  31848. gradient: number;
  31849. }
  31850. /** Class used to store color4 gradient */
  31851. export class ColorGradient implements IValueGradient {
  31852. /**
  31853. * Gets or sets the gradient value (between 0 and 1)
  31854. */
  31855. gradient: number;
  31856. /**
  31857. * Gets or sets first associated color
  31858. */
  31859. color1: Color4;
  31860. /**
  31861. * Gets or sets second associated color
  31862. */
  31863. color2?: Color4;
  31864. /**
  31865. * Will get a color picked randomly between color1 and color2.
  31866. * If color2 is undefined then color1 will be used
  31867. * @param result defines the target Color4 to store the result in
  31868. */
  31869. getColorToRef(result: Color4): void;
  31870. }
  31871. /** Class used to store color 3 gradient */
  31872. export class Color3Gradient implements IValueGradient {
  31873. /**
  31874. * Gets or sets the gradient value (between 0 and 1)
  31875. */
  31876. gradient: number;
  31877. /**
  31878. * Gets or sets the associated color
  31879. */
  31880. color: Color3;
  31881. }
  31882. /** Class used to store factor gradient */
  31883. export class FactorGradient implements IValueGradient {
  31884. /**
  31885. * Gets or sets the gradient value (between 0 and 1)
  31886. */
  31887. gradient: number;
  31888. /**
  31889. * Gets or sets first associated factor
  31890. */
  31891. factor1: number;
  31892. /**
  31893. * Gets or sets second associated factor
  31894. */
  31895. factor2?: number;
  31896. /**
  31897. * Will get a number picked randomly between factor1 and factor2.
  31898. * If factor2 is undefined then factor1 will be used
  31899. * @returns the picked number
  31900. */
  31901. getFactor(): number;
  31902. }
  31903. /**
  31904. * @ignore
  31905. * Application error to support additional information when loading a file
  31906. */
  31907. export class LoadFileError extends Error {
  31908. /** defines the optional web request */
  31909. request?: WebRequest | undefined;
  31910. private static _setPrototypeOf;
  31911. /**
  31912. * Creates a new LoadFileError
  31913. * @param message defines the message of the error
  31914. * @param request defines the optional web request
  31915. */
  31916. constructor(message: string,
  31917. /** defines the optional web request */
  31918. request?: WebRequest | undefined);
  31919. }
  31920. /**
  31921. * Class used to define a retry strategy when error happens while loading assets
  31922. */
  31923. export class RetryStrategy {
  31924. /**
  31925. * Function used to defines an exponential back off strategy
  31926. * @param maxRetries defines the maximum number of retries (3 by default)
  31927. * @param baseInterval defines the interval between retries
  31928. * @returns the strategy function to use
  31929. */
  31930. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  31931. }
  31932. /**
  31933. * File request interface
  31934. */
  31935. export interface IFileRequest {
  31936. /**
  31937. * Raised when the request is complete (success or error).
  31938. */
  31939. onCompleteObservable: Observable<IFileRequest>;
  31940. /**
  31941. * Aborts the request for a file.
  31942. */
  31943. abort: () => void;
  31944. }
  31945. /**
  31946. * Class containing a set of static utilities functions
  31947. */
  31948. export class Tools {
  31949. /**
  31950. * Gets or sets the base URL to use to load assets
  31951. */
  31952. static BaseUrl: string;
  31953. /**
  31954. * Enable/Disable Custom HTTP Request Headers globally.
  31955. * default = false
  31956. * @see CustomRequestHeaders
  31957. */
  31958. static UseCustomRequestHeaders: boolean;
  31959. /**
  31960. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31961. * i.e. when loading files, where the server/service expects an Authorization header
  31962. */
  31963. static CustomRequestHeaders: {
  31964. [key: string]: string;
  31965. };
  31966. /**
  31967. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31968. */
  31969. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31970. /**
  31971. * Default behaviour for cors in the application.
  31972. * It can be a string if the expected behavior is identical in the entire app.
  31973. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31974. */
  31975. static CorsBehavior: string | ((url: string | string[]) => string);
  31976. /**
  31977. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31978. * @ignorenaming
  31979. */
  31980. static UseFallbackTexture: boolean;
  31981. /**
  31982. * Use this object to register external classes like custom textures or material
  31983. * to allow the laoders to instantiate them
  31984. */
  31985. static RegisteredExternalClasses: {
  31986. [key: string]: Object;
  31987. };
  31988. /**
  31989. * Texture content used if a texture cannot loaded
  31990. * @ignorenaming
  31991. */
  31992. static fallbackTexture: string;
  31993. /**
  31994. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31995. * @param u defines the coordinate on X axis
  31996. * @param v defines the coordinate on Y axis
  31997. * @param width defines the width of the source data
  31998. * @param height defines the height of the source data
  31999. * @param pixels defines the source byte array
  32000. * @param color defines the output color
  32001. */
  32002. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  32003. /**
  32004. * Interpolates between a and b via alpha
  32005. * @param a The lower value (returned when alpha = 0)
  32006. * @param b The upper value (returned when alpha = 1)
  32007. * @param alpha The interpolation-factor
  32008. * @return The mixed value
  32009. */
  32010. static Mix(a: number, b: number, alpha: number): number;
  32011. /**
  32012. * Tries to instantiate a new object from a given class name
  32013. * @param className defines the class name to instantiate
  32014. * @returns the new object or null if the system was not able to do the instantiation
  32015. */
  32016. static Instantiate(className: string): any;
  32017. /**
  32018. * Provides a slice function that will work even on IE
  32019. * @param data defines the array to slice
  32020. * @param start defines the start of the data (optional)
  32021. * @param end defines the end of the data (optional)
  32022. * @returns the new sliced array
  32023. */
  32024. static Slice<T>(data: T, start?: number, end?: number): T;
  32025. /**
  32026. * Polyfill for setImmediate
  32027. * @param action defines the action to execute after the current execution block
  32028. */
  32029. static SetImmediate(action: () => void): void;
  32030. /**
  32031. * Function indicating if a number is an exponent of 2
  32032. * @param value defines the value to test
  32033. * @returns true if the value is an exponent of 2
  32034. */
  32035. static IsExponentOfTwo(value: number): boolean;
  32036. private static _tmpFloatArray;
  32037. /**
  32038. * Returns the nearest 32-bit single precision float representation of a Number
  32039. * @param value A Number. If the parameter is of a different type, it will get converted
  32040. * to a number or to NaN if it cannot be converted
  32041. * @returns number
  32042. */
  32043. static FloatRound(value: number): number;
  32044. /**
  32045. * Find the next highest power of two.
  32046. * @param x Number to start search from.
  32047. * @return Next highest power of two.
  32048. */
  32049. static CeilingPOT(x: number): number;
  32050. /**
  32051. * Find the next lowest power of two.
  32052. * @param x Number to start search from.
  32053. * @return Next lowest power of two.
  32054. */
  32055. static FloorPOT(x: number): number;
  32056. /**
  32057. * Find the nearest power of two.
  32058. * @param x Number to start search from.
  32059. * @return Next nearest power of two.
  32060. */
  32061. static NearestPOT(x: number): number;
  32062. /**
  32063. * Get the closest exponent of two
  32064. * @param value defines the value to approximate
  32065. * @param max defines the maximum value to return
  32066. * @param mode defines how to define the closest value
  32067. * @returns closest exponent of two of the given value
  32068. */
  32069. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32070. /**
  32071. * Extracts the filename from a path
  32072. * @param path defines the path to use
  32073. * @returns the filename
  32074. */
  32075. static GetFilename(path: string): string;
  32076. /**
  32077. * Extracts the "folder" part of a path (everything before the filename).
  32078. * @param uri The URI to extract the info from
  32079. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  32080. * @returns The "folder" part of the path
  32081. */
  32082. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  32083. /**
  32084. * Extracts text content from a DOM element hierarchy
  32085. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  32086. */
  32087. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  32088. /**
  32089. * Convert an angle in radians to degrees
  32090. * @param angle defines the angle to convert
  32091. * @returns the angle in degrees
  32092. */
  32093. static ToDegrees(angle: number): number;
  32094. /**
  32095. * Convert an angle in degrees to radians
  32096. * @param angle defines the angle to convert
  32097. * @returns the angle in radians
  32098. */
  32099. static ToRadians(angle: number): number;
  32100. /**
  32101. * Encode a buffer to a base64 string
  32102. * @param buffer defines the buffer to encode
  32103. * @returns the encoded string
  32104. */
  32105. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  32106. /**
  32107. * Extracts minimum and maximum values from a list of indexed positions
  32108. * @param positions defines the positions to use
  32109. * @param indices defines the indices to the positions
  32110. * @param indexStart defines the start index
  32111. * @param indexCount defines the end index
  32112. * @param bias defines bias value to add to the result
  32113. * @return minimum and maximum values
  32114. */
  32115. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  32116. minimum: Vector3;
  32117. maximum: Vector3;
  32118. };
  32119. /**
  32120. * Extracts minimum and maximum values from a list of positions
  32121. * @param positions defines the positions to use
  32122. * @param start defines the start index in the positions array
  32123. * @param count defines the number of positions to handle
  32124. * @param bias defines bias value to add to the result
  32125. * @param stride defines the stride size to use (distance between two positions in the positions array)
  32126. * @return minimum and maximum values
  32127. */
  32128. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  32129. minimum: Vector3;
  32130. maximum: Vector3;
  32131. };
  32132. /**
  32133. * Returns an array if obj is not an array
  32134. * @param obj defines the object to evaluate as an array
  32135. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  32136. * @returns either obj directly if obj is an array or a new array containing obj
  32137. */
  32138. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  32139. /**
  32140. * Gets the pointer prefix to use
  32141. * @returns "pointer" if touch is enabled. Else returns "mouse"
  32142. */
  32143. static GetPointerPrefix(): string;
  32144. /**
  32145. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32146. * @param func - the function to be called
  32147. * @param requester - the object that will request the next frame. Falls back to window.
  32148. * @returns frame number
  32149. */
  32150. static QueueNewFrame(func: () => void, requester?: any): number;
  32151. /**
  32152. * Ask the browser to promote the current element to fullscreen rendering mode
  32153. * @param element defines the DOM element to promote
  32154. */
  32155. static RequestFullscreen(element: HTMLElement): void;
  32156. /**
  32157. * Asks the browser to exit fullscreen mode
  32158. */
  32159. static ExitFullscreen(): void;
  32160. /**
  32161. * Ask the browser to promote the current element to pointerlock mode
  32162. * @param element defines the DOM element to promote
  32163. */
  32164. static RequestPointerlock(element: HTMLElement): void;
  32165. /**
  32166. * Asks the browser to exit pointerlock mode
  32167. */
  32168. static ExitPointerlock(): void;
  32169. /**
  32170. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  32171. * @param url define the url we are trying
  32172. * @param element define the dom element where to configure the cors policy
  32173. */
  32174. static SetCorsBehavior(url: string | string[], element: {
  32175. crossOrigin: string | null;
  32176. }): void;
  32177. /**
  32178. * Removes unwanted characters from an url
  32179. * @param url defines the url to clean
  32180. * @returns the cleaned url
  32181. */
  32182. static CleanUrl(url: string): string;
  32183. /**
  32184. * Gets or sets a function used to pre-process url before using them to load assets
  32185. */
  32186. static PreprocessUrl: (url: string) => string;
  32187. /**
  32188. * Loads an image as an HTMLImageElement.
  32189. * @param input url string, ArrayBuffer, or Blob to load
  32190. * @param onLoad callback called when the image successfully loads
  32191. * @param onError callback called when the image fails to load
  32192. * @param offlineProvider offline provider for caching
  32193. * @returns the HTMLImageElement of the loaded image
  32194. */
  32195. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  32196. /**
  32197. * Loads a file
  32198. * @param url url string, ArrayBuffer, or Blob to load
  32199. * @param onSuccess callback called when the file successfully loads
  32200. * @param onProgress callback called while file is loading (if the server supports this mode)
  32201. * @param offlineProvider defines the offline provider for caching
  32202. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32203. * @param onError callback called when the file fails to load
  32204. * @returns a file request object
  32205. */
  32206. 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;
  32207. /**
  32208. * Loads a file from a url
  32209. * @param url the file url to load
  32210. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  32211. */
  32212. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  32213. /**
  32214. * Load a script (identified by an url). When the url returns, the
  32215. * content of this file is added into a new script element, attached to the DOM (body element)
  32216. * @param scriptUrl defines the url of the script to laod
  32217. * @param onSuccess defines the callback called when the script is loaded
  32218. * @param onError defines the callback to call if an error occurs
  32219. * @param scriptId defines the id of the script element
  32220. */
  32221. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  32222. /**
  32223. * Load an asynchronous script (identified by an url). When the url returns, the
  32224. * content of this file is added into a new script element, attached to the DOM (body element)
  32225. * @param scriptUrl defines the url of the script to laod
  32226. * @param scriptId defines the id of the script element
  32227. * @returns a promise request object
  32228. */
  32229. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  32230. /**
  32231. * Loads a file from a blob
  32232. * @param fileToLoad defines the blob to use
  32233. * @param callback defines the callback to call when data is loaded
  32234. * @param progressCallback defines the callback to call during loading process
  32235. * @returns a file request object
  32236. */
  32237. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  32238. /**
  32239. * Loads a file
  32240. * @param fileToLoad defines the file to load
  32241. * @param callback defines the callback to call when data is loaded
  32242. * @param progressCallBack defines the callback to call during loading process
  32243. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  32244. * @returns a file request object
  32245. */
  32246. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  32247. /**
  32248. * Creates a data url from a given string content
  32249. * @param content defines the content to convert
  32250. * @returns the new data url link
  32251. */
  32252. static FileAsURL(content: string): string;
  32253. /**
  32254. * Format the given number to a specific decimal format
  32255. * @param value defines the number to format
  32256. * @param decimals defines the number of decimals to use
  32257. * @returns the formatted string
  32258. */
  32259. static Format(value: number, decimals?: number): string;
  32260. /**
  32261. * Checks if a given vector is inside a specific range
  32262. * @param v defines the vector to test
  32263. * @param min defines the minimum range
  32264. * @param max defines the maximum range
  32265. */
  32266. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  32267. /**
  32268. * Tries to copy an object by duplicating every property
  32269. * @param source defines the source object
  32270. * @param destination defines the target object
  32271. * @param doNotCopyList defines a list of properties to avoid
  32272. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  32273. */
  32274. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  32275. /**
  32276. * Gets a boolean indicating if the given object has no own property
  32277. * @param obj defines the object to test
  32278. * @returns true if object has no own property
  32279. */
  32280. static IsEmpty(obj: any): boolean;
  32281. /**
  32282. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  32283. * @param str Source string
  32284. * @param suffix Suffix to search for in the source string
  32285. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  32286. */
  32287. static EndsWith(str: string, suffix: string): boolean;
  32288. /**
  32289. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  32290. * @param str Source string
  32291. * @param suffix Suffix to search for in the source string
  32292. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  32293. */
  32294. static StartsWith(str: string, suffix: string): boolean;
  32295. /**
  32296. * Function used to register events at window level
  32297. * @param events defines the events to register
  32298. */
  32299. static RegisterTopRootEvents(events: {
  32300. name: string;
  32301. handler: Nullable<(e: FocusEvent) => any>;
  32302. }[]): void;
  32303. /**
  32304. * Function used to unregister events from window level
  32305. * @param events defines the events to unregister
  32306. */
  32307. static UnregisterTopRootEvents(events: {
  32308. name: string;
  32309. handler: Nullable<(e: FocusEvent) => any>;
  32310. }[]): void;
  32311. /**
  32312. * @ignore
  32313. */
  32314. static _ScreenshotCanvas: HTMLCanvasElement;
  32315. /**
  32316. * Dumps the current bound framebuffer
  32317. * @param width defines the rendering width
  32318. * @param height defines the rendering height
  32319. * @param engine defines the hosting engine
  32320. * @param successCallback defines the callback triggered once the data are available
  32321. * @param mimeType defines the mime type of the result
  32322. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  32323. */
  32324. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32325. /**
  32326. * Converts the canvas data to blob.
  32327. * This acts as a polyfill for browsers not supporting the to blob function.
  32328. * @param canvas Defines the canvas to extract the data from
  32329. * @param successCallback Defines the callback triggered once the data are available
  32330. * @param mimeType Defines the mime type of the result
  32331. */
  32332. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  32333. /**
  32334. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  32335. * @param successCallback defines the callback triggered once the data are available
  32336. * @param mimeType defines the mime type of the result
  32337. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  32338. */
  32339. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32340. /**
  32341. * Downloads a blob in the browser
  32342. * @param blob defines the blob to download
  32343. * @param fileName defines the name of the downloaded file
  32344. */
  32345. static Download(blob: Blob, fileName: string): void;
  32346. /**
  32347. * Captures a screenshot of the current rendering
  32348. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32349. * @param engine defines the rendering engine
  32350. * @param camera defines the source camera
  32351. * @param size This parameter can be set to a single number or to an object with the
  32352. * following (optional) properties: precision, width, height. If a single number is passed,
  32353. * it will be used for both width and height. If an object is passed, the screenshot size
  32354. * will be derived from the parameters. The precision property is a multiplier allowing
  32355. * rendering at a higher or lower resolution
  32356. * @param successCallback defines the callback receives a single parameter which contains the
  32357. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32358. * src parameter of an <img> to display it
  32359. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32360. * Check your browser for supported MIME types
  32361. */
  32362. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  32363. /**
  32364. * Generates an image screenshot from the specified camera.
  32365. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32366. * @param engine The engine to use for rendering
  32367. * @param camera The camera to use for rendering
  32368. * @param size This parameter can be set to a single number or to an object with the
  32369. * following (optional) properties: precision, width, height. If a single number is passed,
  32370. * it will be used for both width and height. If an object is passed, the screenshot size
  32371. * will be derived from the parameters. The precision property is a multiplier allowing
  32372. * rendering at a higher or lower resolution
  32373. * @param successCallback The callback receives a single parameter which contains the
  32374. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32375. * src parameter of an <img> to display it
  32376. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32377. * Check your browser for supported MIME types
  32378. * @param samples Texture samples (default: 1)
  32379. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32380. * @param fileName A name for for the downloaded file.
  32381. */
  32382. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32383. /**
  32384. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32385. * Be aware Math.random() could cause collisions, but:
  32386. * "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"
  32387. * @returns a pseudo random id
  32388. */
  32389. static RandomId(): string;
  32390. /**
  32391. * Test if the given uri is a base64 string
  32392. * @param uri The uri to test
  32393. * @return True if the uri is a base64 string or false otherwise
  32394. */
  32395. static IsBase64(uri: string): boolean;
  32396. /**
  32397. * Decode the given base64 uri.
  32398. * @param uri The uri to decode
  32399. * @return The decoded base64 data.
  32400. */
  32401. static DecodeBase64(uri: string): ArrayBuffer;
  32402. /**
  32403. * Gets the absolute url.
  32404. * @param url the input url
  32405. * @return the absolute url
  32406. */
  32407. static GetAbsoluteUrl(url: string): string;
  32408. /**
  32409. * No log
  32410. */
  32411. static readonly NoneLogLevel: number;
  32412. /**
  32413. * Only message logs
  32414. */
  32415. static readonly MessageLogLevel: number;
  32416. /**
  32417. * Only warning logs
  32418. */
  32419. static readonly WarningLogLevel: number;
  32420. /**
  32421. * Only error logs
  32422. */
  32423. static readonly ErrorLogLevel: number;
  32424. /**
  32425. * All logs
  32426. */
  32427. static readonly AllLogLevel: number;
  32428. /**
  32429. * Gets a value indicating the number of loading errors
  32430. * @ignorenaming
  32431. */
  32432. static readonly errorsCount: number;
  32433. /**
  32434. * Callback called when a new log is added
  32435. */
  32436. static OnNewCacheEntry: (entry: string) => void;
  32437. /**
  32438. * Log a message to the console
  32439. * @param message defines the message to log
  32440. */
  32441. static Log(message: string): void;
  32442. /**
  32443. * Write a warning message to the console
  32444. * @param message defines the message to log
  32445. */
  32446. static Warn(message: string): void;
  32447. /**
  32448. * Write an error message to the console
  32449. * @param message defines the message to log
  32450. */
  32451. static Error(message: string): void;
  32452. /**
  32453. * Gets current log cache (list of logs)
  32454. */
  32455. static readonly LogCache: string;
  32456. /**
  32457. * Clears the log cache
  32458. */
  32459. static ClearLogCache(): void;
  32460. /**
  32461. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  32462. */
  32463. static LogLevels: number;
  32464. /**
  32465. * Checks if the loaded document was accessed via `file:`-Protocol.
  32466. * @returns boolean
  32467. */
  32468. static IsFileURL(): boolean;
  32469. /**
  32470. * Checks if the window object exists
  32471. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  32472. */
  32473. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  32474. /**
  32475. * No performance log
  32476. */
  32477. static readonly PerformanceNoneLogLevel: number;
  32478. /**
  32479. * Use user marks to log performance
  32480. */
  32481. static readonly PerformanceUserMarkLogLevel: number;
  32482. /**
  32483. * Log performance to the console
  32484. */
  32485. static readonly PerformanceConsoleLogLevel: number;
  32486. private static _performance;
  32487. /**
  32488. * Sets the current performance log level
  32489. */
  32490. static PerformanceLogLevel: number;
  32491. private static _StartPerformanceCounterDisabled;
  32492. private static _EndPerformanceCounterDisabled;
  32493. private static _StartUserMark;
  32494. private static _EndUserMark;
  32495. private static _StartPerformanceConsole;
  32496. private static _EndPerformanceConsole;
  32497. /**
  32498. * Starts a performance counter
  32499. */
  32500. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32501. /**
  32502. * Ends a specific performance coutner
  32503. */
  32504. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32505. /**
  32506. * Gets either window.performance.now() if supported or Date.now() else
  32507. */
  32508. static readonly Now: number;
  32509. /**
  32510. * This method will return the name of the class used to create the instance of the given object.
  32511. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32512. * @param object the object to get the class name from
  32513. * @param isType defines if the object is actually a type
  32514. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  32515. */
  32516. static GetClassName(object: any, isType?: boolean): string;
  32517. /**
  32518. * Gets the first element of an array satisfying a given predicate
  32519. * @param array defines the array to browse
  32520. * @param predicate defines the predicate to use
  32521. * @returns null if not found or the element
  32522. */
  32523. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  32524. /**
  32525. * This method will return the name of the full name of the class, including its owning module (if any).
  32526. * 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).
  32527. * @param object the object to get the class name from
  32528. * @param isType defines if the object is actually a type
  32529. * @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.
  32530. * @ignorenaming
  32531. */
  32532. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32533. /**
  32534. * Returns a promise that resolves after the given amount of time.
  32535. * @param delay Number of milliseconds to delay
  32536. * @returns Promise that resolves after the given amount of time
  32537. */
  32538. static DelayAsync(delay: number): Promise<void>;
  32539. /**
  32540. * Gets the current gradient from an array of IValueGradient
  32541. * @param ratio defines the current ratio to get
  32542. * @param gradients defines the array of IValueGradient
  32543. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  32544. */
  32545. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  32546. }
  32547. /**
  32548. * This class is used to track a performance counter which is number based.
  32549. * The user has access to many properties which give statistics of different nature.
  32550. *
  32551. * The implementer can track two kinds of Performance Counter: time and count.
  32552. * 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.
  32553. * 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.
  32554. */
  32555. export class PerfCounter {
  32556. /**
  32557. * Gets or sets a global boolean to turn on and off all the counters
  32558. */
  32559. static Enabled: boolean;
  32560. /**
  32561. * Returns the smallest value ever
  32562. */
  32563. readonly min: number;
  32564. /**
  32565. * Returns the biggest value ever
  32566. */
  32567. readonly max: number;
  32568. /**
  32569. * Returns the average value since the performance counter is running
  32570. */
  32571. readonly average: number;
  32572. /**
  32573. * Returns the average value of the last second the counter was monitored
  32574. */
  32575. readonly lastSecAverage: number;
  32576. /**
  32577. * Returns the current value
  32578. */
  32579. readonly current: number;
  32580. /**
  32581. * Gets the accumulated total
  32582. */
  32583. readonly total: number;
  32584. /**
  32585. * Gets the total value count
  32586. */
  32587. readonly count: number;
  32588. /**
  32589. * Creates a new counter
  32590. */
  32591. constructor();
  32592. /**
  32593. * Call this method to start monitoring a new frame.
  32594. * 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.
  32595. */
  32596. fetchNewFrame(): void;
  32597. /**
  32598. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32599. * @param newCount the count value to add to the monitored count
  32600. * @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.
  32601. */
  32602. addCount(newCount: number, fetchResult: boolean): void;
  32603. /**
  32604. * Start monitoring this performance counter
  32605. */
  32606. beginMonitoring(): void;
  32607. /**
  32608. * Compute the time lapsed since the previous beginMonitoring() call.
  32609. * @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
  32610. */
  32611. endMonitoring(newFrame?: boolean): void;
  32612. private _fetchResult;
  32613. private _startMonitoringTime;
  32614. private _min;
  32615. private _max;
  32616. private _average;
  32617. private _current;
  32618. private _totalValueCount;
  32619. private _totalAccumulated;
  32620. private _lastSecAverage;
  32621. private _lastSecAccumulated;
  32622. private _lastSecTime;
  32623. private _lastSecValueCount;
  32624. }
  32625. /**
  32626. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32627. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32628. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32629. * @param name The name of the class, case should be preserved
  32630. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32631. */
  32632. export function className(name: string, module?: string): (target: Object) => void;
  32633. /**
  32634. * An implementation of a loop for asynchronous functions.
  32635. */
  32636. export class AsyncLoop {
  32637. /**
  32638. * Defines the number of iterations for the loop
  32639. */
  32640. iterations: number;
  32641. /**
  32642. * Defines the current index of the loop.
  32643. */
  32644. index: number;
  32645. private _done;
  32646. private _fn;
  32647. private _successCallback;
  32648. /**
  32649. * Constructor.
  32650. * @param iterations the number of iterations.
  32651. * @param func the function to run each iteration
  32652. * @param successCallback the callback that will be called upon succesful execution
  32653. * @param offset starting offset.
  32654. */
  32655. constructor(
  32656. /**
  32657. * Defines the number of iterations for the loop
  32658. */
  32659. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32660. /**
  32661. * Execute the next iteration. Must be called after the last iteration was finished.
  32662. */
  32663. executeNext(): void;
  32664. /**
  32665. * Break the loop and run the success callback.
  32666. */
  32667. breakLoop(): void;
  32668. /**
  32669. * Create and run an async loop.
  32670. * @param iterations the number of iterations.
  32671. * @param fn the function to run each iteration
  32672. * @param successCallback the callback that will be called upon succesful execution
  32673. * @param offset starting offset.
  32674. * @returns the created async loop object
  32675. */
  32676. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  32677. /**
  32678. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32679. * @param iterations total number of iterations
  32680. * @param syncedIterations number of synchronous iterations in each async iteration.
  32681. * @param fn the function to call each iteration.
  32682. * @param callback a success call back that will be called when iterating stops.
  32683. * @param breakFunction a break condition (optional)
  32684. * @param timeout timeout settings for the setTimeout function. default - 0.
  32685. * @returns the created async loop object
  32686. */
  32687. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  32688. }
  32689. }
  32690. declare module "babylonjs/Collisions/collisionCoordinator" {
  32691. import { Nullable } from "babylonjs/types";
  32692. import { Scene } from "babylonjs/scene";
  32693. import { Vector3 } from "babylonjs/Maths/math";
  32694. import { Collider } from "babylonjs/Collisions/collider";
  32695. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32696. /** @hidden */
  32697. export interface ICollisionCoordinator {
  32698. createCollider(): Collider;
  32699. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32700. init(scene: Scene): void;
  32701. }
  32702. /** @hidden */
  32703. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  32704. private _scene;
  32705. private _scaledPosition;
  32706. private _scaledVelocity;
  32707. private _finalPosition;
  32708. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32709. createCollider(): Collider;
  32710. init(scene: Scene): void;
  32711. private _collideWithWorld;
  32712. }
  32713. }
  32714. declare module "babylonjs/Inputs/scene.inputManager" {
  32715. import { Nullable } from "babylonjs/types";
  32716. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32717. import { Vector2 } from "babylonjs/Maths/math";
  32718. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32719. import { Scene } from "babylonjs/scene";
  32720. /**
  32721. * Class used to manage all inputs for the scene.
  32722. */
  32723. export class InputManager {
  32724. /** The distance in pixel that you have to move to prevent some events */
  32725. static DragMovementThreshold: number;
  32726. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32727. static LongPressDelay: number;
  32728. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32729. static DoubleClickDelay: number;
  32730. /** If you need to check double click without raising a single click at first click, enable this flag */
  32731. static ExclusiveDoubleClickMode: boolean;
  32732. private _wheelEventName;
  32733. private _onPointerMove;
  32734. private _onPointerDown;
  32735. private _onPointerUp;
  32736. private _initClickEvent;
  32737. private _initActionManager;
  32738. private _delayedSimpleClick;
  32739. private _delayedSimpleClickTimeout;
  32740. private _previousDelayedSimpleClickTimeout;
  32741. private _meshPickProceed;
  32742. private _previousButtonPressed;
  32743. private _currentPickResult;
  32744. private _previousPickResult;
  32745. private _totalPointersPressed;
  32746. private _doubleClickOccured;
  32747. private _pointerOverMesh;
  32748. private _pickedDownMesh;
  32749. private _pickedUpMesh;
  32750. private _pointerX;
  32751. private _pointerY;
  32752. private _unTranslatedPointerX;
  32753. private _unTranslatedPointerY;
  32754. private _startingPointerPosition;
  32755. private _previousStartingPointerPosition;
  32756. private _startingPointerTime;
  32757. private _previousStartingPointerTime;
  32758. private _pointerCaptures;
  32759. private _onKeyDown;
  32760. private _onKeyUp;
  32761. private _onCanvasFocusObserver;
  32762. private _onCanvasBlurObserver;
  32763. private _scene;
  32764. /**
  32765. * Creates a new InputManager
  32766. * @param scene defines the hosting scene
  32767. */
  32768. constructor(scene: Scene);
  32769. /**
  32770. * Gets the mesh that is currently under the pointer
  32771. */
  32772. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32773. /**
  32774. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  32775. */
  32776. readonly unTranslatedPointer: Vector2;
  32777. /**
  32778. * Gets or sets the current on-screen X position of the pointer
  32779. */
  32780. pointerX: number;
  32781. /**
  32782. * Gets or sets the current on-screen Y position of the pointer
  32783. */
  32784. pointerY: number;
  32785. private _updatePointerPosition;
  32786. private _processPointerMove;
  32787. private _setRayOnPointerInfo;
  32788. private _checkPrePointerObservable;
  32789. /**
  32790. * Use this method to simulate a pointer move on a mesh
  32791. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32792. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32793. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32794. */
  32795. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32796. /**
  32797. * Use this method to simulate a pointer down on a mesh
  32798. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32799. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32800. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32801. */
  32802. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32803. private _processPointerDown;
  32804. /** @hidden */
  32805. _isPointerSwiping(): boolean;
  32806. /**
  32807. * Use this method to simulate a pointer up on a mesh
  32808. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32809. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32810. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32811. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32812. */
  32813. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  32814. private _processPointerUp;
  32815. /**
  32816. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32817. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32818. * @returns true if the pointer was captured
  32819. */
  32820. isPointerCaptured(pointerId?: number): boolean;
  32821. /**
  32822. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32823. * @param attachUp defines if you want to attach events to pointerup
  32824. * @param attachDown defines if you want to attach events to pointerdown
  32825. * @param attachMove defines if you want to attach events to pointermove
  32826. */
  32827. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32828. /**
  32829. * Detaches all event handlers
  32830. */
  32831. detachControl(): void;
  32832. /**
  32833. * Force the value of meshUnderPointer
  32834. * @param mesh defines the mesh to use
  32835. */
  32836. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32837. /**
  32838. * Gets the mesh under the pointer
  32839. * @returns a Mesh or null if no mesh is under the pointer
  32840. */
  32841. getPointerOverMesh(): Nullable<AbstractMesh>;
  32842. }
  32843. }
  32844. declare module "babylonjs/Animations/animationGroup" {
  32845. import { Animatable } from "babylonjs/Animations/animatable";
  32846. import { Animation } from "babylonjs/Animations/animation";
  32847. import { Scene, IDisposable } from "babylonjs/scene";
  32848. import { Observable } from "babylonjs/Misc/observable";
  32849. import { Nullable } from "babylonjs/types";
  32850. import "babylonjs/Animations/animatable";
  32851. /**
  32852. * This class defines the direct association between an animation and a target
  32853. */
  32854. export class TargetedAnimation {
  32855. /**
  32856. * Animation to perform
  32857. */
  32858. animation: Animation;
  32859. /**
  32860. * Target to animate
  32861. */
  32862. target: any;
  32863. /**
  32864. * Serialize the object
  32865. * @returns the JSON object representing the current entity
  32866. */
  32867. serialize(): any;
  32868. }
  32869. /**
  32870. * Use this class to create coordinated animations on multiple targets
  32871. */
  32872. export class AnimationGroup implements IDisposable {
  32873. /** The name of the animation group */
  32874. name: string;
  32875. private _scene;
  32876. private _targetedAnimations;
  32877. private _animatables;
  32878. private _from;
  32879. private _to;
  32880. private _isStarted;
  32881. private _isPaused;
  32882. private _speedRatio;
  32883. private _loopAnimation;
  32884. /**
  32885. * Gets or sets the unique id of the node
  32886. */
  32887. uniqueId: number;
  32888. /**
  32889. * This observable will notify when one animation have ended
  32890. */
  32891. onAnimationEndObservable: Observable<TargetedAnimation>;
  32892. /**
  32893. * Observer raised when one animation loops
  32894. */
  32895. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32896. /**
  32897. * This observable will notify when all animations have ended.
  32898. */
  32899. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32900. /**
  32901. * This observable will notify when all animations have paused.
  32902. */
  32903. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32904. /**
  32905. * This observable will notify when all animations are playing.
  32906. */
  32907. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32908. /**
  32909. * Gets the first frame
  32910. */
  32911. readonly from: number;
  32912. /**
  32913. * Gets the last frame
  32914. */
  32915. readonly to: number;
  32916. /**
  32917. * Define if the animations are started
  32918. */
  32919. readonly isStarted: boolean;
  32920. /**
  32921. * Gets a value indicating that the current group is playing
  32922. */
  32923. readonly isPlaying: boolean;
  32924. /**
  32925. * Gets or sets the speed ratio to use for all animations
  32926. */
  32927. /**
  32928. * Gets or sets the speed ratio to use for all animations
  32929. */
  32930. speedRatio: number;
  32931. /**
  32932. * Gets or sets if all animations should loop or not
  32933. */
  32934. loopAnimation: boolean;
  32935. /**
  32936. * Gets the targeted animations for this animation group
  32937. */
  32938. readonly targetedAnimations: Array<TargetedAnimation>;
  32939. /**
  32940. * returning the list of animatables controlled by this animation group.
  32941. */
  32942. readonly animatables: Array<Animatable>;
  32943. /**
  32944. * Instantiates a new Animation Group.
  32945. * This helps managing several animations at once.
  32946. * @see http://doc.babylonjs.com/how_to/group
  32947. * @param name Defines the name of the group
  32948. * @param scene Defines the scene the group belongs to
  32949. */
  32950. constructor(
  32951. /** The name of the animation group */
  32952. name: string, scene?: Nullable<Scene>);
  32953. /**
  32954. * Add an animation (with its target) in the group
  32955. * @param animation defines the animation we want to add
  32956. * @param target defines the target of the animation
  32957. * @returns the TargetedAnimation object
  32958. */
  32959. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32960. /**
  32961. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32962. * It can add constant keys at begin or end
  32963. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32964. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32965. * @returns the animation group
  32966. */
  32967. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32968. /**
  32969. * Start all animations on given targets
  32970. * @param loop defines if animations must loop
  32971. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32972. * @param from defines the from key (optional)
  32973. * @param to defines the to key (optional)
  32974. * @returns the current animation group
  32975. */
  32976. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32977. /**
  32978. * Pause all animations
  32979. * @returns the animation group
  32980. */
  32981. pause(): AnimationGroup;
  32982. /**
  32983. * Play all animations to initial state
  32984. * This function will start() the animations if they were not started or will restart() them if they were paused
  32985. * @param loop defines if animations must loop
  32986. * @returns the animation group
  32987. */
  32988. play(loop?: boolean): AnimationGroup;
  32989. /**
  32990. * Reset all animations to initial state
  32991. * @returns the animation group
  32992. */
  32993. reset(): AnimationGroup;
  32994. /**
  32995. * Restart animations from key 0
  32996. * @returns the animation group
  32997. */
  32998. restart(): AnimationGroup;
  32999. /**
  33000. * Stop all animations
  33001. * @returns the animation group
  33002. */
  33003. stop(): AnimationGroup;
  33004. /**
  33005. * Set animation weight for all animatables
  33006. * @param weight defines the weight to use
  33007. * @return the animationGroup
  33008. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33009. */
  33010. setWeightForAllAnimatables(weight: number): AnimationGroup;
  33011. /**
  33012. * Synchronize and normalize all animatables with a source animatable
  33013. * @param root defines the root animatable to synchronize with
  33014. * @return the animationGroup
  33015. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33016. */
  33017. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  33018. /**
  33019. * Goes to a specific frame in this animation group
  33020. * @param frame the frame number to go to
  33021. * @return the animationGroup
  33022. */
  33023. goToFrame(frame: number): AnimationGroup;
  33024. /**
  33025. * Dispose all associated resources
  33026. */
  33027. dispose(): void;
  33028. private _checkAnimationGroupEnded;
  33029. /**
  33030. * Clone the current animation group and returns a copy
  33031. * @param newName defines the name of the new group
  33032. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  33033. * @returns the new aniamtion group
  33034. */
  33035. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  33036. /**
  33037. * Serializes the animationGroup to an object
  33038. * @returns Serialized object
  33039. */
  33040. serialize(): any;
  33041. /**
  33042. * Returns a new AnimationGroup object parsed from the source provided.
  33043. * @param parsedAnimationGroup defines the source
  33044. * @param scene defines the scene that will receive the animationGroup
  33045. * @returns a new AnimationGroup
  33046. */
  33047. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  33048. /**
  33049. * Returns the string "AnimationGroup"
  33050. * @returns "AnimationGroup"
  33051. */
  33052. getClassName(): string;
  33053. /**
  33054. * Creates a detailled string about the object
  33055. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  33056. * @returns a string representing the object
  33057. */
  33058. toString(fullDetails?: boolean): string;
  33059. }
  33060. }
  33061. declare module "babylonjs/scene" {
  33062. import { Nullable } from "babylonjs/types";
  33063. import { IAnimatable, IFileRequest, PerfCounter } from "babylonjs/Misc/tools";
  33064. import { Observable } from "babylonjs/Misc/observable";
  33065. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  33066. import { Color4, Color3, Plane, Vector2, Vector3, Matrix } from "babylonjs/Maths/math";
  33067. import { Geometry } from "babylonjs/Meshes/geometry";
  33068. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33069. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33070. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33071. import { Mesh } from "babylonjs/Meshes/mesh";
  33072. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33073. import { Bone } from "babylonjs/Bones/bone";
  33074. import { Skeleton } from "babylonjs/Bones/skeleton";
  33075. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33076. import { Camera } from "babylonjs/Cameras/camera";
  33077. import { AbstractScene } from "babylonjs/abstractScene";
  33078. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33079. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33080. import { Material } from "babylonjs/Materials/material";
  33081. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  33082. import { Effect } from "babylonjs/Materials/effect";
  33083. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  33084. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33085. import { Light } from "babylonjs/Lights/light";
  33086. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33087. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  33088. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  33089. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  33090. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33091. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  33092. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33093. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  33094. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  33095. import { Engine } from "babylonjs/Engines/engine";
  33096. import { Node } from "babylonjs/node";
  33097. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  33098. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33099. import { WebRequest } from "babylonjs/Misc/webRequest";
  33100. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  33101. import { Ray } from "babylonjs/Culling/ray";
  33102. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  33103. import { Animation } from "babylonjs/Animations/animation";
  33104. import { Animatable } from "babylonjs/Animations/animatable";
  33105. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33106. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  33107. import { Collider } from "babylonjs/Collisions/collider";
  33108. /**
  33109. * Define an interface for all classes that will hold resources
  33110. */
  33111. export interface IDisposable {
  33112. /**
  33113. * Releases all held resources
  33114. */
  33115. dispose(): void;
  33116. }
  33117. /** Interface defining initialization parameters for Scene class */
  33118. export interface SceneOptions {
  33119. /**
  33120. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  33121. * It will improve performance when the number of geometries becomes important.
  33122. */
  33123. useGeometryUniqueIdsMap?: boolean;
  33124. /**
  33125. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  33126. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33127. */
  33128. useMaterialMeshMap?: boolean;
  33129. /**
  33130. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  33131. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33132. */
  33133. useClonedMeshhMap?: boolean;
  33134. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  33135. virtual?: boolean;
  33136. }
  33137. /**
  33138. * Represents a scene to be rendered by the engine.
  33139. * @see http://doc.babylonjs.com/features/scene
  33140. */
  33141. export class Scene extends AbstractScene implements IAnimatable {
  33142. private static _uniqueIdCounter;
  33143. /** The fog is deactivated */
  33144. static readonly FOGMODE_NONE: number;
  33145. /** The fog density is following an exponential function */
  33146. static readonly FOGMODE_EXP: number;
  33147. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  33148. static readonly FOGMODE_EXP2: number;
  33149. /** The fog density is following a linear function. */
  33150. static readonly FOGMODE_LINEAR: number;
  33151. /**
  33152. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  33153. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33154. */
  33155. static MinDeltaTime: number;
  33156. /**
  33157. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  33158. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33159. */
  33160. static MaxDeltaTime: number;
  33161. /**
  33162. * Factory used to create the default material.
  33163. * @param name The name of the material to create
  33164. * @param scene The scene to create the material for
  33165. * @returns The default material
  33166. */
  33167. static DefaultMaterialFactory(scene: Scene): Material;
  33168. /**
  33169. * Factory used to create the a collision coordinator.
  33170. * @returns The collision coordinator
  33171. */
  33172. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  33173. /** @hidden */
  33174. _inputManager: InputManager;
  33175. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  33176. cameraToUseForPointers: Nullable<Camera>;
  33177. /** @hidden */
  33178. readonly _isScene: boolean;
  33179. /**
  33180. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  33181. */
  33182. autoClear: boolean;
  33183. /**
  33184. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  33185. */
  33186. autoClearDepthAndStencil: boolean;
  33187. /**
  33188. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  33189. */
  33190. clearColor: Color4;
  33191. /**
  33192. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  33193. */
  33194. ambientColor: Color3;
  33195. /**
  33196. * This is use to store the default BRDF lookup for PBR materials in your scene.
  33197. * It should only be one of the following (if not the default embedded one):
  33198. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  33199. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  33200. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  33201. * The material properties need to be setup according to the type of texture in use.
  33202. */
  33203. environmentBRDFTexture: BaseTexture;
  33204. /** @hidden */
  33205. protected _environmentTexture: Nullable<BaseTexture>;
  33206. /**
  33207. * Texture used in all pbr material as the reflection texture.
  33208. * As in the majority of the scene they are the same (exception for multi room and so on),
  33209. * this is easier to reference from here than from all the materials.
  33210. */
  33211. /**
  33212. * Texture used in all pbr material as the reflection texture.
  33213. * As in the majority of the scene they are the same (exception for multi room and so on),
  33214. * this is easier to set here than in all the materials.
  33215. */
  33216. environmentTexture: Nullable<BaseTexture>;
  33217. /** @hidden */
  33218. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  33219. /**
  33220. * Default image processing configuration used either in the rendering
  33221. * Forward main pass or through the imageProcessingPostProcess if present.
  33222. * As in the majority of the scene they are the same (exception for multi camera),
  33223. * this is easier to reference from here than from all the materials and post process.
  33224. *
  33225. * No setter as we it is a shared configuration, you can set the values instead.
  33226. */
  33227. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  33228. private _forceWireframe;
  33229. /**
  33230. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  33231. */
  33232. forceWireframe: boolean;
  33233. private _forcePointsCloud;
  33234. /**
  33235. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  33236. */
  33237. forcePointsCloud: boolean;
  33238. /**
  33239. * Gets or sets the active clipplane 1
  33240. */
  33241. clipPlane: Nullable<Plane>;
  33242. /**
  33243. * Gets or sets the active clipplane 2
  33244. */
  33245. clipPlane2: Nullable<Plane>;
  33246. /**
  33247. * Gets or sets the active clipplane 3
  33248. */
  33249. clipPlane3: Nullable<Plane>;
  33250. /**
  33251. * Gets or sets the active clipplane 4
  33252. */
  33253. clipPlane4: Nullable<Plane>;
  33254. /**
  33255. * Gets or sets a boolean indicating if animations are enabled
  33256. */
  33257. animationsEnabled: boolean;
  33258. private _animationPropertiesOverride;
  33259. /**
  33260. * Gets or sets the animation properties override
  33261. */
  33262. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  33263. /**
  33264. * Gets or sets a boolean indicating if a constant deltatime has to be used
  33265. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  33266. */
  33267. useConstantAnimationDeltaTime: boolean;
  33268. /**
  33269. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  33270. * Please note that it requires to run a ray cast through the scene on every frame
  33271. */
  33272. constantlyUpdateMeshUnderPointer: boolean;
  33273. /**
  33274. * Defines the HTML cursor to use when hovering over interactive elements
  33275. */
  33276. hoverCursor: string;
  33277. /**
  33278. * Defines the HTML default cursor to use (empty by default)
  33279. */
  33280. defaultCursor: string;
  33281. /**
  33282. * This is used to call preventDefault() on pointer down
  33283. * in order to block unwanted artifacts like system double clicks
  33284. */
  33285. preventDefaultOnPointerDown: boolean;
  33286. /**
  33287. * This is used to call preventDefault() on pointer up
  33288. * in order to block unwanted artifacts like system double clicks
  33289. */
  33290. preventDefaultOnPointerUp: boolean;
  33291. /**
  33292. * Gets or sets user defined metadata
  33293. */
  33294. metadata: any;
  33295. /**
  33296. * For internal use only. Please do not use.
  33297. */
  33298. reservedDataStore: any;
  33299. /**
  33300. * Gets the name of the plugin used to load this scene (null by default)
  33301. */
  33302. loadingPluginName: string;
  33303. /**
  33304. * Use this array to add regular expressions used to disable offline support for specific urls
  33305. */
  33306. disableOfflineSupportExceptionRules: RegExp[];
  33307. /**
  33308. * An event triggered when the scene is disposed.
  33309. */
  33310. onDisposeObservable: Observable<Scene>;
  33311. private _onDisposeObserver;
  33312. /** Sets a function to be executed when this scene is disposed. */
  33313. onDispose: () => void;
  33314. /**
  33315. * An event triggered before rendering the scene (right after animations and physics)
  33316. */
  33317. onBeforeRenderObservable: Observable<Scene>;
  33318. private _onBeforeRenderObserver;
  33319. /** Sets a function to be executed before rendering this scene */
  33320. beforeRender: Nullable<() => void>;
  33321. /**
  33322. * An event triggered after rendering the scene
  33323. */
  33324. onAfterRenderObservable: Observable<Scene>;
  33325. /**
  33326. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  33327. */
  33328. onAfterRenderCameraObservable: Observable<Camera>;
  33329. private _onAfterRenderObserver;
  33330. /** Sets a function to be executed after rendering this scene */
  33331. afterRender: Nullable<() => void>;
  33332. /**
  33333. * An event triggered before animating the scene
  33334. */
  33335. onBeforeAnimationsObservable: Observable<Scene>;
  33336. /**
  33337. * An event triggered after animations processing
  33338. */
  33339. onAfterAnimationsObservable: Observable<Scene>;
  33340. /**
  33341. * An event triggered before draw calls are ready to be sent
  33342. */
  33343. onBeforeDrawPhaseObservable: Observable<Scene>;
  33344. /**
  33345. * An event triggered after draw calls have been sent
  33346. */
  33347. onAfterDrawPhaseObservable: Observable<Scene>;
  33348. /**
  33349. * An event triggered when the scene is ready
  33350. */
  33351. onReadyObservable: Observable<Scene>;
  33352. /**
  33353. * An event triggered before rendering a camera
  33354. */
  33355. onBeforeCameraRenderObservable: Observable<Camera>;
  33356. private _onBeforeCameraRenderObserver;
  33357. /** Sets a function to be executed before rendering a camera*/
  33358. beforeCameraRender: () => void;
  33359. /**
  33360. * An event triggered after rendering a camera
  33361. */
  33362. onAfterCameraRenderObservable: Observable<Camera>;
  33363. private _onAfterCameraRenderObserver;
  33364. /** Sets a function to be executed after rendering a camera*/
  33365. afterCameraRender: () => void;
  33366. /**
  33367. * An event triggered when active meshes evaluation is about to start
  33368. */
  33369. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  33370. /**
  33371. * An event triggered when active meshes evaluation is done
  33372. */
  33373. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  33374. /**
  33375. * An event triggered when particles rendering is about to start
  33376. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33377. */
  33378. onBeforeParticlesRenderingObservable: Observable<Scene>;
  33379. /**
  33380. * An event triggered when particles rendering is done
  33381. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33382. */
  33383. onAfterParticlesRenderingObservable: Observable<Scene>;
  33384. /**
  33385. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  33386. */
  33387. onDataLoadedObservable: Observable<Scene>;
  33388. /**
  33389. * An event triggered when a camera is created
  33390. */
  33391. onNewCameraAddedObservable: Observable<Camera>;
  33392. /**
  33393. * An event triggered when a camera is removed
  33394. */
  33395. onCameraRemovedObservable: Observable<Camera>;
  33396. /**
  33397. * An event triggered when a light is created
  33398. */
  33399. onNewLightAddedObservable: Observable<Light>;
  33400. /**
  33401. * An event triggered when a light is removed
  33402. */
  33403. onLightRemovedObservable: Observable<Light>;
  33404. /**
  33405. * An event triggered when a geometry is created
  33406. */
  33407. onNewGeometryAddedObservable: Observable<Geometry>;
  33408. /**
  33409. * An event triggered when a geometry is removed
  33410. */
  33411. onGeometryRemovedObservable: Observable<Geometry>;
  33412. /**
  33413. * An event triggered when a transform node is created
  33414. */
  33415. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  33416. /**
  33417. * An event triggered when a transform node is removed
  33418. */
  33419. onTransformNodeRemovedObservable: Observable<TransformNode>;
  33420. /**
  33421. * An event triggered when a mesh is created
  33422. */
  33423. onNewMeshAddedObservable: Observable<AbstractMesh>;
  33424. /**
  33425. * An event triggered when a mesh is removed
  33426. */
  33427. onMeshRemovedObservable: Observable<AbstractMesh>;
  33428. /**
  33429. * An event triggered when a skeleton is created
  33430. */
  33431. onNewSkeletonAddedObservable: Observable<Skeleton>;
  33432. /**
  33433. * An event triggered when a skeleton is removed
  33434. */
  33435. onSkeletonRemovedObservable: Observable<Skeleton>;
  33436. /**
  33437. * An event triggered when a material is created
  33438. */
  33439. onNewMaterialAddedObservable: Observable<Material>;
  33440. /**
  33441. * An event triggered when a material is removed
  33442. */
  33443. onMaterialRemovedObservable: Observable<Material>;
  33444. /**
  33445. * An event triggered when a texture is created
  33446. */
  33447. onNewTextureAddedObservable: Observable<BaseTexture>;
  33448. /**
  33449. * An event triggered when a texture is removed
  33450. */
  33451. onTextureRemovedObservable: Observable<BaseTexture>;
  33452. /**
  33453. * An event triggered when render targets are about to be rendered
  33454. * Can happen multiple times per frame.
  33455. */
  33456. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  33457. /**
  33458. * An event triggered when render targets were rendered.
  33459. * Can happen multiple times per frame.
  33460. */
  33461. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  33462. /**
  33463. * An event triggered before calculating deterministic simulation step
  33464. */
  33465. onBeforeStepObservable: Observable<Scene>;
  33466. /**
  33467. * An event triggered after calculating deterministic simulation step
  33468. */
  33469. onAfterStepObservable: Observable<Scene>;
  33470. /**
  33471. * An event triggered when the activeCamera property is updated
  33472. */
  33473. onActiveCameraChanged: Observable<Scene>;
  33474. /**
  33475. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  33476. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33477. * 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)
  33478. */
  33479. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33480. /**
  33481. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  33482. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33483. * 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)
  33484. */
  33485. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33486. /**
  33487. * This Observable will when a mesh has been imported into the scene.
  33488. */
  33489. onMeshImportedObservable: Observable<AbstractMesh>;
  33490. /**
  33491. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  33492. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  33493. */
  33494. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  33495. /** @hidden */
  33496. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  33497. /**
  33498. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  33499. */
  33500. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  33501. /**
  33502. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  33503. */
  33504. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  33505. /**
  33506. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  33507. */
  33508. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  33509. /** Callback called when a pointer move is detected */
  33510. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33511. /** Callback called when a pointer down is detected */
  33512. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33513. /** Callback called when a pointer up is detected */
  33514. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  33515. /** Callback called when a pointer pick is detected */
  33516. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  33517. /**
  33518. * 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).
  33519. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  33520. */
  33521. onPrePointerObservable: Observable<PointerInfoPre>;
  33522. /**
  33523. * Observable event triggered each time an input event is received from the rendering canvas
  33524. */
  33525. onPointerObservable: Observable<PointerInfo>;
  33526. /**
  33527. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  33528. */
  33529. readonly unTranslatedPointer: Vector2;
  33530. /**
  33531. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  33532. */
  33533. static DragMovementThreshold: number;
  33534. /**
  33535. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  33536. */
  33537. static LongPressDelay: number;
  33538. /**
  33539. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  33540. */
  33541. static DoubleClickDelay: number;
  33542. /** If you need to check double click without raising a single click at first click, enable this flag */
  33543. static ExclusiveDoubleClickMode: boolean;
  33544. /** @hidden */
  33545. _mirroredCameraPosition: Nullable<Vector3>;
  33546. /**
  33547. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  33548. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  33549. */
  33550. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  33551. /**
  33552. * Observable event triggered each time an keyboard event is received from the hosting window
  33553. */
  33554. onKeyboardObservable: Observable<KeyboardInfo>;
  33555. private _useRightHandedSystem;
  33556. /**
  33557. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  33558. */
  33559. useRightHandedSystem: boolean;
  33560. private _timeAccumulator;
  33561. private _currentStepId;
  33562. private _currentInternalStep;
  33563. /**
  33564. * Sets the step Id used by deterministic lock step
  33565. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33566. * @param newStepId defines the step Id
  33567. */
  33568. setStepId(newStepId: number): void;
  33569. /**
  33570. * Gets the step Id used by deterministic lock step
  33571. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33572. * @returns the step Id
  33573. */
  33574. getStepId(): number;
  33575. /**
  33576. * Gets the internal step used by deterministic lock step
  33577. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33578. * @returns the internal step
  33579. */
  33580. getInternalStep(): number;
  33581. private _fogEnabled;
  33582. /**
  33583. * Gets or sets a boolean indicating if fog is enabled on this scene
  33584. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33585. * (Default is true)
  33586. */
  33587. fogEnabled: boolean;
  33588. private _fogMode;
  33589. /**
  33590. * Gets or sets the fog mode to use
  33591. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33592. * | mode | value |
  33593. * | --- | --- |
  33594. * | FOGMODE_NONE | 0 |
  33595. * | FOGMODE_EXP | 1 |
  33596. * | FOGMODE_EXP2 | 2 |
  33597. * | FOGMODE_LINEAR | 3 |
  33598. */
  33599. fogMode: number;
  33600. /**
  33601. * Gets or sets the fog color to use
  33602. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33603. * (Default is Color3(0.2, 0.2, 0.3))
  33604. */
  33605. fogColor: Color3;
  33606. /**
  33607. * Gets or sets the fog density to use
  33608. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33609. * (Default is 0.1)
  33610. */
  33611. fogDensity: number;
  33612. /**
  33613. * Gets or sets the fog start distance to use
  33614. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33615. * (Default is 0)
  33616. */
  33617. fogStart: number;
  33618. /**
  33619. * Gets or sets the fog end distance to use
  33620. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33621. * (Default is 1000)
  33622. */
  33623. fogEnd: number;
  33624. private _shadowsEnabled;
  33625. /**
  33626. * Gets or sets a boolean indicating if shadows are enabled on this scene
  33627. */
  33628. shadowsEnabled: boolean;
  33629. private _lightsEnabled;
  33630. /**
  33631. * Gets or sets a boolean indicating if lights are enabled on this scene
  33632. */
  33633. lightsEnabled: boolean;
  33634. /** All of the active cameras added to this scene. */
  33635. activeCameras: Camera[];
  33636. /** @hidden */
  33637. _activeCamera: Nullable<Camera>;
  33638. /** Gets or sets the current active camera */
  33639. activeCamera: Nullable<Camera>;
  33640. private _defaultMaterial;
  33641. /** The default material used on meshes when no material is affected */
  33642. /** The default material used on meshes when no material is affected */
  33643. defaultMaterial: Material;
  33644. private _texturesEnabled;
  33645. /**
  33646. * Gets or sets a boolean indicating if textures are enabled on this scene
  33647. */
  33648. texturesEnabled: boolean;
  33649. /**
  33650. * Gets or sets a boolean indicating if particles are enabled on this scene
  33651. */
  33652. particlesEnabled: boolean;
  33653. /**
  33654. * Gets or sets a boolean indicating if sprites are enabled on this scene
  33655. */
  33656. spritesEnabled: boolean;
  33657. private _skeletonsEnabled;
  33658. /**
  33659. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  33660. */
  33661. skeletonsEnabled: boolean;
  33662. /**
  33663. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  33664. */
  33665. lensFlaresEnabled: boolean;
  33666. /**
  33667. * Gets or sets a boolean indicating if collisions are enabled on this scene
  33668. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33669. */
  33670. collisionsEnabled: boolean;
  33671. private _collisionCoordinator;
  33672. /** @hidden */
  33673. readonly collisionCoordinator: ICollisionCoordinator;
  33674. /**
  33675. * Defines the gravity applied to this scene (used only for collisions)
  33676. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33677. */
  33678. gravity: Vector3;
  33679. /**
  33680. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  33681. */
  33682. postProcessesEnabled: boolean;
  33683. /**
  33684. * The list of postprocesses added to the scene
  33685. */
  33686. postProcesses: PostProcess[];
  33687. /**
  33688. * Gets the current postprocess manager
  33689. */
  33690. postProcessManager: PostProcessManager;
  33691. /**
  33692. * Gets or sets a boolean indicating if render targets are enabled on this scene
  33693. */
  33694. renderTargetsEnabled: boolean;
  33695. /**
  33696. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  33697. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  33698. */
  33699. dumpNextRenderTargets: boolean;
  33700. /**
  33701. * The list of user defined render targets added to the scene
  33702. */
  33703. customRenderTargets: RenderTargetTexture[];
  33704. /**
  33705. * Defines if texture loading must be delayed
  33706. * If true, textures will only be loaded when they need to be rendered
  33707. */
  33708. useDelayedTextureLoading: boolean;
  33709. /**
  33710. * Gets the list of meshes imported to the scene through SceneLoader
  33711. */
  33712. importedMeshesFiles: String[];
  33713. /**
  33714. * Gets or sets a boolean indicating if probes are enabled on this scene
  33715. */
  33716. probesEnabled: boolean;
  33717. /**
  33718. * Gets or sets the current offline provider to use to store scene data
  33719. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33720. */
  33721. offlineProvider: IOfflineProvider;
  33722. /**
  33723. * Gets or sets the action manager associated with the scene
  33724. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33725. */
  33726. actionManager: AbstractActionManager;
  33727. private _meshesForIntersections;
  33728. /**
  33729. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  33730. */
  33731. proceduralTexturesEnabled: boolean;
  33732. private _engine;
  33733. private _totalVertices;
  33734. /** @hidden */
  33735. _activeIndices: PerfCounter;
  33736. /** @hidden */
  33737. _activeParticles: PerfCounter;
  33738. /** @hidden */
  33739. _activeBones: PerfCounter;
  33740. private _animationRatio;
  33741. /** @hidden */
  33742. _animationTimeLast: number;
  33743. /** @hidden */
  33744. _animationTime: number;
  33745. /**
  33746. * Gets or sets a general scale for animation speed
  33747. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  33748. */
  33749. animationTimeScale: number;
  33750. /** @hidden */
  33751. _cachedMaterial: Nullable<Material>;
  33752. /** @hidden */
  33753. _cachedEffect: Nullable<Effect>;
  33754. /** @hidden */
  33755. _cachedVisibility: Nullable<number>;
  33756. private _renderId;
  33757. private _frameId;
  33758. private _executeWhenReadyTimeoutId;
  33759. private _intermediateRendering;
  33760. private _viewUpdateFlag;
  33761. private _projectionUpdateFlag;
  33762. /** @hidden */
  33763. _toBeDisposed: Nullable<IDisposable>[];
  33764. private _activeRequests;
  33765. /** @hidden */
  33766. _pendingData: any[];
  33767. private _isDisposed;
  33768. /**
  33769. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  33770. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  33771. */
  33772. dispatchAllSubMeshesOfActiveMeshes: boolean;
  33773. private _activeMeshes;
  33774. private _processedMaterials;
  33775. private _renderTargets;
  33776. /** @hidden */
  33777. _activeParticleSystems: SmartArray<IParticleSystem>;
  33778. private _activeSkeletons;
  33779. private _softwareSkinnedMeshes;
  33780. private _renderingManager;
  33781. /** @hidden */
  33782. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  33783. private _transformMatrix;
  33784. private _sceneUbo;
  33785. /** @hidden */
  33786. _viewMatrix: Matrix;
  33787. private _projectionMatrix;
  33788. /** @hidden */
  33789. _forcedViewPosition: Nullable<Vector3>;
  33790. /** @hidden */
  33791. _frustumPlanes: Plane[];
  33792. /**
  33793. * Gets the list of frustum planes (built from the active camera)
  33794. */
  33795. readonly frustumPlanes: Plane[];
  33796. /**
  33797. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33798. * This is useful if there are more lights that the maximum simulteanous authorized
  33799. */
  33800. requireLightSorting: boolean;
  33801. /** @hidden */
  33802. readonly useMaterialMeshMap: boolean;
  33803. /** @hidden */
  33804. readonly useClonedMeshhMap: boolean;
  33805. private _externalData;
  33806. private _uid;
  33807. /**
  33808. * @hidden
  33809. * Backing store of defined scene components.
  33810. */
  33811. _components: ISceneComponent[];
  33812. /**
  33813. * @hidden
  33814. * Backing store of defined scene components.
  33815. */
  33816. _serializableComponents: ISceneSerializableComponent[];
  33817. /**
  33818. * List of components to register on the next registration step.
  33819. */
  33820. private _transientComponents;
  33821. /**
  33822. * Registers the transient components if needed.
  33823. */
  33824. private _registerTransientComponents;
  33825. /**
  33826. * @hidden
  33827. * Add a component to the scene.
  33828. * Note that the ccomponent could be registered on th next frame if this is called after
  33829. * the register component stage.
  33830. * @param component Defines the component to add to the scene
  33831. */
  33832. _addComponent(component: ISceneComponent): void;
  33833. /**
  33834. * @hidden
  33835. * Gets a component from the scene.
  33836. * @param name defines the name of the component to retrieve
  33837. * @returns the component or null if not present
  33838. */
  33839. _getComponent(name: string): Nullable<ISceneComponent>;
  33840. /**
  33841. * @hidden
  33842. * Defines the actions happening before camera updates.
  33843. */
  33844. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33845. /**
  33846. * @hidden
  33847. * Defines the actions happening before clear the canvas.
  33848. */
  33849. _beforeClearStage: Stage<SimpleStageAction>;
  33850. /**
  33851. * @hidden
  33852. * Defines the actions when collecting render targets for the frame.
  33853. */
  33854. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33855. /**
  33856. * @hidden
  33857. * Defines the actions happening for one camera in the frame.
  33858. */
  33859. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33860. /**
  33861. * @hidden
  33862. * Defines the actions happening during the per mesh ready checks.
  33863. */
  33864. _isReadyForMeshStage: Stage<MeshStageAction>;
  33865. /**
  33866. * @hidden
  33867. * Defines the actions happening before evaluate active mesh checks.
  33868. */
  33869. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33870. /**
  33871. * @hidden
  33872. * Defines the actions happening during the evaluate sub mesh checks.
  33873. */
  33874. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33875. /**
  33876. * @hidden
  33877. * Defines the actions happening during the active mesh stage.
  33878. */
  33879. _activeMeshStage: Stage<ActiveMeshStageAction>;
  33880. /**
  33881. * @hidden
  33882. * Defines the actions happening during the per camera render target step.
  33883. */
  33884. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  33885. /**
  33886. * @hidden
  33887. * Defines the actions happening just before the active camera is drawing.
  33888. */
  33889. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33890. /**
  33891. * @hidden
  33892. * Defines the actions happening just before a render target is drawing.
  33893. */
  33894. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33895. /**
  33896. * @hidden
  33897. * Defines the actions happening just before a rendering group is drawing.
  33898. */
  33899. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33900. /**
  33901. * @hidden
  33902. * Defines the actions happening just before a mesh is drawing.
  33903. */
  33904. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33905. /**
  33906. * @hidden
  33907. * Defines the actions happening just after a mesh has been drawn.
  33908. */
  33909. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33910. /**
  33911. * @hidden
  33912. * Defines the actions happening just after a rendering group has been drawn.
  33913. */
  33914. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33915. /**
  33916. * @hidden
  33917. * Defines the actions happening just after the active camera has been drawn.
  33918. */
  33919. _afterCameraDrawStage: Stage<CameraStageAction>;
  33920. /**
  33921. * @hidden
  33922. * Defines the actions happening just after a render target has been drawn.
  33923. */
  33924. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33925. /**
  33926. * @hidden
  33927. * Defines the actions happening just after rendering all cameras and computing intersections.
  33928. */
  33929. _afterRenderStage: Stage<SimpleStageAction>;
  33930. /**
  33931. * @hidden
  33932. * Defines the actions happening when a pointer move event happens.
  33933. */
  33934. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33935. /**
  33936. * @hidden
  33937. * Defines the actions happening when a pointer down event happens.
  33938. */
  33939. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33940. /**
  33941. * @hidden
  33942. * Defines the actions happening when a pointer up event happens.
  33943. */
  33944. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33945. /**
  33946. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33947. */
  33948. private geometriesByUniqueId;
  33949. /**
  33950. * Creates a new Scene
  33951. * @param engine defines the engine to use to render this scene
  33952. * @param options defines the scene options
  33953. */
  33954. constructor(engine: Engine, options?: SceneOptions);
  33955. /**
  33956. * Gets a string idenfifying the name of the class
  33957. * @returns "Scene" string
  33958. */
  33959. getClassName(): string;
  33960. private _defaultMeshCandidates;
  33961. /**
  33962. * @hidden
  33963. */
  33964. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33965. private _defaultSubMeshCandidates;
  33966. /**
  33967. * @hidden
  33968. */
  33969. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33970. /**
  33971. * Sets the default candidate providers for the scene.
  33972. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33973. * and getCollidingSubMeshCandidates to their default function
  33974. */
  33975. setDefaultCandidateProviders(): void;
  33976. /**
  33977. * Gets the mesh that is currently under the pointer
  33978. */
  33979. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33980. /**
  33981. * Gets or sets the current on-screen X position of the pointer
  33982. */
  33983. pointerX: number;
  33984. /**
  33985. * Gets or sets the current on-screen Y position of the pointer
  33986. */
  33987. pointerY: number;
  33988. /**
  33989. * Gets the cached material (ie. the latest rendered one)
  33990. * @returns the cached material
  33991. */
  33992. getCachedMaterial(): Nullable<Material>;
  33993. /**
  33994. * Gets the cached effect (ie. the latest rendered one)
  33995. * @returns the cached effect
  33996. */
  33997. getCachedEffect(): Nullable<Effect>;
  33998. /**
  33999. * Gets the cached visibility state (ie. the latest rendered one)
  34000. * @returns the cached visibility state
  34001. */
  34002. getCachedVisibility(): Nullable<number>;
  34003. /**
  34004. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  34005. * @param material defines the current material
  34006. * @param effect defines the current effect
  34007. * @param visibility defines the current visibility state
  34008. * @returns true if one parameter is not cached
  34009. */
  34010. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  34011. /**
  34012. * Gets the engine associated with the scene
  34013. * @returns an Engine
  34014. */
  34015. getEngine(): Engine;
  34016. /**
  34017. * Gets the total number of vertices rendered per frame
  34018. * @returns the total number of vertices rendered per frame
  34019. */
  34020. getTotalVertices(): number;
  34021. /**
  34022. * Gets the performance counter for total vertices
  34023. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34024. */
  34025. readonly totalVerticesPerfCounter: PerfCounter;
  34026. /**
  34027. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  34028. * @returns the total number of active indices rendered per frame
  34029. */
  34030. getActiveIndices(): number;
  34031. /**
  34032. * Gets the performance counter for active indices
  34033. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34034. */
  34035. readonly totalActiveIndicesPerfCounter: PerfCounter;
  34036. /**
  34037. * Gets the total number of active particles rendered per frame
  34038. * @returns the total number of active particles rendered per frame
  34039. */
  34040. getActiveParticles(): number;
  34041. /**
  34042. * Gets the performance counter for active particles
  34043. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34044. */
  34045. readonly activeParticlesPerfCounter: PerfCounter;
  34046. /**
  34047. * Gets the total number of active bones rendered per frame
  34048. * @returns the total number of active bones rendered per frame
  34049. */
  34050. getActiveBones(): number;
  34051. /**
  34052. * Gets the performance counter for active bones
  34053. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34054. */
  34055. readonly activeBonesPerfCounter: PerfCounter;
  34056. /**
  34057. * Gets the array of active meshes
  34058. * @returns an array of AbstractMesh
  34059. */
  34060. getActiveMeshes(): SmartArray<AbstractMesh>;
  34061. /**
  34062. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  34063. * @returns a number
  34064. */
  34065. getAnimationRatio(): number;
  34066. /**
  34067. * Gets an unique Id for the current render phase
  34068. * @returns a number
  34069. */
  34070. getRenderId(): number;
  34071. /**
  34072. * Gets an unique Id for the current frame
  34073. * @returns a number
  34074. */
  34075. getFrameId(): number;
  34076. /** Call this function if you want to manually increment the render Id*/
  34077. incrementRenderId(): void;
  34078. private _createUbo;
  34079. /**
  34080. * Use this method to simulate a pointer move on a mesh
  34081. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34082. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34083. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34084. * @returns the current scene
  34085. */
  34086. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34087. /**
  34088. * Use this method to simulate a pointer down on a mesh
  34089. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34090. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34091. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34092. * @returns the current scene
  34093. */
  34094. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34095. /**
  34096. * Use this method to simulate a pointer up on a mesh
  34097. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34098. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34099. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34100. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34101. * @returns the current scene
  34102. */
  34103. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  34104. /**
  34105. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34106. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34107. * @returns true if the pointer was captured
  34108. */
  34109. isPointerCaptured(pointerId?: number): boolean;
  34110. /**
  34111. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34112. * @param attachUp defines if you want to attach events to pointerup
  34113. * @param attachDown defines if you want to attach events to pointerdown
  34114. * @param attachMove defines if you want to attach events to pointermove
  34115. */
  34116. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34117. /** Detaches all event handlers*/
  34118. detachControl(): void;
  34119. /**
  34120. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  34121. * Delay loaded resources are not taking in account
  34122. * @return true if all required resources are ready
  34123. */
  34124. isReady(): boolean;
  34125. /** Resets all cached information relative to material (including effect and visibility) */
  34126. resetCachedMaterial(): void;
  34127. /**
  34128. * Registers a function to be called before every frame render
  34129. * @param func defines the function to register
  34130. */
  34131. registerBeforeRender(func: () => void): void;
  34132. /**
  34133. * Unregisters a function called before every frame render
  34134. * @param func defines the function to unregister
  34135. */
  34136. unregisterBeforeRender(func: () => void): void;
  34137. /**
  34138. * Registers a function to be called after every frame render
  34139. * @param func defines the function to register
  34140. */
  34141. registerAfterRender(func: () => void): void;
  34142. /**
  34143. * Unregisters a function called after every frame render
  34144. * @param func defines the function to unregister
  34145. */
  34146. unregisterAfterRender(func: () => void): void;
  34147. private _executeOnceBeforeRender;
  34148. /**
  34149. * The provided function will run before render once and will be disposed afterwards.
  34150. * A timeout delay can be provided so that the function will be executed in N ms.
  34151. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  34152. * @param func The function to be executed.
  34153. * @param timeout optional delay in ms
  34154. */
  34155. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  34156. /** @hidden */
  34157. _addPendingData(data: any): void;
  34158. /** @hidden */
  34159. _removePendingData(data: any): void;
  34160. /**
  34161. * Returns the number of items waiting to be loaded
  34162. * @returns the number of items waiting to be loaded
  34163. */
  34164. getWaitingItemsCount(): number;
  34165. /**
  34166. * Returns a boolean indicating if the scene is still loading data
  34167. */
  34168. readonly isLoading: boolean;
  34169. /**
  34170. * Registers a function to be executed when the scene is ready
  34171. * @param {Function} func - the function to be executed
  34172. */
  34173. executeWhenReady(func: () => void): void;
  34174. /**
  34175. * Returns a promise that resolves when the scene is ready
  34176. * @returns A promise that resolves when the scene is ready
  34177. */
  34178. whenReadyAsync(): Promise<void>;
  34179. /** @hidden */
  34180. _checkIsReady(): void;
  34181. /**
  34182. * Gets all animatable attached to the scene
  34183. */
  34184. readonly animatables: Animatable[];
  34185. /**
  34186. * Resets the last animation time frame.
  34187. * Useful to override when animations start running when loading a scene for the first time.
  34188. */
  34189. resetLastAnimationTimeFrame(): void;
  34190. /**
  34191. * Gets the current view matrix
  34192. * @returns a Matrix
  34193. */
  34194. getViewMatrix(): Matrix;
  34195. /**
  34196. * Gets the current projection matrix
  34197. * @returns a Matrix
  34198. */
  34199. getProjectionMatrix(): Matrix;
  34200. /**
  34201. * Gets the current transform matrix
  34202. * @returns a Matrix made of View * Projection
  34203. */
  34204. getTransformMatrix(): Matrix;
  34205. /**
  34206. * Sets the current transform matrix
  34207. * @param viewL defines the View matrix to use
  34208. * @param projectionL defines the Projection matrix to use
  34209. * @param viewR defines the right View matrix to use (if provided)
  34210. * @param projectionR defines the right Projection matrix to use (if provided)
  34211. */
  34212. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  34213. /**
  34214. * Gets the uniform buffer used to store scene data
  34215. * @returns a UniformBuffer
  34216. */
  34217. getSceneUniformBuffer(): UniformBuffer;
  34218. /**
  34219. * Gets an unique (relatively to the current scene) Id
  34220. * @returns an unique number for the scene
  34221. */
  34222. getUniqueId(): number;
  34223. /**
  34224. * Add a mesh to the list of scene's meshes
  34225. * @param newMesh defines the mesh to add
  34226. * @param recursive if all child meshes should also be added to the scene
  34227. */
  34228. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  34229. /**
  34230. * Remove a mesh for the list of scene's meshes
  34231. * @param toRemove defines the mesh to remove
  34232. * @param recursive if all child meshes should also be removed from the scene
  34233. * @returns the index where the mesh was in the mesh list
  34234. */
  34235. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  34236. /**
  34237. * Add a transform node to the list of scene's transform nodes
  34238. * @param newTransformNode defines the transform node to add
  34239. */
  34240. addTransformNode(newTransformNode: TransformNode): void;
  34241. /**
  34242. * Remove a transform node for the list of scene's transform nodes
  34243. * @param toRemove defines the transform node to remove
  34244. * @returns the index where the transform node was in the transform node list
  34245. */
  34246. removeTransformNode(toRemove: TransformNode): number;
  34247. /**
  34248. * Remove a skeleton for the list of scene's skeletons
  34249. * @param toRemove defines the skeleton to remove
  34250. * @returns the index where the skeleton was in the skeleton list
  34251. */
  34252. removeSkeleton(toRemove: Skeleton): number;
  34253. /**
  34254. * Remove a morph target for the list of scene's morph targets
  34255. * @param toRemove defines the morph target to remove
  34256. * @returns the index where the morph target was in the morph target list
  34257. */
  34258. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  34259. /**
  34260. * Remove a light for the list of scene's lights
  34261. * @param toRemove defines the light to remove
  34262. * @returns the index where the light was in the light list
  34263. */
  34264. removeLight(toRemove: Light): number;
  34265. /**
  34266. * Remove a camera for the list of scene's cameras
  34267. * @param toRemove defines the camera to remove
  34268. * @returns the index where the camera was in the camera list
  34269. */
  34270. removeCamera(toRemove: Camera): number;
  34271. /**
  34272. * Remove a particle system for the list of scene's particle systems
  34273. * @param toRemove defines the particle system to remove
  34274. * @returns the index where the particle system was in the particle system list
  34275. */
  34276. removeParticleSystem(toRemove: IParticleSystem): number;
  34277. /**
  34278. * Remove a animation for the list of scene's animations
  34279. * @param toRemove defines the animation to remove
  34280. * @returns the index where the animation was in the animation list
  34281. */
  34282. removeAnimation(toRemove: Animation): number;
  34283. /**
  34284. * Will stop the animation of the given target
  34285. * @param target - the target
  34286. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  34287. * @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)
  34288. */
  34289. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  34290. /**
  34291. * Removes the given animation group from this scene.
  34292. * @param toRemove The animation group to remove
  34293. * @returns The index of the removed animation group
  34294. */
  34295. removeAnimationGroup(toRemove: AnimationGroup): number;
  34296. /**
  34297. * Removes the given multi-material from this scene.
  34298. * @param toRemove The multi-material to remove
  34299. * @returns The index of the removed multi-material
  34300. */
  34301. removeMultiMaterial(toRemove: MultiMaterial): number;
  34302. /**
  34303. * Removes the given material from this scene.
  34304. * @param toRemove The material to remove
  34305. * @returns The index of the removed material
  34306. */
  34307. removeMaterial(toRemove: Material): number;
  34308. /**
  34309. * Removes the given action manager from this scene.
  34310. * @param toRemove The action manager to remove
  34311. * @returns The index of the removed action manager
  34312. */
  34313. removeActionManager(toRemove: AbstractActionManager): number;
  34314. /**
  34315. * Removes the given texture from this scene.
  34316. * @param toRemove The texture to remove
  34317. * @returns The index of the removed texture
  34318. */
  34319. removeTexture(toRemove: BaseTexture): number;
  34320. /**
  34321. * Adds the given light to this scene
  34322. * @param newLight The light to add
  34323. */
  34324. addLight(newLight: Light): void;
  34325. /**
  34326. * Sorts the list list based on light priorities
  34327. */
  34328. sortLightsByPriority(): void;
  34329. /**
  34330. * Adds the given camera to this scene
  34331. * @param newCamera The camera to add
  34332. */
  34333. addCamera(newCamera: Camera): void;
  34334. /**
  34335. * Adds the given skeleton to this scene
  34336. * @param newSkeleton The skeleton to add
  34337. */
  34338. addSkeleton(newSkeleton: Skeleton): void;
  34339. /**
  34340. * Adds the given particle system to this scene
  34341. * @param newParticleSystem The particle system to add
  34342. */
  34343. addParticleSystem(newParticleSystem: IParticleSystem): void;
  34344. /**
  34345. * Adds the given animation to this scene
  34346. * @param newAnimation The animation to add
  34347. */
  34348. addAnimation(newAnimation: Animation): void;
  34349. /**
  34350. * Adds the given animation group to this scene.
  34351. * @param newAnimationGroup The animation group to add
  34352. */
  34353. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  34354. /**
  34355. * Adds the given multi-material to this scene
  34356. * @param newMultiMaterial The multi-material to add
  34357. */
  34358. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  34359. /**
  34360. * Adds the given material to this scene
  34361. * @param newMaterial The material to add
  34362. */
  34363. addMaterial(newMaterial: Material): void;
  34364. /**
  34365. * Adds the given morph target to this scene
  34366. * @param newMorphTargetManager The morph target to add
  34367. */
  34368. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  34369. /**
  34370. * Adds the given geometry to this scene
  34371. * @param newGeometry The geometry to add
  34372. */
  34373. addGeometry(newGeometry: Geometry): void;
  34374. /**
  34375. * Adds the given action manager to this scene
  34376. * @param newActionManager The action manager to add
  34377. */
  34378. addActionManager(newActionManager: AbstractActionManager): void;
  34379. /**
  34380. * Adds the given texture to this scene.
  34381. * @param newTexture The texture to add
  34382. */
  34383. addTexture(newTexture: BaseTexture): void;
  34384. /**
  34385. * Switch active camera
  34386. * @param newCamera defines the new active camera
  34387. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  34388. */
  34389. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  34390. /**
  34391. * sets the active camera of the scene using its ID
  34392. * @param id defines the camera's ID
  34393. * @return the new active camera or null if none found.
  34394. */
  34395. setActiveCameraByID(id: string): Nullable<Camera>;
  34396. /**
  34397. * sets the active camera of the scene using its name
  34398. * @param name defines the camera's name
  34399. * @returns the new active camera or null if none found.
  34400. */
  34401. setActiveCameraByName(name: string): Nullable<Camera>;
  34402. /**
  34403. * get an animation group using its name
  34404. * @param name defines the material's name
  34405. * @return the animation group or null if none found.
  34406. */
  34407. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  34408. /**
  34409. * Get a material using its unique id
  34410. * @param uniqueId defines the material's unique id
  34411. * @return the material or null if none found.
  34412. */
  34413. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  34414. /**
  34415. * get a material using its id
  34416. * @param id defines the material's ID
  34417. * @return the material or null if none found.
  34418. */
  34419. getMaterialByID(id: string): Nullable<Material>;
  34420. /**
  34421. * Gets a material using its name
  34422. * @param name defines the material's name
  34423. * @return the material or null if none found.
  34424. */
  34425. getMaterialByName(name: string): Nullable<Material>;
  34426. /**
  34427. * Gets a camera using its id
  34428. * @param id defines the id to look for
  34429. * @returns the camera or null if not found
  34430. */
  34431. getCameraByID(id: string): Nullable<Camera>;
  34432. /**
  34433. * Gets a camera using its unique id
  34434. * @param uniqueId defines the unique id to look for
  34435. * @returns the camera or null if not found
  34436. */
  34437. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  34438. /**
  34439. * Gets a camera using its name
  34440. * @param name defines the camera's name
  34441. * @return the camera or null if none found.
  34442. */
  34443. getCameraByName(name: string): Nullable<Camera>;
  34444. /**
  34445. * Gets a bone using its id
  34446. * @param id defines the bone's id
  34447. * @return the bone or null if not found
  34448. */
  34449. getBoneByID(id: string): Nullable<Bone>;
  34450. /**
  34451. * Gets a bone using its id
  34452. * @param name defines the bone's name
  34453. * @return the bone or null if not found
  34454. */
  34455. getBoneByName(name: string): Nullable<Bone>;
  34456. /**
  34457. * Gets a light node using its name
  34458. * @param name defines the the light's name
  34459. * @return the light or null if none found.
  34460. */
  34461. getLightByName(name: string): Nullable<Light>;
  34462. /**
  34463. * Gets a light node using its id
  34464. * @param id defines the light's id
  34465. * @return the light or null if none found.
  34466. */
  34467. getLightByID(id: string): Nullable<Light>;
  34468. /**
  34469. * Gets a light node using its scene-generated unique ID
  34470. * @param uniqueId defines the light's unique id
  34471. * @return the light or null if none found.
  34472. */
  34473. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  34474. /**
  34475. * Gets a particle system by id
  34476. * @param id defines the particle system id
  34477. * @return the corresponding system or null if none found
  34478. */
  34479. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  34480. /**
  34481. * Gets a geometry using its ID
  34482. * @param id defines the geometry's id
  34483. * @return the geometry or null if none found.
  34484. */
  34485. getGeometryByID(id: string): Nullable<Geometry>;
  34486. private _getGeometryByUniqueID;
  34487. /**
  34488. * Add a new geometry to this scene
  34489. * @param geometry defines the geometry to be added to the scene.
  34490. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  34491. * @return a boolean defining if the geometry was added or not
  34492. */
  34493. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  34494. /**
  34495. * Removes an existing geometry
  34496. * @param geometry defines the geometry to be removed from the scene
  34497. * @return a boolean defining if the geometry was removed or not
  34498. */
  34499. removeGeometry(geometry: Geometry): boolean;
  34500. /**
  34501. * Gets the list of geometries attached to the scene
  34502. * @returns an array of Geometry
  34503. */
  34504. getGeometries(): Geometry[];
  34505. /**
  34506. * Gets the first added mesh found of a given ID
  34507. * @param id defines the id to search for
  34508. * @return the mesh found or null if not found at all
  34509. */
  34510. getMeshByID(id: string): Nullable<AbstractMesh>;
  34511. /**
  34512. * Gets a list of meshes using their id
  34513. * @param id defines the id to search for
  34514. * @returns a list of meshes
  34515. */
  34516. getMeshesByID(id: string): Array<AbstractMesh>;
  34517. /**
  34518. * Gets the first added transform node found of a given ID
  34519. * @param id defines the id to search for
  34520. * @return the found transform node or null if not found at all.
  34521. */
  34522. getTransformNodeByID(id: string): Nullable<TransformNode>;
  34523. /**
  34524. * Gets a transform node with its auto-generated unique id
  34525. * @param uniqueId efines the unique id to search for
  34526. * @return the found transform node or null if not found at all.
  34527. */
  34528. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  34529. /**
  34530. * Gets a list of transform nodes using their id
  34531. * @param id defines the id to search for
  34532. * @returns a list of transform nodes
  34533. */
  34534. getTransformNodesByID(id: string): Array<TransformNode>;
  34535. /**
  34536. * Gets a mesh with its auto-generated unique id
  34537. * @param uniqueId defines the unique id to search for
  34538. * @return the found mesh or null if not found at all.
  34539. */
  34540. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  34541. /**
  34542. * Gets a the last added mesh using a given id
  34543. * @param id defines the id to search for
  34544. * @return the found mesh or null if not found at all.
  34545. */
  34546. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  34547. /**
  34548. * Gets a the last added node (Mesh, Camera, Light) using a given id
  34549. * @param id defines the id to search for
  34550. * @return the found node or null if not found at all
  34551. */
  34552. getLastEntryByID(id: string): Nullable<Node>;
  34553. /**
  34554. * Gets a node (Mesh, Camera, Light) using a given id
  34555. * @param id defines the id to search for
  34556. * @return the found node or null if not found at all
  34557. */
  34558. getNodeByID(id: string): Nullable<Node>;
  34559. /**
  34560. * Gets a node (Mesh, Camera, Light) using a given name
  34561. * @param name defines the name to search for
  34562. * @return the found node or null if not found at all.
  34563. */
  34564. getNodeByName(name: string): Nullable<Node>;
  34565. /**
  34566. * Gets a mesh using a given name
  34567. * @param name defines the name to search for
  34568. * @return the found mesh or null if not found at all.
  34569. */
  34570. getMeshByName(name: string): Nullable<AbstractMesh>;
  34571. /**
  34572. * Gets a transform node using a given name
  34573. * @param name defines the name to search for
  34574. * @return the found transform node or null if not found at all.
  34575. */
  34576. getTransformNodeByName(name: string): Nullable<TransformNode>;
  34577. /**
  34578. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  34579. * @param id defines the id to search for
  34580. * @return the found skeleton or null if not found at all.
  34581. */
  34582. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  34583. /**
  34584. * Gets a skeleton using a given auto generated unique id
  34585. * @param uniqueId defines the unique id to search for
  34586. * @return the found skeleton or null if not found at all.
  34587. */
  34588. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  34589. /**
  34590. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  34591. * @param id defines the id to search for
  34592. * @return the found skeleton or null if not found at all.
  34593. */
  34594. getSkeletonById(id: string): Nullable<Skeleton>;
  34595. /**
  34596. * Gets a skeleton using a given name
  34597. * @param name defines the name to search for
  34598. * @return the found skeleton or null if not found at all.
  34599. */
  34600. getSkeletonByName(name: string): Nullable<Skeleton>;
  34601. /**
  34602. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  34603. * @param id defines the id to search for
  34604. * @return the found morph target manager or null if not found at all.
  34605. */
  34606. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  34607. /**
  34608. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  34609. * @param id defines the id to search for
  34610. * @return the found morph target or null if not found at all.
  34611. */
  34612. getMorphTargetById(id: string): Nullable<MorphTarget>;
  34613. /**
  34614. * Gets a boolean indicating if the given mesh is active
  34615. * @param mesh defines the mesh to look for
  34616. * @returns true if the mesh is in the active list
  34617. */
  34618. isActiveMesh(mesh: AbstractMesh): boolean;
  34619. /**
  34620. * Return a unique id as a string which can serve as an identifier for the scene
  34621. */
  34622. readonly uid: string;
  34623. /**
  34624. * Add an externaly attached data from its key.
  34625. * This method call will fail and return false, if such key already exists.
  34626. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  34627. * @param key the unique key that identifies the data
  34628. * @param data the data object to associate to the key for this Engine instance
  34629. * @return true if no such key were already present and the data was added successfully, false otherwise
  34630. */
  34631. addExternalData<T>(key: string, data: T): boolean;
  34632. /**
  34633. * Get an externaly attached data from its key
  34634. * @param key the unique key that identifies the data
  34635. * @return the associated data, if present (can be null), or undefined if not present
  34636. */
  34637. getExternalData<T>(key: string): Nullable<T>;
  34638. /**
  34639. * Get an externaly attached data from its key, create it using a factory if it's not already present
  34640. * @param key the unique key that identifies the data
  34641. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  34642. * @return the associated data, can be null if the factory returned null.
  34643. */
  34644. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  34645. /**
  34646. * Remove an externaly attached data from the Engine instance
  34647. * @param key the unique key that identifies the data
  34648. * @return true if the data was successfully removed, false if it doesn't exist
  34649. */
  34650. removeExternalData(key: string): boolean;
  34651. private _evaluateSubMesh;
  34652. /**
  34653. * Clear the processed materials smart array preventing retention point in material dispose.
  34654. */
  34655. freeProcessedMaterials(): void;
  34656. private _preventFreeActiveMeshesAndRenderingGroups;
  34657. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  34658. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  34659. * when disposing several meshes in a row or a hierarchy of meshes.
  34660. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  34661. */
  34662. blockfreeActiveMeshesAndRenderingGroups: boolean;
  34663. /**
  34664. * Clear the active meshes smart array preventing retention point in mesh dispose.
  34665. */
  34666. freeActiveMeshes(): void;
  34667. /**
  34668. * Clear the info related to rendering groups preventing retention points during dispose.
  34669. */
  34670. freeRenderingGroups(): void;
  34671. /** @hidden */
  34672. _isInIntermediateRendering(): boolean;
  34673. /**
  34674. * Lambda returning the list of potentially active meshes.
  34675. */
  34676. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  34677. /**
  34678. * Lambda returning the list of potentially active sub meshes.
  34679. */
  34680. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  34681. /**
  34682. * Lambda returning the list of potentially intersecting sub meshes.
  34683. */
  34684. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  34685. /**
  34686. * Lambda returning the list of potentially colliding sub meshes.
  34687. */
  34688. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  34689. private _activeMeshesFrozen;
  34690. /**
  34691. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  34692. * @returns the current scene
  34693. */
  34694. freezeActiveMeshes(): Scene;
  34695. /**
  34696. * Use this function to restart evaluating active meshes on every frame
  34697. * @returns the current scene
  34698. */
  34699. unfreezeActiveMeshes(): Scene;
  34700. private _evaluateActiveMeshes;
  34701. private _activeMesh;
  34702. /**
  34703. * Update the transform matrix to update from the current active camera
  34704. * @param force defines a boolean used to force the update even if cache is up to date
  34705. */
  34706. updateTransformMatrix(force?: boolean): void;
  34707. private _bindFrameBuffer;
  34708. /** @hidden */
  34709. _allowPostProcessClearColor: boolean;
  34710. /** @hidden */
  34711. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  34712. private _processSubCameras;
  34713. private _checkIntersections;
  34714. /** @hidden */
  34715. _advancePhysicsEngineStep(step: number): void;
  34716. /**
  34717. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  34718. */
  34719. getDeterministicFrameTime: () => number;
  34720. /** @hidden */
  34721. _animate(): void;
  34722. /** Execute all animations (for a frame) */
  34723. animate(): void;
  34724. /**
  34725. * Render the scene
  34726. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  34727. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  34728. */
  34729. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  34730. /**
  34731. * Freeze all materials
  34732. * A frozen material will not be updatable but should be faster to render
  34733. */
  34734. freezeMaterials(): void;
  34735. /**
  34736. * Unfreeze all materials
  34737. * A frozen material will not be updatable but should be faster to render
  34738. */
  34739. unfreezeMaterials(): void;
  34740. /**
  34741. * Releases all held ressources
  34742. */
  34743. dispose(): void;
  34744. /**
  34745. * Gets if the scene is already disposed
  34746. */
  34747. readonly isDisposed: boolean;
  34748. /**
  34749. * Call this function to reduce memory footprint of the scene.
  34750. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  34751. */
  34752. clearCachedVertexData(): void;
  34753. /**
  34754. * This function will remove the local cached buffer data from texture.
  34755. * It will save memory but will prevent the texture from being rebuilt
  34756. */
  34757. cleanCachedTextureBuffer(): void;
  34758. /**
  34759. * Get the world extend vectors with an optional filter
  34760. *
  34761. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  34762. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  34763. */
  34764. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  34765. min: Vector3;
  34766. max: Vector3;
  34767. };
  34768. /**
  34769. * Creates a ray that can be used to pick in the scene
  34770. * @param x defines the x coordinate of the origin (on-screen)
  34771. * @param y defines the y coordinate of the origin (on-screen)
  34772. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34773. * @param camera defines the camera to use for the picking
  34774. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34775. * @returns a Ray
  34776. */
  34777. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  34778. /**
  34779. * Creates a ray that can be used to pick in the scene
  34780. * @param x defines the x coordinate of the origin (on-screen)
  34781. * @param y defines the y coordinate of the origin (on-screen)
  34782. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34783. * @param result defines the ray where to store the picking ray
  34784. * @param camera defines the camera to use for the picking
  34785. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34786. * @returns the current scene
  34787. */
  34788. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  34789. /**
  34790. * Creates a ray that can be used to pick in the scene
  34791. * @param x defines the x coordinate of the origin (on-screen)
  34792. * @param y defines the y coordinate of the origin (on-screen)
  34793. * @param camera defines the camera to use for the picking
  34794. * @returns a Ray
  34795. */
  34796. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  34797. /**
  34798. * Creates a ray that can be used to pick in the scene
  34799. * @param x defines the x coordinate of the origin (on-screen)
  34800. * @param y defines the y coordinate of the origin (on-screen)
  34801. * @param result defines the ray where to store the picking ray
  34802. * @param camera defines the camera to use for the picking
  34803. * @returns the current scene
  34804. */
  34805. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34806. /** Launch a ray to try to pick a mesh in the scene
  34807. * @param x position on screen
  34808. * @param y position on screen
  34809. * @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
  34810. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34811. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34812. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34813. * @returns a PickingInfo
  34814. */
  34815. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34816. /** Use the given ray to pick a mesh in the scene
  34817. * @param ray The ray to use to pick meshes
  34818. * @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
  34819. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  34820. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34821. * @returns a PickingInfo
  34822. */
  34823. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34824. /**
  34825. * Launch a ray to try to pick a mesh in the scene
  34826. * @param x X position on screen
  34827. * @param y Y position on screen
  34828. * @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
  34829. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34830. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34831. * @returns an array of PickingInfo
  34832. */
  34833. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34834. /**
  34835. * Launch a ray to try to pick a mesh in the scene
  34836. * @param ray Ray to use
  34837. * @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
  34838. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34839. * @returns an array of PickingInfo
  34840. */
  34841. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34842. /**
  34843. * Force the value of meshUnderPointer
  34844. * @param mesh defines the mesh to use
  34845. */
  34846. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34847. /**
  34848. * Gets the mesh under the pointer
  34849. * @returns a Mesh or null if no mesh is under the pointer
  34850. */
  34851. getPointerOverMesh(): Nullable<AbstractMesh>;
  34852. /** @hidden */
  34853. _rebuildGeometries(): void;
  34854. /** @hidden */
  34855. _rebuildTextures(): void;
  34856. private _getByTags;
  34857. /**
  34858. * Get a list of meshes by tags
  34859. * @param tagsQuery defines the tags query to use
  34860. * @param forEach defines a predicate used to filter results
  34861. * @returns an array of Mesh
  34862. */
  34863. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34864. /**
  34865. * Get a list of cameras by tags
  34866. * @param tagsQuery defines the tags query to use
  34867. * @param forEach defines a predicate used to filter results
  34868. * @returns an array of Camera
  34869. */
  34870. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34871. /**
  34872. * Get a list of lights by tags
  34873. * @param tagsQuery defines the tags query to use
  34874. * @param forEach defines a predicate used to filter results
  34875. * @returns an array of Light
  34876. */
  34877. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34878. /**
  34879. * Get a list of materials by tags
  34880. * @param tagsQuery defines the tags query to use
  34881. * @param forEach defines a predicate used to filter results
  34882. * @returns an array of Material
  34883. */
  34884. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34885. /**
  34886. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34887. * This allowed control for front to back rendering or reversly depending of the special needs.
  34888. *
  34889. * @param renderingGroupId The rendering group id corresponding to its index
  34890. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34891. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34892. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34893. */
  34894. 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;
  34895. /**
  34896. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34897. *
  34898. * @param renderingGroupId The rendering group id corresponding to its index
  34899. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34900. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34901. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34902. */
  34903. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34904. /**
  34905. * Gets the current auto clear configuration for one rendering group of the rendering
  34906. * manager.
  34907. * @param index the rendering group index to get the information for
  34908. * @returns The auto clear setup for the requested rendering group
  34909. */
  34910. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34911. private _blockMaterialDirtyMechanism;
  34912. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34913. blockMaterialDirtyMechanism: boolean;
  34914. /**
  34915. * Will flag all materials as dirty to trigger new shader compilation
  34916. * @param flag defines the flag used to specify which material part must be marked as dirty
  34917. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34918. */
  34919. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34920. /** @hidden */
  34921. _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;
  34922. /** @hidden */
  34923. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34924. }
  34925. }
  34926. declare module "babylonjs/assetContainer" {
  34927. import { AbstractScene } from "babylonjs/abstractScene";
  34928. import { Scene } from "babylonjs/scene";
  34929. import { Mesh } from "babylonjs/Meshes/mesh";
  34930. /**
  34931. * Set of assets to keep when moving a scene into an asset container.
  34932. */
  34933. export class KeepAssets extends AbstractScene {
  34934. }
  34935. /**
  34936. * Container with a set of assets that can be added or removed from a scene.
  34937. */
  34938. export class AssetContainer extends AbstractScene {
  34939. /**
  34940. * The scene the AssetContainer belongs to.
  34941. */
  34942. scene: Scene;
  34943. /**
  34944. * Instantiates an AssetContainer.
  34945. * @param scene The scene the AssetContainer belongs to.
  34946. */
  34947. constructor(scene: Scene);
  34948. /**
  34949. * Adds all the assets from the container to the scene.
  34950. */
  34951. addAllToScene(): void;
  34952. /**
  34953. * Removes all the assets in the container from the scene
  34954. */
  34955. removeAllFromScene(): void;
  34956. /**
  34957. * Disposes all the assets in the container
  34958. */
  34959. dispose(): void;
  34960. private _moveAssets;
  34961. /**
  34962. * Removes all the assets contained in the scene and adds them to the container.
  34963. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34964. */
  34965. moveAllFromScene(keepAssets?: KeepAssets): void;
  34966. /**
  34967. * 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.
  34968. * @returns the root mesh
  34969. */
  34970. createRootMesh(): Mesh;
  34971. }
  34972. }
  34973. declare module "babylonjs/abstractScene" {
  34974. import { Scene } from "babylonjs/scene";
  34975. import { Nullable } from "babylonjs/types";
  34976. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34977. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34978. import { Geometry } from "babylonjs/Meshes/geometry";
  34979. import { Skeleton } from "babylonjs/Bones/skeleton";
  34980. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  34981. import { AssetContainer } from "babylonjs/assetContainer";
  34982. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  34983. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  34984. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34985. import { Material } from "babylonjs/Materials/material";
  34986. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  34987. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  34988. import { Camera } from "babylonjs/Cameras/camera";
  34989. import { Light } from "babylonjs/Lights/light";
  34990. import { Node } from "babylonjs/node";
  34991. import { Animation } from "babylonjs/Animations/animation";
  34992. /**
  34993. * Defines how the parser contract is defined.
  34994. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34995. */
  34996. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34997. /**
  34998. * Defines how the individual parser contract is defined.
  34999. * These parser can parse an individual asset
  35000. */
  35001. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  35002. /**
  35003. * Base class of the scene acting as a container for the different elements composing a scene.
  35004. * This class is dynamically extended by the different components of the scene increasing
  35005. * flexibility and reducing coupling
  35006. */
  35007. export abstract class AbstractScene {
  35008. /**
  35009. * Stores the list of available parsers in the application.
  35010. */
  35011. private static _BabylonFileParsers;
  35012. /**
  35013. * Stores the list of available individual parsers in the application.
  35014. */
  35015. private static _IndividualBabylonFileParsers;
  35016. /**
  35017. * Adds a parser in the list of available ones
  35018. * @param name Defines the name of the parser
  35019. * @param parser Defines the parser to add
  35020. */
  35021. static AddParser(name: string, parser: BabylonFileParser): void;
  35022. /**
  35023. * Gets a general parser from the list of avaialble ones
  35024. * @param name Defines the name of the parser
  35025. * @returns the requested parser or null
  35026. */
  35027. static GetParser(name: string): Nullable<BabylonFileParser>;
  35028. /**
  35029. * Adds n individual parser in the list of available ones
  35030. * @param name Defines the name of the parser
  35031. * @param parser Defines the parser to add
  35032. */
  35033. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  35034. /**
  35035. * Gets an individual parser from the list of avaialble ones
  35036. * @param name Defines the name of the parser
  35037. * @returns the requested parser or null
  35038. */
  35039. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  35040. /**
  35041. * Parser json data and populate both a scene and its associated container object
  35042. * @param jsonData Defines the data to parse
  35043. * @param scene Defines the scene to parse the data for
  35044. * @param container Defines the container attached to the parsing sequence
  35045. * @param rootUrl Defines the root url of the data
  35046. */
  35047. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  35048. /**
  35049. * Gets the list of root nodes (ie. nodes with no parent)
  35050. */
  35051. rootNodes: Node[];
  35052. /** All of the cameras added to this scene
  35053. * @see http://doc.babylonjs.com/babylon101/cameras
  35054. */
  35055. cameras: Camera[];
  35056. /**
  35057. * All of the lights added to this scene
  35058. * @see http://doc.babylonjs.com/babylon101/lights
  35059. */
  35060. lights: Light[];
  35061. /**
  35062. * All of the (abstract) meshes added to this scene
  35063. */
  35064. meshes: AbstractMesh[];
  35065. /**
  35066. * The list of skeletons added to the scene
  35067. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35068. */
  35069. skeletons: Skeleton[];
  35070. /**
  35071. * All of the particle systems added to this scene
  35072. * @see http://doc.babylonjs.com/babylon101/particles
  35073. */
  35074. particleSystems: IParticleSystem[];
  35075. /**
  35076. * Gets a list of Animations associated with the scene
  35077. */
  35078. animations: Animation[];
  35079. /**
  35080. * All of the animation groups added to this scene
  35081. * @see http://doc.babylonjs.com/how_to/group
  35082. */
  35083. animationGroups: AnimationGroup[];
  35084. /**
  35085. * All of the multi-materials added to this scene
  35086. * @see http://doc.babylonjs.com/how_to/multi_materials
  35087. */
  35088. multiMaterials: MultiMaterial[];
  35089. /**
  35090. * All of the materials added to this scene
  35091. * In the context of a Scene, it is not supposed to be modified manually.
  35092. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  35093. * Note also that the order of the Material wihin the array is not significant and might change.
  35094. * @see http://doc.babylonjs.com/babylon101/materials
  35095. */
  35096. materials: Material[];
  35097. /**
  35098. * The list of morph target managers added to the scene
  35099. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  35100. */
  35101. morphTargetManagers: MorphTargetManager[];
  35102. /**
  35103. * The list of geometries used in the scene.
  35104. */
  35105. geometries: Geometry[];
  35106. /**
  35107. * All of the tranform nodes added to this scene
  35108. * In the context of a Scene, it is not supposed to be modified manually.
  35109. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  35110. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  35111. * @see http://doc.babylonjs.com/how_to/transformnode
  35112. */
  35113. transformNodes: TransformNode[];
  35114. /**
  35115. * ActionManagers available on the scene.
  35116. */
  35117. actionManagers: AbstractActionManager[];
  35118. /**
  35119. * Textures to keep.
  35120. */
  35121. textures: BaseTexture[];
  35122. /**
  35123. * Environment texture for the scene
  35124. */
  35125. environmentTexture: Nullable<BaseTexture>;
  35126. }
  35127. }
  35128. declare module "babylonjs/Audio/sound" {
  35129. import { Observable } from "babylonjs/Misc/observable";
  35130. import { Vector3 } from "babylonjs/Maths/math";
  35131. import { Nullable } from "babylonjs/types";
  35132. import { Scene } from "babylonjs/scene";
  35133. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35134. /**
  35135. * Interface used to define options for Sound class
  35136. */
  35137. export interface ISoundOptions {
  35138. /**
  35139. * Does the sound autoplay once loaded.
  35140. */
  35141. autoplay?: boolean;
  35142. /**
  35143. * Does the sound loop after it finishes playing once.
  35144. */
  35145. loop?: boolean;
  35146. /**
  35147. * Sound's volume
  35148. */
  35149. volume?: number;
  35150. /**
  35151. * Is it a spatial sound?
  35152. */
  35153. spatialSound?: boolean;
  35154. /**
  35155. * Maximum distance to hear that sound
  35156. */
  35157. maxDistance?: number;
  35158. /**
  35159. * Uses user defined attenuation function
  35160. */
  35161. useCustomAttenuation?: boolean;
  35162. /**
  35163. * Define the roll off factor of spatial sounds.
  35164. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35165. */
  35166. rolloffFactor?: number;
  35167. /**
  35168. * Define the reference distance the sound should be heard perfectly.
  35169. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35170. */
  35171. refDistance?: number;
  35172. /**
  35173. * Define the distance attenuation model the sound will follow.
  35174. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35175. */
  35176. distanceModel?: string;
  35177. /**
  35178. * Defines the playback speed (1 by default)
  35179. */
  35180. playbackRate?: number;
  35181. /**
  35182. * Defines if the sound is from a streaming source
  35183. */
  35184. streaming?: boolean;
  35185. /**
  35186. * Defines an optional length (in seconds) inside the sound file
  35187. */
  35188. length?: number;
  35189. /**
  35190. * Defines an optional offset (in seconds) inside the sound file
  35191. */
  35192. offset?: number;
  35193. }
  35194. /**
  35195. * Defines a sound that can be played in the application.
  35196. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  35197. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35198. */
  35199. export class Sound {
  35200. /**
  35201. * The name of the sound in the scene.
  35202. */
  35203. name: string;
  35204. /**
  35205. * Does the sound autoplay once loaded.
  35206. */
  35207. autoplay: boolean;
  35208. /**
  35209. * Does the sound loop after it finishes playing once.
  35210. */
  35211. loop: boolean;
  35212. /**
  35213. * Does the sound use a custom attenuation curve to simulate the falloff
  35214. * happening when the source gets further away from the camera.
  35215. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35216. */
  35217. useCustomAttenuation: boolean;
  35218. /**
  35219. * The sound track id this sound belongs to.
  35220. */
  35221. soundTrackId: number;
  35222. /**
  35223. * Is this sound currently played.
  35224. */
  35225. isPlaying: boolean;
  35226. /**
  35227. * Is this sound currently paused.
  35228. */
  35229. isPaused: boolean;
  35230. /**
  35231. * Does this sound enables spatial sound.
  35232. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35233. */
  35234. spatialSound: boolean;
  35235. /**
  35236. * Define the reference distance the sound should be heard perfectly.
  35237. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35238. */
  35239. refDistance: number;
  35240. /**
  35241. * Define the roll off factor of spatial sounds.
  35242. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35243. */
  35244. rolloffFactor: number;
  35245. /**
  35246. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  35247. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35248. */
  35249. maxDistance: number;
  35250. /**
  35251. * Define the distance attenuation model the sound will follow.
  35252. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35253. */
  35254. distanceModel: string;
  35255. /**
  35256. * @hidden
  35257. * Back Compat
  35258. **/
  35259. onended: () => any;
  35260. /**
  35261. * Observable event when the current playing sound finishes.
  35262. */
  35263. onEndedObservable: Observable<Sound>;
  35264. private _panningModel;
  35265. private _playbackRate;
  35266. private _streaming;
  35267. private _startTime;
  35268. private _startOffset;
  35269. private _position;
  35270. /** @hidden */
  35271. _positionInEmitterSpace: boolean;
  35272. private _localDirection;
  35273. private _volume;
  35274. private _isReadyToPlay;
  35275. private _isDirectional;
  35276. private _readyToPlayCallback;
  35277. private _audioBuffer;
  35278. private _soundSource;
  35279. private _streamingSource;
  35280. private _soundPanner;
  35281. private _soundGain;
  35282. private _inputAudioNode;
  35283. private _outputAudioNode;
  35284. private _coneInnerAngle;
  35285. private _coneOuterAngle;
  35286. private _coneOuterGain;
  35287. private _scene;
  35288. private _connectedTransformNode;
  35289. private _customAttenuationFunction;
  35290. private _registerFunc;
  35291. private _isOutputConnected;
  35292. private _htmlAudioElement;
  35293. private _urlType;
  35294. private _length?;
  35295. private _offset?;
  35296. /** @hidden */
  35297. static _SceneComponentInitialization: (scene: Scene) => void;
  35298. /**
  35299. * Create a sound and attach it to a scene
  35300. * @param name Name of your sound
  35301. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  35302. * @param scene defines the scene the sound belongs to
  35303. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  35304. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  35305. */
  35306. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  35307. /**
  35308. * Release the sound and its associated resources
  35309. */
  35310. dispose(): void;
  35311. /**
  35312. * Gets if the sounds is ready to be played or not.
  35313. * @returns true if ready, otherwise false
  35314. */
  35315. isReady(): boolean;
  35316. private _soundLoaded;
  35317. /**
  35318. * Sets the data of the sound from an audiobuffer
  35319. * @param audioBuffer The audioBuffer containing the data
  35320. */
  35321. setAudioBuffer(audioBuffer: AudioBuffer): void;
  35322. /**
  35323. * Updates the current sounds options such as maxdistance, loop...
  35324. * @param options A JSON object containing values named as the object properties
  35325. */
  35326. updateOptions(options: ISoundOptions): void;
  35327. private _createSpatialParameters;
  35328. private _updateSpatialParameters;
  35329. /**
  35330. * Switch the panning model to HRTF:
  35331. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35332. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35333. */
  35334. switchPanningModelToHRTF(): void;
  35335. /**
  35336. * Switch the panning model to Equal Power:
  35337. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35338. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35339. */
  35340. switchPanningModelToEqualPower(): void;
  35341. private _switchPanningModel;
  35342. /**
  35343. * Connect this sound to a sound track audio node like gain...
  35344. * @param soundTrackAudioNode the sound track audio node to connect to
  35345. */
  35346. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  35347. /**
  35348. * Transform this sound into a directional source
  35349. * @param coneInnerAngle Size of the inner cone in degree
  35350. * @param coneOuterAngle Size of the outer cone in degree
  35351. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  35352. */
  35353. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  35354. /**
  35355. * Gets or sets the inner angle for the directional cone.
  35356. */
  35357. /**
  35358. * Gets or sets the inner angle for the directional cone.
  35359. */
  35360. directionalConeInnerAngle: number;
  35361. /**
  35362. * Gets or sets the outer angle for the directional cone.
  35363. */
  35364. /**
  35365. * Gets or sets the outer angle for the directional cone.
  35366. */
  35367. directionalConeOuterAngle: number;
  35368. /**
  35369. * Sets the position of the emitter if spatial sound is enabled
  35370. * @param newPosition Defines the new posisiton
  35371. */
  35372. setPosition(newPosition: Vector3): void;
  35373. /**
  35374. * Sets the local direction of the emitter if spatial sound is enabled
  35375. * @param newLocalDirection Defines the new local direction
  35376. */
  35377. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  35378. private _updateDirection;
  35379. /** @hidden */
  35380. updateDistanceFromListener(): void;
  35381. /**
  35382. * Sets a new custom attenuation function for the sound.
  35383. * @param callback Defines the function used for the attenuation
  35384. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35385. */
  35386. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  35387. /**
  35388. * Play the sound
  35389. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  35390. * @param offset (optional) Start the sound at a specific time in seconds
  35391. * @param length (optional) Sound duration (in seconds)
  35392. */
  35393. play(time?: number, offset?: number, length?: number): void;
  35394. private _onended;
  35395. /**
  35396. * Stop the sound
  35397. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  35398. */
  35399. stop(time?: number): void;
  35400. /**
  35401. * Put the sound in pause
  35402. */
  35403. pause(): void;
  35404. /**
  35405. * Sets a dedicated volume for this sounds
  35406. * @param newVolume Define the new volume of the sound
  35407. * @param time Define time for gradual change to new volume
  35408. */
  35409. setVolume(newVolume: number, time?: number): void;
  35410. /**
  35411. * Set the sound play back rate
  35412. * @param newPlaybackRate Define the playback rate the sound should be played at
  35413. */
  35414. setPlaybackRate(newPlaybackRate: number): void;
  35415. /**
  35416. * Gets the volume of the sound.
  35417. * @returns the volume of the sound
  35418. */
  35419. getVolume(): number;
  35420. /**
  35421. * Attach the sound to a dedicated mesh
  35422. * @param transformNode The transform node to connect the sound with
  35423. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35424. */
  35425. attachToMesh(transformNode: TransformNode): void;
  35426. /**
  35427. * Detach the sound from the previously attached mesh
  35428. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35429. */
  35430. detachFromMesh(): void;
  35431. private _onRegisterAfterWorldMatrixUpdate;
  35432. /**
  35433. * Clone the current sound in the scene.
  35434. * @returns the new sound clone
  35435. */
  35436. clone(): Nullable<Sound>;
  35437. /**
  35438. * Gets the current underlying audio buffer containing the data
  35439. * @returns the audio buffer
  35440. */
  35441. getAudioBuffer(): Nullable<AudioBuffer>;
  35442. /**
  35443. * Serializes the Sound in a JSON representation
  35444. * @returns the JSON representation of the sound
  35445. */
  35446. serialize(): any;
  35447. /**
  35448. * Parse a JSON representation of a sound to innstantiate in a given scene
  35449. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  35450. * @param scene Define the scene the new parsed sound should be created in
  35451. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  35452. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  35453. * @returns the newly parsed sound
  35454. */
  35455. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  35456. }
  35457. }
  35458. declare module "babylonjs/Actions/directAudioActions" {
  35459. import { Action } from "babylonjs/Actions/action";
  35460. import { Condition } from "babylonjs/Actions/condition";
  35461. import { Sound } from "babylonjs/Audio/sound";
  35462. /**
  35463. * This defines an action helpful to play a defined sound on a triggered action.
  35464. */
  35465. export class PlaySoundAction extends Action {
  35466. private _sound;
  35467. /**
  35468. * Instantiate the action
  35469. * @param triggerOptions defines the trigger options
  35470. * @param sound defines the sound to play
  35471. * @param condition defines the trigger related conditions
  35472. */
  35473. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35474. /** @hidden */
  35475. _prepare(): void;
  35476. /**
  35477. * Execute the action and play the sound.
  35478. */
  35479. execute(): void;
  35480. /**
  35481. * Serializes the actions and its related information.
  35482. * @param parent defines the object to serialize in
  35483. * @returns the serialized object
  35484. */
  35485. serialize(parent: any): any;
  35486. }
  35487. /**
  35488. * This defines an action helpful to stop a defined sound on a triggered action.
  35489. */
  35490. export class StopSoundAction extends Action {
  35491. private _sound;
  35492. /**
  35493. * Instantiate the action
  35494. * @param triggerOptions defines the trigger options
  35495. * @param sound defines the sound to stop
  35496. * @param condition defines the trigger related conditions
  35497. */
  35498. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35499. /** @hidden */
  35500. _prepare(): void;
  35501. /**
  35502. * Execute the action and stop the sound.
  35503. */
  35504. execute(): void;
  35505. /**
  35506. * Serializes the actions and its related information.
  35507. * @param parent defines the object to serialize in
  35508. * @returns the serialized object
  35509. */
  35510. serialize(parent: any): any;
  35511. }
  35512. }
  35513. declare module "babylonjs/Actions/interpolateValueAction" {
  35514. import { Action } from "babylonjs/Actions/action";
  35515. import { Condition } from "babylonjs/Actions/condition";
  35516. import { Observable } from "babylonjs/Misc/observable";
  35517. /**
  35518. * This defines an action responsible to change the value of a property
  35519. * by interpolating between its current value and the newly set one once triggered.
  35520. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35521. */
  35522. export class InterpolateValueAction extends Action {
  35523. /**
  35524. * Defines the path of the property where the value should be interpolated
  35525. */
  35526. propertyPath: string;
  35527. /**
  35528. * Defines the target value at the end of the interpolation.
  35529. */
  35530. value: any;
  35531. /**
  35532. * Defines the time it will take for the property to interpolate to the value.
  35533. */
  35534. duration: number;
  35535. /**
  35536. * Defines if the other scene animations should be stopped when the action has been triggered
  35537. */
  35538. stopOtherAnimations?: boolean;
  35539. /**
  35540. * Defines a callback raised once the interpolation animation has been done.
  35541. */
  35542. onInterpolationDone?: () => void;
  35543. /**
  35544. * Observable triggered once the interpolation animation has been done.
  35545. */
  35546. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  35547. private _target;
  35548. private _effectiveTarget;
  35549. private _property;
  35550. /**
  35551. * Instantiate the action
  35552. * @param triggerOptions defines the trigger options
  35553. * @param target defines the object containing the value to interpolate
  35554. * @param propertyPath defines the path to the property in the target object
  35555. * @param value defines the target value at the end of the interpolation
  35556. * @param duration deines the time it will take for the property to interpolate to the value.
  35557. * @param condition defines the trigger related conditions
  35558. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  35559. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  35560. */
  35561. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  35562. /** @hidden */
  35563. _prepare(): void;
  35564. /**
  35565. * Execute the action starts the value interpolation.
  35566. */
  35567. execute(): void;
  35568. /**
  35569. * Serializes the actions and its related information.
  35570. * @param parent defines the object to serialize in
  35571. * @returns the serialized object
  35572. */
  35573. serialize(parent: any): any;
  35574. }
  35575. }
  35576. declare module "babylonjs/Actions/index" {
  35577. export * from "babylonjs/Actions/action";
  35578. export * from "babylonjs/Actions/actionEvent";
  35579. export * from "babylonjs/Actions/actionManager";
  35580. export * from "babylonjs/Actions/condition";
  35581. export * from "babylonjs/Actions/directActions";
  35582. export * from "babylonjs/Actions/directAudioActions";
  35583. export * from "babylonjs/Actions/interpolateValueAction";
  35584. }
  35585. declare module "babylonjs/Animations/index" {
  35586. export * from "babylonjs/Animations/animatable";
  35587. export * from "babylonjs/Animations/animation";
  35588. export * from "babylonjs/Animations/animationGroup";
  35589. export * from "babylonjs/Animations/animationPropertiesOverride";
  35590. export * from "babylonjs/Animations/easing";
  35591. export * from "babylonjs/Animations/runtimeAnimation";
  35592. export * from "babylonjs/Animations/animationEvent";
  35593. export * from "babylonjs/Animations/animationGroup";
  35594. export * from "babylonjs/Animations/animationKey";
  35595. export * from "babylonjs/Animations/animationRange";
  35596. }
  35597. declare module "babylonjs/Audio/soundTrack" {
  35598. import { Sound } from "babylonjs/Audio/sound";
  35599. import { Analyser } from "babylonjs/Audio/analyser";
  35600. import { Scene } from "babylonjs/scene";
  35601. /**
  35602. * Options allowed during the creation of a sound track.
  35603. */
  35604. export interface ISoundTrackOptions {
  35605. /**
  35606. * The volume the sound track should take during creation
  35607. */
  35608. volume?: number;
  35609. /**
  35610. * Define if the sound track is the main sound track of the scene
  35611. */
  35612. mainTrack?: boolean;
  35613. }
  35614. /**
  35615. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  35616. * It will be also used in a future release to apply effects on a specific track.
  35617. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35618. */
  35619. export class SoundTrack {
  35620. /**
  35621. * The unique identifier of the sound track in the scene.
  35622. */
  35623. id: number;
  35624. /**
  35625. * The list of sounds included in the sound track.
  35626. */
  35627. soundCollection: Array<Sound>;
  35628. private _outputAudioNode;
  35629. private _scene;
  35630. private _isMainTrack;
  35631. private _connectedAnalyser;
  35632. private _options;
  35633. private _isInitialized;
  35634. /**
  35635. * Creates a new sound track.
  35636. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35637. * @param scene Define the scene the sound track belongs to
  35638. * @param options
  35639. */
  35640. constructor(scene: Scene, options?: ISoundTrackOptions);
  35641. private _initializeSoundTrackAudioGraph;
  35642. /**
  35643. * Release the sound track and its associated resources
  35644. */
  35645. dispose(): void;
  35646. /**
  35647. * Adds a sound to this sound track
  35648. * @param sound define the cound to add
  35649. * @ignoreNaming
  35650. */
  35651. AddSound(sound: Sound): void;
  35652. /**
  35653. * Removes a sound to this sound track
  35654. * @param sound define the cound to remove
  35655. * @ignoreNaming
  35656. */
  35657. RemoveSound(sound: Sound): void;
  35658. /**
  35659. * Set a global volume for the full sound track.
  35660. * @param newVolume Define the new volume of the sound track
  35661. */
  35662. setVolume(newVolume: number): void;
  35663. /**
  35664. * Switch the panning model to HRTF:
  35665. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35666. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35667. */
  35668. switchPanningModelToHRTF(): void;
  35669. /**
  35670. * Switch the panning model to Equal Power:
  35671. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35672. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35673. */
  35674. switchPanningModelToEqualPower(): void;
  35675. /**
  35676. * Connect the sound track to an audio analyser allowing some amazing
  35677. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35678. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35679. * @param analyser The analyser to connect to the engine
  35680. */
  35681. connectToAnalyser(analyser: Analyser): void;
  35682. }
  35683. }
  35684. declare module "babylonjs/Audio/audioSceneComponent" {
  35685. import { Sound } from "babylonjs/Audio/sound";
  35686. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  35687. import { Nullable } from "babylonjs/types";
  35688. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  35689. import { Scene } from "babylonjs/scene";
  35690. import { AbstractScene } from "babylonjs/abstractScene";
  35691. module "babylonjs/abstractScene" {
  35692. interface AbstractScene {
  35693. /**
  35694. * The list of sounds used in the scene.
  35695. */
  35696. sounds: Nullable<Array<Sound>>;
  35697. }
  35698. }
  35699. module "babylonjs/scene" {
  35700. interface Scene {
  35701. /**
  35702. * @hidden
  35703. * Backing field
  35704. */
  35705. _mainSoundTrack: SoundTrack;
  35706. /**
  35707. * The main sound track played by the scene.
  35708. * It cotains your primary collection of sounds.
  35709. */
  35710. mainSoundTrack: SoundTrack;
  35711. /**
  35712. * The list of sound tracks added to the scene
  35713. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35714. */
  35715. soundTracks: Nullable<Array<SoundTrack>>;
  35716. /**
  35717. * Gets a sound using a given name
  35718. * @param name defines the name to search for
  35719. * @return the found sound or null if not found at all.
  35720. */
  35721. getSoundByName(name: string): Nullable<Sound>;
  35722. /**
  35723. * Gets or sets if audio support is enabled
  35724. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35725. */
  35726. audioEnabled: boolean;
  35727. /**
  35728. * Gets or sets if audio will be output to headphones
  35729. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35730. */
  35731. headphone: boolean;
  35732. }
  35733. }
  35734. /**
  35735. * Defines the sound scene component responsible to manage any sounds
  35736. * in a given scene.
  35737. */
  35738. export class AudioSceneComponent implements ISceneSerializableComponent {
  35739. /**
  35740. * The component name helpfull to identify the component in the list of scene components.
  35741. */
  35742. readonly name: string;
  35743. /**
  35744. * The scene the component belongs to.
  35745. */
  35746. scene: Scene;
  35747. private _audioEnabled;
  35748. /**
  35749. * Gets whether audio is enabled or not.
  35750. * Please use related enable/disable method to switch state.
  35751. */
  35752. readonly audioEnabled: boolean;
  35753. private _headphone;
  35754. /**
  35755. * Gets whether audio is outputing to headphone or not.
  35756. * Please use the according Switch methods to change output.
  35757. */
  35758. readonly headphone: boolean;
  35759. /**
  35760. * Creates a new instance of the component for the given scene
  35761. * @param scene Defines the scene to register the component in
  35762. */
  35763. constructor(scene: Scene);
  35764. /**
  35765. * Registers the component in a given scene
  35766. */
  35767. register(): void;
  35768. /**
  35769. * Rebuilds the elements related to this component in case of
  35770. * context lost for instance.
  35771. */
  35772. rebuild(): void;
  35773. /**
  35774. * Serializes the component data to the specified json object
  35775. * @param serializationObject The object to serialize to
  35776. */
  35777. serialize(serializationObject: any): void;
  35778. /**
  35779. * Adds all the elements from the container to the scene
  35780. * @param container the container holding the elements
  35781. */
  35782. addFromContainer(container: AbstractScene): void;
  35783. /**
  35784. * Removes all the elements in the container from the scene
  35785. * @param container contains the elements to remove
  35786. * @param dispose if the removed element should be disposed (default: false)
  35787. */
  35788. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  35789. /**
  35790. * Disposes the component and the associated ressources.
  35791. */
  35792. dispose(): void;
  35793. /**
  35794. * Disables audio in the associated scene.
  35795. */
  35796. disableAudio(): void;
  35797. /**
  35798. * Enables audio in the associated scene.
  35799. */
  35800. enableAudio(): void;
  35801. /**
  35802. * Switch audio to headphone output.
  35803. */
  35804. switchAudioModeForHeadphones(): void;
  35805. /**
  35806. * Switch audio to normal speakers.
  35807. */
  35808. switchAudioModeForNormalSpeakers(): void;
  35809. private _afterRender;
  35810. }
  35811. }
  35812. declare module "babylonjs/Audio/weightedsound" {
  35813. import { Sound } from "babylonjs/Audio/sound";
  35814. /**
  35815. * Wraps one or more Sound objects and selects one with random weight for playback.
  35816. */
  35817. export class WeightedSound {
  35818. /** When true a Sound will be selected and played when the current playing Sound completes. */
  35819. loop: boolean;
  35820. private _coneInnerAngle;
  35821. private _coneOuterAngle;
  35822. private _volume;
  35823. /** A Sound is currently playing. */
  35824. isPlaying: boolean;
  35825. /** A Sound is currently paused. */
  35826. isPaused: boolean;
  35827. private _sounds;
  35828. private _weights;
  35829. private _currentIndex?;
  35830. /**
  35831. * Creates a new WeightedSound from the list of sounds given.
  35832. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  35833. * @param sounds Array of Sounds that will be selected from.
  35834. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  35835. */
  35836. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  35837. /**
  35838. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  35839. */
  35840. /**
  35841. * The size of cone in degress for a directional sound in which there will be no attenuation.
  35842. */
  35843. directionalConeInnerAngle: number;
  35844. /**
  35845. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35846. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35847. */
  35848. /**
  35849. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35850. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35851. */
  35852. directionalConeOuterAngle: number;
  35853. /**
  35854. * Playback volume.
  35855. */
  35856. /**
  35857. * Playback volume.
  35858. */
  35859. volume: number;
  35860. private _onended;
  35861. /**
  35862. * Suspend playback
  35863. */
  35864. pause(): void;
  35865. /**
  35866. * Stop playback
  35867. */
  35868. stop(): void;
  35869. /**
  35870. * Start playback.
  35871. * @param startOffset Position the clip head at a specific time in seconds.
  35872. */
  35873. play(startOffset?: number): void;
  35874. }
  35875. }
  35876. declare module "babylonjs/Audio/index" {
  35877. export * from "babylonjs/Audio/analyser";
  35878. export * from "babylonjs/Audio/audioEngine";
  35879. export * from "babylonjs/Audio/audioSceneComponent";
  35880. export * from "babylonjs/Audio/sound";
  35881. export * from "babylonjs/Audio/soundTrack";
  35882. export * from "babylonjs/Audio/weightedsound";
  35883. }
  35884. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  35885. import { Behavior } from "babylonjs/Behaviors/behavior";
  35886. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35887. import { BackEase } from "babylonjs/Animations/easing";
  35888. /**
  35889. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  35890. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35891. */
  35892. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35893. /**
  35894. * Gets the name of the behavior.
  35895. */
  35896. readonly name: string;
  35897. /**
  35898. * The easing function used by animations
  35899. */
  35900. static EasingFunction: BackEase;
  35901. /**
  35902. * The easing mode used by animations
  35903. */
  35904. static EasingMode: number;
  35905. /**
  35906. * The duration of the animation, in milliseconds
  35907. */
  35908. transitionDuration: number;
  35909. /**
  35910. * Length of the distance animated by the transition when lower radius is reached
  35911. */
  35912. lowerRadiusTransitionRange: number;
  35913. /**
  35914. * Length of the distance animated by the transition when upper radius is reached
  35915. */
  35916. upperRadiusTransitionRange: number;
  35917. private _autoTransitionRange;
  35918. /**
  35919. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35920. */
  35921. /**
  35922. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35923. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35924. */
  35925. autoTransitionRange: boolean;
  35926. private _attachedCamera;
  35927. private _onAfterCheckInputsObserver;
  35928. private _onMeshTargetChangedObserver;
  35929. /**
  35930. * Initializes the behavior.
  35931. */
  35932. init(): void;
  35933. /**
  35934. * Attaches the behavior to its arc rotate camera.
  35935. * @param camera Defines the camera to attach the behavior to
  35936. */
  35937. attach(camera: ArcRotateCamera): void;
  35938. /**
  35939. * Detaches the behavior from its current arc rotate camera.
  35940. */
  35941. detach(): void;
  35942. private _radiusIsAnimating;
  35943. private _radiusBounceTransition;
  35944. private _animatables;
  35945. private _cachedWheelPrecision;
  35946. /**
  35947. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35948. * @param radiusLimit The limit to check against.
  35949. * @return Bool to indicate if at limit.
  35950. */
  35951. private _isRadiusAtLimit;
  35952. /**
  35953. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35954. * @param radiusDelta The delta by which to animate to. Can be negative.
  35955. */
  35956. private _applyBoundRadiusAnimation;
  35957. /**
  35958. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35959. */
  35960. protected _clearAnimationLocks(): void;
  35961. /**
  35962. * Stops and removes all animations that have been applied to the camera
  35963. */
  35964. stopAllAnimations(): void;
  35965. }
  35966. }
  35967. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  35968. import { Behavior } from "babylonjs/Behaviors/behavior";
  35969. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35970. import { ExponentialEase } from "babylonjs/Animations/easing";
  35971. import { Nullable } from "babylonjs/types";
  35972. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35973. import { Vector3 } from "babylonjs/Maths/math";
  35974. /**
  35975. * 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.
  35976. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35977. */
  35978. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  35979. /**
  35980. * Gets the name of the behavior.
  35981. */
  35982. readonly name: string;
  35983. private _mode;
  35984. private _radiusScale;
  35985. private _positionScale;
  35986. private _defaultElevation;
  35987. private _elevationReturnTime;
  35988. private _elevationReturnWaitTime;
  35989. private _zoomStopsAnimation;
  35990. private _framingTime;
  35991. /**
  35992. * The easing function used by animations
  35993. */
  35994. static EasingFunction: ExponentialEase;
  35995. /**
  35996. * The easing mode used by animations
  35997. */
  35998. static EasingMode: number;
  35999. /**
  36000. * Sets the current mode used by the behavior
  36001. */
  36002. /**
  36003. * Gets current mode used by the behavior.
  36004. */
  36005. mode: number;
  36006. /**
  36007. * Sets the scale applied to the radius (1 by default)
  36008. */
  36009. /**
  36010. * Gets the scale applied to the radius
  36011. */
  36012. radiusScale: number;
  36013. /**
  36014. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36015. */
  36016. /**
  36017. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36018. */
  36019. positionScale: number;
  36020. /**
  36021. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36022. * behaviour is triggered, in radians.
  36023. */
  36024. /**
  36025. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36026. * behaviour is triggered, in radians.
  36027. */
  36028. defaultElevation: number;
  36029. /**
  36030. * Sets the time (in milliseconds) taken to return to the default beta position.
  36031. * Negative value indicates camera should not return to default.
  36032. */
  36033. /**
  36034. * Gets the time (in milliseconds) taken to return to the default beta position.
  36035. * Negative value indicates camera should not return to default.
  36036. */
  36037. elevationReturnTime: number;
  36038. /**
  36039. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36040. */
  36041. /**
  36042. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36043. */
  36044. elevationReturnWaitTime: number;
  36045. /**
  36046. * Sets the flag that indicates if user zooming should stop animation.
  36047. */
  36048. /**
  36049. * Gets the flag that indicates if user zooming should stop animation.
  36050. */
  36051. zoomStopsAnimation: boolean;
  36052. /**
  36053. * Sets the transition time when framing the mesh, in milliseconds
  36054. */
  36055. /**
  36056. * Gets the transition time when framing the mesh, in milliseconds
  36057. */
  36058. framingTime: number;
  36059. /**
  36060. * Define if the behavior should automatically change the configured
  36061. * camera limits and sensibilities.
  36062. */
  36063. autoCorrectCameraLimitsAndSensibility: boolean;
  36064. private _onPrePointerObservableObserver;
  36065. private _onAfterCheckInputsObserver;
  36066. private _onMeshTargetChangedObserver;
  36067. private _attachedCamera;
  36068. private _isPointerDown;
  36069. private _lastInteractionTime;
  36070. /**
  36071. * Initializes the behavior.
  36072. */
  36073. init(): void;
  36074. /**
  36075. * Attaches the behavior to its arc rotate camera.
  36076. * @param camera Defines the camera to attach the behavior to
  36077. */
  36078. attach(camera: ArcRotateCamera): void;
  36079. /**
  36080. * Detaches the behavior from its current arc rotate camera.
  36081. */
  36082. detach(): void;
  36083. private _animatables;
  36084. private _betaIsAnimating;
  36085. private _betaTransition;
  36086. private _radiusTransition;
  36087. private _vectorTransition;
  36088. /**
  36089. * Targets the given mesh and updates zoom level accordingly.
  36090. * @param mesh The mesh to target.
  36091. * @param radius Optional. If a cached radius position already exists, overrides default.
  36092. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36093. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36094. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36095. */
  36096. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36097. /**
  36098. * Targets the given mesh with its children and updates zoom level accordingly.
  36099. * @param mesh The mesh to target.
  36100. * @param radius Optional. If a cached radius position already exists, overrides default.
  36101. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36102. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36103. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36104. */
  36105. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36106. /**
  36107. * Targets the given meshes with their children and updates zoom level accordingly.
  36108. * @param meshes The mesh to target.
  36109. * @param radius Optional. If a cached radius position already exists, overrides default.
  36110. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36111. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36112. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36113. */
  36114. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36115. /**
  36116. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  36117. * @param minimumWorld Determines the smaller position of the bounding box extend
  36118. * @param maximumWorld Determines the bigger position of the bounding box extend
  36119. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36120. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36121. */
  36122. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36123. /**
  36124. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  36125. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  36126. * frustum width.
  36127. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  36128. * to fully enclose the mesh in the viewing frustum.
  36129. */
  36130. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  36131. /**
  36132. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  36133. * is automatically returned to its default position (expected to be above ground plane).
  36134. */
  36135. private _maintainCameraAboveGround;
  36136. /**
  36137. * Returns the frustum slope based on the canvas ratio and camera FOV
  36138. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  36139. */
  36140. private _getFrustumSlope;
  36141. /**
  36142. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  36143. */
  36144. private _clearAnimationLocks;
  36145. /**
  36146. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36147. */
  36148. private _applyUserInteraction;
  36149. /**
  36150. * Stops and removes all animations that have been applied to the camera
  36151. */
  36152. stopAllAnimations(): void;
  36153. /**
  36154. * Gets a value indicating if the user is moving the camera
  36155. */
  36156. readonly isUserIsMoving: boolean;
  36157. /**
  36158. * The camera can move all the way towards the mesh.
  36159. */
  36160. static IgnoreBoundsSizeMode: number;
  36161. /**
  36162. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  36163. */
  36164. static FitFrustumSidesMode: number;
  36165. }
  36166. }
  36167. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  36168. import { Nullable } from "babylonjs/types";
  36169. import { Camera } from "babylonjs/Cameras/camera";
  36170. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36171. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36172. /**
  36173. * Base class for Camera Pointer Inputs.
  36174. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  36175. * for example usage.
  36176. */
  36177. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  36178. /**
  36179. * Defines the camera the input is attached to.
  36180. */
  36181. abstract camera: Camera;
  36182. /**
  36183. * Whether keyboard modifier keys are pressed at time of last mouse event.
  36184. */
  36185. protected _altKey: boolean;
  36186. protected _ctrlKey: boolean;
  36187. protected _metaKey: boolean;
  36188. protected _shiftKey: boolean;
  36189. /**
  36190. * Which mouse buttons were pressed at time of last mouse event.
  36191. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  36192. */
  36193. protected _buttonsPressed: number;
  36194. /**
  36195. * Defines the buttons associated with the input to handle camera move.
  36196. */
  36197. buttons: number[];
  36198. /**
  36199. * Attach the input controls to a specific dom element to get the input from.
  36200. * @param element Defines the element the controls should be listened from
  36201. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36202. */
  36203. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36204. /**
  36205. * Detach the current controls from the specified dom element.
  36206. * @param element Defines the element to stop listening the inputs from
  36207. */
  36208. detachControl(element: Nullable<HTMLElement>): void;
  36209. /**
  36210. * Gets the class name of the current input.
  36211. * @returns the class name
  36212. */
  36213. getClassName(): string;
  36214. /**
  36215. * Get the friendly name associated with the input class.
  36216. * @returns the input friendly name
  36217. */
  36218. getSimpleName(): string;
  36219. /**
  36220. * Called on pointer POINTERDOUBLETAP event.
  36221. * Override this method to provide functionality on POINTERDOUBLETAP event.
  36222. */
  36223. protected onDoubleTap(type: string): void;
  36224. /**
  36225. * Called on pointer POINTERMOVE event if only a single touch is active.
  36226. * Override this method to provide functionality.
  36227. */
  36228. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36229. /**
  36230. * Called on pointer POINTERMOVE event if multiple touches are active.
  36231. * Override this method to provide functionality.
  36232. */
  36233. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36234. /**
  36235. * Called on JS contextmenu event.
  36236. * Override this method to provide functionality.
  36237. */
  36238. protected onContextMenu(evt: PointerEvent): void;
  36239. /**
  36240. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36241. * press.
  36242. * Override this method to provide functionality.
  36243. */
  36244. protected onButtonDown(evt: PointerEvent): void;
  36245. /**
  36246. * Called each time a new POINTERUP event occurs. Ie, for each button
  36247. * release.
  36248. * Override this method to provide functionality.
  36249. */
  36250. protected onButtonUp(evt: PointerEvent): void;
  36251. /**
  36252. * Called when window becomes inactive.
  36253. * Override this method to provide functionality.
  36254. */
  36255. protected onLostFocus(): void;
  36256. private _pointerInput;
  36257. private _observer;
  36258. private _onLostFocus;
  36259. private pointA;
  36260. private pointB;
  36261. }
  36262. }
  36263. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  36264. import { Nullable } from "babylonjs/types";
  36265. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36266. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  36267. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36268. /**
  36269. * Manage the pointers inputs to control an arc rotate camera.
  36270. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36271. */
  36272. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  36273. /**
  36274. * Defines the camera the input is attached to.
  36275. */
  36276. camera: ArcRotateCamera;
  36277. /**
  36278. * Gets the class name of the current input.
  36279. * @returns the class name
  36280. */
  36281. getClassName(): string;
  36282. /**
  36283. * Defines the buttons associated with the input to handle camera move.
  36284. */
  36285. buttons: number[];
  36286. /**
  36287. * Defines the pointer angular sensibility along the X axis or how fast is
  36288. * the camera rotating.
  36289. */
  36290. angularSensibilityX: number;
  36291. /**
  36292. * Defines the pointer angular sensibility along the Y axis or how fast is
  36293. * the camera rotating.
  36294. */
  36295. angularSensibilityY: number;
  36296. /**
  36297. * Defines the pointer pinch precision or how fast is the camera zooming.
  36298. */
  36299. pinchPrecision: number;
  36300. /**
  36301. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36302. * from 0.
  36303. * It defines the percentage of current camera.radius to use as delta when
  36304. * pinch zoom is used.
  36305. */
  36306. pinchDeltaPercentage: number;
  36307. /**
  36308. * Defines the pointer panning sensibility or how fast is the camera moving.
  36309. */
  36310. panningSensibility: number;
  36311. /**
  36312. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  36313. */
  36314. multiTouchPanning: boolean;
  36315. /**
  36316. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  36317. * zoom (pinch) through multitouch.
  36318. */
  36319. multiTouchPanAndZoom: boolean;
  36320. /**
  36321. * Revers pinch action direction.
  36322. */
  36323. pinchInwards: boolean;
  36324. private _isPanClick;
  36325. private _twoFingerActivityCount;
  36326. private _isPinching;
  36327. /**
  36328. * Called on pointer POINTERMOVE event if only a single touch is active.
  36329. */
  36330. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36331. /**
  36332. * Called on pointer POINTERDOUBLETAP event.
  36333. */
  36334. protected onDoubleTap(type: string): void;
  36335. /**
  36336. * Called on pointer POINTERMOVE event if multiple touches are active.
  36337. */
  36338. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36339. /**
  36340. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36341. * press.
  36342. */
  36343. protected onButtonDown(evt: PointerEvent): void;
  36344. /**
  36345. * Called each time a new POINTERUP event occurs. Ie, for each button
  36346. * release.
  36347. */
  36348. protected onButtonUp(evt: PointerEvent): void;
  36349. /**
  36350. * Called when window becomes inactive.
  36351. */
  36352. protected onLostFocus(): void;
  36353. }
  36354. }
  36355. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  36356. import { Nullable } from "babylonjs/types";
  36357. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36358. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36359. /**
  36360. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  36361. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36362. */
  36363. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  36364. /**
  36365. * Defines the camera the input is attached to.
  36366. */
  36367. camera: ArcRotateCamera;
  36368. /**
  36369. * Defines the list of key codes associated with the up action (increase alpha)
  36370. */
  36371. keysUp: number[];
  36372. /**
  36373. * Defines the list of key codes associated with the down action (decrease alpha)
  36374. */
  36375. keysDown: number[];
  36376. /**
  36377. * Defines the list of key codes associated with the left action (increase beta)
  36378. */
  36379. keysLeft: number[];
  36380. /**
  36381. * Defines the list of key codes associated with the right action (decrease beta)
  36382. */
  36383. keysRight: number[];
  36384. /**
  36385. * Defines the list of key codes associated with the reset action.
  36386. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  36387. */
  36388. keysReset: number[];
  36389. /**
  36390. * Defines the panning sensibility of the inputs.
  36391. * (How fast is the camera paning)
  36392. */
  36393. panningSensibility: number;
  36394. /**
  36395. * Defines the zooming sensibility of the inputs.
  36396. * (How fast is the camera zooming)
  36397. */
  36398. zoomingSensibility: number;
  36399. /**
  36400. * Defines wether maintaining the alt key down switch the movement mode from
  36401. * orientation to zoom.
  36402. */
  36403. useAltToZoom: boolean;
  36404. /**
  36405. * Rotation speed of the camera
  36406. */
  36407. angularSpeed: number;
  36408. private _keys;
  36409. private _ctrlPressed;
  36410. private _altPressed;
  36411. private _onCanvasBlurObserver;
  36412. private _onKeyboardObserver;
  36413. private _engine;
  36414. private _scene;
  36415. /**
  36416. * Attach the input controls to a specific dom element to get the input from.
  36417. * @param element Defines the element the controls should be listened from
  36418. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36419. */
  36420. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36421. /**
  36422. * Detach the current controls from the specified dom element.
  36423. * @param element Defines the element to stop listening the inputs from
  36424. */
  36425. detachControl(element: Nullable<HTMLElement>): void;
  36426. /**
  36427. * Update the current camera state depending on the inputs that have been used this frame.
  36428. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36429. */
  36430. checkInputs(): void;
  36431. /**
  36432. * Gets the class name of the current intput.
  36433. * @returns the class name
  36434. */
  36435. getClassName(): string;
  36436. /**
  36437. * Get the friendly name associated with the input class.
  36438. * @returns the input friendly name
  36439. */
  36440. getSimpleName(): string;
  36441. }
  36442. }
  36443. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  36444. import { Nullable } from "babylonjs/types";
  36445. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36446. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36447. /**
  36448. * Manage the mouse wheel inputs to control an arc rotate camera.
  36449. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36450. */
  36451. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  36452. /**
  36453. * Defines the camera the input is attached to.
  36454. */
  36455. camera: ArcRotateCamera;
  36456. /**
  36457. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36458. */
  36459. wheelPrecision: number;
  36460. /**
  36461. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36462. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36463. */
  36464. wheelDeltaPercentage: number;
  36465. private _wheel;
  36466. private _observer;
  36467. private computeDeltaFromMouseWheelLegacyEvent;
  36468. /**
  36469. * Attach the input controls to a specific dom element to get the input from.
  36470. * @param element Defines the element the controls should be listened from
  36471. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36472. */
  36473. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36474. /**
  36475. * Detach the current controls from the specified dom element.
  36476. * @param element Defines the element to stop listening the inputs from
  36477. */
  36478. detachControl(element: Nullable<HTMLElement>): void;
  36479. /**
  36480. * Gets the class name of the current intput.
  36481. * @returns the class name
  36482. */
  36483. getClassName(): string;
  36484. /**
  36485. * Get the friendly name associated with the input class.
  36486. * @returns the input friendly name
  36487. */
  36488. getSimpleName(): string;
  36489. }
  36490. }
  36491. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  36492. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36493. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36494. /**
  36495. * Default Inputs manager for the ArcRotateCamera.
  36496. * It groups all the default supported inputs for ease of use.
  36497. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36498. */
  36499. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  36500. /**
  36501. * Instantiates a new ArcRotateCameraInputsManager.
  36502. * @param camera Defines the camera the inputs belong to
  36503. */
  36504. constructor(camera: ArcRotateCamera);
  36505. /**
  36506. * Add mouse wheel input support to the input manager.
  36507. * @returns the current input manager
  36508. */
  36509. addMouseWheel(): ArcRotateCameraInputsManager;
  36510. /**
  36511. * Add pointers input support to the input manager.
  36512. * @returns the current input manager
  36513. */
  36514. addPointers(): ArcRotateCameraInputsManager;
  36515. /**
  36516. * Add keyboard input support to the input manager.
  36517. * @returns the current input manager
  36518. */
  36519. addKeyboard(): ArcRotateCameraInputsManager;
  36520. }
  36521. }
  36522. declare module "babylonjs/Cameras/arcRotateCamera" {
  36523. import { Observable } from "babylonjs/Misc/observable";
  36524. import { Nullable } from "babylonjs/types";
  36525. import { Scene } from "babylonjs/scene";
  36526. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  36527. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36528. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36529. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36530. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  36531. import { Camera } from "babylonjs/Cameras/camera";
  36532. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36533. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  36534. import { Collider } from "babylonjs/Collisions/collider";
  36535. /**
  36536. * This represents an orbital type of camera.
  36537. *
  36538. * 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.
  36539. * 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.
  36540. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  36541. */
  36542. export class ArcRotateCamera extends TargetCamera {
  36543. /**
  36544. * Defines the rotation angle of the camera along the longitudinal axis.
  36545. */
  36546. alpha: number;
  36547. /**
  36548. * Defines the rotation angle of the camera along the latitudinal axis.
  36549. */
  36550. beta: number;
  36551. /**
  36552. * Defines the radius of the camera from it s target point.
  36553. */
  36554. radius: number;
  36555. protected _target: Vector3;
  36556. protected _targetHost: Nullable<AbstractMesh>;
  36557. /**
  36558. * Defines the target point of the camera.
  36559. * The camera looks towards it form the radius distance.
  36560. */
  36561. target: Vector3;
  36562. /**
  36563. * Define the current local position of the camera in the scene
  36564. */
  36565. position: Vector3;
  36566. protected _upVector: Vector3;
  36567. protected _upToYMatrix: Matrix;
  36568. protected _YToUpMatrix: Matrix;
  36569. /**
  36570. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  36571. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  36572. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  36573. */
  36574. upVector: Vector3;
  36575. /**
  36576. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  36577. */
  36578. setMatUp(): void;
  36579. /**
  36580. * Current inertia value on the longitudinal axis.
  36581. * The bigger this number the longer it will take for the camera to stop.
  36582. */
  36583. inertialAlphaOffset: number;
  36584. /**
  36585. * Current inertia value on the latitudinal axis.
  36586. * The bigger this number the longer it will take for the camera to stop.
  36587. */
  36588. inertialBetaOffset: number;
  36589. /**
  36590. * Current inertia value on the radius axis.
  36591. * The bigger this number the longer it will take for the camera to stop.
  36592. */
  36593. inertialRadiusOffset: number;
  36594. /**
  36595. * Minimum allowed angle on the longitudinal axis.
  36596. * This can help limiting how the Camera is able to move in the scene.
  36597. */
  36598. lowerAlphaLimit: Nullable<number>;
  36599. /**
  36600. * Maximum allowed angle on the longitudinal axis.
  36601. * This can help limiting how the Camera is able to move in the scene.
  36602. */
  36603. upperAlphaLimit: Nullable<number>;
  36604. /**
  36605. * Minimum allowed angle on the latitudinal axis.
  36606. * This can help limiting how the Camera is able to move in the scene.
  36607. */
  36608. lowerBetaLimit: number;
  36609. /**
  36610. * Maximum allowed angle on the latitudinal axis.
  36611. * This can help limiting how the Camera is able to move in the scene.
  36612. */
  36613. upperBetaLimit: number;
  36614. /**
  36615. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  36616. * This can help limiting how the Camera is able to move in the scene.
  36617. */
  36618. lowerRadiusLimit: Nullable<number>;
  36619. /**
  36620. * Maximum allowed distance of the camera to the target (The camera can not get further).
  36621. * This can help limiting how the Camera is able to move in the scene.
  36622. */
  36623. upperRadiusLimit: Nullable<number>;
  36624. /**
  36625. * Defines the current inertia value used during panning of the camera along the X axis.
  36626. */
  36627. inertialPanningX: number;
  36628. /**
  36629. * Defines the current inertia value used during panning of the camera along the Y axis.
  36630. */
  36631. inertialPanningY: number;
  36632. /**
  36633. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  36634. * Basically if your fingers moves away from more than this distance you will be considered
  36635. * in pinch mode.
  36636. */
  36637. pinchToPanMaxDistance: number;
  36638. /**
  36639. * Defines the maximum distance the camera can pan.
  36640. * This could help keeping the cammera always in your scene.
  36641. */
  36642. panningDistanceLimit: Nullable<number>;
  36643. /**
  36644. * Defines the target of the camera before paning.
  36645. */
  36646. panningOriginTarget: Vector3;
  36647. /**
  36648. * Defines the value of the inertia used during panning.
  36649. * 0 would mean stop inertia and one would mean no decelleration at all.
  36650. */
  36651. panningInertia: number;
  36652. /**
  36653. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  36654. */
  36655. angularSensibilityX: number;
  36656. /**
  36657. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  36658. */
  36659. angularSensibilityY: number;
  36660. /**
  36661. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  36662. */
  36663. pinchPrecision: number;
  36664. /**
  36665. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  36666. * It will be used instead of pinchDeltaPrecision if different from 0.
  36667. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36668. */
  36669. pinchDeltaPercentage: number;
  36670. /**
  36671. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  36672. */
  36673. panningSensibility: number;
  36674. /**
  36675. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  36676. */
  36677. keysUp: number[];
  36678. /**
  36679. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  36680. */
  36681. keysDown: number[];
  36682. /**
  36683. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  36684. */
  36685. keysLeft: number[];
  36686. /**
  36687. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  36688. */
  36689. keysRight: number[];
  36690. /**
  36691. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36692. */
  36693. wheelPrecision: number;
  36694. /**
  36695. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  36696. * It will be used instead of pinchDeltaPrecision if different from 0.
  36697. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36698. */
  36699. wheelDeltaPercentage: number;
  36700. /**
  36701. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  36702. */
  36703. zoomOnFactor: number;
  36704. /**
  36705. * Defines a screen offset for the camera position.
  36706. */
  36707. targetScreenOffset: Vector2;
  36708. /**
  36709. * Allows the camera to be completely reversed.
  36710. * If false the camera can not arrive upside down.
  36711. */
  36712. allowUpsideDown: boolean;
  36713. /**
  36714. * Define if double tap/click is used to restore the previously saved state of the camera.
  36715. */
  36716. useInputToRestoreState: boolean;
  36717. /** @hidden */
  36718. _viewMatrix: Matrix;
  36719. /** @hidden */
  36720. _useCtrlForPanning: boolean;
  36721. /** @hidden */
  36722. _panningMouseButton: number;
  36723. /**
  36724. * Defines the input associated to the camera.
  36725. */
  36726. inputs: ArcRotateCameraInputsManager;
  36727. /** @hidden */
  36728. _reset: () => void;
  36729. /**
  36730. * Defines the allowed panning axis.
  36731. */
  36732. panningAxis: Vector3;
  36733. protected _localDirection: Vector3;
  36734. protected _transformedDirection: Vector3;
  36735. private _bouncingBehavior;
  36736. /**
  36737. * Gets the bouncing behavior of the camera if it has been enabled.
  36738. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36739. */
  36740. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  36741. /**
  36742. * Defines if the bouncing behavior of the camera is enabled on the camera.
  36743. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36744. */
  36745. useBouncingBehavior: boolean;
  36746. private _framingBehavior;
  36747. /**
  36748. * Gets the framing behavior of the camera if it has been enabled.
  36749. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36750. */
  36751. readonly framingBehavior: Nullable<FramingBehavior>;
  36752. /**
  36753. * Defines if the framing behavior of the camera is enabled on the camera.
  36754. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36755. */
  36756. useFramingBehavior: boolean;
  36757. private _autoRotationBehavior;
  36758. /**
  36759. * Gets the auto rotation behavior of the camera if it has been enabled.
  36760. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36761. */
  36762. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  36763. /**
  36764. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  36765. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36766. */
  36767. useAutoRotationBehavior: boolean;
  36768. /**
  36769. * Observable triggered when the mesh target has been changed on the camera.
  36770. */
  36771. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  36772. /**
  36773. * Event raised when the camera is colliding with a mesh.
  36774. */
  36775. onCollide: (collidedMesh: AbstractMesh) => void;
  36776. /**
  36777. * Defines whether the camera should check collision with the objects oh the scene.
  36778. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  36779. */
  36780. checkCollisions: boolean;
  36781. /**
  36782. * Defines the collision radius of the camera.
  36783. * This simulates a sphere around the camera.
  36784. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36785. */
  36786. collisionRadius: Vector3;
  36787. protected _collider: Collider;
  36788. protected _previousPosition: Vector3;
  36789. protected _collisionVelocity: Vector3;
  36790. protected _newPosition: Vector3;
  36791. protected _previousAlpha: number;
  36792. protected _previousBeta: number;
  36793. protected _previousRadius: number;
  36794. protected _collisionTriggered: boolean;
  36795. protected _targetBoundingCenter: Nullable<Vector3>;
  36796. private _computationVector;
  36797. /**
  36798. * Instantiates a new ArcRotateCamera in a given scene
  36799. * @param name Defines the name of the camera
  36800. * @param alpha Defines the camera rotation along the logitudinal axis
  36801. * @param beta Defines the camera rotation along the latitudinal axis
  36802. * @param radius Defines the camera distance from its target
  36803. * @param target Defines the camera target
  36804. * @param scene Defines the scene the camera belongs to
  36805. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  36806. */
  36807. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36808. /** @hidden */
  36809. _initCache(): void;
  36810. /** @hidden */
  36811. _updateCache(ignoreParentClass?: boolean): void;
  36812. protected _getTargetPosition(): Vector3;
  36813. private _storedAlpha;
  36814. private _storedBeta;
  36815. private _storedRadius;
  36816. private _storedTarget;
  36817. /**
  36818. * Stores the current state of the camera (alpha, beta, radius and target)
  36819. * @returns the camera itself
  36820. */
  36821. storeState(): Camera;
  36822. /**
  36823. * @hidden
  36824. * Restored camera state. You must call storeState() first
  36825. */
  36826. _restoreStateValues(): boolean;
  36827. /** @hidden */
  36828. _isSynchronizedViewMatrix(): boolean;
  36829. /**
  36830. * Attached controls to the current camera.
  36831. * @param element Defines the element the controls should be listened from
  36832. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36833. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  36834. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  36835. */
  36836. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  36837. /**
  36838. * Detach the current controls from the camera.
  36839. * The camera will stop reacting to inputs.
  36840. * @param element Defines the element to stop listening the inputs from
  36841. */
  36842. detachControl(element: HTMLElement): void;
  36843. /** @hidden */
  36844. _checkInputs(): void;
  36845. protected _checkLimits(): void;
  36846. /**
  36847. * Rebuilds angles (alpha, beta) and radius from the give position and target
  36848. */
  36849. rebuildAnglesAndRadius(): void;
  36850. /**
  36851. * Use a position to define the current camera related information like aplha, beta and radius
  36852. * @param position Defines the position to set the camera at
  36853. */
  36854. setPosition(position: Vector3): void;
  36855. /**
  36856. * Defines the target the camera should look at.
  36857. * This will automatically adapt alpha beta and radius to fit within the new target.
  36858. * @param target Defines the new target as a Vector or a mesh
  36859. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  36860. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  36861. */
  36862. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  36863. /** @hidden */
  36864. _getViewMatrix(): Matrix;
  36865. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  36866. /**
  36867. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  36868. * @param meshes Defines the mesh to zoom on
  36869. * @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)
  36870. */
  36871. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  36872. /**
  36873. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  36874. * The target will be changed but the radius
  36875. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  36876. * @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)
  36877. */
  36878. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  36879. min: Vector3;
  36880. max: Vector3;
  36881. distance: number;
  36882. }, doNotUpdateMaxZ?: boolean): void;
  36883. /**
  36884. * @override
  36885. * Override Camera.createRigCamera
  36886. */
  36887. createRigCamera(name: string, cameraIndex: number): Camera;
  36888. /**
  36889. * @hidden
  36890. * @override
  36891. * Override Camera._updateRigCameras
  36892. */
  36893. _updateRigCameras(): void;
  36894. /**
  36895. * Destroy the camera and release the current resources hold by it.
  36896. */
  36897. dispose(): void;
  36898. /**
  36899. * Gets the current object class name.
  36900. * @return the class name
  36901. */
  36902. getClassName(): string;
  36903. }
  36904. }
  36905. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  36906. import { Behavior } from "babylonjs/Behaviors/behavior";
  36907. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36908. /**
  36909. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  36910. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36911. */
  36912. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  36913. /**
  36914. * Gets the name of the behavior.
  36915. */
  36916. readonly name: string;
  36917. private _zoomStopsAnimation;
  36918. private _idleRotationSpeed;
  36919. private _idleRotationWaitTime;
  36920. private _idleRotationSpinupTime;
  36921. /**
  36922. * Sets the flag that indicates if user zooming should stop animation.
  36923. */
  36924. /**
  36925. * Gets the flag that indicates if user zooming should stop animation.
  36926. */
  36927. zoomStopsAnimation: boolean;
  36928. /**
  36929. * Sets the default speed at which the camera rotates around the model.
  36930. */
  36931. /**
  36932. * Gets the default speed at which the camera rotates around the model.
  36933. */
  36934. idleRotationSpeed: number;
  36935. /**
  36936. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36937. */
  36938. /**
  36939. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36940. */
  36941. idleRotationWaitTime: number;
  36942. /**
  36943. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36944. */
  36945. /**
  36946. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36947. */
  36948. idleRotationSpinupTime: number;
  36949. /**
  36950. * Gets a value indicating if the camera is currently rotating because of this behavior
  36951. */
  36952. readonly rotationInProgress: boolean;
  36953. private _onPrePointerObservableObserver;
  36954. private _onAfterCheckInputsObserver;
  36955. private _attachedCamera;
  36956. private _isPointerDown;
  36957. private _lastFrameTime;
  36958. private _lastInteractionTime;
  36959. private _cameraRotationSpeed;
  36960. /**
  36961. * Initializes the behavior.
  36962. */
  36963. init(): void;
  36964. /**
  36965. * Attaches the behavior to its arc rotate camera.
  36966. * @param camera Defines the camera to attach the behavior to
  36967. */
  36968. attach(camera: ArcRotateCamera): void;
  36969. /**
  36970. * Detaches the behavior from its current arc rotate camera.
  36971. */
  36972. detach(): void;
  36973. /**
  36974. * Returns true if user is scrolling.
  36975. * @return true if user is scrolling.
  36976. */
  36977. private _userIsZooming;
  36978. private _lastFrameRadius;
  36979. private _shouldAnimationStopForInteraction;
  36980. /**
  36981. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36982. */
  36983. private _applyUserInteraction;
  36984. private _userIsMoving;
  36985. }
  36986. }
  36987. declare module "babylonjs/Behaviors/Cameras/index" {
  36988. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36989. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36990. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  36991. }
  36992. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  36993. import { Mesh } from "babylonjs/Meshes/mesh";
  36994. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36995. import { Behavior } from "babylonjs/Behaviors/behavior";
  36996. /**
  36997. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36998. */
  36999. export class AttachToBoxBehavior implements Behavior<Mesh> {
  37000. private ui;
  37001. /**
  37002. * The name of the behavior
  37003. */
  37004. name: string;
  37005. /**
  37006. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  37007. */
  37008. distanceAwayFromFace: number;
  37009. /**
  37010. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  37011. */
  37012. distanceAwayFromBottomOfFace: number;
  37013. private _faceVectors;
  37014. private _target;
  37015. private _scene;
  37016. private _onRenderObserver;
  37017. private _tmpMatrix;
  37018. private _tmpVector;
  37019. /**
  37020. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  37021. * @param ui The transform node that should be attched to the mesh
  37022. */
  37023. constructor(ui: TransformNode);
  37024. /**
  37025. * Initializes the behavior
  37026. */
  37027. init(): void;
  37028. private _closestFace;
  37029. private _zeroVector;
  37030. private _lookAtTmpMatrix;
  37031. private _lookAtToRef;
  37032. /**
  37033. * Attaches the AttachToBoxBehavior to the passed in mesh
  37034. * @param target The mesh that the specified node will be attached to
  37035. */
  37036. attach(target: Mesh): void;
  37037. /**
  37038. * Detaches the behavior from the mesh
  37039. */
  37040. detach(): void;
  37041. }
  37042. }
  37043. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  37044. import { Behavior } from "babylonjs/Behaviors/behavior";
  37045. import { Mesh } from "babylonjs/Meshes/mesh";
  37046. /**
  37047. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  37048. */
  37049. export class FadeInOutBehavior implements Behavior<Mesh> {
  37050. /**
  37051. * Time in milliseconds to delay before fading in (Default: 0)
  37052. */
  37053. delay: number;
  37054. /**
  37055. * Time in milliseconds for the mesh to fade in (Default: 300)
  37056. */
  37057. fadeInTime: number;
  37058. private _millisecondsPerFrame;
  37059. private _hovered;
  37060. private _hoverValue;
  37061. private _ownerNode;
  37062. /**
  37063. * Instatiates the FadeInOutBehavior
  37064. */
  37065. constructor();
  37066. /**
  37067. * The name of the behavior
  37068. */
  37069. readonly name: string;
  37070. /**
  37071. * Initializes the behavior
  37072. */
  37073. init(): void;
  37074. /**
  37075. * Attaches the fade behavior on the passed in mesh
  37076. * @param ownerNode The mesh that will be faded in/out once attached
  37077. */
  37078. attach(ownerNode: Mesh): void;
  37079. /**
  37080. * Detaches the behavior from the mesh
  37081. */
  37082. detach(): void;
  37083. /**
  37084. * Triggers the mesh to begin fading in or out
  37085. * @param value if the object should fade in or out (true to fade in)
  37086. */
  37087. fadeIn(value: boolean): void;
  37088. private _update;
  37089. private _setAllVisibility;
  37090. }
  37091. }
  37092. declare module "babylonjs/Misc/pivotTools" {
  37093. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37094. /**
  37095. * Class containing a set of static utilities functions for managing Pivots
  37096. * @hidden
  37097. */
  37098. export class PivotTools {
  37099. private static _PivotCached;
  37100. private static _OldPivotPoint;
  37101. private static _PivotTranslation;
  37102. private static _PivotTmpVector;
  37103. /** @hidden */
  37104. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  37105. /** @hidden */
  37106. static _RestorePivotPoint(mesh: AbstractMesh): void;
  37107. }
  37108. }
  37109. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  37110. import { Scene } from "babylonjs/scene";
  37111. import { Vector4, Plane } from "babylonjs/Maths/math";
  37112. import { Mesh } from "babylonjs/Meshes/mesh";
  37113. import { Nullable } from "babylonjs/types";
  37114. /**
  37115. * Class containing static functions to help procedurally build meshes
  37116. */
  37117. export class PlaneBuilder {
  37118. /**
  37119. * Creates a plane mesh
  37120. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  37121. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  37122. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  37123. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  37124. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  37125. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  37126. * @param name defines the name of the mesh
  37127. * @param options defines the options used to create the mesh
  37128. * @param scene defines the hosting scene
  37129. * @returns the plane mesh
  37130. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  37131. */
  37132. static CreatePlane(name: string, options: {
  37133. size?: number;
  37134. width?: number;
  37135. height?: number;
  37136. sideOrientation?: number;
  37137. frontUVs?: Vector4;
  37138. backUVs?: Vector4;
  37139. updatable?: boolean;
  37140. sourcePlane?: Plane;
  37141. }, scene?: Nullable<Scene>): Mesh;
  37142. }
  37143. }
  37144. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  37145. import { Behavior } from "babylonjs/Behaviors/behavior";
  37146. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37147. import { Observable } from "babylonjs/Misc/observable";
  37148. import { Vector3 } from "babylonjs/Maths/math";
  37149. import { Ray } from "babylonjs/Culling/ray";
  37150. import "babylonjs/Meshes/Builders/planeBuilder";
  37151. /**
  37152. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  37153. */
  37154. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  37155. private static _AnyMouseID;
  37156. /**
  37157. * Abstract mesh the behavior is set on
  37158. */
  37159. attachedNode: AbstractMesh;
  37160. private _dragPlane;
  37161. private _scene;
  37162. private _pointerObserver;
  37163. private _beforeRenderObserver;
  37164. private static _planeScene;
  37165. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  37166. /**
  37167. * 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)
  37168. */
  37169. maxDragAngle: number;
  37170. /**
  37171. * @hidden
  37172. */
  37173. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  37174. /**
  37175. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37176. */
  37177. currentDraggingPointerID: number;
  37178. /**
  37179. * The last position where the pointer hit the drag plane in world space
  37180. */
  37181. lastDragPosition: Vector3;
  37182. /**
  37183. * If the behavior is currently in a dragging state
  37184. */
  37185. dragging: boolean;
  37186. /**
  37187. * 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)
  37188. */
  37189. dragDeltaRatio: number;
  37190. /**
  37191. * If the drag plane orientation should be updated during the dragging (Default: true)
  37192. */
  37193. updateDragPlane: boolean;
  37194. private _debugMode;
  37195. private _moving;
  37196. /**
  37197. * Fires each time the attached mesh is dragged with the pointer
  37198. * * delta between last drag position and current drag position in world space
  37199. * * dragDistance along the drag axis
  37200. * * dragPlaneNormal normal of the current drag plane used during the drag
  37201. * * dragPlanePoint in world space where the drag intersects the drag plane
  37202. */
  37203. onDragObservable: Observable<{
  37204. delta: Vector3;
  37205. dragPlanePoint: Vector3;
  37206. dragPlaneNormal: Vector3;
  37207. dragDistance: number;
  37208. pointerId: number;
  37209. }>;
  37210. /**
  37211. * Fires each time a drag begins (eg. mouse down on mesh)
  37212. */
  37213. onDragStartObservable: Observable<{
  37214. dragPlanePoint: Vector3;
  37215. pointerId: number;
  37216. }>;
  37217. /**
  37218. * Fires each time a drag ends (eg. mouse release after drag)
  37219. */
  37220. onDragEndObservable: Observable<{
  37221. dragPlanePoint: Vector3;
  37222. pointerId: number;
  37223. }>;
  37224. /**
  37225. * If the attached mesh should be moved when dragged
  37226. */
  37227. moveAttached: boolean;
  37228. /**
  37229. * If the drag behavior will react to drag events (Default: true)
  37230. */
  37231. enabled: boolean;
  37232. /**
  37233. * If camera controls should be detached during the drag
  37234. */
  37235. detachCameraControls: boolean;
  37236. /**
  37237. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  37238. */
  37239. useObjectOrienationForDragging: boolean;
  37240. private _options;
  37241. /**
  37242. * Creates a pointer drag behavior that can be attached to a mesh
  37243. * @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)
  37244. */
  37245. constructor(options?: {
  37246. dragAxis?: Vector3;
  37247. dragPlaneNormal?: Vector3;
  37248. });
  37249. /**
  37250. * Predicate to determine if it is valid to move the object to a new position when it is moved
  37251. */
  37252. validateDrag: (targetPosition: Vector3) => boolean;
  37253. /**
  37254. * The name of the behavior
  37255. */
  37256. readonly name: string;
  37257. /**
  37258. * Initializes the behavior
  37259. */
  37260. init(): void;
  37261. private _tmpVector;
  37262. private _alternatePickedPoint;
  37263. private _worldDragAxis;
  37264. private _targetPosition;
  37265. private _attachedElement;
  37266. /**
  37267. * Attaches the drag behavior the passed in mesh
  37268. * @param ownerNode The mesh that will be dragged around once attached
  37269. */
  37270. attach(ownerNode: AbstractMesh): void;
  37271. /**
  37272. * Force relase the drag action by code.
  37273. */
  37274. releaseDrag(): void;
  37275. private _startDragRay;
  37276. private _lastPointerRay;
  37277. /**
  37278. * Simulates the start of a pointer drag event on the behavior
  37279. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  37280. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  37281. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  37282. */
  37283. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  37284. private _startDrag;
  37285. private _dragDelta;
  37286. private _moveDrag;
  37287. private _pickWithRayOnDragPlane;
  37288. private _pointA;
  37289. private _pointB;
  37290. private _pointC;
  37291. private _lineA;
  37292. private _lineB;
  37293. private _localAxis;
  37294. private _lookAt;
  37295. private _updateDragPlanePosition;
  37296. /**
  37297. * Detaches the behavior from the mesh
  37298. */
  37299. detach(): void;
  37300. }
  37301. }
  37302. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  37303. import { Mesh } from "babylonjs/Meshes/mesh";
  37304. import { Behavior } from "babylonjs/Behaviors/behavior";
  37305. /**
  37306. * A behavior that when attached to a mesh will allow the mesh to be scaled
  37307. */
  37308. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  37309. private _dragBehaviorA;
  37310. private _dragBehaviorB;
  37311. private _startDistance;
  37312. private _initialScale;
  37313. private _targetScale;
  37314. private _ownerNode;
  37315. private _sceneRenderObserver;
  37316. /**
  37317. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  37318. */
  37319. constructor();
  37320. /**
  37321. * The name of the behavior
  37322. */
  37323. readonly name: string;
  37324. /**
  37325. * Initializes the behavior
  37326. */
  37327. init(): void;
  37328. private _getCurrentDistance;
  37329. /**
  37330. * Attaches the scale behavior the passed in mesh
  37331. * @param ownerNode The mesh that will be scaled around once attached
  37332. */
  37333. attach(ownerNode: Mesh): void;
  37334. /**
  37335. * Detaches the behavior from the mesh
  37336. */
  37337. detach(): void;
  37338. }
  37339. }
  37340. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  37341. import { Behavior } from "babylonjs/Behaviors/behavior";
  37342. import { Mesh } from "babylonjs/Meshes/mesh";
  37343. import { Observable } from "babylonjs/Misc/observable";
  37344. /**
  37345. * 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
  37346. */
  37347. export class SixDofDragBehavior implements Behavior<Mesh> {
  37348. private static _virtualScene;
  37349. private _ownerNode;
  37350. private _sceneRenderObserver;
  37351. private _scene;
  37352. private _targetPosition;
  37353. private _virtualOriginMesh;
  37354. private _virtualDragMesh;
  37355. private _pointerObserver;
  37356. private _moving;
  37357. private _startingOrientation;
  37358. /**
  37359. * 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)
  37360. */
  37361. private zDragFactor;
  37362. /**
  37363. * If the object should rotate to face the drag origin
  37364. */
  37365. rotateDraggedObject: boolean;
  37366. /**
  37367. * If the behavior is currently in a dragging state
  37368. */
  37369. dragging: boolean;
  37370. /**
  37371. * 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)
  37372. */
  37373. dragDeltaRatio: number;
  37374. /**
  37375. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37376. */
  37377. currentDraggingPointerID: number;
  37378. /**
  37379. * If camera controls should be detached during the drag
  37380. */
  37381. detachCameraControls: boolean;
  37382. /**
  37383. * Fires each time a drag starts
  37384. */
  37385. onDragStartObservable: Observable<{}>;
  37386. /**
  37387. * Fires each time a drag ends (eg. mouse release after drag)
  37388. */
  37389. onDragEndObservable: Observable<{}>;
  37390. /**
  37391. * 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
  37392. */
  37393. constructor();
  37394. /**
  37395. * The name of the behavior
  37396. */
  37397. readonly name: string;
  37398. /**
  37399. * Initializes the behavior
  37400. */
  37401. init(): void;
  37402. /**
  37403. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  37404. */
  37405. private readonly _pointerCamera;
  37406. /**
  37407. * Attaches the scale behavior the passed in mesh
  37408. * @param ownerNode The mesh that will be scaled around once attached
  37409. */
  37410. attach(ownerNode: Mesh): void;
  37411. /**
  37412. * Detaches the behavior from the mesh
  37413. */
  37414. detach(): void;
  37415. }
  37416. }
  37417. declare module "babylonjs/Behaviors/Meshes/index" {
  37418. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  37419. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  37420. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  37421. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  37422. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  37423. }
  37424. declare module "babylonjs/Behaviors/index" {
  37425. export * from "babylonjs/Behaviors/behavior";
  37426. export * from "babylonjs/Behaviors/Cameras/index";
  37427. export * from "babylonjs/Behaviors/Meshes/index";
  37428. }
  37429. declare module "babylonjs/Bones/boneIKController" {
  37430. import { Bone } from "babylonjs/Bones/bone";
  37431. import { Vector3 } from "babylonjs/Maths/math";
  37432. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37433. import { Nullable } from "babylonjs/types";
  37434. /**
  37435. * Class used to apply inverse kinematics to bones
  37436. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  37437. */
  37438. export class BoneIKController {
  37439. private static _tmpVecs;
  37440. private static _tmpQuat;
  37441. private static _tmpMats;
  37442. /**
  37443. * Gets or sets the target mesh
  37444. */
  37445. targetMesh: AbstractMesh;
  37446. /** Gets or sets the mesh used as pole */
  37447. poleTargetMesh: AbstractMesh;
  37448. /**
  37449. * Gets or sets the bone used as pole
  37450. */
  37451. poleTargetBone: Nullable<Bone>;
  37452. /**
  37453. * Gets or sets the target position
  37454. */
  37455. targetPosition: Vector3;
  37456. /**
  37457. * Gets or sets the pole target position
  37458. */
  37459. poleTargetPosition: Vector3;
  37460. /**
  37461. * Gets or sets the pole target local offset
  37462. */
  37463. poleTargetLocalOffset: Vector3;
  37464. /**
  37465. * Gets or sets the pole angle
  37466. */
  37467. poleAngle: number;
  37468. /**
  37469. * Gets or sets the mesh associated with the controller
  37470. */
  37471. mesh: AbstractMesh;
  37472. /**
  37473. * 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)
  37474. */
  37475. slerpAmount: number;
  37476. private _bone1Quat;
  37477. private _bone1Mat;
  37478. private _bone2Ang;
  37479. private _bone1;
  37480. private _bone2;
  37481. private _bone1Length;
  37482. private _bone2Length;
  37483. private _maxAngle;
  37484. private _maxReach;
  37485. private _rightHandedSystem;
  37486. private _bendAxis;
  37487. private _slerping;
  37488. private _adjustRoll;
  37489. /**
  37490. * Gets or sets maximum allowed angle
  37491. */
  37492. maxAngle: number;
  37493. /**
  37494. * Creates a new BoneIKController
  37495. * @param mesh defines the mesh to control
  37496. * @param bone defines the bone to control
  37497. * @param options defines options to set up the controller
  37498. */
  37499. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  37500. targetMesh?: AbstractMesh;
  37501. poleTargetMesh?: AbstractMesh;
  37502. poleTargetBone?: Bone;
  37503. poleTargetLocalOffset?: Vector3;
  37504. poleAngle?: number;
  37505. bendAxis?: Vector3;
  37506. maxAngle?: number;
  37507. slerpAmount?: number;
  37508. });
  37509. private _setMaxAngle;
  37510. /**
  37511. * Force the controller to update the bones
  37512. */
  37513. update(): void;
  37514. }
  37515. }
  37516. declare module "babylonjs/Bones/boneLookController" {
  37517. import { Vector3, Space } from "babylonjs/Maths/math";
  37518. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37519. import { Bone } from "babylonjs/Bones/bone";
  37520. /**
  37521. * Class used to make a bone look toward a point in space
  37522. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  37523. */
  37524. export class BoneLookController {
  37525. private static _tmpVecs;
  37526. private static _tmpQuat;
  37527. private static _tmpMats;
  37528. /**
  37529. * The target Vector3 that the bone will look at
  37530. */
  37531. target: Vector3;
  37532. /**
  37533. * The mesh that the bone is attached to
  37534. */
  37535. mesh: AbstractMesh;
  37536. /**
  37537. * The bone that will be looking to the target
  37538. */
  37539. bone: Bone;
  37540. /**
  37541. * The up axis of the coordinate system that is used when the bone is rotated
  37542. */
  37543. upAxis: Vector3;
  37544. /**
  37545. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  37546. */
  37547. upAxisSpace: Space;
  37548. /**
  37549. * Used to make an adjustment to the yaw of the bone
  37550. */
  37551. adjustYaw: number;
  37552. /**
  37553. * Used to make an adjustment to the pitch of the bone
  37554. */
  37555. adjustPitch: number;
  37556. /**
  37557. * Used to make an adjustment to the roll of the bone
  37558. */
  37559. adjustRoll: number;
  37560. /**
  37561. * 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)
  37562. */
  37563. slerpAmount: number;
  37564. private _minYaw;
  37565. private _maxYaw;
  37566. private _minPitch;
  37567. private _maxPitch;
  37568. private _minYawSin;
  37569. private _minYawCos;
  37570. private _maxYawSin;
  37571. private _maxYawCos;
  37572. private _midYawConstraint;
  37573. private _minPitchTan;
  37574. private _maxPitchTan;
  37575. private _boneQuat;
  37576. private _slerping;
  37577. private _transformYawPitch;
  37578. private _transformYawPitchInv;
  37579. private _firstFrameSkipped;
  37580. private _yawRange;
  37581. private _fowardAxis;
  37582. /**
  37583. * Gets or sets the minimum yaw angle that the bone can look to
  37584. */
  37585. minYaw: number;
  37586. /**
  37587. * Gets or sets the maximum yaw angle that the bone can look to
  37588. */
  37589. maxYaw: number;
  37590. /**
  37591. * Gets or sets the minimum pitch angle that the bone can look to
  37592. */
  37593. minPitch: number;
  37594. /**
  37595. * Gets or sets the maximum pitch angle that the bone can look to
  37596. */
  37597. maxPitch: number;
  37598. /**
  37599. * Create a BoneLookController
  37600. * @param mesh the mesh that the bone belongs to
  37601. * @param bone the bone that will be looking to the target
  37602. * @param target the target Vector3 to look at
  37603. * @param options optional settings:
  37604. * * maxYaw: the maximum angle the bone will yaw to
  37605. * * minYaw: the minimum angle the bone will yaw to
  37606. * * maxPitch: the maximum angle the bone will pitch to
  37607. * * minPitch: the minimum angle the bone will yaw to
  37608. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  37609. * * upAxis: the up axis of the coordinate system
  37610. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  37611. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  37612. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  37613. * * adjustYaw: used to make an adjustment to the yaw of the bone
  37614. * * adjustPitch: used to make an adjustment to the pitch of the bone
  37615. * * adjustRoll: used to make an adjustment to the roll of the bone
  37616. **/
  37617. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  37618. maxYaw?: number;
  37619. minYaw?: number;
  37620. maxPitch?: number;
  37621. minPitch?: number;
  37622. slerpAmount?: number;
  37623. upAxis?: Vector3;
  37624. upAxisSpace?: Space;
  37625. yawAxis?: Vector3;
  37626. pitchAxis?: Vector3;
  37627. adjustYaw?: number;
  37628. adjustPitch?: number;
  37629. adjustRoll?: number;
  37630. });
  37631. /**
  37632. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  37633. */
  37634. update(): void;
  37635. private _getAngleDiff;
  37636. private _getAngleBetween;
  37637. private _isAngleBetween;
  37638. }
  37639. }
  37640. declare module "babylonjs/Bones/index" {
  37641. export * from "babylonjs/Bones/bone";
  37642. export * from "babylonjs/Bones/boneIKController";
  37643. export * from "babylonjs/Bones/boneLookController";
  37644. export * from "babylonjs/Bones/skeleton";
  37645. }
  37646. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  37647. import { Nullable } from "babylonjs/types";
  37648. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37649. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37650. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  37651. /**
  37652. * Manage the gamepad inputs to control an arc rotate camera.
  37653. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37654. */
  37655. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  37656. /**
  37657. * Defines the camera the input is attached to.
  37658. */
  37659. camera: ArcRotateCamera;
  37660. /**
  37661. * Defines the gamepad the input is gathering event from.
  37662. */
  37663. gamepad: Nullable<Gamepad>;
  37664. /**
  37665. * Defines the gamepad rotation sensiblity.
  37666. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37667. */
  37668. gamepadRotationSensibility: number;
  37669. /**
  37670. * Defines the gamepad move sensiblity.
  37671. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37672. */
  37673. gamepadMoveSensibility: number;
  37674. private _onGamepadConnectedObserver;
  37675. private _onGamepadDisconnectedObserver;
  37676. /**
  37677. * Attach the input controls to a specific dom element to get the input from.
  37678. * @param element Defines the element the controls should be listened from
  37679. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37680. */
  37681. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37682. /**
  37683. * Detach the current controls from the specified dom element.
  37684. * @param element Defines the element to stop listening the inputs from
  37685. */
  37686. detachControl(element: Nullable<HTMLElement>): void;
  37687. /**
  37688. * Update the current camera state depending on the inputs that have been used this frame.
  37689. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37690. */
  37691. checkInputs(): void;
  37692. /**
  37693. * Gets the class name of the current intput.
  37694. * @returns the class name
  37695. */
  37696. getClassName(): string;
  37697. /**
  37698. * Get the friendly name associated with the input class.
  37699. * @returns the input friendly name
  37700. */
  37701. getSimpleName(): string;
  37702. }
  37703. }
  37704. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  37705. import { Nullable } from "babylonjs/types";
  37706. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37707. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37708. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37709. interface ArcRotateCameraInputsManager {
  37710. /**
  37711. * Add orientation input support to the input manager.
  37712. * @returns the current input manager
  37713. */
  37714. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  37715. }
  37716. }
  37717. /**
  37718. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  37719. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37720. */
  37721. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  37722. /**
  37723. * Defines the camera the input is attached to.
  37724. */
  37725. camera: ArcRotateCamera;
  37726. /**
  37727. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  37728. */
  37729. alphaCorrection: number;
  37730. /**
  37731. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  37732. */
  37733. gammaCorrection: number;
  37734. private _alpha;
  37735. private _gamma;
  37736. private _dirty;
  37737. private _deviceOrientationHandler;
  37738. /**
  37739. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  37740. */
  37741. constructor();
  37742. /**
  37743. * Attach the input controls to a specific dom element to get the input from.
  37744. * @param element Defines the element the controls should be listened from
  37745. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37746. */
  37747. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37748. /** @hidden */
  37749. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  37750. /**
  37751. * Update the current camera state depending on the inputs that have been used this frame.
  37752. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37753. */
  37754. checkInputs(): void;
  37755. /**
  37756. * Detach the current controls from the specified dom element.
  37757. * @param element Defines the element to stop listening the inputs from
  37758. */
  37759. detachControl(element: Nullable<HTMLElement>): void;
  37760. /**
  37761. * Gets the class name of the current intput.
  37762. * @returns the class name
  37763. */
  37764. getClassName(): string;
  37765. /**
  37766. * Get the friendly name associated with the input class.
  37767. * @returns the input friendly name
  37768. */
  37769. getSimpleName(): string;
  37770. }
  37771. }
  37772. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  37773. import { Nullable } from "babylonjs/types";
  37774. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37775. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37776. /**
  37777. * Listen to mouse events to control the camera.
  37778. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37779. */
  37780. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  37781. /**
  37782. * Defines the camera the input is attached to.
  37783. */
  37784. camera: FlyCamera;
  37785. /**
  37786. * Defines if touch is enabled. (Default is true.)
  37787. */
  37788. touchEnabled: boolean;
  37789. /**
  37790. * Defines the buttons associated with the input to handle camera rotation.
  37791. */
  37792. buttons: number[];
  37793. /**
  37794. * Assign buttons for Yaw control.
  37795. */
  37796. buttonsYaw: number[];
  37797. /**
  37798. * Assign buttons for Pitch control.
  37799. */
  37800. buttonsPitch: number[];
  37801. /**
  37802. * Assign buttons for Roll control.
  37803. */
  37804. buttonsRoll: number[];
  37805. /**
  37806. * Detect if any button is being pressed while mouse is moved.
  37807. * -1 = Mouse locked.
  37808. * 0 = Left button.
  37809. * 1 = Middle Button.
  37810. * 2 = Right Button.
  37811. */
  37812. activeButton: number;
  37813. /**
  37814. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  37815. * Higher values reduce its sensitivity.
  37816. */
  37817. angularSensibility: number;
  37818. private _mousemoveCallback;
  37819. private _observer;
  37820. private _rollObserver;
  37821. private previousPosition;
  37822. private noPreventDefault;
  37823. private element;
  37824. /**
  37825. * Listen to mouse events to control the camera.
  37826. * @param touchEnabled Define if touch is enabled. (Default is true.)
  37827. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37828. */
  37829. constructor(touchEnabled?: boolean);
  37830. /**
  37831. * Attach the mouse control to the HTML DOM element.
  37832. * @param element Defines the element that listens to the input events.
  37833. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  37834. */
  37835. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37836. /**
  37837. * Detach the current controls from the specified dom element.
  37838. * @param element Defines the element to stop listening the inputs from
  37839. */
  37840. detachControl(element: Nullable<HTMLElement>): void;
  37841. /**
  37842. * Gets the class name of the current input.
  37843. * @returns the class name.
  37844. */
  37845. getClassName(): string;
  37846. /**
  37847. * Get the friendly name associated with the input class.
  37848. * @returns the input's friendly name.
  37849. */
  37850. getSimpleName(): string;
  37851. private _pointerInput;
  37852. private _onMouseMove;
  37853. /**
  37854. * Rotate camera by mouse offset.
  37855. */
  37856. private rotateCamera;
  37857. }
  37858. }
  37859. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  37860. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37861. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37862. /**
  37863. * Default Inputs manager for the FlyCamera.
  37864. * It groups all the default supported inputs for ease of use.
  37865. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37866. */
  37867. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  37868. /**
  37869. * Instantiates a new FlyCameraInputsManager.
  37870. * @param camera Defines the camera the inputs belong to.
  37871. */
  37872. constructor(camera: FlyCamera);
  37873. /**
  37874. * Add keyboard input support to the input manager.
  37875. * @returns the new FlyCameraKeyboardMoveInput().
  37876. */
  37877. addKeyboard(): FlyCameraInputsManager;
  37878. /**
  37879. * Add mouse input support to the input manager.
  37880. * @param touchEnabled Enable touch screen support.
  37881. * @returns the new FlyCameraMouseInput().
  37882. */
  37883. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  37884. }
  37885. }
  37886. declare module "babylonjs/Cameras/flyCamera" {
  37887. import { Scene } from "babylonjs/scene";
  37888. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  37889. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37890. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37891. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  37892. /**
  37893. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37894. * such as in a 3D Space Shooter or a Flight Simulator.
  37895. */
  37896. export class FlyCamera extends TargetCamera {
  37897. /**
  37898. * Define the collision ellipsoid of the camera.
  37899. * This is helpful for simulating a camera body, like a player's body.
  37900. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37901. */
  37902. ellipsoid: Vector3;
  37903. /**
  37904. * Define an offset for the position of the ellipsoid around the camera.
  37905. * This can be helpful if the camera is attached away from the player's body center,
  37906. * such as at its head.
  37907. */
  37908. ellipsoidOffset: Vector3;
  37909. /**
  37910. * Enable or disable collisions of the camera with the rest of the scene objects.
  37911. */
  37912. checkCollisions: boolean;
  37913. /**
  37914. * Enable or disable gravity on the camera.
  37915. */
  37916. applyGravity: boolean;
  37917. /**
  37918. * Define the current direction the camera is moving to.
  37919. */
  37920. cameraDirection: Vector3;
  37921. /**
  37922. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  37923. * This overrides and empties cameraRotation.
  37924. */
  37925. rotationQuaternion: Quaternion;
  37926. /**
  37927. * Track Roll to maintain the wanted Rolling when looking around.
  37928. */
  37929. _trackRoll: number;
  37930. /**
  37931. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  37932. */
  37933. rollCorrect: number;
  37934. /**
  37935. * Mimic a banked turn, Rolling the camera when Yawing.
  37936. * It's recommended to use rollCorrect = 10 for faster banking correction.
  37937. */
  37938. bankedTurn: boolean;
  37939. /**
  37940. * Limit in radians for how much Roll banking will add. (Default: 90°)
  37941. */
  37942. bankedTurnLimit: number;
  37943. /**
  37944. * Value of 0 disables the banked Roll.
  37945. * Value of 1 is equal to the Yaw angle in radians.
  37946. */
  37947. bankedTurnMultiplier: number;
  37948. /**
  37949. * The inputs manager loads all the input sources, such as keyboard and mouse.
  37950. */
  37951. inputs: FlyCameraInputsManager;
  37952. /**
  37953. * Gets the input sensibility for mouse input.
  37954. * Higher values reduce sensitivity.
  37955. */
  37956. /**
  37957. * Sets the input sensibility for a mouse input.
  37958. * Higher values reduce sensitivity.
  37959. */
  37960. angularSensibility: number;
  37961. /**
  37962. * Get the keys for camera movement forward.
  37963. */
  37964. /**
  37965. * Set the keys for camera movement forward.
  37966. */
  37967. keysForward: number[];
  37968. /**
  37969. * Get the keys for camera movement backward.
  37970. */
  37971. keysBackward: number[];
  37972. /**
  37973. * Get the keys for camera movement up.
  37974. */
  37975. /**
  37976. * Set the keys for camera movement up.
  37977. */
  37978. keysUp: number[];
  37979. /**
  37980. * Get the keys for camera movement down.
  37981. */
  37982. /**
  37983. * Set the keys for camera movement down.
  37984. */
  37985. keysDown: number[];
  37986. /**
  37987. * Get the keys for camera movement left.
  37988. */
  37989. /**
  37990. * Set the keys for camera movement left.
  37991. */
  37992. keysLeft: number[];
  37993. /**
  37994. * Set the keys for camera movement right.
  37995. */
  37996. /**
  37997. * Set the keys for camera movement right.
  37998. */
  37999. keysRight: number[];
  38000. /**
  38001. * Event raised when the camera collides with a mesh in the scene.
  38002. */
  38003. onCollide: (collidedMesh: AbstractMesh) => void;
  38004. private _collider;
  38005. private _needMoveForGravity;
  38006. private _oldPosition;
  38007. private _diffPosition;
  38008. private _newPosition;
  38009. /** @hidden */
  38010. _localDirection: Vector3;
  38011. /** @hidden */
  38012. _transformedDirection: Vector3;
  38013. /**
  38014. * Instantiates a FlyCamera.
  38015. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38016. * such as in a 3D Space Shooter or a Flight Simulator.
  38017. * @param name Define the name of the camera in the scene.
  38018. * @param position Define the starting position of the camera in the scene.
  38019. * @param scene Define the scene the camera belongs to.
  38020. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  38021. */
  38022. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38023. /**
  38024. * Attach a control to the HTML DOM element.
  38025. * @param element Defines the element that listens to the input events.
  38026. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  38027. */
  38028. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38029. /**
  38030. * Detach a control from the HTML DOM element.
  38031. * The camera will stop reacting to that input.
  38032. * @param element Defines the element that listens to the input events.
  38033. */
  38034. detachControl(element: HTMLElement): void;
  38035. private _collisionMask;
  38036. /**
  38037. * Get the mask that the camera ignores in collision events.
  38038. */
  38039. /**
  38040. * Set the mask that the camera ignores in collision events.
  38041. */
  38042. collisionMask: number;
  38043. /** @hidden */
  38044. _collideWithWorld(displacement: Vector3): void;
  38045. /** @hidden */
  38046. private _onCollisionPositionChange;
  38047. /** @hidden */
  38048. _checkInputs(): void;
  38049. /** @hidden */
  38050. _decideIfNeedsToMove(): boolean;
  38051. /** @hidden */
  38052. _updatePosition(): void;
  38053. /**
  38054. * Restore the Roll to its target value at the rate specified.
  38055. * @param rate - Higher means slower restoring.
  38056. * @hidden
  38057. */
  38058. restoreRoll(rate: number): void;
  38059. /**
  38060. * Destroy the camera and release the current resources held by it.
  38061. */
  38062. dispose(): void;
  38063. /**
  38064. * Get the current object class name.
  38065. * @returns the class name.
  38066. */
  38067. getClassName(): string;
  38068. }
  38069. }
  38070. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  38071. import { Nullable } from "babylonjs/types";
  38072. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38073. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38074. /**
  38075. * Listen to keyboard events to control the camera.
  38076. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38077. */
  38078. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  38079. /**
  38080. * Defines the camera the input is attached to.
  38081. */
  38082. camera: FlyCamera;
  38083. /**
  38084. * The list of keyboard keys used to control the forward move of the camera.
  38085. */
  38086. keysForward: number[];
  38087. /**
  38088. * The list of keyboard keys used to control the backward move of the camera.
  38089. */
  38090. keysBackward: number[];
  38091. /**
  38092. * The list of keyboard keys used to control the forward move of the camera.
  38093. */
  38094. keysUp: number[];
  38095. /**
  38096. * The list of keyboard keys used to control the backward move of the camera.
  38097. */
  38098. keysDown: number[];
  38099. /**
  38100. * The list of keyboard keys used to control the right strafe move of the camera.
  38101. */
  38102. keysRight: number[];
  38103. /**
  38104. * The list of keyboard keys used to control the left strafe move of the camera.
  38105. */
  38106. keysLeft: number[];
  38107. private _keys;
  38108. private _onCanvasBlurObserver;
  38109. private _onKeyboardObserver;
  38110. private _engine;
  38111. private _scene;
  38112. /**
  38113. * Attach the input controls to a specific dom element to get the input from.
  38114. * @param element Defines the element the controls should be listened from
  38115. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38116. */
  38117. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38118. /**
  38119. * Detach the current controls from the specified dom element.
  38120. * @param element Defines the element to stop listening the inputs from
  38121. */
  38122. detachControl(element: Nullable<HTMLElement>): void;
  38123. /**
  38124. * Gets the class name of the current intput.
  38125. * @returns the class name
  38126. */
  38127. getClassName(): string;
  38128. /** @hidden */
  38129. _onLostFocus(e: FocusEvent): void;
  38130. /**
  38131. * Get the friendly name associated with the input class.
  38132. * @returns the input friendly name
  38133. */
  38134. getSimpleName(): string;
  38135. /**
  38136. * Update the current camera state depending on the inputs that have been used this frame.
  38137. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38138. */
  38139. checkInputs(): void;
  38140. }
  38141. }
  38142. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  38143. import { Nullable } from "babylonjs/types";
  38144. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38145. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38146. /**
  38147. * Manage the mouse wheel inputs to control a follow camera.
  38148. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38149. */
  38150. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  38151. /**
  38152. * Defines the camera the input is attached to.
  38153. */
  38154. camera: FollowCamera;
  38155. /**
  38156. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  38157. */
  38158. axisControlRadius: boolean;
  38159. /**
  38160. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  38161. */
  38162. axisControlHeight: boolean;
  38163. /**
  38164. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  38165. */
  38166. axisControlRotation: boolean;
  38167. /**
  38168. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  38169. * relation to mouseWheel events.
  38170. */
  38171. wheelPrecision: number;
  38172. /**
  38173. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38174. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38175. */
  38176. wheelDeltaPercentage: number;
  38177. private _wheel;
  38178. private _observer;
  38179. /**
  38180. * Attach the input controls to a specific dom element to get the input from.
  38181. * @param element Defines the element the controls should be listened from
  38182. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38183. */
  38184. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38185. /**
  38186. * Detach the current controls from the specified dom element.
  38187. * @param element Defines the element to stop listening the inputs from
  38188. */
  38189. detachControl(element: Nullable<HTMLElement>): void;
  38190. /**
  38191. * Gets the class name of the current intput.
  38192. * @returns the class name
  38193. */
  38194. getClassName(): string;
  38195. /**
  38196. * Get the friendly name associated with the input class.
  38197. * @returns the input friendly name
  38198. */
  38199. getSimpleName(): string;
  38200. }
  38201. }
  38202. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  38203. import { Nullable } from "babylonjs/types";
  38204. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38205. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  38206. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  38207. /**
  38208. * Manage the pointers inputs to control an follow camera.
  38209. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38210. */
  38211. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  38212. /**
  38213. * Defines the camera the input is attached to.
  38214. */
  38215. camera: FollowCamera;
  38216. /**
  38217. * Gets the class name of the current input.
  38218. * @returns the class name
  38219. */
  38220. getClassName(): string;
  38221. /**
  38222. * Defines the pointer angular sensibility along the X axis or how fast is
  38223. * the camera rotating.
  38224. * A negative number will reverse the axis direction.
  38225. */
  38226. angularSensibilityX: number;
  38227. /**
  38228. * Defines the pointer angular sensibility along the Y axis or how fast is
  38229. * the camera rotating.
  38230. * A negative number will reverse the axis direction.
  38231. */
  38232. angularSensibilityY: number;
  38233. /**
  38234. * Defines the pointer pinch precision or how fast is the camera zooming.
  38235. * A negative number will reverse the axis direction.
  38236. */
  38237. pinchPrecision: number;
  38238. /**
  38239. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38240. * from 0.
  38241. * It defines the percentage of current camera.radius to use as delta when
  38242. * pinch zoom is used.
  38243. */
  38244. pinchDeltaPercentage: number;
  38245. /**
  38246. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  38247. */
  38248. axisXControlRadius: boolean;
  38249. /**
  38250. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  38251. */
  38252. axisXControlHeight: boolean;
  38253. /**
  38254. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  38255. */
  38256. axisXControlRotation: boolean;
  38257. /**
  38258. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  38259. */
  38260. axisYControlRadius: boolean;
  38261. /**
  38262. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  38263. */
  38264. axisYControlHeight: boolean;
  38265. /**
  38266. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  38267. */
  38268. axisYControlRotation: boolean;
  38269. /**
  38270. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  38271. */
  38272. axisPinchControlRadius: boolean;
  38273. /**
  38274. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  38275. */
  38276. axisPinchControlHeight: boolean;
  38277. /**
  38278. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  38279. */
  38280. axisPinchControlRotation: boolean;
  38281. /**
  38282. * Log error messages if basic misconfiguration has occurred.
  38283. */
  38284. warningEnable: boolean;
  38285. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38286. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38287. private _warningCounter;
  38288. private _warning;
  38289. }
  38290. }
  38291. declare module "babylonjs/Cameras/followCameraInputsManager" {
  38292. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38293. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38294. /**
  38295. * Default Inputs manager for the FollowCamera.
  38296. * It groups all the default supported inputs for ease of use.
  38297. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38298. */
  38299. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  38300. /**
  38301. * Instantiates a new FollowCameraInputsManager.
  38302. * @param camera Defines the camera the inputs belong to
  38303. */
  38304. constructor(camera: FollowCamera);
  38305. /**
  38306. * Add keyboard input support to the input manager.
  38307. * @returns the current input manager
  38308. */
  38309. addKeyboard(): FollowCameraInputsManager;
  38310. /**
  38311. * Add mouse wheel input support to the input manager.
  38312. * @returns the current input manager
  38313. */
  38314. addMouseWheel(): FollowCameraInputsManager;
  38315. /**
  38316. * Add pointers input support to the input manager.
  38317. * @returns the current input manager
  38318. */
  38319. addPointers(): FollowCameraInputsManager;
  38320. /**
  38321. * Add orientation input support to the input manager.
  38322. * @returns the current input manager
  38323. */
  38324. addVRDeviceOrientation(): FollowCameraInputsManager;
  38325. }
  38326. }
  38327. declare module "babylonjs/Cameras/followCamera" {
  38328. import { Nullable } from "babylonjs/types";
  38329. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38330. import { Scene } from "babylonjs/scene";
  38331. import { Vector3 } from "babylonjs/Maths/math";
  38332. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38333. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  38334. /**
  38335. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  38336. * an arc rotate version arcFollowCamera are available.
  38337. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38338. */
  38339. export class FollowCamera extends TargetCamera {
  38340. /**
  38341. * Distance the follow camera should follow an object at
  38342. */
  38343. radius: number;
  38344. /**
  38345. * Minimum allowed distance of the camera to the axis of rotation
  38346. * (The camera can not get closer).
  38347. * This can help limiting how the Camera is able to move in the scene.
  38348. */
  38349. lowerRadiusLimit: Nullable<number>;
  38350. /**
  38351. * Maximum allowed distance of the camera to the axis of rotation
  38352. * (The camera can not get further).
  38353. * This can help limiting how the Camera is able to move in the scene.
  38354. */
  38355. upperRadiusLimit: Nullable<number>;
  38356. /**
  38357. * Define a rotation offset between the camera and the object it follows
  38358. */
  38359. rotationOffset: number;
  38360. /**
  38361. * Minimum allowed angle to camera position relative to target object.
  38362. * This can help limiting how the Camera is able to move in the scene.
  38363. */
  38364. lowerRotationOffsetLimit: Nullable<number>;
  38365. /**
  38366. * Maximum allowed angle to camera position relative to target object.
  38367. * This can help limiting how the Camera is able to move in the scene.
  38368. */
  38369. upperRotationOffsetLimit: Nullable<number>;
  38370. /**
  38371. * Define a height offset between the camera and the object it follows.
  38372. * It can help following an object from the top (like a car chaing a plane)
  38373. */
  38374. heightOffset: number;
  38375. /**
  38376. * Minimum allowed height of camera position relative to target object.
  38377. * This can help limiting how the Camera is able to move in the scene.
  38378. */
  38379. lowerHeightOffsetLimit: Nullable<number>;
  38380. /**
  38381. * Maximum allowed height of camera position relative to target object.
  38382. * This can help limiting how the Camera is able to move in the scene.
  38383. */
  38384. upperHeightOffsetLimit: Nullable<number>;
  38385. /**
  38386. * Define how fast the camera can accelerate to follow it s target.
  38387. */
  38388. cameraAcceleration: number;
  38389. /**
  38390. * Define the speed limit of the camera following an object.
  38391. */
  38392. maxCameraSpeed: number;
  38393. /**
  38394. * Define the target of the camera.
  38395. */
  38396. lockedTarget: Nullable<AbstractMesh>;
  38397. /**
  38398. * Defines the input associated with the camera.
  38399. */
  38400. inputs: FollowCameraInputsManager;
  38401. /**
  38402. * Instantiates the follow camera.
  38403. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38404. * @param name Define the name of the camera in the scene
  38405. * @param position Define the position of the camera
  38406. * @param scene Define the scene the camera belong to
  38407. * @param lockedTarget Define the target of the camera
  38408. */
  38409. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  38410. private _follow;
  38411. /**
  38412. * Attached controls to the current camera.
  38413. * @param element Defines the element the controls should be listened from
  38414. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38415. */
  38416. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38417. /**
  38418. * Detach the current controls from the camera.
  38419. * The camera will stop reacting to inputs.
  38420. * @param element Defines the element to stop listening the inputs from
  38421. */
  38422. detachControl(element: HTMLElement): void;
  38423. /** @hidden */
  38424. _checkInputs(): void;
  38425. private _checkLimits;
  38426. /**
  38427. * Gets the camera class name.
  38428. * @returns the class name
  38429. */
  38430. getClassName(): string;
  38431. }
  38432. /**
  38433. * Arc Rotate version of the follow camera.
  38434. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  38435. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38436. */
  38437. export class ArcFollowCamera extends TargetCamera {
  38438. /** The longitudinal angle of the camera */
  38439. alpha: number;
  38440. /** The latitudinal angle of the camera */
  38441. beta: number;
  38442. /** The radius of the camera from its target */
  38443. radius: number;
  38444. /** Define the camera target (the messh it should follow) */
  38445. target: Nullable<AbstractMesh>;
  38446. private _cartesianCoordinates;
  38447. /**
  38448. * Instantiates a new ArcFollowCamera
  38449. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38450. * @param name Define the name of the camera
  38451. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  38452. * @param beta Define the rotation angle of the camera around the elevation axis
  38453. * @param radius Define the radius of the camera from its target point
  38454. * @param target Define the target of the camera
  38455. * @param scene Define the scene the camera belongs to
  38456. */
  38457. constructor(name: string,
  38458. /** The longitudinal angle of the camera */
  38459. alpha: number,
  38460. /** The latitudinal angle of the camera */
  38461. beta: number,
  38462. /** The radius of the camera from its target */
  38463. radius: number,
  38464. /** Define the camera target (the messh it should follow) */
  38465. target: Nullable<AbstractMesh>, scene: Scene);
  38466. private _follow;
  38467. /** @hidden */
  38468. _checkInputs(): void;
  38469. /**
  38470. * Returns the class name of the object.
  38471. * It is mostly used internally for serialization purposes.
  38472. */
  38473. getClassName(): string;
  38474. }
  38475. }
  38476. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  38477. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38478. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38479. import { Nullable } from "babylonjs/types";
  38480. /**
  38481. * Manage the keyboard inputs to control the movement of a follow camera.
  38482. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38483. */
  38484. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  38485. /**
  38486. * Defines the camera the input is attached to.
  38487. */
  38488. camera: FollowCamera;
  38489. /**
  38490. * Defines the list of key codes associated with the up action (increase heightOffset)
  38491. */
  38492. keysHeightOffsetIncr: number[];
  38493. /**
  38494. * Defines the list of key codes associated with the down action (decrease heightOffset)
  38495. */
  38496. keysHeightOffsetDecr: number[];
  38497. /**
  38498. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  38499. */
  38500. keysHeightOffsetModifierAlt: boolean;
  38501. /**
  38502. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  38503. */
  38504. keysHeightOffsetModifierCtrl: boolean;
  38505. /**
  38506. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  38507. */
  38508. keysHeightOffsetModifierShift: boolean;
  38509. /**
  38510. * Defines the list of key codes associated with the left action (increase rotationOffset)
  38511. */
  38512. keysRotationOffsetIncr: number[];
  38513. /**
  38514. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  38515. */
  38516. keysRotationOffsetDecr: number[];
  38517. /**
  38518. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  38519. */
  38520. keysRotationOffsetModifierAlt: boolean;
  38521. /**
  38522. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  38523. */
  38524. keysRotationOffsetModifierCtrl: boolean;
  38525. /**
  38526. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  38527. */
  38528. keysRotationOffsetModifierShift: boolean;
  38529. /**
  38530. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  38531. */
  38532. keysRadiusIncr: number[];
  38533. /**
  38534. * Defines the list of key codes associated with the zoom-out action (increase radius)
  38535. */
  38536. keysRadiusDecr: number[];
  38537. /**
  38538. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  38539. */
  38540. keysRadiusModifierAlt: boolean;
  38541. /**
  38542. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  38543. */
  38544. keysRadiusModifierCtrl: boolean;
  38545. /**
  38546. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  38547. */
  38548. keysRadiusModifierShift: boolean;
  38549. /**
  38550. * Defines the rate of change of heightOffset.
  38551. */
  38552. heightSensibility: number;
  38553. /**
  38554. * Defines the rate of change of rotationOffset.
  38555. */
  38556. rotationSensibility: number;
  38557. /**
  38558. * Defines the rate of change of radius.
  38559. */
  38560. radiusSensibility: number;
  38561. private _keys;
  38562. private _ctrlPressed;
  38563. private _altPressed;
  38564. private _shiftPressed;
  38565. private _onCanvasBlurObserver;
  38566. private _onKeyboardObserver;
  38567. private _engine;
  38568. private _scene;
  38569. /**
  38570. * Attach the input controls to a specific dom element to get the input from.
  38571. * @param element Defines the element the controls should be listened from
  38572. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38573. */
  38574. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38575. /**
  38576. * Detach the current controls from the specified dom element.
  38577. * @param element Defines the element to stop listening the inputs from
  38578. */
  38579. detachControl(element: Nullable<HTMLElement>): void;
  38580. /**
  38581. * Update the current camera state depending on the inputs that have been used this frame.
  38582. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38583. */
  38584. checkInputs(): void;
  38585. /**
  38586. * Gets the class name of the current input.
  38587. * @returns the class name
  38588. */
  38589. getClassName(): string;
  38590. /**
  38591. * Get the friendly name associated with the input class.
  38592. * @returns the input friendly name
  38593. */
  38594. getSimpleName(): string;
  38595. /**
  38596. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38597. * allow modification of the heightOffset value.
  38598. */
  38599. private _modifierHeightOffset;
  38600. /**
  38601. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38602. * allow modification of the rotationOffset value.
  38603. */
  38604. private _modifierRotationOffset;
  38605. /**
  38606. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38607. * allow modification of the radius value.
  38608. */
  38609. private _modifierRadius;
  38610. }
  38611. }
  38612. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  38613. import { Nullable } from "babylonjs/types";
  38614. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38615. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38616. import { Observable } from "babylonjs/Misc/observable";
  38617. module "babylonjs/Cameras/freeCameraInputsManager" {
  38618. interface FreeCameraInputsManager {
  38619. /**
  38620. * @hidden
  38621. */
  38622. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  38623. /**
  38624. * Add orientation input support to the input manager.
  38625. * @returns the current input manager
  38626. */
  38627. addDeviceOrientation(): FreeCameraInputsManager;
  38628. }
  38629. }
  38630. /**
  38631. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  38632. * Screen rotation is taken into account.
  38633. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38634. */
  38635. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  38636. private _camera;
  38637. private _screenOrientationAngle;
  38638. private _constantTranform;
  38639. private _screenQuaternion;
  38640. private _alpha;
  38641. private _beta;
  38642. private _gamma;
  38643. /**
  38644. * Can be used to detect if a device orientation sensor is availible on a device
  38645. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  38646. * @returns a promise that will resolve on orientation change
  38647. */
  38648. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  38649. /**
  38650. * @hidden
  38651. */
  38652. _onDeviceOrientationChangedObservable: Observable<void>;
  38653. /**
  38654. * Instantiates a new input
  38655. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38656. */
  38657. constructor();
  38658. /**
  38659. * Define the camera controlled by the input.
  38660. */
  38661. camera: FreeCamera;
  38662. /**
  38663. * Attach the input controls to a specific dom element to get the input from.
  38664. * @param element Defines the element the controls should be listened from
  38665. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38666. */
  38667. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38668. private _orientationChanged;
  38669. private _deviceOrientation;
  38670. /**
  38671. * Detach the current controls from the specified dom element.
  38672. * @param element Defines the element to stop listening the inputs from
  38673. */
  38674. detachControl(element: Nullable<HTMLElement>): void;
  38675. /**
  38676. * Update the current camera state depending on the inputs that have been used this frame.
  38677. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38678. */
  38679. checkInputs(): void;
  38680. /**
  38681. * Gets the class name of the current intput.
  38682. * @returns the class name
  38683. */
  38684. getClassName(): string;
  38685. /**
  38686. * Get the friendly name associated with the input class.
  38687. * @returns the input friendly name
  38688. */
  38689. getSimpleName(): string;
  38690. }
  38691. }
  38692. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  38693. import { Nullable } from "babylonjs/types";
  38694. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38695. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38696. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38697. /**
  38698. * Manage the gamepad inputs to control a free camera.
  38699. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38700. */
  38701. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  38702. /**
  38703. * Define the camera the input is attached to.
  38704. */
  38705. camera: FreeCamera;
  38706. /**
  38707. * Define the Gamepad controlling the input
  38708. */
  38709. gamepad: Nullable<Gamepad>;
  38710. /**
  38711. * Defines the gamepad rotation sensiblity.
  38712. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38713. */
  38714. gamepadAngularSensibility: number;
  38715. /**
  38716. * Defines the gamepad move sensiblity.
  38717. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38718. */
  38719. gamepadMoveSensibility: number;
  38720. private _onGamepadConnectedObserver;
  38721. private _onGamepadDisconnectedObserver;
  38722. private _cameraTransform;
  38723. private _deltaTransform;
  38724. private _vector3;
  38725. private _vector2;
  38726. /**
  38727. * Attach the input controls to a specific dom element to get the input from.
  38728. * @param element Defines the element the controls should be listened from
  38729. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38730. */
  38731. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38732. /**
  38733. * Detach the current controls from the specified dom element.
  38734. * @param element Defines the element to stop listening the inputs from
  38735. */
  38736. detachControl(element: Nullable<HTMLElement>): void;
  38737. /**
  38738. * Update the current camera state depending on the inputs that have been used this frame.
  38739. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38740. */
  38741. checkInputs(): void;
  38742. /**
  38743. * Gets the class name of the current intput.
  38744. * @returns the class name
  38745. */
  38746. getClassName(): string;
  38747. /**
  38748. * Get the friendly name associated with the input class.
  38749. * @returns the input friendly name
  38750. */
  38751. getSimpleName(): string;
  38752. }
  38753. }
  38754. declare module "babylonjs/Misc/virtualJoystick" {
  38755. import { Nullable } from "babylonjs/types";
  38756. import { Vector3 } from "babylonjs/Maths/math";
  38757. /**
  38758. * Defines the potential axis of a Joystick
  38759. */
  38760. export enum JoystickAxis {
  38761. /** X axis */
  38762. X = 0,
  38763. /** Y axis */
  38764. Y = 1,
  38765. /** Z axis */
  38766. Z = 2
  38767. }
  38768. /**
  38769. * Class used to define virtual joystick (used in touch mode)
  38770. */
  38771. export class VirtualJoystick {
  38772. /**
  38773. * Gets or sets a boolean indicating that left and right values must be inverted
  38774. */
  38775. reverseLeftRight: boolean;
  38776. /**
  38777. * Gets or sets a boolean indicating that up and down values must be inverted
  38778. */
  38779. reverseUpDown: boolean;
  38780. /**
  38781. * Gets the offset value for the position (ie. the change of the position value)
  38782. */
  38783. deltaPosition: Vector3;
  38784. /**
  38785. * Gets a boolean indicating if the virtual joystick was pressed
  38786. */
  38787. pressed: boolean;
  38788. /**
  38789. * Canvas the virtual joystick will render onto, default z-index of this is 5
  38790. */
  38791. static Canvas: Nullable<HTMLCanvasElement>;
  38792. private static _globalJoystickIndex;
  38793. private static vjCanvasContext;
  38794. private static vjCanvasWidth;
  38795. private static vjCanvasHeight;
  38796. private static halfWidth;
  38797. private _action;
  38798. private _axisTargetedByLeftAndRight;
  38799. private _axisTargetedByUpAndDown;
  38800. private _joystickSensibility;
  38801. private _inversedSensibility;
  38802. private _joystickPointerID;
  38803. private _joystickColor;
  38804. private _joystickPointerPos;
  38805. private _joystickPreviousPointerPos;
  38806. private _joystickPointerStartPos;
  38807. private _deltaJoystickVector;
  38808. private _leftJoystick;
  38809. private _touches;
  38810. private _onPointerDownHandlerRef;
  38811. private _onPointerMoveHandlerRef;
  38812. private _onPointerUpHandlerRef;
  38813. private _onResize;
  38814. /**
  38815. * Creates a new virtual joystick
  38816. * @param leftJoystick defines that the joystick is for left hand (false by default)
  38817. */
  38818. constructor(leftJoystick?: boolean);
  38819. /**
  38820. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  38821. * @param newJoystickSensibility defines the new sensibility
  38822. */
  38823. setJoystickSensibility(newJoystickSensibility: number): void;
  38824. private _onPointerDown;
  38825. private _onPointerMove;
  38826. private _onPointerUp;
  38827. /**
  38828. * Change the color of the virtual joystick
  38829. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  38830. */
  38831. setJoystickColor(newColor: string): void;
  38832. /**
  38833. * Defines a callback to call when the joystick is touched
  38834. * @param action defines the callback
  38835. */
  38836. setActionOnTouch(action: () => any): void;
  38837. /**
  38838. * Defines which axis you'd like to control for left & right
  38839. * @param axis defines the axis to use
  38840. */
  38841. setAxisForLeftRight(axis: JoystickAxis): void;
  38842. /**
  38843. * Defines which axis you'd like to control for up & down
  38844. * @param axis defines the axis to use
  38845. */
  38846. setAxisForUpDown(axis: JoystickAxis): void;
  38847. private _drawVirtualJoystick;
  38848. /**
  38849. * Release internal HTML canvas
  38850. */
  38851. releaseCanvas(): void;
  38852. }
  38853. }
  38854. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  38855. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  38856. import { Nullable } from "babylonjs/types";
  38857. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38858. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38859. module "babylonjs/Cameras/freeCameraInputsManager" {
  38860. interface FreeCameraInputsManager {
  38861. /**
  38862. * Add virtual joystick input support to the input manager.
  38863. * @returns the current input manager
  38864. */
  38865. addVirtualJoystick(): FreeCameraInputsManager;
  38866. }
  38867. }
  38868. /**
  38869. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  38870. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38871. */
  38872. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  38873. /**
  38874. * Defines the camera the input is attached to.
  38875. */
  38876. camera: FreeCamera;
  38877. private _leftjoystick;
  38878. private _rightjoystick;
  38879. /**
  38880. * Gets the left stick of the virtual joystick.
  38881. * @returns The virtual Joystick
  38882. */
  38883. getLeftJoystick(): VirtualJoystick;
  38884. /**
  38885. * Gets the right stick of the virtual joystick.
  38886. * @returns The virtual Joystick
  38887. */
  38888. getRightJoystick(): VirtualJoystick;
  38889. /**
  38890. * Update the current camera state depending on the inputs that have been used this frame.
  38891. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38892. */
  38893. checkInputs(): void;
  38894. /**
  38895. * Attach the input controls to a specific dom element to get the input from.
  38896. * @param element Defines the element the controls should be listened from
  38897. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38898. */
  38899. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38900. /**
  38901. * Detach the current controls from the specified dom element.
  38902. * @param element Defines the element to stop listening the inputs from
  38903. */
  38904. detachControl(element: Nullable<HTMLElement>): void;
  38905. /**
  38906. * Gets the class name of the current intput.
  38907. * @returns the class name
  38908. */
  38909. getClassName(): string;
  38910. /**
  38911. * Get the friendly name associated with the input class.
  38912. * @returns the input friendly name
  38913. */
  38914. getSimpleName(): string;
  38915. }
  38916. }
  38917. declare module "babylonjs/Cameras/Inputs/index" {
  38918. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  38919. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  38920. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  38921. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  38922. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  38923. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  38924. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  38925. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  38926. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  38927. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  38928. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  38929. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  38930. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  38931. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  38932. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  38933. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  38934. }
  38935. declare module "babylonjs/Cameras/touchCamera" {
  38936. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38937. import { Scene } from "babylonjs/scene";
  38938. import { Vector3 } from "babylonjs/Maths/math";
  38939. /**
  38940. * This represents a FPS type of camera controlled by touch.
  38941. * This is like a universal camera minus the Gamepad controls.
  38942. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38943. */
  38944. export class TouchCamera extends FreeCamera {
  38945. /**
  38946. * Defines the touch sensibility for rotation.
  38947. * The higher the faster.
  38948. */
  38949. touchAngularSensibility: number;
  38950. /**
  38951. * Defines the touch sensibility for move.
  38952. * The higher the faster.
  38953. */
  38954. touchMoveSensibility: number;
  38955. /**
  38956. * Instantiates a new touch camera.
  38957. * This represents a FPS type of camera controlled by touch.
  38958. * This is like a universal camera minus the Gamepad controls.
  38959. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38960. * @param name Define the name of the camera in the scene
  38961. * @param position Define the start position of the camera in the scene
  38962. * @param scene Define the scene the camera belongs to
  38963. */
  38964. constructor(name: string, position: Vector3, scene: Scene);
  38965. /**
  38966. * Gets the current object class name.
  38967. * @return the class name
  38968. */
  38969. getClassName(): string;
  38970. /** @hidden */
  38971. _setupInputs(): void;
  38972. }
  38973. }
  38974. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  38975. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38976. import { Scene } from "babylonjs/scene";
  38977. import { Vector3, Axis } from "babylonjs/Maths/math";
  38978. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  38979. /**
  38980. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  38981. * being tilted forward or back and left or right.
  38982. */
  38983. export class DeviceOrientationCamera extends FreeCamera {
  38984. private _initialQuaternion;
  38985. private _quaternionCache;
  38986. private _tmpDragQuaternion;
  38987. /**
  38988. * Creates a new device orientation camera
  38989. * @param name The name of the camera
  38990. * @param position The start position camera
  38991. * @param scene The scene the camera belongs to
  38992. */
  38993. constructor(name: string, position: Vector3, scene: Scene);
  38994. /**
  38995. * @hidden
  38996. * Disabled pointer input on first orientation sensor update (Default: true)
  38997. */
  38998. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  38999. private _dragFactor;
  39000. /**
  39001. * Enabled turning on the y axis when the orientation sensor is active
  39002. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  39003. */
  39004. enableHorizontalDragging(dragFactor?: number): void;
  39005. /**
  39006. * Gets the current instance class name ("DeviceOrientationCamera").
  39007. * This helps avoiding instanceof at run time.
  39008. * @returns the class name
  39009. */
  39010. getClassName(): string;
  39011. /**
  39012. * @hidden
  39013. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  39014. */
  39015. _checkInputs(): void;
  39016. /**
  39017. * Reset the camera to its default orientation on the specified axis only.
  39018. * @param axis The axis to reset
  39019. */
  39020. resetToCurrentRotation(axis?: Axis): void;
  39021. }
  39022. }
  39023. declare module "babylonjs/Gamepads/xboxGamepad" {
  39024. import { Observable } from "babylonjs/Misc/observable";
  39025. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39026. /**
  39027. * Defines supported buttons for XBox360 compatible gamepads
  39028. */
  39029. export enum Xbox360Button {
  39030. /** A */
  39031. A = 0,
  39032. /** B */
  39033. B = 1,
  39034. /** X */
  39035. X = 2,
  39036. /** Y */
  39037. Y = 3,
  39038. /** Start */
  39039. Start = 4,
  39040. /** Back */
  39041. Back = 5,
  39042. /** Left button */
  39043. LB = 6,
  39044. /** Right button */
  39045. RB = 7,
  39046. /** Left stick */
  39047. LeftStick = 8,
  39048. /** Right stick */
  39049. RightStick = 9
  39050. }
  39051. /** Defines values for XBox360 DPad */
  39052. export enum Xbox360Dpad {
  39053. /** Up */
  39054. Up = 0,
  39055. /** Down */
  39056. Down = 1,
  39057. /** Left */
  39058. Left = 2,
  39059. /** Right */
  39060. Right = 3
  39061. }
  39062. /**
  39063. * Defines a XBox360 gamepad
  39064. */
  39065. export class Xbox360Pad extends Gamepad {
  39066. private _leftTrigger;
  39067. private _rightTrigger;
  39068. private _onlefttriggerchanged;
  39069. private _onrighttriggerchanged;
  39070. private _onbuttondown;
  39071. private _onbuttonup;
  39072. private _ondpaddown;
  39073. private _ondpadup;
  39074. /** Observable raised when a button is pressed */
  39075. onButtonDownObservable: Observable<Xbox360Button>;
  39076. /** Observable raised when a button is released */
  39077. onButtonUpObservable: Observable<Xbox360Button>;
  39078. /** Observable raised when a pad is pressed */
  39079. onPadDownObservable: Observable<Xbox360Dpad>;
  39080. /** Observable raised when a pad is released */
  39081. onPadUpObservable: Observable<Xbox360Dpad>;
  39082. private _buttonA;
  39083. private _buttonB;
  39084. private _buttonX;
  39085. private _buttonY;
  39086. private _buttonBack;
  39087. private _buttonStart;
  39088. private _buttonLB;
  39089. private _buttonRB;
  39090. private _buttonLeftStick;
  39091. private _buttonRightStick;
  39092. private _dPadUp;
  39093. private _dPadDown;
  39094. private _dPadLeft;
  39095. private _dPadRight;
  39096. private _isXboxOnePad;
  39097. /**
  39098. * Creates a new XBox360 gamepad object
  39099. * @param id defines the id of this gamepad
  39100. * @param index defines its index
  39101. * @param gamepad defines the internal HTML gamepad object
  39102. * @param xboxOne defines if it is a XBox One gamepad
  39103. */
  39104. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  39105. /**
  39106. * Defines the callback to call when left trigger is pressed
  39107. * @param callback defines the callback to use
  39108. */
  39109. onlefttriggerchanged(callback: (value: number) => void): void;
  39110. /**
  39111. * Defines the callback to call when right trigger is pressed
  39112. * @param callback defines the callback to use
  39113. */
  39114. onrighttriggerchanged(callback: (value: number) => void): void;
  39115. /**
  39116. * Gets the left trigger value
  39117. */
  39118. /**
  39119. * Sets the left trigger value
  39120. */
  39121. leftTrigger: number;
  39122. /**
  39123. * Gets the right trigger value
  39124. */
  39125. /**
  39126. * Sets the right trigger value
  39127. */
  39128. rightTrigger: number;
  39129. /**
  39130. * Defines the callback to call when a button is pressed
  39131. * @param callback defines the callback to use
  39132. */
  39133. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  39134. /**
  39135. * Defines the callback to call when a button is released
  39136. * @param callback defines the callback to use
  39137. */
  39138. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  39139. /**
  39140. * Defines the callback to call when a pad is pressed
  39141. * @param callback defines the callback to use
  39142. */
  39143. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  39144. /**
  39145. * Defines the callback to call when a pad is released
  39146. * @param callback defines the callback to use
  39147. */
  39148. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  39149. private _setButtonValue;
  39150. private _setDPadValue;
  39151. /**
  39152. * Gets the value of the `A` button
  39153. */
  39154. /**
  39155. * Sets the value of the `A` button
  39156. */
  39157. buttonA: number;
  39158. /**
  39159. * Gets the value of the `B` button
  39160. */
  39161. /**
  39162. * Sets the value of the `B` button
  39163. */
  39164. buttonB: number;
  39165. /**
  39166. * Gets the value of the `X` button
  39167. */
  39168. /**
  39169. * Sets the value of the `X` button
  39170. */
  39171. buttonX: number;
  39172. /**
  39173. * Gets the value of the `Y` button
  39174. */
  39175. /**
  39176. * Sets the value of the `Y` button
  39177. */
  39178. buttonY: number;
  39179. /**
  39180. * Gets the value of the `Start` button
  39181. */
  39182. /**
  39183. * Sets the value of the `Start` button
  39184. */
  39185. buttonStart: number;
  39186. /**
  39187. * Gets the value of the `Back` button
  39188. */
  39189. /**
  39190. * Sets the value of the `Back` button
  39191. */
  39192. buttonBack: number;
  39193. /**
  39194. * Gets the value of the `Left` button
  39195. */
  39196. /**
  39197. * Sets the value of the `Left` button
  39198. */
  39199. buttonLB: number;
  39200. /**
  39201. * Gets the value of the `Right` button
  39202. */
  39203. /**
  39204. * Sets the value of the `Right` button
  39205. */
  39206. buttonRB: number;
  39207. /**
  39208. * Gets the value of the Left joystick
  39209. */
  39210. /**
  39211. * Sets the value of the Left joystick
  39212. */
  39213. buttonLeftStick: number;
  39214. /**
  39215. * Gets the value of the Right joystick
  39216. */
  39217. /**
  39218. * Sets the value of the Right joystick
  39219. */
  39220. buttonRightStick: number;
  39221. /**
  39222. * Gets the value of D-pad up
  39223. */
  39224. /**
  39225. * Sets the value of D-pad up
  39226. */
  39227. dPadUp: number;
  39228. /**
  39229. * Gets the value of D-pad down
  39230. */
  39231. /**
  39232. * Sets the value of D-pad down
  39233. */
  39234. dPadDown: number;
  39235. /**
  39236. * Gets the value of D-pad left
  39237. */
  39238. /**
  39239. * Sets the value of D-pad left
  39240. */
  39241. dPadLeft: number;
  39242. /**
  39243. * Gets the value of D-pad right
  39244. */
  39245. /**
  39246. * Sets the value of D-pad right
  39247. */
  39248. dPadRight: number;
  39249. /**
  39250. * Force the gamepad to synchronize with device values
  39251. */
  39252. update(): void;
  39253. /**
  39254. * Disposes the gamepad
  39255. */
  39256. dispose(): void;
  39257. }
  39258. }
  39259. declare module "babylonjs/Gamepads/gamepadManager" {
  39260. import { Observable } from "babylonjs/Misc/observable";
  39261. import { Nullable } from "babylonjs/types";
  39262. import { Scene } from "babylonjs/scene";
  39263. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39264. /**
  39265. * Manager for handling gamepads
  39266. */
  39267. export class GamepadManager {
  39268. private _scene?;
  39269. private _babylonGamepads;
  39270. private _oneGamepadConnected;
  39271. /** @hidden */
  39272. _isMonitoring: boolean;
  39273. private _gamepadEventSupported;
  39274. private _gamepadSupport;
  39275. /**
  39276. * observable to be triggered when the gamepad controller has been connected
  39277. */
  39278. onGamepadConnectedObservable: Observable<Gamepad>;
  39279. /**
  39280. * observable to be triggered when the gamepad controller has been disconnected
  39281. */
  39282. onGamepadDisconnectedObservable: Observable<Gamepad>;
  39283. private _onGamepadConnectedEvent;
  39284. private _onGamepadDisconnectedEvent;
  39285. /**
  39286. * Initializes the gamepad manager
  39287. * @param _scene BabylonJS scene
  39288. */
  39289. constructor(_scene?: Scene | undefined);
  39290. /**
  39291. * The gamepads in the game pad manager
  39292. */
  39293. readonly gamepads: Gamepad[];
  39294. /**
  39295. * Get the gamepad controllers based on type
  39296. * @param type The type of gamepad controller
  39297. * @returns Nullable gamepad
  39298. */
  39299. getGamepadByType(type?: number): Nullable<Gamepad>;
  39300. /**
  39301. * Disposes the gamepad manager
  39302. */
  39303. dispose(): void;
  39304. private _addNewGamepad;
  39305. private _startMonitoringGamepads;
  39306. private _stopMonitoringGamepads;
  39307. /** @hidden */
  39308. _checkGamepadsStatus(): void;
  39309. private _updateGamepadObjects;
  39310. }
  39311. }
  39312. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  39313. import { Nullable } from "babylonjs/types";
  39314. import { Scene } from "babylonjs/scene";
  39315. import { ISceneComponent } from "babylonjs/sceneComponent";
  39316. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  39317. module "babylonjs/scene" {
  39318. interface Scene {
  39319. /** @hidden */
  39320. _gamepadManager: Nullable<GamepadManager>;
  39321. /**
  39322. * Gets the gamepad manager associated with the scene
  39323. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  39324. */
  39325. gamepadManager: GamepadManager;
  39326. }
  39327. }
  39328. module "babylonjs/Cameras/freeCameraInputsManager" {
  39329. /**
  39330. * Interface representing a free camera inputs manager
  39331. */
  39332. interface FreeCameraInputsManager {
  39333. /**
  39334. * Adds gamepad input support to the FreeCameraInputsManager.
  39335. * @returns the FreeCameraInputsManager
  39336. */
  39337. addGamepad(): FreeCameraInputsManager;
  39338. }
  39339. }
  39340. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39341. /**
  39342. * Interface representing an arc rotate camera inputs manager
  39343. */
  39344. interface ArcRotateCameraInputsManager {
  39345. /**
  39346. * Adds gamepad input support to the ArcRotateCamera InputManager.
  39347. * @returns the camera inputs manager
  39348. */
  39349. addGamepad(): ArcRotateCameraInputsManager;
  39350. }
  39351. }
  39352. /**
  39353. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  39354. */
  39355. export class GamepadSystemSceneComponent implements ISceneComponent {
  39356. /**
  39357. * The component name helpfull to identify the component in the list of scene components.
  39358. */
  39359. readonly name: string;
  39360. /**
  39361. * The scene the component belongs to.
  39362. */
  39363. scene: Scene;
  39364. /**
  39365. * Creates a new instance of the component for the given scene
  39366. * @param scene Defines the scene to register the component in
  39367. */
  39368. constructor(scene: Scene);
  39369. /**
  39370. * Registers the component in a given scene
  39371. */
  39372. register(): void;
  39373. /**
  39374. * Rebuilds the elements related to this component in case of
  39375. * context lost for instance.
  39376. */
  39377. rebuild(): void;
  39378. /**
  39379. * Disposes the component and the associated ressources
  39380. */
  39381. dispose(): void;
  39382. private _beforeCameraUpdate;
  39383. }
  39384. }
  39385. declare module "babylonjs/Cameras/universalCamera" {
  39386. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  39387. import { Scene } from "babylonjs/scene";
  39388. import { Vector3 } from "babylonjs/Maths/math";
  39389. import "babylonjs/Gamepads/gamepadSceneComponent";
  39390. /**
  39391. * 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,
  39392. * which still works and will still be found in many Playgrounds.
  39393. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39394. */
  39395. export class UniversalCamera extends TouchCamera {
  39396. /**
  39397. * Defines the gamepad rotation sensiblity.
  39398. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39399. */
  39400. gamepadAngularSensibility: number;
  39401. /**
  39402. * Defines the gamepad move sensiblity.
  39403. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39404. */
  39405. gamepadMoveSensibility: number;
  39406. /**
  39407. * 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,
  39408. * which still works and will still be found in many Playgrounds.
  39409. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39410. * @param name Define the name of the camera in the scene
  39411. * @param position Define the start position of the camera in the scene
  39412. * @param scene Define the scene the camera belongs to
  39413. */
  39414. constructor(name: string, position: Vector3, scene: Scene);
  39415. /**
  39416. * Gets the current object class name.
  39417. * @return the class name
  39418. */
  39419. getClassName(): string;
  39420. }
  39421. }
  39422. declare module "babylonjs/Cameras/gamepadCamera" {
  39423. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  39424. import { Scene } from "babylonjs/scene";
  39425. import { Vector3 } from "babylonjs/Maths/math";
  39426. /**
  39427. * This represents a FPS type of camera. This is only here for back compat purpose.
  39428. * Please use the UniversalCamera instead as both are identical.
  39429. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39430. */
  39431. export class GamepadCamera extends UniversalCamera {
  39432. /**
  39433. * Instantiates a new Gamepad Camera
  39434. * This represents a FPS type of camera. This is only here for back compat purpose.
  39435. * Please use the UniversalCamera instead as both are identical.
  39436. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39437. * @param name Define the name of the camera in the scene
  39438. * @param position Define the start position of the camera in the scene
  39439. * @param scene Define the scene the camera belongs to
  39440. */
  39441. constructor(name: string, position: Vector3, scene: Scene);
  39442. /**
  39443. * Gets the current object class name.
  39444. * @return the class name
  39445. */
  39446. getClassName(): string;
  39447. }
  39448. }
  39449. declare module "babylonjs/Shaders/pass.fragment" {
  39450. /** @hidden */
  39451. export var passPixelShader: {
  39452. name: string;
  39453. shader: string;
  39454. };
  39455. }
  39456. declare module "babylonjs/Shaders/passCube.fragment" {
  39457. /** @hidden */
  39458. export var passCubePixelShader: {
  39459. name: string;
  39460. shader: string;
  39461. };
  39462. }
  39463. declare module "babylonjs/PostProcesses/passPostProcess" {
  39464. import { Nullable } from "babylonjs/types";
  39465. import { Camera } from "babylonjs/Cameras/camera";
  39466. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39467. import { Engine } from "babylonjs/Engines/engine";
  39468. import "babylonjs/Shaders/pass.fragment";
  39469. import "babylonjs/Shaders/passCube.fragment";
  39470. /**
  39471. * PassPostProcess which produces an output the same as it's input
  39472. */
  39473. export class PassPostProcess extends PostProcess {
  39474. /**
  39475. * Creates the PassPostProcess
  39476. * @param name The name of the effect.
  39477. * @param options The required width/height ratio to downsize to before computing the render pass.
  39478. * @param camera The camera to apply the render pass to.
  39479. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39480. * @param engine The engine which the post process will be applied. (default: current engine)
  39481. * @param reusable If the post process can be reused on the same frame. (default: false)
  39482. * @param textureType The type of texture to be used when performing the post processing.
  39483. * @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)
  39484. */
  39485. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39486. }
  39487. /**
  39488. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  39489. */
  39490. export class PassCubePostProcess extends PostProcess {
  39491. private _face;
  39492. /**
  39493. * Gets or sets the cube face to display.
  39494. * * 0 is +X
  39495. * * 1 is -X
  39496. * * 2 is +Y
  39497. * * 3 is -Y
  39498. * * 4 is +Z
  39499. * * 5 is -Z
  39500. */
  39501. face: number;
  39502. /**
  39503. * Creates the PassCubePostProcess
  39504. * @param name The name of the effect.
  39505. * @param options The required width/height ratio to downsize to before computing the render pass.
  39506. * @param camera The camera to apply the render pass to.
  39507. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39508. * @param engine The engine which the post process will be applied. (default: current engine)
  39509. * @param reusable If the post process can be reused on the same frame. (default: false)
  39510. * @param textureType The type of texture to be used when performing the post processing.
  39511. * @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)
  39512. */
  39513. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39514. }
  39515. }
  39516. declare module "babylonjs/Shaders/anaglyph.fragment" {
  39517. /** @hidden */
  39518. export var anaglyphPixelShader: {
  39519. name: string;
  39520. shader: string;
  39521. };
  39522. }
  39523. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  39524. import { Engine } from "babylonjs/Engines/engine";
  39525. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39526. import { Camera } from "babylonjs/Cameras/camera";
  39527. import "babylonjs/Shaders/anaglyph.fragment";
  39528. /**
  39529. * Postprocess used to generate anaglyphic rendering
  39530. */
  39531. export class AnaglyphPostProcess extends PostProcess {
  39532. private _passedProcess;
  39533. /**
  39534. * Creates a new AnaglyphPostProcess
  39535. * @param name defines postprocess name
  39536. * @param options defines creation options or target ratio scale
  39537. * @param rigCameras defines cameras using this postprocess
  39538. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  39539. * @param engine defines hosting engine
  39540. * @param reusable defines if the postprocess will be reused multiple times per frame
  39541. */
  39542. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  39543. }
  39544. }
  39545. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  39546. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  39547. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39548. import { Scene } from "babylonjs/scene";
  39549. import { Vector3 } from "babylonjs/Maths/math";
  39550. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39551. /**
  39552. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  39553. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39554. */
  39555. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  39556. /**
  39557. * Creates a new AnaglyphArcRotateCamera
  39558. * @param name defines camera name
  39559. * @param alpha defines alpha angle (in radians)
  39560. * @param beta defines beta angle (in radians)
  39561. * @param radius defines radius
  39562. * @param target defines camera target
  39563. * @param interaxialDistance defines distance between each color axis
  39564. * @param scene defines the hosting scene
  39565. */
  39566. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  39567. /**
  39568. * Gets camera class name
  39569. * @returns AnaglyphArcRotateCamera
  39570. */
  39571. getClassName(): string;
  39572. }
  39573. }
  39574. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  39575. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39576. import { Scene } from "babylonjs/scene";
  39577. import { Vector3 } from "babylonjs/Maths/math";
  39578. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39579. /**
  39580. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  39581. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39582. */
  39583. export class AnaglyphFreeCamera extends FreeCamera {
  39584. /**
  39585. * Creates a new AnaglyphFreeCamera
  39586. * @param name defines camera name
  39587. * @param position defines initial position
  39588. * @param interaxialDistance defines distance between each color axis
  39589. * @param scene defines the hosting scene
  39590. */
  39591. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39592. /**
  39593. * Gets camera class name
  39594. * @returns AnaglyphFreeCamera
  39595. */
  39596. getClassName(): string;
  39597. }
  39598. }
  39599. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  39600. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  39601. import { Scene } from "babylonjs/scene";
  39602. import { Vector3 } from "babylonjs/Maths/math";
  39603. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39604. /**
  39605. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  39606. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39607. */
  39608. export class AnaglyphGamepadCamera extends GamepadCamera {
  39609. /**
  39610. * Creates a new AnaglyphGamepadCamera
  39611. * @param name defines camera name
  39612. * @param position defines initial position
  39613. * @param interaxialDistance defines distance between each color axis
  39614. * @param scene defines the hosting scene
  39615. */
  39616. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39617. /**
  39618. * Gets camera class name
  39619. * @returns AnaglyphGamepadCamera
  39620. */
  39621. getClassName(): string;
  39622. }
  39623. }
  39624. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  39625. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  39626. import { Scene } from "babylonjs/scene";
  39627. import { Vector3 } from "babylonjs/Maths/math";
  39628. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39629. /**
  39630. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  39631. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39632. */
  39633. export class AnaglyphUniversalCamera extends UniversalCamera {
  39634. /**
  39635. * Creates a new AnaglyphUniversalCamera
  39636. * @param name defines camera name
  39637. * @param position defines initial position
  39638. * @param interaxialDistance defines distance between each color axis
  39639. * @param scene defines the hosting scene
  39640. */
  39641. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39642. /**
  39643. * Gets camera class name
  39644. * @returns AnaglyphUniversalCamera
  39645. */
  39646. getClassName(): string;
  39647. }
  39648. }
  39649. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  39650. /** @hidden */
  39651. export var stereoscopicInterlacePixelShader: {
  39652. name: string;
  39653. shader: string;
  39654. };
  39655. }
  39656. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  39657. import { Camera } from "babylonjs/Cameras/camera";
  39658. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39659. import { Engine } from "babylonjs/Engines/engine";
  39660. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  39661. /**
  39662. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  39663. */
  39664. export class StereoscopicInterlacePostProcess extends PostProcess {
  39665. private _stepSize;
  39666. private _passedProcess;
  39667. /**
  39668. * Initializes a StereoscopicInterlacePostProcess
  39669. * @param name The name of the effect.
  39670. * @param rigCameras The rig cameras to be appled to the post process
  39671. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  39672. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39673. * @param engine The engine which the post process will be applied. (default: current engine)
  39674. * @param reusable If the post process can be reused on the same frame. (default: false)
  39675. */
  39676. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  39677. }
  39678. }
  39679. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  39680. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  39681. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39682. import { Scene } from "babylonjs/scene";
  39683. import { Vector3 } from "babylonjs/Maths/math";
  39684. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39685. /**
  39686. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  39687. * @see http://doc.babylonjs.com/features/cameras
  39688. */
  39689. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  39690. /**
  39691. * Creates a new StereoscopicArcRotateCamera
  39692. * @param name defines camera name
  39693. * @param alpha defines alpha angle (in radians)
  39694. * @param beta defines beta angle (in radians)
  39695. * @param radius defines radius
  39696. * @param target defines camera target
  39697. * @param interaxialDistance defines distance between each color axis
  39698. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39699. * @param scene defines the hosting scene
  39700. */
  39701. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39702. /**
  39703. * Gets camera class name
  39704. * @returns StereoscopicArcRotateCamera
  39705. */
  39706. getClassName(): string;
  39707. }
  39708. }
  39709. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  39710. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39711. import { Scene } from "babylonjs/scene";
  39712. import { Vector3 } from "babylonjs/Maths/math";
  39713. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39714. /**
  39715. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  39716. * @see http://doc.babylonjs.com/features/cameras
  39717. */
  39718. export class StereoscopicFreeCamera extends FreeCamera {
  39719. /**
  39720. * Creates a new StereoscopicFreeCamera
  39721. * @param name defines camera name
  39722. * @param position defines initial position
  39723. * @param interaxialDistance defines distance between each color axis
  39724. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39725. * @param scene defines the hosting scene
  39726. */
  39727. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39728. /**
  39729. * Gets camera class name
  39730. * @returns StereoscopicFreeCamera
  39731. */
  39732. getClassName(): string;
  39733. }
  39734. }
  39735. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  39736. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  39737. import { Scene } from "babylonjs/scene";
  39738. import { Vector3 } from "babylonjs/Maths/math";
  39739. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39740. /**
  39741. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  39742. * @see http://doc.babylonjs.com/features/cameras
  39743. */
  39744. export class StereoscopicGamepadCamera extends GamepadCamera {
  39745. /**
  39746. * Creates a new StereoscopicGamepadCamera
  39747. * @param name defines camera name
  39748. * @param position defines initial position
  39749. * @param interaxialDistance defines distance between each color axis
  39750. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39751. * @param scene defines the hosting scene
  39752. */
  39753. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39754. /**
  39755. * Gets camera class name
  39756. * @returns StereoscopicGamepadCamera
  39757. */
  39758. getClassName(): string;
  39759. }
  39760. }
  39761. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  39762. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  39763. import { Scene } from "babylonjs/scene";
  39764. import { Vector3 } from "babylonjs/Maths/math";
  39765. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39766. /**
  39767. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  39768. * @see http://doc.babylonjs.com/features/cameras
  39769. */
  39770. export class StereoscopicUniversalCamera extends UniversalCamera {
  39771. /**
  39772. * Creates a new StereoscopicUniversalCamera
  39773. * @param name defines camera name
  39774. * @param position defines initial position
  39775. * @param interaxialDistance defines distance between each color axis
  39776. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39777. * @param scene defines the hosting scene
  39778. */
  39779. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39780. /**
  39781. * Gets camera class name
  39782. * @returns StereoscopicUniversalCamera
  39783. */
  39784. getClassName(): string;
  39785. }
  39786. }
  39787. declare module "babylonjs/Cameras/Stereoscopic/index" {
  39788. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  39789. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  39790. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  39791. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  39792. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  39793. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  39794. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  39795. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  39796. }
  39797. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  39798. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39799. import { Scene } from "babylonjs/scene";
  39800. import { Vector3 } from "babylonjs/Maths/math";
  39801. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  39802. /**
  39803. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  39804. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39805. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39806. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39807. */
  39808. export class VirtualJoysticksCamera extends FreeCamera {
  39809. /**
  39810. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  39811. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39812. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39813. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39814. * @param name Define the name of the camera in the scene
  39815. * @param position Define the start position of the camera in the scene
  39816. * @param scene Define the scene the camera belongs to
  39817. */
  39818. constructor(name: string, position: Vector3, scene: Scene);
  39819. /**
  39820. * Gets the current object class name.
  39821. * @return the class name
  39822. */
  39823. getClassName(): string;
  39824. }
  39825. }
  39826. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  39827. import { Matrix } from "babylonjs/Maths/math";
  39828. /**
  39829. * This represents all the required metrics to create a VR camera.
  39830. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  39831. */
  39832. export class VRCameraMetrics {
  39833. /**
  39834. * Define the horizontal resolution off the screen.
  39835. */
  39836. hResolution: number;
  39837. /**
  39838. * Define the vertical resolution off the screen.
  39839. */
  39840. vResolution: number;
  39841. /**
  39842. * Define the horizontal screen size.
  39843. */
  39844. hScreenSize: number;
  39845. /**
  39846. * Define the vertical screen size.
  39847. */
  39848. vScreenSize: number;
  39849. /**
  39850. * Define the vertical screen center position.
  39851. */
  39852. vScreenCenter: number;
  39853. /**
  39854. * Define the distance of the eyes to the screen.
  39855. */
  39856. eyeToScreenDistance: number;
  39857. /**
  39858. * Define the distance between both lenses
  39859. */
  39860. lensSeparationDistance: number;
  39861. /**
  39862. * Define the distance between both viewer's eyes.
  39863. */
  39864. interpupillaryDistance: number;
  39865. /**
  39866. * Define the distortion factor of the VR postprocess.
  39867. * Please, touch with care.
  39868. */
  39869. distortionK: number[];
  39870. /**
  39871. * Define the chromatic aberration correction factors for the VR post process.
  39872. */
  39873. chromaAbCorrection: number[];
  39874. /**
  39875. * Define the scale factor of the post process.
  39876. * The smaller the better but the slower.
  39877. */
  39878. postProcessScaleFactor: number;
  39879. /**
  39880. * Define an offset for the lens center.
  39881. */
  39882. lensCenterOffset: number;
  39883. /**
  39884. * Define if the current vr camera should compensate the distortion of the lense or not.
  39885. */
  39886. compensateDistortion: boolean;
  39887. /**
  39888. * Defines if multiview should be enabled when rendering (Default: false)
  39889. */
  39890. multiviewEnabled: boolean;
  39891. /**
  39892. * Gets the rendering aspect ratio based on the provided resolutions.
  39893. */
  39894. readonly aspectRatio: number;
  39895. /**
  39896. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  39897. */
  39898. readonly aspectRatioFov: number;
  39899. /**
  39900. * @hidden
  39901. */
  39902. readonly leftHMatrix: Matrix;
  39903. /**
  39904. * @hidden
  39905. */
  39906. readonly rightHMatrix: Matrix;
  39907. /**
  39908. * @hidden
  39909. */
  39910. readonly leftPreViewMatrix: Matrix;
  39911. /**
  39912. * @hidden
  39913. */
  39914. readonly rightPreViewMatrix: Matrix;
  39915. /**
  39916. * Get the default VRMetrics based on the most generic setup.
  39917. * @returns the default vr metrics
  39918. */
  39919. static GetDefault(): VRCameraMetrics;
  39920. }
  39921. }
  39922. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  39923. /** @hidden */
  39924. export var vrDistortionCorrectionPixelShader: {
  39925. name: string;
  39926. shader: string;
  39927. };
  39928. }
  39929. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  39930. import { Camera } from "babylonjs/Cameras/camera";
  39931. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39932. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39933. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  39934. /**
  39935. * VRDistortionCorrectionPostProcess used for mobile VR
  39936. */
  39937. export class VRDistortionCorrectionPostProcess extends PostProcess {
  39938. private _isRightEye;
  39939. private _distortionFactors;
  39940. private _postProcessScaleFactor;
  39941. private _lensCenterOffset;
  39942. private _scaleIn;
  39943. private _scaleFactor;
  39944. private _lensCenter;
  39945. /**
  39946. * Initializes the VRDistortionCorrectionPostProcess
  39947. * @param name The name of the effect.
  39948. * @param camera The camera to apply the render pass to.
  39949. * @param isRightEye If this is for the right eye distortion
  39950. * @param vrMetrics All the required metrics for the VR camera
  39951. */
  39952. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  39953. }
  39954. }
  39955. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  39956. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  39957. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39958. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39959. import { Scene } from "babylonjs/scene";
  39960. import { Vector3 } from "babylonjs/Maths/math";
  39961. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  39962. import "babylonjs/Cameras/RigModes/vrRigMode";
  39963. /**
  39964. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  39965. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39966. */
  39967. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  39968. /**
  39969. * Creates a new VRDeviceOrientationArcRotateCamera
  39970. * @param name defines camera name
  39971. * @param alpha defines the camera rotation along the logitudinal axis
  39972. * @param beta defines the camera rotation along the latitudinal axis
  39973. * @param radius defines the camera distance from its target
  39974. * @param target defines the camera target
  39975. * @param scene defines the scene the camera belongs to
  39976. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39977. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39978. */
  39979. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39980. /**
  39981. * Gets camera class name
  39982. * @returns VRDeviceOrientationArcRotateCamera
  39983. */
  39984. getClassName(): string;
  39985. }
  39986. }
  39987. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  39988. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  39989. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39990. import { Scene } from "babylonjs/scene";
  39991. import { Vector3 } from "babylonjs/Maths/math";
  39992. import "babylonjs/Cameras/RigModes/vrRigMode";
  39993. /**
  39994. * Camera used to simulate VR rendering (based on FreeCamera)
  39995. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39996. */
  39997. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  39998. /**
  39999. * Creates a new VRDeviceOrientationFreeCamera
  40000. * @param name defines camera name
  40001. * @param position defines the start position of the camera
  40002. * @param scene defines the scene the camera belongs to
  40003. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40004. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40005. */
  40006. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40007. /**
  40008. * Gets camera class name
  40009. * @returns VRDeviceOrientationFreeCamera
  40010. */
  40011. getClassName(): string;
  40012. }
  40013. }
  40014. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  40015. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40016. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40017. import { Scene } from "babylonjs/scene";
  40018. import { Vector3 } from "babylonjs/Maths/math";
  40019. import "babylonjs/Gamepads/gamepadSceneComponent";
  40020. /**
  40021. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  40022. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40023. */
  40024. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  40025. /**
  40026. * Creates a new VRDeviceOrientationGamepadCamera
  40027. * @param name defines camera name
  40028. * @param position defines the start position of the camera
  40029. * @param scene defines the scene the camera belongs to
  40030. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40031. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40032. */
  40033. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40034. /**
  40035. * Gets camera class name
  40036. * @returns VRDeviceOrientationGamepadCamera
  40037. */
  40038. getClassName(): string;
  40039. }
  40040. }
  40041. declare module "babylonjs/Materials/pushMaterial" {
  40042. import { Nullable } from "babylonjs/types";
  40043. import { Scene } from "babylonjs/scene";
  40044. import { Matrix } from "babylonjs/Maths/math";
  40045. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40046. import { Mesh } from "babylonjs/Meshes/mesh";
  40047. import { Material } from "babylonjs/Materials/material";
  40048. import { Effect } from "babylonjs/Materials/effect";
  40049. /**
  40050. * Base class of materials working in push mode in babylon JS
  40051. * @hidden
  40052. */
  40053. export class PushMaterial extends Material {
  40054. protected _activeEffect: Effect;
  40055. protected _normalMatrix: Matrix;
  40056. /**
  40057. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  40058. * This means that the material can keep using a previous shader while a new one is being compiled.
  40059. * This is mostly used when shader parallel compilation is supported (true by default)
  40060. */
  40061. allowShaderHotSwapping: boolean;
  40062. constructor(name: string, scene: Scene);
  40063. getEffect(): Effect;
  40064. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  40065. /**
  40066. * Binds the given world matrix to the active effect
  40067. *
  40068. * @param world the matrix to bind
  40069. */
  40070. bindOnlyWorldMatrix(world: Matrix): void;
  40071. /**
  40072. * Binds the given normal matrix to the active effect
  40073. *
  40074. * @param normalMatrix the matrix to bind
  40075. */
  40076. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  40077. bind(world: Matrix, mesh?: Mesh): void;
  40078. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  40079. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  40080. }
  40081. }
  40082. declare module "babylonjs/Materials/materialFlags" {
  40083. /**
  40084. * This groups all the flags used to control the materials channel.
  40085. */
  40086. export class MaterialFlags {
  40087. private static _DiffuseTextureEnabled;
  40088. /**
  40089. * Are diffuse textures enabled in the application.
  40090. */
  40091. static DiffuseTextureEnabled: boolean;
  40092. private static _AmbientTextureEnabled;
  40093. /**
  40094. * Are ambient textures enabled in the application.
  40095. */
  40096. static AmbientTextureEnabled: boolean;
  40097. private static _OpacityTextureEnabled;
  40098. /**
  40099. * Are opacity textures enabled in the application.
  40100. */
  40101. static OpacityTextureEnabled: boolean;
  40102. private static _ReflectionTextureEnabled;
  40103. /**
  40104. * Are reflection textures enabled in the application.
  40105. */
  40106. static ReflectionTextureEnabled: boolean;
  40107. private static _EmissiveTextureEnabled;
  40108. /**
  40109. * Are emissive textures enabled in the application.
  40110. */
  40111. static EmissiveTextureEnabled: boolean;
  40112. private static _SpecularTextureEnabled;
  40113. /**
  40114. * Are specular textures enabled in the application.
  40115. */
  40116. static SpecularTextureEnabled: boolean;
  40117. private static _BumpTextureEnabled;
  40118. /**
  40119. * Are bump textures enabled in the application.
  40120. */
  40121. static BumpTextureEnabled: boolean;
  40122. private static _LightmapTextureEnabled;
  40123. /**
  40124. * Are lightmap textures enabled in the application.
  40125. */
  40126. static LightmapTextureEnabled: boolean;
  40127. private static _RefractionTextureEnabled;
  40128. /**
  40129. * Are refraction textures enabled in the application.
  40130. */
  40131. static RefractionTextureEnabled: boolean;
  40132. private static _ColorGradingTextureEnabled;
  40133. /**
  40134. * Are color grading textures enabled in the application.
  40135. */
  40136. static ColorGradingTextureEnabled: boolean;
  40137. private static _FresnelEnabled;
  40138. /**
  40139. * Are fresnels enabled in the application.
  40140. */
  40141. static FresnelEnabled: boolean;
  40142. private static _ClearCoatTextureEnabled;
  40143. /**
  40144. * Are clear coat textures enabled in the application.
  40145. */
  40146. static ClearCoatTextureEnabled: boolean;
  40147. private static _ClearCoatBumpTextureEnabled;
  40148. /**
  40149. * Are clear coat bump textures enabled in the application.
  40150. */
  40151. static ClearCoatBumpTextureEnabled: boolean;
  40152. private static _ClearCoatTintTextureEnabled;
  40153. /**
  40154. * Are clear coat tint textures enabled in the application.
  40155. */
  40156. static ClearCoatTintTextureEnabled: boolean;
  40157. private static _SheenTextureEnabled;
  40158. /**
  40159. * Are sheen textures enabled in the application.
  40160. */
  40161. static SheenTextureEnabled: boolean;
  40162. private static _AnisotropicTextureEnabled;
  40163. /**
  40164. * Are anisotropic textures enabled in the application.
  40165. */
  40166. static AnisotropicTextureEnabled: boolean;
  40167. private static _ThicknessTextureEnabled;
  40168. /**
  40169. * Are thickness textures enabled in the application.
  40170. */
  40171. static ThicknessTextureEnabled: boolean;
  40172. }
  40173. }
  40174. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  40175. /** @hidden */
  40176. export var defaultFragmentDeclaration: {
  40177. name: string;
  40178. shader: string;
  40179. };
  40180. }
  40181. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  40182. /** @hidden */
  40183. export var defaultUboDeclaration: {
  40184. name: string;
  40185. shader: string;
  40186. };
  40187. }
  40188. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  40189. /** @hidden */
  40190. export var lightFragmentDeclaration: {
  40191. name: string;
  40192. shader: string;
  40193. };
  40194. }
  40195. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  40196. /** @hidden */
  40197. export var lightUboDeclaration: {
  40198. name: string;
  40199. shader: string;
  40200. };
  40201. }
  40202. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  40203. /** @hidden */
  40204. export var lightsFragmentFunctions: {
  40205. name: string;
  40206. shader: string;
  40207. };
  40208. }
  40209. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  40210. /** @hidden */
  40211. export var shadowsFragmentFunctions: {
  40212. name: string;
  40213. shader: string;
  40214. };
  40215. }
  40216. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  40217. /** @hidden */
  40218. export var fresnelFunction: {
  40219. name: string;
  40220. shader: string;
  40221. };
  40222. }
  40223. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  40224. /** @hidden */
  40225. export var reflectionFunction: {
  40226. name: string;
  40227. shader: string;
  40228. };
  40229. }
  40230. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  40231. /** @hidden */
  40232. export var bumpFragmentFunctions: {
  40233. name: string;
  40234. shader: string;
  40235. };
  40236. }
  40237. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  40238. /** @hidden */
  40239. export var logDepthDeclaration: {
  40240. name: string;
  40241. shader: string;
  40242. };
  40243. }
  40244. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  40245. /** @hidden */
  40246. export var bumpFragment: {
  40247. name: string;
  40248. shader: string;
  40249. };
  40250. }
  40251. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  40252. /** @hidden */
  40253. export var depthPrePass: {
  40254. name: string;
  40255. shader: string;
  40256. };
  40257. }
  40258. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  40259. /** @hidden */
  40260. export var lightFragment: {
  40261. name: string;
  40262. shader: string;
  40263. };
  40264. }
  40265. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  40266. /** @hidden */
  40267. export var logDepthFragment: {
  40268. name: string;
  40269. shader: string;
  40270. };
  40271. }
  40272. declare module "babylonjs/Shaders/default.fragment" {
  40273. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  40274. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  40275. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40276. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  40277. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  40278. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  40279. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  40280. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  40281. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  40282. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  40283. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  40284. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  40285. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  40286. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  40287. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  40288. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  40289. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  40290. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  40291. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  40292. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  40293. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  40294. /** @hidden */
  40295. export var defaultPixelShader: {
  40296. name: string;
  40297. shader: string;
  40298. };
  40299. }
  40300. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  40301. /** @hidden */
  40302. export var defaultVertexDeclaration: {
  40303. name: string;
  40304. shader: string;
  40305. };
  40306. }
  40307. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  40308. /** @hidden */
  40309. export var bumpVertexDeclaration: {
  40310. name: string;
  40311. shader: string;
  40312. };
  40313. }
  40314. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  40315. /** @hidden */
  40316. export var bumpVertex: {
  40317. name: string;
  40318. shader: string;
  40319. };
  40320. }
  40321. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  40322. /** @hidden */
  40323. export var fogVertex: {
  40324. name: string;
  40325. shader: string;
  40326. };
  40327. }
  40328. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  40329. /** @hidden */
  40330. export var shadowsVertex: {
  40331. name: string;
  40332. shader: string;
  40333. };
  40334. }
  40335. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  40336. /** @hidden */
  40337. export var pointCloudVertex: {
  40338. name: string;
  40339. shader: string;
  40340. };
  40341. }
  40342. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  40343. /** @hidden */
  40344. export var logDepthVertex: {
  40345. name: string;
  40346. shader: string;
  40347. };
  40348. }
  40349. declare module "babylonjs/Shaders/default.vertex" {
  40350. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  40351. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  40352. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40353. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  40354. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  40355. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  40356. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  40357. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  40358. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  40359. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  40360. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  40361. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  40362. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  40363. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  40364. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  40365. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  40366. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  40367. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  40368. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  40369. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  40370. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  40371. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  40372. /** @hidden */
  40373. export var defaultVertexShader: {
  40374. name: string;
  40375. shader: string;
  40376. };
  40377. }
  40378. declare module "babylonjs/Materials/standardMaterial" {
  40379. import { SmartArray } from "babylonjs/Misc/smartArray";
  40380. import { IAnimatable } from "babylonjs/Misc/tools";
  40381. import { Nullable } from "babylonjs/types";
  40382. import { Scene } from "babylonjs/scene";
  40383. import { Matrix, Color3 } from "babylonjs/Maths/math";
  40384. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40385. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40386. import { Mesh } from "babylonjs/Meshes/mesh";
  40387. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  40388. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  40389. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  40390. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  40391. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  40392. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40393. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  40394. import "babylonjs/Shaders/default.fragment";
  40395. import "babylonjs/Shaders/default.vertex";
  40396. /** @hidden */
  40397. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  40398. MAINUV1: boolean;
  40399. MAINUV2: boolean;
  40400. DIFFUSE: boolean;
  40401. DIFFUSEDIRECTUV: number;
  40402. AMBIENT: boolean;
  40403. AMBIENTDIRECTUV: number;
  40404. OPACITY: boolean;
  40405. OPACITYDIRECTUV: number;
  40406. OPACITYRGB: boolean;
  40407. REFLECTION: boolean;
  40408. EMISSIVE: boolean;
  40409. EMISSIVEDIRECTUV: number;
  40410. SPECULAR: boolean;
  40411. SPECULARDIRECTUV: number;
  40412. BUMP: boolean;
  40413. BUMPDIRECTUV: number;
  40414. PARALLAX: boolean;
  40415. PARALLAXOCCLUSION: boolean;
  40416. SPECULAROVERALPHA: boolean;
  40417. CLIPPLANE: boolean;
  40418. CLIPPLANE2: boolean;
  40419. CLIPPLANE3: boolean;
  40420. CLIPPLANE4: boolean;
  40421. ALPHATEST: boolean;
  40422. DEPTHPREPASS: boolean;
  40423. ALPHAFROMDIFFUSE: boolean;
  40424. POINTSIZE: boolean;
  40425. FOG: boolean;
  40426. SPECULARTERM: boolean;
  40427. DIFFUSEFRESNEL: boolean;
  40428. OPACITYFRESNEL: boolean;
  40429. REFLECTIONFRESNEL: boolean;
  40430. REFRACTIONFRESNEL: boolean;
  40431. EMISSIVEFRESNEL: boolean;
  40432. FRESNEL: boolean;
  40433. NORMAL: boolean;
  40434. UV1: boolean;
  40435. UV2: boolean;
  40436. VERTEXCOLOR: boolean;
  40437. VERTEXALPHA: boolean;
  40438. NUM_BONE_INFLUENCERS: number;
  40439. BonesPerMesh: number;
  40440. BONETEXTURE: boolean;
  40441. INSTANCES: boolean;
  40442. GLOSSINESS: boolean;
  40443. ROUGHNESS: boolean;
  40444. EMISSIVEASILLUMINATION: boolean;
  40445. LINKEMISSIVEWITHDIFFUSE: boolean;
  40446. REFLECTIONFRESNELFROMSPECULAR: boolean;
  40447. LIGHTMAP: boolean;
  40448. LIGHTMAPDIRECTUV: number;
  40449. OBJECTSPACE_NORMALMAP: boolean;
  40450. USELIGHTMAPASSHADOWMAP: boolean;
  40451. REFLECTIONMAP_3D: boolean;
  40452. REFLECTIONMAP_SPHERICAL: boolean;
  40453. REFLECTIONMAP_PLANAR: boolean;
  40454. REFLECTIONMAP_CUBIC: boolean;
  40455. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  40456. REFLECTIONMAP_PROJECTION: boolean;
  40457. REFLECTIONMAP_SKYBOX: boolean;
  40458. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  40459. REFLECTIONMAP_EXPLICIT: boolean;
  40460. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  40461. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  40462. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  40463. INVERTCUBICMAP: boolean;
  40464. LOGARITHMICDEPTH: boolean;
  40465. REFRACTION: boolean;
  40466. REFRACTIONMAP_3D: boolean;
  40467. REFLECTIONOVERALPHA: boolean;
  40468. TWOSIDEDLIGHTING: boolean;
  40469. SHADOWFLOAT: boolean;
  40470. MORPHTARGETS: boolean;
  40471. MORPHTARGETS_NORMAL: boolean;
  40472. MORPHTARGETS_TANGENT: boolean;
  40473. MORPHTARGETS_UV: boolean;
  40474. NUM_MORPH_INFLUENCERS: number;
  40475. NONUNIFORMSCALING: boolean;
  40476. PREMULTIPLYALPHA: boolean;
  40477. IMAGEPROCESSING: boolean;
  40478. VIGNETTE: boolean;
  40479. VIGNETTEBLENDMODEMULTIPLY: boolean;
  40480. VIGNETTEBLENDMODEOPAQUE: boolean;
  40481. TONEMAPPING: boolean;
  40482. TONEMAPPING_ACES: boolean;
  40483. CONTRAST: boolean;
  40484. COLORCURVES: boolean;
  40485. COLORGRADING: boolean;
  40486. COLORGRADING3D: boolean;
  40487. SAMPLER3DGREENDEPTH: boolean;
  40488. SAMPLER3DBGRMAP: boolean;
  40489. IMAGEPROCESSINGPOSTPROCESS: boolean;
  40490. MULTIVIEW: boolean;
  40491. /**
  40492. * If the reflection texture on this material is in linear color space
  40493. * @hidden
  40494. */
  40495. IS_REFLECTION_LINEAR: boolean;
  40496. /**
  40497. * If the refraction texture on this material is in linear color space
  40498. * @hidden
  40499. */
  40500. IS_REFRACTION_LINEAR: boolean;
  40501. EXPOSURE: boolean;
  40502. constructor();
  40503. setReflectionMode(modeToEnable: string): void;
  40504. }
  40505. /**
  40506. * This is the default material used in Babylon. It is the best trade off between quality
  40507. * and performances.
  40508. * @see http://doc.babylonjs.com/babylon101/materials
  40509. */
  40510. export class StandardMaterial extends PushMaterial {
  40511. private _diffuseTexture;
  40512. /**
  40513. * The basic texture of the material as viewed under a light.
  40514. */
  40515. diffuseTexture: Nullable<BaseTexture>;
  40516. private _ambientTexture;
  40517. /**
  40518. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  40519. */
  40520. ambientTexture: Nullable<BaseTexture>;
  40521. private _opacityTexture;
  40522. /**
  40523. * Define the transparency of the material from a texture.
  40524. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  40525. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  40526. */
  40527. opacityTexture: Nullable<BaseTexture>;
  40528. private _reflectionTexture;
  40529. /**
  40530. * Define the texture used to display the reflection.
  40531. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40532. */
  40533. reflectionTexture: Nullable<BaseTexture>;
  40534. private _emissiveTexture;
  40535. /**
  40536. * Define texture of the material as if self lit.
  40537. * This will be mixed in the final result even in the absence of light.
  40538. */
  40539. emissiveTexture: Nullable<BaseTexture>;
  40540. private _specularTexture;
  40541. /**
  40542. * Define how the color and intensity of the highlight given by the light in the material.
  40543. */
  40544. specularTexture: Nullable<BaseTexture>;
  40545. private _bumpTexture;
  40546. /**
  40547. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  40548. * 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.
  40549. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  40550. */
  40551. bumpTexture: Nullable<BaseTexture>;
  40552. private _lightmapTexture;
  40553. /**
  40554. * Complex lighting can be computationally expensive to compute at runtime.
  40555. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  40556. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  40557. */
  40558. lightmapTexture: Nullable<BaseTexture>;
  40559. private _refractionTexture;
  40560. /**
  40561. * Define the texture used to display the refraction.
  40562. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40563. */
  40564. refractionTexture: Nullable<BaseTexture>;
  40565. /**
  40566. * The color of the material lit by the environmental background lighting.
  40567. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  40568. */
  40569. ambientColor: Color3;
  40570. /**
  40571. * The basic color of the material as viewed under a light.
  40572. */
  40573. diffuseColor: Color3;
  40574. /**
  40575. * Define how the color and intensity of the highlight given by the light in the material.
  40576. */
  40577. specularColor: Color3;
  40578. /**
  40579. * Define the color of the material as if self lit.
  40580. * This will be mixed in the final result even in the absence of light.
  40581. */
  40582. emissiveColor: Color3;
  40583. /**
  40584. * Defines how sharp are the highlights in the material.
  40585. * The bigger the value the sharper giving a more glossy feeling to the result.
  40586. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  40587. */
  40588. specularPower: number;
  40589. private _useAlphaFromDiffuseTexture;
  40590. /**
  40591. * Does the transparency come from the diffuse texture alpha channel.
  40592. */
  40593. useAlphaFromDiffuseTexture: boolean;
  40594. private _useEmissiveAsIllumination;
  40595. /**
  40596. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  40597. */
  40598. useEmissiveAsIllumination: boolean;
  40599. private _linkEmissiveWithDiffuse;
  40600. /**
  40601. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  40602. * the emissive level when the final color is close to one.
  40603. */
  40604. linkEmissiveWithDiffuse: boolean;
  40605. private _useSpecularOverAlpha;
  40606. /**
  40607. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  40608. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  40609. */
  40610. useSpecularOverAlpha: boolean;
  40611. private _useReflectionOverAlpha;
  40612. /**
  40613. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  40614. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  40615. */
  40616. useReflectionOverAlpha: boolean;
  40617. private _disableLighting;
  40618. /**
  40619. * Does lights from the scene impacts this material.
  40620. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  40621. */
  40622. disableLighting: boolean;
  40623. private _useObjectSpaceNormalMap;
  40624. /**
  40625. * Allows using an object space normal map (instead of tangent space).
  40626. */
  40627. useObjectSpaceNormalMap: boolean;
  40628. private _useParallax;
  40629. /**
  40630. * Is parallax enabled or not.
  40631. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40632. */
  40633. useParallax: boolean;
  40634. private _useParallaxOcclusion;
  40635. /**
  40636. * Is parallax occlusion enabled or not.
  40637. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  40638. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40639. */
  40640. useParallaxOcclusion: boolean;
  40641. /**
  40642. * 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.
  40643. */
  40644. parallaxScaleBias: number;
  40645. private _roughness;
  40646. /**
  40647. * Helps to define how blurry the reflections should appears in the material.
  40648. */
  40649. roughness: number;
  40650. /**
  40651. * In case of refraction, define the value of the index of refraction.
  40652. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40653. */
  40654. indexOfRefraction: number;
  40655. /**
  40656. * Invert the refraction texture alongside the y axis.
  40657. * It can be useful with procedural textures or probe for instance.
  40658. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40659. */
  40660. invertRefractionY: boolean;
  40661. /**
  40662. * Defines the alpha limits in alpha test mode.
  40663. */
  40664. alphaCutOff: number;
  40665. private _useLightmapAsShadowmap;
  40666. /**
  40667. * In case of light mapping, define whether the map contains light or shadow informations.
  40668. */
  40669. useLightmapAsShadowmap: boolean;
  40670. private _diffuseFresnelParameters;
  40671. /**
  40672. * Define the diffuse fresnel parameters of the material.
  40673. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40674. */
  40675. diffuseFresnelParameters: FresnelParameters;
  40676. private _opacityFresnelParameters;
  40677. /**
  40678. * Define the opacity fresnel parameters of the material.
  40679. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40680. */
  40681. opacityFresnelParameters: FresnelParameters;
  40682. private _reflectionFresnelParameters;
  40683. /**
  40684. * Define the reflection fresnel parameters of the material.
  40685. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40686. */
  40687. reflectionFresnelParameters: FresnelParameters;
  40688. private _refractionFresnelParameters;
  40689. /**
  40690. * Define the refraction fresnel parameters of the material.
  40691. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40692. */
  40693. refractionFresnelParameters: FresnelParameters;
  40694. private _emissiveFresnelParameters;
  40695. /**
  40696. * Define the emissive fresnel parameters of the material.
  40697. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40698. */
  40699. emissiveFresnelParameters: FresnelParameters;
  40700. private _useReflectionFresnelFromSpecular;
  40701. /**
  40702. * If true automatically deducts the fresnels values from the material specularity.
  40703. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40704. */
  40705. useReflectionFresnelFromSpecular: boolean;
  40706. private _useGlossinessFromSpecularMapAlpha;
  40707. /**
  40708. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  40709. */
  40710. useGlossinessFromSpecularMapAlpha: boolean;
  40711. private _maxSimultaneousLights;
  40712. /**
  40713. * Defines the maximum number of lights that can be used in the material
  40714. */
  40715. maxSimultaneousLights: number;
  40716. private _invertNormalMapX;
  40717. /**
  40718. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  40719. */
  40720. invertNormalMapX: boolean;
  40721. private _invertNormalMapY;
  40722. /**
  40723. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  40724. */
  40725. invertNormalMapY: boolean;
  40726. private _twoSidedLighting;
  40727. /**
  40728. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  40729. */
  40730. twoSidedLighting: boolean;
  40731. /**
  40732. * Default configuration related to image processing available in the standard Material.
  40733. */
  40734. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40735. /**
  40736. * Gets the image processing configuration used either in this material.
  40737. */
  40738. /**
  40739. * Sets the Default image processing configuration used either in the this material.
  40740. *
  40741. * If sets to null, the scene one is in use.
  40742. */
  40743. imageProcessingConfiguration: ImageProcessingConfiguration;
  40744. /**
  40745. * Keep track of the image processing observer to allow dispose and replace.
  40746. */
  40747. private _imageProcessingObserver;
  40748. /**
  40749. * Attaches a new image processing configuration to the Standard Material.
  40750. * @param configuration
  40751. */
  40752. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  40753. /**
  40754. * Gets wether the color curves effect is enabled.
  40755. */
  40756. /**
  40757. * Sets wether the color curves effect is enabled.
  40758. */
  40759. cameraColorCurvesEnabled: boolean;
  40760. /**
  40761. * Gets wether the color grading effect is enabled.
  40762. */
  40763. /**
  40764. * Gets wether the color grading effect is enabled.
  40765. */
  40766. cameraColorGradingEnabled: boolean;
  40767. /**
  40768. * Gets wether tonemapping is enabled or not.
  40769. */
  40770. /**
  40771. * Sets wether tonemapping is enabled or not
  40772. */
  40773. cameraToneMappingEnabled: boolean;
  40774. /**
  40775. * The camera exposure used on this material.
  40776. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40777. * This corresponds to a photographic exposure.
  40778. */
  40779. /**
  40780. * The camera exposure used on this material.
  40781. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40782. * This corresponds to a photographic exposure.
  40783. */
  40784. cameraExposure: number;
  40785. /**
  40786. * Gets The camera contrast used on this material.
  40787. */
  40788. /**
  40789. * Sets The camera contrast used on this material.
  40790. */
  40791. cameraContrast: number;
  40792. /**
  40793. * Gets the Color Grading 2D Lookup Texture.
  40794. */
  40795. /**
  40796. * Sets the Color Grading 2D Lookup Texture.
  40797. */
  40798. cameraColorGradingTexture: Nullable<BaseTexture>;
  40799. /**
  40800. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40801. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40802. * 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;
  40803. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40804. */
  40805. /**
  40806. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40807. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40808. * 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;
  40809. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40810. */
  40811. cameraColorCurves: Nullable<ColorCurves>;
  40812. /**
  40813. * Custom callback helping to override the default shader used in the material.
  40814. */
  40815. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  40816. protected _renderTargets: SmartArray<RenderTargetTexture>;
  40817. protected _worldViewProjectionMatrix: Matrix;
  40818. protected _globalAmbientColor: Color3;
  40819. protected _useLogarithmicDepth: boolean;
  40820. /**
  40821. * Instantiates a new standard material.
  40822. * This is the default material used in Babylon. It is the best trade off between quality
  40823. * and performances.
  40824. * @see http://doc.babylonjs.com/babylon101/materials
  40825. * @param name Define the name of the material in the scene
  40826. * @param scene Define the scene the material belong to
  40827. */
  40828. constructor(name: string, scene: Scene);
  40829. /**
  40830. * Gets a boolean indicating that current material needs to register RTT
  40831. */
  40832. readonly hasRenderTargetTextures: boolean;
  40833. /**
  40834. * Gets the current class name of the material e.g. "StandardMaterial"
  40835. * Mainly use in serialization.
  40836. * @returns the class name
  40837. */
  40838. getClassName(): string;
  40839. /**
  40840. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  40841. * You can try switching to logarithmic depth.
  40842. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  40843. */
  40844. useLogarithmicDepth: boolean;
  40845. /**
  40846. * Specifies if the material will require alpha blending
  40847. * @returns a boolean specifying if alpha blending is needed
  40848. */
  40849. needAlphaBlending(): boolean;
  40850. /**
  40851. * Specifies if this material should be rendered in alpha test mode
  40852. * @returns a boolean specifying if an alpha test is needed.
  40853. */
  40854. needAlphaTesting(): boolean;
  40855. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  40856. /**
  40857. * Get the texture used for alpha test purpose.
  40858. * @returns the diffuse texture in case of the standard material.
  40859. */
  40860. getAlphaTestTexture(): Nullable<BaseTexture>;
  40861. /**
  40862. * Get if the submesh is ready to be used and all its information available.
  40863. * Child classes can use it to update shaders
  40864. * @param mesh defines the mesh to check
  40865. * @param subMesh defines which submesh to check
  40866. * @param useInstances specifies that instances should be used
  40867. * @returns a boolean indicating that the submesh is ready or not
  40868. */
  40869. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  40870. /**
  40871. * Builds the material UBO layouts.
  40872. * Used internally during the effect preparation.
  40873. */
  40874. buildUniformLayout(): void;
  40875. /**
  40876. * Unbinds the material from the mesh
  40877. */
  40878. unbind(): void;
  40879. /**
  40880. * Binds the submesh to this material by preparing the effect and shader to draw
  40881. * @param world defines the world transformation matrix
  40882. * @param mesh defines the mesh containing the submesh
  40883. * @param subMesh defines the submesh to bind the material to
  40884. */
  40885. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  40886. /**
  40887. * Get the list of animatables in the material.
  40888. * @returns the list of animatables object used in the material
  40889. */
  40890. getAnimatables(): IAnimatable[];
  40891. /**
  40892. * Gets the active textures from the material
  40893. * @returns an array of textures
  40894. */
  40895. getActiveTextures(): BaseTexture[];
  40896. /**
  40897. * Specifies if the material uses a texture
  40898. * @param texture defines the texture to check against the material
  40899. * @returns a boolean specifying if the material uses the texture
  40900. */
  40901. hasTexture(texture: BaseTexture): boolean;
  40902. /**
  40903. * Disposes the material
  40904. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  40905. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  40906. */
  40907. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  40908. /**
  40909. * Makes a duplicate of the material, and gives it a new name
  40910. * @param name defines the new name for the duplicated material
  40911. * @returns the cloned material
  40912. */
  40913. clone(name: string): StandardMaterial;
  40914. /**
  40915. * Serializes this material in a JSON representation
  40916. * @returns the serialized material object
  40917. */
  40918. serialize(): any;
  40919. /**
  40920. * Creates a standard material from parsed material data
  40921. * @param source defines the JSON representation of the material
  40922. * @param scene defines the hosting scene
  40923. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  40924. * @returns a new standard material
  40925. */
  40926. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  40927. /**
  40928. * Are diffuse textures enabled in the application.
  40929. */
  40930. static DiffuseTextureEnabled: boolean;
  40931. /**
  40932. * Are ambient textures enabled in the application.
  40933. */
  40934. static AmbientTextureEnabled: boolean;
  40935. /**
  40936. * Are opacity textures enabled in the application.
  40937. */
  40938. static OpacityTextureEnabled: boolean;
  40939. /**
  40940. * Are reflection textures enabled in the application.
  40941. */
  40942. static ReflectionTextureEnabled: boolean;
  40943. /**
  40944. * Are emissive textures enabled in the application.
  40945. */
  40946. static EmissiveTextureEnabled: boolean;
  40947. /**
  40948. * Are specular textures enabled in the application.
  40949. */
  40950. static SpecularTextureEnabled: boolean;
  40951. /**
  40952. * Are bump textures enabled in the application.
  40953. */
  40954. static BumpTextureEnabled: boolean;
  40955. /**
  40956. * Are lightmap textures enabled in the application.
  40957. */
  40958. static LightmapTextureEnabled: boolean;
  40959. /**
  40960. * Are refraction textures enabled in the application.
  40961. */
  40962. static RefractionTextureEnabled: boolean;
  40963. /**
  40964. * Are color grading textures enabled in the application.
  40965. */
  40966. static ColorGradingTextureEnabled: boolean;
  40967. /**
  40968. * Are fresnels enabled in the application.
  40969. */
  40970. static FresnelEnabled: boolean;
  40971. }
  40972. }
  40973. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  40974. import { Scene } from "babylonjs/scene";
  40975. import { Texture } from "babylonjs/Materials/Textures/texture";
  40976. /**
  40977. * A class extending Texture allowing drawing on a texture
  40978. * @see http://doc.babylonjs.com/how_to/dynamictexture
  40979. */
  40980. export class DynamicTexture extends Texture {
  40981. private _generateMipMaps;
  40982. private _canvas;
  40983. private _context;
  40984. private _engine;
  40985. /**
  40986. * Creates a DynamicTexture
  40987. * @param name defines the name of the texture
  40988. * @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
  40989. * @param scene defines the scene where you want the texture
  40990. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  40991. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  40992. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  40993. */
  40994. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  40995. /**
  40996. * Get the current class name of the texture useful for serialization or dynamic coding.
  40997. * @returns "DynamicTexture"
  40998. */
  40999. getClassName(): string;
  41000. /**
  41001. * Gets the current state of canRescale
  41002. */
  41003. readonly canRescale: boolean;
  41004. private _recreate;
  41005. /**
  41006. * Scales the texture
  41007. * @param ratio the scale factor to apply to both width and height
  41008. */
  41009. scale(ratio: number): void;
  41010. /**
  41011. * Resizes the texture
  41012. * @param width the new width
  41013. * @param height the new height
  41014. */
  41015. scaleTo(width: number, height: number): void;
  41016. /**
  41017. * Gets the context of the canvas used by the texture
  41018. * @returns the canvas context of the dynamic texture
  41019. */
  41020. getContext(): CanvasRenderingContext2D;
  41021. /**
  41022. * Clears the texture
  41023. */
  41024. clear(): void;
  41025. /**
  41026. * Updates the texture
  41027. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  41028. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  41029. */
  41030. update(invertY?: boolean, premulAlpha?: boolean): void;
  41031. /**
  41032. * Draws text onto the texture
  41033. * @param text defines the text to be drawn
  41034. * @param x defines the placement of the text from the left
  41035. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  41036. * @param font defines the font to be used with font-style, font-size, font-name
  41037. * @param color defines the color used for the text
  41038. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  41039. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  41040. * @param update defines whether texture is immediately update (default is true)
  41041. */
  41042. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  41043. /**
  41044. * Clones the texture
  41045. * @returns the clone of the texture.
  41046. */
  41047. clone(): DynamicTexture;
  41048. /**
  41049. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  41050. * @returns a serialized dynamic texture object
  41051. */
  41052. serialize(): any;
  41053. /** @hidden */
  41054. _rebuild(): void;
  41055. }
  41056. }
  41057. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  41058. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41059. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41060. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41061. /** @hidden */
  41062. export var imageProcessingPixelShader: {
  41063. name: string;
  41064. shader: string;
  41065. };
  41066. }
  41067. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  41068. import { Nullable } from "babylonjs/types";
  41069. import { Color4 } from "babylonjs/Maths/math";
  41070. import { Camera } from "babylonjs/Cameras/camera";
  41071. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41072. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41073. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  41074. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  41075. import { Engine } from "babylonjs/Engines/engine";
  41076. import "babylonjs/Shaders/imageProcessing.fragment";
  41077. import "babylonjs/Shaders/postprocess.vertex";
  41078. /**
  41079. * ImageProcessingPostProcess
  41080. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  41081. */
  41082. export class ImageProcessingPostProcess extends PostProcess {
  41083. /**
  41084. * Default configuration related to image processing available in the PBR Material.
  41085. */
  41086. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41087. /**
  41088. * Gets the image processing configuration used either in this material.
  41089. */
  41090. /**
  41091. * Sets the Default image processing configuration used either in the this material.
  41092. *
  41093. * If sets to null, the scene one is in use.
  41094. */
  41095. imageProcessingConfiguration: ImageProcessingConfiguration;
  41096. /**
  41097. * Keep track of the image processing observer to allow dispose and replace.
  41098. */
  41099. private _imageProcessingObserver;
  41100. /**
  41101. * Attaches a new image processing configuration to the PBR Material.
  41102. * @param configuration
  41103. */
  41104. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  41105. /**
  41106. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41107. */
  41108. /**
  41109. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41110. */
  41111. colorCurves: Nullable<ColorCurves>;
  41112. /**
  41113. * Gets wether the color curves effect is enabled.
  41114. */
  41115. /**
  41116. * Sets wether the color curves effect is enabled.
  41117. */
  41118. colorCurvesEnabled: boolean;
  41119. /**
  41120. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41121. */
  41122. /**
  41123. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41124. */
  41125. colorGradingTexture: Nullable<BaseTexture>;
  41126. /**
  41127. * Gets wether the color grading effect is enabled.
  41128. */
  41129. /**
  41130. * Gets wether the color grading effect is enabled.
  41131. */
  41132. colorGradingEnabled: boolean;
  41133. /**
  41134. * Gets exposure used in the effect.
  41135. */
  41136. /**
  41137. * Sets exposure used in the effect.
  41138. */
  41139. exposure: number;
  41140. /**
  41141. * Gets wether tonemapping is enabled or not.
  41142. */
  41143. /**
  41144. * Sets wether tonemapping is enabled or not
  41145. */
  41146. toneMappingEnabled: boolean;
  41147. /**
  41148. * Gets the type of tone mapping effect.
  41149. */
  41150. /**
  41151. * Sets the type of tone mapping effect.
  41152. */
  41153. toneMappingType: number;
  41154. /**
  41155. * Gets contrast used in the effect.
  41156. */
  41157. /**
  41158. * Sets contrast used in the effect.
  41159. */
  41160. contrast: number;
  41161. /**
  41162. * Gets Vignette stretch size.
  41163. */
  41164. /**
  41165. * Sets Vignette stretch size.
  41166. */
  41167. vignetteStretch: number;
  41168. /**
  41169. * Gets Vignette centre X Offset.
  41170. */
  41171. /**
  41172. * Sets Vignette centre X Offset.
  41173. */
  41174. vignetteCentreX: number;
  41175. /**
  41176. * Gets Vignette centre Y Offset.
  41177. */
  41178. /**
  41179. * Sets Vignette centre Y Offset.
  41180. */
  41181. vignetteCentreY: number;
  41182. /**
  41183. * Gets Vignette weight or intensity of the vignette effect.
  41184. */
  41185. /**
  41186. * Sets Vignette weight or intensity of the vignette effect.
  41187. */
  41188. vignetteWeight: number;
  41189. /**
  41190. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41191. * if vignetteEnabled is set to true.
  41192. */
  41193. /**
  41194. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41195. * if vignetteEnabled is set to true.
  41196. */
  41197. vignetteColor: Color4;
  41198. /**
  41199. * Gets Camera field of view used by the Vignette effect.
  41200. */
  41201. /**
  41202. * Sets Camera field of view used by the Vignette effect.
  41203. */
  41204. vignetteCameraFov: number;
  41205. /**
  41206. * Gets the vignette blend mode allowing different kind of effect.
  41207. */
  41208. /**
  41209. * Sets the vignette blend mode allowing different kind of effect.
  41210. */
  41211. vignetteBlendMode: number;
  41212. /**
  41213. * Gets wether the vignette effect is enabled.
  41214. */
  41215. /**
  41216. * Sets wether the vignette effect is enabled.
  41217. */
  41218. vignetteEnabled: boolean;
  41219. private _fromLinearSpace;
  41220. /**
  41221. * Gets wether the input of the processing is in Gamma or Linear Space.
  41222. */
  41223. /**
  41224. * Sets wether the input of the processing is in Gamma or Linear Space.
  41225. */
  41226. fromLinearSpace: boolean;
  41227. /**
  41228. * Defines cache preventing GC.
  41229. */
  41230. private _defines;
  41231. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  41232. /**
  41233. * "ImageProcessingPostProcess"
  41234. * @returns "ImageProcessingPostProcess"
  41235. */
  41236. getClassName(): string;
  41237. protected _updateParameters(): void;
  41238. dispose(camera?: Camera): void;
  41239. }
  41240. }
  41241. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  41242. import { Scene } from "babylonjs/scene";
  41243. import { Color3 } from "babylonjs/Maths/math";
  41244. import { Mesh } from "babylonjs/Meshes/mesh";
  41245. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  41246. import { Nullable } from "babylonjs/types";
  41247. /**
  41248. * Class containing static functions to help procedurally build meshes
  41249. */
  41250. export class GroundBuilder {
  41251. /**
  41252. * Creates a ground mesh
  41253. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  41254. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  41255. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41256. * @param name defines the name of the mesh
  41257. * @param options defines the options used to create the mesh
  41258. * @param scene defines the hosting scene
  41259. * @returns the ground mesh
  41260. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  41261. */
  41262. static CreateGround(name: string, options: {
  41263. width?: number;
  41264. height?: number;
  41265. subdivisions?: number;
  41266. subdivisionsX?: number;
  41267. subdivisionsY?: number;
  41268. updatable?: boolean;
  41269. }, scene: any): Mesh;
  41270. /**
  41271. * Creates a tiled ground mesh
  41272. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  41273. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  41274. * * 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
  41275. * * 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
  41276. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41277. * @param name defines the name of the mesh
  41278. * @param options defines the options used to create the mesh
  41279. * @param scene defines the hosting scene
  41280. * @returns the tiled ground mesh
  41281. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  41282. */
  41283. static CreateTiledGround(name: string, options: {
  41284. xmin: number;
  41285. zmin: number;
  41286. xmax: number;
  41287. zmax: number;
  41288. subdivisions?: {
  41289. w: number;
  41290. h: number;
  41291. };
  41292. precision?: {
  41293. w: number;
  41294. h: number;
  41295. };
  41296. updatable?: boolean;
  41297. }, scene?: Nullable<Scene>): Mesh;
  41298. /**
  41299. * Creates a ground mesh from a height map
  41300. * * The parameter `url` sets the URL of the height map image resource.
  41301. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  41302. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  41303. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  41304. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  41305. * * 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.
  41306. * * 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).
  41307. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  41308. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41309. * @param name defines the name of the mesh
  41310. * @param url defines the url to the height map
  41311. * @param options defines the options used to create the mesh
  41312. * @param scene defines the hosting scene
  41313. * @returns the ground mesh
  41314. * @see https://doc.babylonjs.com/babylon101/height_map
  41315. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  41316. */
  41317. static CreateGroundFromHeightMap(name: string, url: string, options: {
  41318. width?: number;
  41319. height?: number;
  41320. subdivisions?: number;
  41321. minHeight?: number;
  41322. maxHeight?: number;
  41323. colorFilter?: Color3;
  41324. alphaFilter?: number;
  41325. updatable?: boolean;
  41326. onReady?: (mesh: GroundMesh) => void;
  41327. }, scene?: Nullable<Scene>): GroundMesh;
  41328. }
  41329. }
  41330. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  41331. import { Vector4 } from "babylonjs/Maths/math";
  41332. import { Mesh } from "babylonjs/Meshes/mesh";
  41333. /**
  41334. * Class containing static functions to help procedurally build meshes
  41335. */
  41336. export class TorusBuilder {
  41337. /**
  41338. * Creates a torus mesh
  41339. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  41340. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  41341. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  41342. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41343. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41344. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41345. * @param name defines the name of the mesh
  41346. * @param options defines the options used to create the mesh
  41347. * @param scene defines the hosting scene
  41348. * @returns the torus mesh
  41349. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  41350. */
  41351. static CreateTorus(name: string, options: {
  41352. diameter?: number;
  41353. thickness?: number;
  41354. tessellation?: number;
  41355. updatable?: boolean;
  41356. sideOrientation?: number;
  41357. frontUVs?: Vector4;
  41358. backUVs?: Vector4;
  41359. }, scene: any): Mesh;
  41360. }
  41361. }
  41362. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  41363. import { Color4, Vector4 } from "babylonjs/Maths/math";
  41364. import { Mesh } from "babylonjs/Meshes/mesh";
  41365. /**
  41366. * Class containing static functions to help procedurally build meshes
  41367. */
  41368. export class CylinderBuilder {
  41369. /**
  41370. * Creates a cylinder or a cone mesh
  41371. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  41372. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  41373. * * 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.
  41374. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  41375. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  41376. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  41377. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  41378. * * 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).
  41379. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  41380. * * 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).
  41381. * * 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
  41382. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  41383. * * 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
  41384. * * 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.
  41385. * * If `enclose` is false, a ring surface is one element.
  41386. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  41387. * * 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
  41388. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41389. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41390. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41391. * @param name defines the name of the mesh
  41392. * @param options defines the options used to create the mesh
  41393. * @param scene defines the hosting scene
  41394. * @returns the cylinder mesh
  41395. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  41396. */
  41397. static CreateCylinder(name: string, options: {
  41398. height?: number;
  41399. diameterTop?: number;
  41400. diameterBottom?: number;
  41401. diameter?: number;
  41402. tessellation?: number;
  41403. subdivisions?: number;
  41404. arc?: number;
  41405. faceColors?: Color4[];
  41406. faceUV?: Vector4[];
  41407. updatable?: boolean;
  41408. hasRings?: boolean;
  41409. enclose?: boolean;
  41410. cap?: number;
  41411. sideOrientation?: number;
  41412. frontUVs?: Vector4;
  41413. backUVs?: Vector4;
  41414. }, scene: any): Mesh;
  41415. }
  41416. }
  41417. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  41418. import { Observable } from "babylonjs/Misc/observable";
  41419. import { Nullable } from "babylonjs/types";
  41420. import { Camera } from "babylonjs/Cameras/camera";
  41421. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  41422. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41423. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  41424. import { Scene } from "babylonjs/scene";
  41425. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41426. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  41427. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41428. import { Mesh } from "babylonjs/Meshes/mesh";
  41429. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  41430. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41431. import "babylonjs/Meshes/Builders/groundBuilder";
  41432. import "babylonjs/Meshes/Builders/torusBuilder";
  41433. import "babylonjs/Meshes/Builders/cylinderBuilder";
  41434. import "babylonjs/Gamepads/gamepadSceneComponent";
  41435. import "babylonjs/Animations/animatable";
  41436. /**
  41437. * Options to modify the vr teleportation behavior.
  41438. */
  41439. export interface VRTeleportationOptions {
  41440. /**
  41441. * The name of the mesh which should be used as the teleportation floor. (default: null)
  41442. */
  41443. floorMeshName?: string;
  41444. /**
  41445. * A list of meshes to be used as the teleportation floor. (default: empty)
  41446. */
  41447. floorMeshes?: Mesh[];
  41448. }
  41449. /**
  41450. * Options to modify the vr experience helper's behavior.
  41451. */
  41452. export interface VRExperienceHelperOptions extends WebVROptions {
  41453. /**
  41454. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  41455. */
  41456. createDeviceOrientationCamera?: boolean;
  41457. /**
  41458. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  41459. */
  41460. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  41461. /**
  41462. * Uses the main button on the controller to toggle the laser casted. (default: true)
  41463. */
  41464. laserToggle?: boolean;
  41465. /**
  41466. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  41467. */
  41468. floorMeshes?: Mesh[];
  41469. /**
  41470. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  41471. */
  41472. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  41473. }
  41474. /**
  41475. * Event containing information after VR has been entered
  41476. */
  41477. export class OnAfterEnteringVRObservableEvent {
  41478. /**
  41479. * If entering vr was successful
  41480. */
  41481. success: boolean;
  41482. }
  41483. /**
  41484. * Helps to quickly add VR support to an existing scene.
  41485. * See http://doc.babylonjs.com/how_to/webvr_helper
  41486. */
  41487. export class VRExperienceHelper {
  41488. /** Options to modify the vr experience helper's behavior. */
  41489. webVROptions: VRExperienceHelperOptions;
  41490. private _scene;
  41491. private _position;
  41492. private _btnVR;
  41493. private _btnVRDisplayed;
  41494. private _webVRsupported;
  41495. private _webVRready;
  41496. private _webVRrequesting;
  41497. private _webVRpresenting;
  41498. private _hasEnteredVR;
  41499. private _fullscreenVRpresenting;
  41500. private _canvas;
  41501. private _webVRCamera;
  41502. private _vrDeviceOrientationCamera;
  41503. private _deviceOrientationCamera;
  41504. private _existingCamera;
  41505. private _onKeyDown;
  41506. private _onVrDisplayPresentChange;
  41507. private _onVRDisplayChanged;
  41508. private _onVRRequestPresentStart;
  41509. private _onVRRequestPresentComplete;
  41510. /**
  41511. * Observable raised right before entering VR.
  41512. */
  41513. onEnteringVRObservable: Observable<VRExperienceHelper>;
  41514. /**
  41515. * Observable raised when entering VR has completed.
  41516. */
  41517. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  41518. /**
  41519. * Observable raised when exiting VR.
  41520. */
  41521. onExitingVRObservable: Observable<VRExperienceHelper>;
  41522. /**
  41523. * Observable raised when controller mesh is loaded.
  41524. */
  41525. onControllerMeshLoadedObservable: Observable<WebVRController>;
  41526. /** Return this.onEnteringVRObservable
  41527. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  41528. */
  41529. readonly onEnteringVR: Observable<VRExperienceHelper>;
  41530. /** Return this.onExitingVRObservable
  41531. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  41532. */
  41533. readonly onExitingVR: Observable<VRExperienceHelper>;
  41534. /** Return this.onControllerMeshLoadedObservable
  41535. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  41536. */
  41537. readonly onControllerMeshLoaded: Observable<WebVRController>;
  41538. private _rayLength;
  41539. private _useCustomVRButton;
  41540. private _teleportationRequested;
  41541. private _teleportActive;
  41542. private _floorMeshName;
  41543. private _floorMeshesCollection;
  41544. private _rotationAllowed;
  41545. private _teleportBackwardsVector;
  41546. private _teleportationTarget;
  41547. private _isDefaultTeleportationTarget;
  41548. private _postProcessMove;
  41549. private _teleportationFillColor;
  41550. private _teleportationBorderColor;
  41551. private _rotationAngle;
  41552. private _haloCenter;
  41553. private _cameraGazer;
  41554. private _padSensibilityUp;
  41555. private _padSensibilityDown;
  41556. private _leftController;
  41557. private _rightController;
  41558. /**
  41559. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  41560. */
  41561. onNewMeshSelected: Observable<AbstractMesh>;
  41562. /**
  41563. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  41564. */
  41565. onNewMeshPicked: Observable<PickingInfo>;
  41566. private _circleEase;
  41567. /**
  41568. * Observable raised before camera teleportation
  41569. */
  41570. onBeforeCameraTeleport: Observable<Vector3>;
  41571. /**
  41572. * Observable raised after camera teleportation
  41573. */
  41574. onAfterCameraTeleport: Observable<Vector3>;
  41575. /**
  41576. * Observable raised when current selected mesh gets unselected
  41577. */
  41578. onSelectedMeshUnselected: Observable<AbstractMesh>;
  41579. private _raySelectionPredicate;
  41580. /**
  41581. * To be optionaly changed by user to define custom ray selection
  41582. */
  41583. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  41584. /**
  41585. * To be optionaly changed by user to define custom selection logic (after ray selection)
  41586. */
  41587. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  41588. /**
  41589. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  41590. */
  41591. teleportationEnabled: boolean;
  41592. private _defaultHeight;
  41593. private _teleportationInitialized;
  41594. private _interactionsEnabled;
  41595. private _interactionsRequested;
  41596. private _displayGaze;
  41597. private _displayLaserPointer;
  41598. /**
  41599. * The mesh used to display where the user is going to teleport.
  41600. */
  41601. /**
  41602. * Sets the mesh to be used to display where the user is going to teleport.
  41603. */
  41604. teleportationTarget: Mesh;
  41605. /**
  41606. * 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
  41607. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  41608. * See http://doc.babylonjs.com/resources/baking_transformations
  41609. */
  41610. gazeTrackerMesh: Mesh;
  41611. /**
  41612. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  41613. */
  41614. updateGazeTrackerScale: boolean;
  41615. /**
  41616. * If the gaze trackers color should be updated when selecting meshes
  41617. */
  41618. updateGazeTrackerColor: boolean;
  41619. /**
  41620. * The gaze tracking mesh corresponding to the left controller
  41621. */
  41622. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  41623. /**
  41624. * The gaze tracking mesh corresponding to the right controller
  41625. */
  41626. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  41627. /**
  41628. * If the ray of the gaze should be displayed.
  41629. */
  41630. /**
  41631. * Sets if the ray of the gaze should be displayed.
  41632. */
  41633. displayGaze: boolean;
  41634. /**
  41635. * If the ray of the LaserPointer should be displayed.
  41636. */
  41637. /**
  41638. * Sets if the ray of the LaserPointer should be displayed.
  41639. */
  41640. displayLaserPointer: boolean;
  41641. /**
  41642. * The deviceOrientationCamera used as the camera when not in VR.
  41643. */
  41644. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  41645. /**
  41646. * Based on the current WebVR support, returns the current VR camera used.
  41647. */
  41648. readonly currentVRCamera: Nullable<Camera>;
  41649. /**
  41650. * The webVRCamera which is used when in VR.
  41651. */
  41652. readonly webVRCamera: WebVRFreeCamera;
  41653. /**
  41654. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  41655. */
  41656. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  41657. private readonly _teleportationRequestInitiated;
  41658. /**
  41659. * Defines wether or not Pointer lock should be requested when switching to
  41660. * full screen.
  41661. */
  41662. requestPointerLockOnFullScreen: boolean;
  41663. /**
  41664. * Instantiates a VRExperienceHelper.
  41665. * Helps to quickly add VR support to an existing scene.
  41666. * @param scene The scene the VRExperienceHelper belongs to.
  41667. * @param webVROptions Options to modify the vr experience helper's behavior.
  41668. */
  41669. constructor(scene: Scene,
  41670. /** Options to modify the vr experience helper's behavior. */
  41671. webVROptions?: VRExperienceHelperOptions);
  41672. private _onDefaultMeshLoaded;
  41673. private _onResize;
  41674. private _onFullscreenChange;
  41675. /**
  41676. * Gets a value indicating if we are currently in VR mode.
  41677. */
  41678. readonly isInVRMode: boolean;
  41679. private onVrDisplayPresentChange;
  41680. private onVRDisplayChanged;
  41681. private moveButtonToBottomRight;
  41682. private displayVRButton;
  41683. private updateButtonVisibility;
  41684. private _cachedAngularSensibility;
  41685. /**
  41686. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  41687. * Otherwise, will use the fullscreen API.
  41688. */
  41689. enterVR(): void;
  41690. /**
  41691. * Attempt to exit VR, or fullscreen.
  41692. */
  41693. exitVR(): void;
  41694. /**
  41695. * The position of the vr experience helper.
  41696. */
  41697. /**
  41698. * Sets the position of the vr experience helper.
  41699. */
  41700. position: Vector3;
  41701. /**
  41702. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  41703. */
  41704. enableInteractions(): void;
  41705. private readonly _noControllerIsActive;
  41706. private beforeRender;
  41707. private _isTeleportationFloor;
  41708. /**
  41709. * Adds a floor mesh to be used for teleportation.
  41710. * @param floorMesh the mesh to be used for teleportation.
  41711. */
  41712. addFloorMesh(floorMesh: Mesh): void;
  41713. /**
  41714. * Removes a floor mesh from being used for teleportation.
  41715. * @param floorMesh the mesh to be removed.
  41716. */
  41717. removeFloorMesh(floorMesh: Mesh): void;
  41718. /**
  41719. * Enables interactions and teleportation using the VR controllers and gaze.
  41720. * @param vrTeleportationOptions options to modify teleportation behavior.
  41721. */
  41722. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  41723. private _onNewGamepadConnected;
  41724. private _tryEnableInteractionOnController;
  41725. private _onNewGamepadDisconnected;
  41726. private _enableInteractionOnController;
  41727. private _checkTeleportWithRay;
  41728. private _checkRotate;
  41729. private _checkTeleportBackwards;
  41730. private _enableTeleportationOnController;
  41731. private _createTeleportationCircles;
  41732. private _displayTeleportationTarget;
  41733. private _hideTeleportationTarget;
  41734. private _rotateCamera;
  41735. private _moveTeleportationSelectorTo;
  41736. private _workingVector;
  41737. private _workingQuaternion;
  41738. private _workingMatrix;
  41739. /**
  41740. * Teleports the users feet to the desired location
  41741. * @param location The location where the user's feet should be placed
  41742. */
  41743. teleportCamera(location: Vector3): void;
  41744. private _convertNormalToDirectionOfRay;
  41745. private _castRayAndSelectObject;
  41746. private _notifySelectedMeshUnselected;
  41747. /**
  41748. * Sets the color of the laser ray from the vr controllers.
  41749. * @param color new color for the ray.
  41750. */
  41751. changeLaserColor(color: Color3): void;
  41752. /**
  41753. * Sets the color of the ray from the vr headsets gaze.
  41754. * @param color new color for the ray.
  41755. */
  41756. changeGazeColor(color: Color3): void;
  41757. /**
  41758. * Exits VR and disposes of the vr experience helper
  41759. */
  41760. dispose(): void;
  41761. /**
  41762. * Gets the name of the VRExperienceHelper class
  41763. * @returns "VRExperienceHelper"
  41764. */
  41765. getClassName(): string;
  41766. }
  41767. }
  41768. declare module "babylonjs/Cameras/VR/index" {
  41769. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  41770. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  41771. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41772. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  41773. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  41774. export * from "babylonjs/Cameras/VR/webVRCamera";
  41775. }
  41776. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  41777. import { Observable } from "babylonjs/Misc/observable";
  41778. import { Nullable } from "babylonjs/types";
  41779. import { IDisposable, Scene } from "babylonjs/scene";
  41780. import { Vector3 } from "babylonjs/Maths/math";
  41781. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41782. import { Ray } from "babylonjs/Culling/ray";
  41783. /**
  41784. * Manages an XRSession
  41785. * @see https://doc.babylonjs.com/how_to/webxr
  41786. */
  41787. export class WebXRSessionManager implements IDisposable {
  41788. private scene;
  41789. /**
  41790. * Fires every time a new xrFrame arrives which can be used to update the camera
  41791. */
  41792. onXRFrameObservable: Observable<any>;
  41793. /**
  41794. * Fires when the xr session is ended either by the device or manually done
  41795. */
  41796. onXRSessionEnded: Observable<any>;
  41797. /** @hidden */
  41798. _xrSession: XRSession;
  41799. /** @hidden */
  41800. _frameOfReference: XRFrameOfReference;
  41801. /** @hidden */
  41802. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  41803. /** @hidden */
  41804. _currentXRFrame: Nullable<XRFrame>;
  41805. private _xrNavigator;
  41806. private _xrDevice;
  41807. private _tmpMatrix;
  41808. /**
  41809. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  41810. * @param scene The scene which the session should be created for
  41811. */
  41812. constructor(scene: Scene);
  41813. /**
  41814. * Initializes the manager
  41815. * After initialization enterXR can be called to start an XR session
  41816. * @returns Promise which resolves after it is initialized
  41817. */
  41818. initializeAsync(): Promise<void>;
  41819. /**
  41820. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  41821. * @param sessionCreationOptions xr options to create the session with
  41822. * @param frameOfReferenceType option to configure how the xr pose is expressed
  41823. * @returns Promise which resolves after it enters XR
  41824. */
  41825. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  41826. /**
  41827. * Stops the xrSession and restores the renderloop
  41828. * @returns Promise which resolves after it exits XR
  41829. */
  41830. exitXRAsync(): Promise<void>;
  41831. /**
  41832. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  41833. * @param ray ray to cast into the environment
  41834. * @returns Promise which resolves with a collision point in the environment if it exists
  41835. */
  41836. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  41837. /**
  41838. * Checks if a session would be supported for the creation options specified
  41839. * @param options creation options to check if they are supported
  41840. * @returns true if supported
  41841. */
  41842. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  41843. /**
  41844. * @hidden
  41845. * Converts the render layer of xrSession to a render target
  41846. * @param session session to create render target for
  41847. * @param scene scene the new render target should be created for
  41848. */
  41849. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  41850. /**
  41851. * Disposes of the session manager
  41852. */
  41853. dispose(): void;
  41854. }
  41855. }
  41856. declare module "babylonjs/Cameras/XR/webXRCamera" {
  41857. import { Scene } from "babylonjs/scene";
  41858. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41859. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  41860. /**
  41861. * WebXR Camera which holds the views for the xrSession
  41862. * @see https://doc.babylonjs.com/how_to/webxr
  41863. */
  41864. export class WebXRCamera extends FreeCamera {
  41865. private static _TmpMatrix;
  41866. /**
  41867. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  41868. * @param name the name of the camera
  41869. * @param scene the scene to add the camera to
  41870. */
  41871. constructor(name: string, scene: Scene);
  41872. private _updateNumberOfRigCameras;
  41873. /** @hidden */
  41874. _updateForDualEyeDebugging(pupilDistance?: number): void;
  41875. /**
  41876. * Updates the cameras position from the current pose information of the XR session
  41877. * @param xrSessionManager the session containing pose information
  41878. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  41879. */
  41880. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  41881. }
  41882. }
  41883. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  41884. import { Nullable } from "babylonjs/types";
  41885. import { Observable } from "babylonjs/Misc/observable";
  41886. import { IDisposable, Scene } from "babylonjs/scene";
  41887. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  41888. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41889. import { Ray } from "babylonjs/Culling/ray";
  41890. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  41891. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  41892. /**
  41893. * States of the webXR experience
  41894. */
  41895. export enum WebXRState {
  41896. /**
  41897. * Transitioning to being in XR mode
  41898. */
  41899. ENTERING_XR = 0,
  41900. /**
  41901. * Transitioning to non XR mode
  41902. */
  41903. EXITING_XR = 1,
  41904. /**
  41905. * In XR mode and presenting
  41906. */
  41907. IN_XR = 2,
  41908. /**
  41909. * Not entered XR mode
  41910. */
  41911. NOT_IN_XR = 3
  41912. }
  41913. /**
  41914. * Helper class used to enable XR
  41915. * @see https://doc.babylonjs.com/how_to/webxr
  41916. */
  41917. export class WebXRExperienceHelper implements IDisposable {
  41918. private scene;
  41919. /**
  41920. * 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
  41921. */
  41922. container: AbstractMesh;
  41923. /**
  41924. * Camera used to render xr content
  41925. */
  41926. camera: WebXRCamera;
  41927. /**
  41928. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  41929. */
  41930. state: WebXRState;
  41931. private _setState;
  41932. private static _TmpVector;
  41933. /**
  41934. * Fires when the state of the experience helper has changed
  41935. */
  41936. onStateChangedObservable: Observable<WebXRState>;
  41937. /** @hidden */
  41938. _sessionManager: WebXRSessionManager;
  41939. private _nonVRCamera;
  41940. private _originalSceneAutoClear;
  41941. private _supported;
  41942. /**
  41943. * Creates the experience helper
  41944. * @param scene the scene to attach the experience helper to
  41945. * @returns a promise for the experience helper
  41946. */
  41947. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  41948. /**
  41949. * Creates a WebXRExperienceHelper
  41950. * @param scene The scene the helper should be created in
  41951. */
  41952. private constructor();
  41953. /**
  41954. * Exits XR mode and returns the scene to its original state
  41955. * @returns promise that resolves after xr mode has exited
  41956. */
  41957. exitXRAsync(): Promise<void>;
  41958. /**
  41959. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  41960. * @param sessionCreationOptions options for the XR session
  41961. * @param frameOfReference frame of reference of the XR session
  41962. * @returns promise that resolves after xr mode has entered
  41963. */
  41964. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  41965. /**
  41966. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  41967. * @param ray ray to cast into the environment
  41968. * @returns Promise which resolves with a collision point in the environment if it exists
  41969. */
  41970. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  41971. /**
  41972. * Updates the global position of the camera by moving the camera's container
  41973. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  41974. * @param position The desired global position of the camera
  41975. */
  41976. setPositionOfCameraUsingContainer(position: Vector3): void;
  41977. /**
  41978. * Rotates the xr camera by rotating the camera's container around the camera's position
  41979. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  41980. * @param rotation the desired quaternion rotation to apply to the camera
  41981. */
  41982. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  41983. /**
  41984. * Checks if the creation options are supported by the xr session
  41985. * @param options creation options
  41986. * @returns true if supported
  41987. */
  41988. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  41989. /**
  41990. * Disposes of the experience helper
  41991. */
  41992. dispose(): void;
  41993. }
  41994. }
  41995. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  41996. import { Nullable } from "babylonjs/types";
  41997. import { Observable } from "babylonjs/Misc/observable";
  41998. import { IDisposable, Scene } from "babylonjs/scene";
  41999. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42000. /**
  42001. * Button which can be used to enter a different mode of XR
  42002. */
  42003. export class WebXREnterExitUIButton {
  42004. /** button element */
  42005. element: HTMLElement;
  42006. /** XR initialization options for the button */
  42007. initializationOptions: XRSessionCreationOptions;
  42008. /**
  42009. * Creates a WebXREnterExitUIButton
  42010. * @param element button element
  42011. * @param initializationOptions XR initialization options for the button
  42012. */
  42013. constructor(
  42014. /** button element */
  42015. element: HTMLElement,
  42016. /** XR initialization options for the button */
  42017. initializationOptions: XRSessionCreationOptions);
  42018. /**
  42019. * Overwritable function which can be used to update the button's visuals when the state changes
  42020. * @param activeButton the current active button in the UI
  42021. */
  42022. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  42023. }
  42024. /**
  42025. * Options to create the webXR UI
  42026. */
  42027. export class WebXREnterExitUIOptions {
  42028. /**
  42029. * Context to enter xr with
  42030. */
  42031. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  42032. /**
  42033. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  42034. */
  42035. customButtons?: Array<WebXREnterExitUIButton>;
  42036. }
  42037. /**
  42038. * UI to allow the user to enter/exit XR mode
  42039. */
  42040. export class WebXREnterExitUI implements IDisposable {
  42041. private scene;
  42042. private _overlay;
  42043. private _buttons;
  42044. private _activeButton;
  42045. /**
  42046. * Fired every time the active button is changed.
  42047. *
  42048. * When xr is entered via a button that launches xr that button will be the callback parameter
  42049. *
  42050. * When exiting xr the callback parameter will be null)
  42051. */
  42052. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  42053. /**
  42054. * Creates UI to allow the user to enter/exit XR mode
  42055. * @param scene the scene to add the ui to
  42056. * @param helper the xr experience helper to enter/exit xr with
  42057. * @param options options to configure the UI
  42058. * @returns the created ui
  42059. */
  42060. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  42061. private constructor();
  42062. private _updateButtons;
  42063. /**
  42064. * Disposes of the object
  42065. */
  42066. dispose(): void;
  42067. }
  42068. }
  42069. declare module "babylonjs/Cameras/XR/webXRInput" {
  42070. import { IDisposable, Scene } from "babylonjs/scene";
  42071. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42072. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42073. /**
  42074. * Represents an XR input
  42075. */
  42076. export class WebXRController {
  42077. /**
  42078. * 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
  42079. */
  42080. grip?: AbstractMesh;
  42081. /**
  42082. * Pointer which can be used to select objects or attach a visible laser to
  42083. */
  42084. pointer: AbstractMesh;
  42085. /**
  42086. * Creates the controller
  42087. * @see https://doc.babylonjs.com/how_to/webxr
  42088. * @param scene the scene which the controller should be associated to
  42089. */
  42090. constructor(scene: Scene);
  42091. /**
  42092. * Disposes of the object
  42093. */
  42094. dispose(): void;
  42095. }
  42096. /**
  42097. * XR input used to track XR inputs such as controllers/rays
  42098. */
  42099. export class WebXRInput implements IDisposable {
  42100. private helper;
  42101. /**
  42102. * XR controllers being tracked
  42103. */
  42104. controllers: Array<WebXRController>;
  42105. private _tmpMatrix;
  42106. private _frameObserver;
  42107. /**
  42108. * Initializes the WebXRInput
  42109. * @param helper experience helper which the input should be created for
  42110. */
  42111. constructor(helper: WebXRExperienceHelper);
  42112. /**
  42113. * Disposes of the object
  42114. */
  42115. dispose(): void;
  42116. }
  42117. }
  42118. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  42119. import { Nullable } from "babylonjs/types";
  42120. import { IDisposable } from "babylonjs/scene";
  42121. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42122. /**
  42123. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42124. */
  42125. export class WebXRManagedOutputCanvas implements IDisposable {
  42126. private _canvas;
  42127. /**
  42128. * xrpresent context of the canvas which can be used to display/mirror xr content
  42129. */
  42130. canvasContext: Nullable<WebGLRenderingContext>;
  42131. /**
  42132. * Initializes the canvas to be added/removed upon entering/exiting xr
  42133. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  42134. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  42135. */
  42136. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  42137. /**
  42138. * Disposes of the object
  42139. */
  42140. dispose(): void;
  42141. private _setManagedOutputCanvas;
  42142. private _addCanvas;
  42143. private _removeCanvas;
  42144. }
  42145. }
  42146. declare module "babylonjs/Cameras/XR/index" {
  42147. export * from "babylonjs/Cameras/XR/webXRCamera";
  42148. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  42149. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42150. export * from "babylonjs/Cameras/XR/webXRInput";
  42151. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  42152. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  42153. }
  42154. declare module "babylonjs/Cameras/RigModes/index" {
  42155. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42156. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  42157. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  42158. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  42159. }
  42160. declare module "babylonjs/Cameras/index" {
  42161. export * from "babylonjs/Cameras/Inputs/index";
  42162. export * from "babylonjs/Cameras/cameraInputsManager";
  42163. export * from "babylonjs/Cameras/camera";
  42164. export * from "babylonjs/Cameras/targetCamera";
  42165. export * from "babylonjs/Cameras/freeCamera";
  42166. export * from "babylonjs/Cameras/freeCameraInputsManager";
  42167. export * from "babylonjs/Cameras/touchCamera";
  42168. export * from "babylonjs/Cameras/arcRotateCamera";
  42169. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  42170. export * from "babylonjs/Cameras/deviceOrientationCamera";
  42171. export * from "babylonjs/Cameras/flyCamera";
  42172. export * from "babylonjs/Cameras/flyCameraInputsManager";
  42173. export * from "babylonjs/Cameras/followCamera";
  42174. export * from "babylonjs/Cameras/gamepadCamera";
  42175. export * from "babylonjs/Cameras/Stereoscopic/index";
  42176. export * from "babylonjs/Cameras/universalCamera";
  42177. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  42178. export * from "babylonjs/Cameras/VR/index";
  42179. export * from "babylonjs/Cameras/XR/index";
  42180. export * from "babylonjs/Cameras/RigModes/index";
  42181. }
  42182. declare module "babylonjs/Collisions/index" {
  42183. export * from "babylonjs/Collisions/collider";
  42184. export * from "babylonjs/Collisions/collisionCoordinator";
  42185. export * from "babylonjs/Collisions/pickingInfo";
  42186. export * from "babylonjs/Collisions/intersectionInfo";
  42187. export * from "babylonjs/Collisions/meshCollisionData";
  42188. }
  42189. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  42190. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  42191. import { Vector3, Plane } from "babylonjs/Maths/math";
  42192. import { Ray } from "babylonjs/Culling/ray";
  42193. /**
  42194. * Contains an array of blocks representing the octree
  42195. */
  42196. export interface IOctreeContainer<T> {
  42197. /**
  42198. * Blocks within the octree
  42199. */
  42200. blocks: Array<OctreeBlock<T>>;
  42201. }
  42202. /**
  42203. * Class used to store a cell in an octree
  42204. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42205. */
  42206. export class OctreeBlock<T> {
  42207. /**
  42208. * Gets the content of the current block
  42209. */
  42210. entries: T[];
  42211. /**
  42212. * Gets the list of block children
  42213. */
  42214. blocks: Array<OctreeBlock<T>>;
  42215. private _depth;
  42216. private _maxDepth;
  42217. private _capacity;
  42218. private _minPoint;
  42219. private _maxPoint;
  42220. private _boundingVectors;
  42221. private _creationFunc;
  42222. /**
  42223. * Creates a new block
  42224. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  42225. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  42226. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42227. * @param depth defines the current depth of this block in the octree
  42228. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  42229. * @param creationFunc defines a callback to call when an element is added to the block
  42230. */
  42231. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  42232. /**
  42233. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42234. */
  42235. readonly capacity: number;
  42236. /**
  42237. * Gets the minimum vector (in world space) of the block's bounding box
  42238. */
  42239. readonly minPoint: Vector3;
  42240. /**
  42241. * Gets the maximum vector (in world space) of the block's bounding box
  42242. */
  42243. readonly maxPoint: Vector3;
  42244. /**
  42245. * Add a new element to this block
  42246. * @param entry defines the element to add
  42247. */
  42248. addEntry(entry: T): void;
  42249. /**
  42250. * Remove an element from this block
  42251. * @param entry defines the element to remove
  42252. */
  42253. removeEntry(entry: T): void;
  42254. /**
  42255. * Add an array of elements to this block
  42256. * @param entries defines the array of elements to add
  42257. */
  42258. addEntries(entries: T[]): void;
  42259. /**
  42260. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  42261. * @param frustumPlanes defines the frustum planes to test
  42262. * @param selection defines the array to store current content if selection is positive
  42263. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42264. */
  42265. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42266. /**
  42267. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  42268. * @param sphereCenter defines the bounding sphere center
  42269. * @param sphereRadius defines the bounding sphere radius
  42270. * @param selection defines the array to store current content if selection is positive
  42271. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42272. */
  42273. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42274. /**
  42275. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  42276. * @param ray defines the ray to test with
  42277. * @param selection defines the array to store current content if selection is positive
  42278. */
  42279. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  42280. /**
  42281. * Subdivide the content into child blocks (this block will then be empty)
  42282. */
  42283. createInnerBlocks(): void;
  42284. /**
  42285. * @hidden
  42286. */
  42287. 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;
  42288. }
  42289. }
  42290. declare module "babylonjs/Culling/Octrees/octree" {
  42291. import { SmartArray } from "babylonjs/Misc/smartArray";
  42292. import { Vector3, Plane } from "babylonjs/Maths/math";
  42293. import { SubMesh } from "babylonjs/Meshes/subMesh";
  42294. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42295. import { Ray } from "babylonjs/Culling/ray";
  42296. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  42297. /**
  42298. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  42299. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42300. */
  42301. export class Octree<T> {
  42302. /** 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.) */
  42303. maxDepth: number;
  42304. /**
  42305. * Blocks within the octree containing objects
  42306. */
  42307. blocks: Array<OctreeBlock<T>>;
  42308. /**
  42309. * Content stored in the octree
  42310. */
  42311. dynamicContent: T[];
  42312. private _maxBlockCapacity;
  42313. private _selectionContent;
  42314. private _creationFunc;
  42315. /**
  42316. * Creates a octree
  42317. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42318. * @param creationFunc function to be used to instatiate the octree
  42319. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  42320. * @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.)
  42321. */
  42322. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  42323. /** 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.) */
  42324. maxDepth?: number);
  42325. /**
  42326. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  42327. * @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);
  42328. * @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);
  42329. * @param entries meshes to be added to the octree blocks
  42330. */
  42331. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  42332. /**
  42333. * Adds a mesh to the octree
  42334. * @param entry Mesh to add to the octree
  42335. */
  42336. addMesh(entry: T): void;
  42337. /**
  42338. * Remove an element from the octree
  42339. * @param entry defines the element to remove
  42340. */
  42341. removeMesh(entry: T): void;
  42342. /**
  42343. * Selects an array of meshes within the frustum
  42344. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  42345. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  42346. * @returns array of meshes within the frustum
  42347. */
  42348. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  42349. /**
  42350. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  42351. * @param sphereCenter defines the bounding sphere center
  42352. * @param sphereRadius defines the bounding sphere radius
  42353. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42354. * @returns an array of objects that intersect the sphere
  42355. */
  42356. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  42357. /**
  42358. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  42359. * @param ray defines the ray to test with
  42360. * @returns array of intersected objects
  42361. */
  42362. intersectsRay(ray: Ray): SmartArray<T>;
  42363. /**
  42364. * Adds a mesh into the octree block if it intersects the block
  42365. */
  42366. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  42367. /**
  42368. * Adds a submesh into the octree block if it intersects the block
  42369. */
  42370. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  42371. }
  42372. }
  42373. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  42374. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  42375. import { Scene } from "babylonjs/scene";
  42376. import { SubMesh } from "babylonjs/Meshes/subMesh";
  42377. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42378. import { Ray } from "babylonjs/Culling/ray";
  42379. import { Octree } from "babylonjs/Culling/Octrees/octree";
  42380. import { Collider } from "babylonjs/Collisions/collider";
  42381. module "babylonjs/scene" {
  42382. interface Scene {
  42383. /**
  42384. * @hidden
  42385. * Backing Filed
  42386. */
  42387. _selectionOctree: Octree<AbstractMesh>;
  42388. /**
  42389. * Gets the octree used to boost mesh selection (picking)
  42390. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42391. */
  42392. selectionOctree: Octree<AbstractMesh>;
  42393. /**
  42394. * Creates or updates the octree used to boost selection (picking)
  42395. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42396. * @param maxCapacity defines the maximum capacity per leaf
  42397. * @param maxDepth defines the maximum depth of the octree
  42398. * @returns an octree of AbstractMesh
  42399. */
  42400. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  42401. }
  42402. }
  42403. module "babylonjs/Meshes/abstractMesh" {
  42404. interface AbstractMesh {
  42405. /**
  42406. * @hidden
  42407. * Backing Field
  42408. */
  42409. _submeshesOctree: Octree<SubMesh>;
  42410. /**
  42411. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  42412. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  42413. * @param maxCapacity defines the maximum size of each block (64 by default)
  42414. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  42415. * @returns the new octree
  42416. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  42417. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42418. */
  42419. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  42420. }
  42421. }
  42422. /**
  42423. * Defines the octree scene component responsible to manage any octrees
  42424. * in a given scene.
  42425. */
  42426. export class OctreeSceneComponent {
  42427. /**
  42428. * The component name help to identify the component in the list of scene components.
  42429. */
  42430. readonly name: string;
  42431. /**
  42432. * The scene the component belongs to.
  42433. */
  42434. scene: Scene;
  42435. /**
  42436. * Indicates if the meshes have been checked to make sure they are isEnabled()
  42437. */
  42438. readonly checksIsEnabled: boolean;
  42439. /**
  42440. * Creates a new instance of the component for the given scene
  42441. * @param scene Defines the scene to register the component in
  42442. */
  42443. constructor(scene: Scene);
  42444. /**
  42445. * Registers the component in a given scene
  42446. */
  42447. register(): void;
  42448. /**
  42449. * Return the list of active meshes
  42450. * @returns the list of active meshes
  42451. */
  42452. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  42453. /**
  42454. * Return the list of active sub meshes
  42455. * @param mesh The mesh to get the candidates sub meshes from
  42456. * @returns the list of active sub meshes
  42457. */
  42458. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  42459. private _tempRay;
  42460. /**
  42461. * Return the list of sub meshes intersecting with a given local ray
  42462. * @param mesh defines the mesh to find the submesh for
  42463. * @param localRay defines the ray in local space
  42464. * @returns the list of intersecting sub meshes
  42465. */
  42466. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  42467. /**
  42468. * Return the list of sub meshes colliding with a collider
  42469. * @param mesh defines the mesh to find the submesh for
  42470. * @param collider defines the collider to evaluate the collision against
  42471. * @returns the list of colliding sub meshes
  42472. */
  42473. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  42474. /**
  42475. * Rebuilds the elements related to this component in case of
  42476. * context lost for instance.
  42477. */
  42478. rebuild(): void;
  42479. /**
  42480. * Disposes the component and the associated ressources.
  42481. */
  42482. dispose(): void;
  42483. }
  42484. }
  42485. declare module "babylonjs/Culling/Octrees/index" {
  42486. export * from "babylonjs/Culling/Octrees/octree";
  42487. export * from "babylonjs/Culling/Octrees/octreeBlock";
  42488. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  42489. }
  42490. declare module "babylonjs/Culling/index" {
  42491. export * from "babylonjs/Culling/boundingBox";
  42492. export * from "babylonjs/Culling/boundingInfo";
  42493. export * from "babylonjs/Culling/boundingSphere";
  42494. export * from "babylonjs/Culling/Octrees/index";
  42495. export * from "babylonjs/Culling/ray";
  42496. }
  42497. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  42498. import { IDisposable, Scene } from "babylonjs/scene";
  42499. import { Nullable } from "babylonjs/types";
  42500. import { Observable } from "babylonjs/Misc/observable";
  42501. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42502. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  42503. import { Camera } from "babylonjs/Cameras/camera";
  42504. /**
  42505. * Renders a layer on top of an existing scene
  42506. */
  42507. export class UtilityLayerRenderer implements IDisposable {
  42508. /** the original scene that will be rendered on top of */
  42509. originalScene: Scene;
  42510. private _pointerCaptures;
  42511. private _lastPointerEvents;
  42512. private static _DefaultUtilityLayer;
  42513. private static _DefaultKeepDepthUtilityLayer;
  42514. private _sharedGizmoLight;
  42515. private _renderCamera;
  42516. /**
  42517. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  42518. * @returns the camera that is used when rendering the utility layer
  42519. */
  42520. getRenderCamera(): Nullable<Camera>;
  42521. /**
  42522. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  42523. * @param cam the camera that should be used when rendering the utility layer
  42524. */
  42525. setRenderCamera(cam: Nullable<Camera>): void;
  42526. /**
  42527. * @hidden
  42528. * Light which used by gizmos to get light shading
  42529. */
  42530. _getSharedGizmoLight(): HemisphericLight;
  42531. /**
  42532. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  42533. */
  42534. pickUtilitySceneFirst: boolean;
  42535. /**
  42536. * 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)
  42537. */
  42538. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  42539. /**
  42540. * 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)
  42541. */
  42542. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  42543. /**
  42544. * The scene that is rendered on top of the original scene
  42545. */
  42546. utilityLayerScene: Scene;
  42547. /**
  42548. * If the utility layer should automatically be rendered on top of existing scene
  42549. */
  42550. shouldRender: boolean;
  42551. /**
  42552. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  42553. */
  42554. onlyCheckPointerDownEvents: boolean;
  42555. /**
  42556. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  42557. */
  42558. processAllEvents: boolean;
  42559. /**
  42560. * Observable raised when the pointer move from the utility layer scene to the main scene
  42561. */
  42562. onPointerOutObservable: Observable<number>;
  42563. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  42564. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  42565. private _afterRenderObserver;
  42566. private _sceneDisposeObserver;
  42567. private _originalPointerObserver;
  42568. /**
  42569. * Instantiates a UtilityLayerRenderer
  42570. * @param originalScene the original scene that will be rendered on top of
  42571. * @param handleEvents boolean indicating if the utility layer should handle events
  42572. */
  42573. constructor(
  42574. /** the original scene that will be rendered on top of */
  42575. originalScene: Scene, handleEvents?: boolean);
  42576. private _notifyObservers;
  42577. /**
  42578. * Renders the utility layers scene on top of the original scene
  42579. */
  42580. render(): void;
  42581. /**
  42582. * Disposes of the renderer
  42583. */
  42584. dispose(): void;
  42585. private _updateCamera;
  42586. }
  42587. }
  42588. declare module "babylonjs/Gizmos/gizmo" {
  42589. import { Nullable } from "babylonjs/types";
  42590. import { IDisposable } from "babylonjs/scene";
  42591. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42592. import { Mesh } from "babylonjs/Meshes/mesh";
  42593. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42594. /**
  42595. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  42596. */
  42597. export class Gizmo implements IDisposable {
  42598. /** The utility layer the gizmo will be added to */
  42599. gizmoLayer: UtilityLayerRenderer;
  42600. /**
  42601. * The root mesh of the gizmo
  42602. */
  42603. _rootMesh: Mesh;
  42604. private _attachedMesh;
  42605. /**
  42606. * Ratio for the scale of the gizmo (Default: 1)
  42607. */
  42608. scaleRatio: number;
  42609. /**
  42610. * If a custom mesh has been set (Default: false)
  42611. */
  42612. protected _customMeshSet: boolean;
  42613. /**
  42614. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  42615. * * When set, interactions will be enabled
  42616. */
  42617. attachedMesh: Nullable<AbstractMesh>;
  42618. /**
  42619. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42620. * @param mesh The mesh to replace the default mesh of the gizmo
  42621. */
  42622. setCustomMesh(mesh: Mesh): void;
  42623. /**
  42624. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  42625. */
  42626. updateGizmoRotationToMatchAttachedMesh: boolean;
  42627. /**
  42628. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  42629. */
  42630. updateGizmoPositionToMatchAttachedMesh: boolean;
  42631. /**
  42632. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  42633. */
  42634. protected _updateScale: boolean;
  42635. protected _interactionsEnabled: boolean;
  42636. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42637. private _beforeRenderObserver;
  42638. private _tempVector;
  42639. /**
  42640. * Creates a gizmo
  42641. * @param gizmoLayer The utility layer the gizmo will be added to
  42642. */
  42643. constructor(
  42644. /** The utility layer the gizmo will be added to */
  42645. gizmoLayer?: UtilityLayerRenderer);
  42646. /**
  42647. * Updates the gizmo to match the attached mesh's position/rotation
  42648. */
  42649. protected _update(): void;
  42650. /**
  42651. * Disposes of the gizmo
  42652. */
  42653. dispose(): void;
  42654. }
  42655. }
  42656. declare module "babylonjs/Gizmos/planeDragGizmo" {
  42657. import { Observable } from "babylonjs/Misc/observable";
  42658. import { Nullable } from "babylonjs/types";
  42659. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42660. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42661. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42662. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  42663. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42664. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42665. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  42666. import { Scene } from "babylonjs/scene";
  42667. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  42668. /**
  42669. * Single plane drag gizmo
  42670. */
  42671. export class PlaneDragGizmo extends Gizmo {
  42672. /**
  42673. * Drag behavior responsible for the gizmos dragging interactions
  42674. */
  42675. dragBehavior: PointerDragBehavior;
  42676. private _pointerObserver;
  42677. /**
  42678. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42679. */
  42680. snapDistance: number;
  42681. /**
  42682. * Event that fires each time the gizmo snaps to a new location.
  42683. * * snapDistance is the the change in distance
  42684. */
  42685. onSnapObservable: Observable<{
  42686. snapDistance: number;
  42687. }>;
  42688. private _plane;
  42689. private _coloredMaterial;
  42690. private _hoverMaterial;
  42691. private _isEnabled;
  42692. private _parent;
  42693. /** @hidden */
  42694. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  42695. /** @hidden */
  42696. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42697. /**
  42698. * Creates a PlaneDragGizmo
  42699. * @param gizmoLayer The utility layer the gizmo will be added to
  42700. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  42701. * @param color The color of the gizmo
  42702. */
  42703. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42704. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42705. /**
  42706. * If the gizmo is enabled
  42707. */
  42708. isEnabled: boolean;
  42709. /**
  42710. * Disposes of the gizmo
  42711. */
  42712. dispose(): void;
  42713. }
  42714. }
  42715. declare module "babylonjs/Gizmos/positionGizmo" {
  42716. import { Observable } from "babylonjs/Misc/observable";
  42717. import { Nullable } from "babylonjs/types";
  42718. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42719. import { Mesh } from "babylonjs/Meshes/mesh";
  42720. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42721. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  42722. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  42723. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42724. /**
  42725. * Gizmo that enables dragging a mesh along 3 axis
  42726. */
  42727. export class PositionGizmo extends Gizmo {
  42728. /**
  42729. * Internal gizmo used for interactions on the x axis
  42730. */
  42731. xGizmo: AxisDragGizmo;
  42732. /**
  42733. * Internal gizmo used for interactions on the y axis
  42734. */
  42735. yGizmo: AxisDragGizmo;
  42736. /**
  42737. * Internal gizmo used for interactions on the z axis
  42738. */
  42739. zGizmo: AxisDragGizmo;
  42740. /**
  42741. * Internal gizmo used for interactions on the yz plane
  42742. */
  42743. xPlaneGizmo: PlaneDragGizmo;
  42744. /**
  42745. * Internal gizmo used for interactions on the xz plane
  42746. */
  42747. yPlaneGizmo: PlaneDragGizmo;
  42748. /**
  42749. * Internal gizmo used for interactions on the xy plane
  42750. */
  42751. zPlaneGizmo: PlaneDragGizmo;
  42752. /**
  42753. * private variables
  42754. */
  42755. private _meshAttached;
  42756. private _updateGizmoRotationToMatchAttachedMesh;
  42757. private _snapDistance;
  42758. private _scaleRatio;
  42759. /** Fires an event when any of it's sub gizmos are dragged */
  42760. onDragStartObservable: Observable<unknown>;
  42761. /** Fires an event when any of it's sub gizmos are released from dragging */
  42762. onDragEndObservable: Observable<unknown>;
  42763. /**
  42764. * If set to true, planar drag is enabled
  42765. */
  42766. private _planarGizmoEnabled;
  42767. attachedMesh: Nullable<AbstractMesh>;
  42768. /**
  42769. * Creates a PositionGizmo
  42770. * @param gizmoLayer The utility layer the gizmo will be added to
  42771. */
  42772. constructor(gizmoLayer?: UtilityLayerRenderer);
  42773. /**
  42774. * If the planar drag gizmo is enabled
  42775. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  42776. */
  42777. planarGizmoEnabled: boolean;
  42778. updateGizmoRotationToMatchAttachedMesh: boolean;
  42779. /**
  42780. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42781. */
  42782. snapDistance: number;
  42783. /**
  42784. * Ratio for the scale of the gizmo (Default: 1)
  42785. */
  42786. scaleRatio: number;
  42787. /**
  42788. * Disposes of the gizmo
  42789. */
  42790. dispose(): void;
  42791. /**
  42792. * CustomMeshes are not supported by this gizmo
  42793. * @param mesh The mesh to replace the default mesh of the gizmo
  42794. */
  42795. setCustomMesh(mesh: Mesh): void;
  42796. }
  42797. }
  42798. declare module "babylonjs/Gizmos/axisDragGizmo" {
  42799. import { Observable } from "babylonjs/Misc/observable";
  42800. import { Nullable } from "babylonjs/types";
  42801. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42802. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42803. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42804. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  42805. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42806. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42807. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  42808. import { Scene } from "babylonjs/scene";
  42809. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  42810. /**
  42811. * Single axis drag gizmo
  42812. */
  42813. export class AxisDragGizmo extends Gizmo {
  42814. /**
  42815. * Drag behavior responsible for the gizmos dragging interactions
  42816. */
  42817. dragBehavior: PointerDragBehavior;
  42818. private _pointerObserver;
  42819. /**
  42820. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42821. */
  42822. snapDistance: number;
  42823. /**
  42824. * Event that fires each time the gizmo snaps to a new location.
  42825. * * snapDistance is the the change in distance
  42826. */
  42827. onSnapObservable: Observable<{
  42828. snapDistance: number;
  42829. }>;
  42830. private _isEnabled;
  42831. private _parent;
  42832. private _arrow;
  42833. private _coloredMaterial;
  42834. private _hoverMaterial;
  42835. /** @hidden */
  42836. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  42837. /** @hidden */
  42838. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42839. /**
  42840. * Creates an AxisDragGizmo
  42841. * @param gizmoLayer The utility layer the gizmo will be added to
  42842. * @param dragAxis The axis which the gizmo will be able to drag on
  42843. * @param color The color of the gizmo
  42844. */
  42845. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42846. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42847. /**
  42848. * If the gizmo is enabled
  42849. */
  42850. isEnabled: boolean;
  42851. /**
  42852. * Disposes of the gizmo
  42853. */
  42854. dispose(): void;
  42855. }
  42856. }
  42857. declare module "babylonjs/Debug/axesViewer" {
  42858. import { Vector3 } from "babylonjs/Maths/math";
  42859. import { Nullable } from "babylonjs/types";
  42860. import { Scene } from "babylonjs/scene";
  42861. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42862. /**
  42863. * The Axes viewer will show 3 axes in a specific point in space
  42864. */
  42865. export class AxesViewer {
  42866. private _xAxis;
  42867. private _yAxis;
  42868. private _zAxis;
  42869. private _scaleLinesFactor;
  42870. private _instanced;
  42871. /**
  42872. * Gets the hosting scene
  42873. */
  42874. scene: Scene;
  42875. /**
  42876. * Gets or sets a number used to scale line length
  42877. */
  42878. scaleLines: number;
  42879. /** Gets the node hierarchy used to render x-axis */
  42880. readonly xAxis: TransformNode;
  42881. /** Gets the node hierarchy used to render y-axis */
  42882. readonly yAxis: TransformNode;
  42883. /** Gets the node hierarchy used to render z-axis */
  42884. readonly zAxis: TransformNode;
  42885. /**
  42886. * Creates a new AxesViewer
  42887. * @param scene defines the hosting scene
  42888. * @param scaleLines defines a number used to scale line length (1 by default)
  42889. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  42890. * @param xAxis defines the node hierarchy used to render the x-axis
  42891. * @param yAxis defines the node hierarchy used to render the y-axis
  42892. * @param zAxis defines the node hierarchy used to render the z-axis
  42893. */
  42894. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  42895. /**
  42896. * Force the viewer to update
  42897. * @param position defines the position of the viewer
  42898. * @param xaxis defines the x axis of the viewer
  42899. * @param yaxis defines the y axis of the viewer
  42900. * @param zaxis defines the z axis of the viewer
  42901. */
  42902. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  42903. /**
  42904. * Creates an instance of this axes viewer.
  42905. * @returns a new axes viewer with instanced meshes
  42906. */
  42907. createInstance(): AxesViewer;
  42908. /** Releases resources */
  42909. dispose(): void;
  42910. private static _SetRenderingGroupId;
  42911. }
  42912. }
  42913. declare module "babylonjs/Debug/boneAxesViewer" {
  42914. import { Nullable } from "babylonjs/types";
  42915. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  42916. import { Vector3 } from "babylonjs/Maths/math";
  42917. import { Mesh } from "babylonjs/Meshes/mesh";
  42918. import { Bone } from "babylonjs/Bones/bone";
  42919. import { Scene } from "babylonjs/scene";
  42920. /**
  42921. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  42922. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  42923. */
  42924. export class BoneAxesViewer extends AxesViewer {
  42925. /**
  42926. * Gets or sets the target mesh where to display the axes viewer
  42927. */
  42928. mesh: Nullable<Mesh>;
  42929. /**
  42930. * Gets or sets the target bone where to display the axes viewer
  42931. */
  42932. bone: Nullable<Bone>;
  42933. /** Gets current position */
  42934. pos: Vector3;
  42935. /** Gets direction of X axis */
  42936. xaxis: Vector3;
  42937. /** Gets direction of Y axis */
  42938. yaxis: Vector3;
  42939. /** Gets direction of Z axis */
  42940. zaxis: Vector3;
  42941. /**
  42942. * Creates a new BoneAxesViewer
  42943. * @param scene defines the hosting scene
  42944. * @param bone defines the target bone
  42945. * @param mesh defines the target mesh
  42946. * @param scaleLines defines a scaling factor for line length (1 by default)
  42947. */
  42948. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  42949. /**
  42950. * Force the viewer to update
  42951. */
  42952. update(): void;
  42953. /** Releases resources */
  42954. dispose(): void;
  42955. }
  42956. }
  42957. declare module "babylonjs/Debug/debugLayer" {
  42958. import { Observable } from "babylonjs/Misc/observable";
  42959. import { Scene } from "babylonjs/scene";
  42960. /**
  42961. * Interface used to define scene explorer extensibility option
  42962. */
  42963. export interface IExplorerExtensibilityOption {
  42964. /**
  42965. * Define the option label
  42966. */
  42967. label: string;
  42968. /**
  42969. * Defines the action to execute on click
  42970. */
  42971. action: (entity: any) => void;
  42972. }
  42973. /**
  42974. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  42975. */
  42976. export interface IExplorerExtensibilityGroup {
  42977. /**
  42978. * Defines a predicate to test if a given type mut be extended
  42979. */
  42980. predicate: (entity: any) => boolean;
  42981. /**
  42982. * Gets the list of options added to a type
  42983. */
  42984. entries: IExplorerExtensibilityOption[];
  42985. }
  42986. /**
  42987. * Interface used to define the options to use to create the Inspector
  42988. */
  42989. export interface IInspectorOptions {
  42990. /**
  42991. * Display in overlay mode (default: false)
  42992. */
  42993. overlay?: boolean;
  42994. /**
  42995. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  42996. */
  42997. globalRoot?: HTMLElement;
  42998. /**
  42999. * Display the Scene explorer
  43000. */
  43001. showExplorer?: boolean;
  43002. /**
  43003. * Display the property inspector
  43004. */
  43005. showInspector?: boolean;
  43006. /**
  43007. * Display in embed mode (both panes on the right)
  43008. */
  43009. embedMode?: boolean;
  43010. /**
  43011. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  43012. */
  43013. handleResize?: boolean;
  43014. /**
  43015. * Allow the panes to popup (default: true)
  43016. */
  43017. enablePopup?: boolean;
  43018. /**
  43019. * Allow the panes to be closed by users (default: true)
  43020. */
  43021. enableClose?: boolean;
  43022. /**
  43023. * Optional list of extensibility entries
  43024. */
  43025. explorerExtensibility?: IExplorerExtensibilityGroup[];
  43026. /**
  43027. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  43028. */
  43029. inspectorURL?: string;
  43030. }
  43031. module "babylonjs/scene" {
  43032. interface Scene {
  43033. /**
  43034. * @hidden
  43035. * Backing field
  43036. */
  43037. _debugLayer: DebugLayer;
  43038. /**
  43039. * Gets the debug layer (aka Inspector) associated with the scene
  43040. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43041. */
  43042. debugLayer: DebugLayer;
  43043. }
  43044. }
  43045. /**
  43046. * The debug layer (aka Inspector) is the go to tool in order to better understand
  43047. * what is happening in your scene
  43048. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43049. */
  43050. export class DebugLayer {
  43051. /**
  43052. * Define the url to get the inspector script from.
  43053. * By default it uses the babylonjs CDN.
  43054. * @ignoreNaming
  43055. */
  43056. static InspectorURL: string;
  43057. private _scene;
  43058. private BJSINSPECTOR;
  43059. /**
  43060. * Observable triggered when a property is changed through the inspector.
  43061. */
  43062. onPropertyChangedObservable: Observable<{
  43063. object: any;
  43064. property: string;
  43065. value: any;
  43066. initialValue: any;
  43067. }>;
  43068. /**
  43069. * Instantiates a new debug layer.
  43070. * The debug layer (aka Inspector) is the go to tool in order to better understand
  43071. * what is happening in your scene
  43072. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43073. * @param scene Defines the scene to inspect
  43074. */
  43075. constructor(scene: Scene);
  43076. /** Creates the inspector window. */
  43077. private _createInspector;
  43078. /**
  43079. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  43080. * @param entity defines the entity to select
  43081. * @param lineContainerTitle defines the specific block to highlight
  43082. */
  43083. select(entity: any, lineContainerTitle?: string): void;
  43084. /** Get the inspector from bundle or global */
  43085. private _getGlobalInspector;
  43086. /**
  43087. * Get if the inspector is visible or not.
  43088. * @returns true if visible otherwise, false
  43089. */
  43090. isVisible(): boolean;
  43091. /**
  43092. * Hide the inspector and close its window.
  43093. */
  43094. hide(): void;
  43095. /**
  43096. * Launch the debugLayer.
  43097. * @param config Define the configuration of the inspector
  43098. * @return a promise fulfilled when the debug layer is visible
  43099. */
  43100. show(config?: IInspectorOptions): Promise<DebugLayer>;
  43101. }
  43102. }
  43103. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  43104. import { Nullable } from "babylonjs/types";
  43105. import { Scene } from "babylonjs/scene";
  43106. import { Vector4, Color4 } from "babylonjs/Maths/math";
  43107. import { Mesh } from "babylonjs/Meshes/mesh";
  43108. /**
  43109. * Class containing static functions to help procedurally build meshes
  43110. */
  43111. export class BoxBuilder {
  43112. /**
  43113. * Creates a box mesh
  43114. * * The parameter `size` sets the size (float) of each box side (default 1)
  43115. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  43116. * * 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)
  43117. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  43118. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43119. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43120. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43121. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  43122. * @param name defines the name of the mesh
  43123. * @param options defines the options used to create the mesh
  43124. * @param scene defines the hosting scene
  43125. * @returns the box mesh
  43126. */
  43127. static CreateBox(name: string, options: {
  43128. size?: number;
  43129. width?: number;
  43130. height?: number;
  43131. depth?: number;
  43132. faceUV?: Vector4[];
  43133. faceColors?: Color4[];
  43134. sideOrientation?: number;
  43135. frontUVs?: Vector4;
  43136. backUVs?: Vector4;
  43137. wrap?: boolean;
  43138. topBaseAt?: number;
  43139. bottomBaseAt?: number;
  43140. updatable?: boolean;
  43141. }, scene?: Nullable<Scene>): Mesh;
  43142. }
  43143. }
  43144. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  43145. import { Vector4 } from "babylonjs/Maths/math";
  43146. import { Mesh } from "babylonjs/Meshes/mesh";
  43147. /**
  43148. * Class containing static functions to help procedurally build meshes
  43149. */
  43150. export class SphereBuilder {
  43151. /**
  43152. * Creates a sphere mesh
  43153. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  43154. * * 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`)
  43155. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  43156. * * 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
  43157. * * 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)
  43158. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43159. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43160. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43161. * @param name defines the name of the mesh
  43162. * @param options defines the options used to create the mesh
  43163. * @param scene defines the hosting scene
  43164. * @returns the sphere mesh
  43165. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  43166. */
  43167. static CreateSphere(name: string, options: {
  43168. segments?: number;
  43169. diameter?: number;
  43170. diameterX?: number;
  43171. diameterY?: number;
  43172. diameterZ?: number;
  43173. arc?: number;
  43174. slice?: number;
  43175. sideOrientation?: number;
  43176. frontUVs?: Vector4;
  43177. backUVs?: Vector4;
  43178. updatable?: boolean;
  43179. }, scene: any): Mesh;
  43180. }
  43181. }
  43182. declare module "babylonjs/Debug/physicsViewer" {
  43183. import { Nullable } from "babylonjs/types";
  43184. import { Scene } from "babylonjs/scene";
  43185. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43186. import { Mesh } from "babylonjs/Meshes/mesh";
  43187. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  43188. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  43189. /**
  43190. * Used to show the physics impostor around the specific mesh
  43191. */
  43192. export class PhysicsViewer {
  43193. /** @hidden */
  43194. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  43195. /** @hidden */
  43196. protected _meshes: Array<Nullable<AbstractMesh>>;
  43197. /** @hidden */
  43198. protected _scene: Nullable<Scene>;
  43199. /** @hidden */
  43200. protected _numMeshes: number;
  43201. /** @hidden */
  43202. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  43203. private _renderFunction;
  43204. private _utilityLayer;
  43205. private _debugBoxMesh;
  43206. private _debugSphereMesh;
  43207. private _debugCylinderMesh;
  43208. private _debugMaterial;
  43209. private _debugMeshMeshes;
  43210. /**
  43211. * Creates a new PhysicsViewer
  43212. * @param scene defines the hosting scene
  43213. */
  43214. constructor(scene: Scene);
  43215. /** @hidden */
  43216. protected _updateDebugMeshes(): void;
  43217. /**
  43218. * Renders a specified physic impostor
  43219. * @param impostor defines the impostor to render
  43220. * @param targetMesh defines the mesh represented by the impostor
  43221. * @returns the new debug mesh used to render the impostor
  43222. */
  43223. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  43224. /**
  43225. * Hides a specified physic impostor
  43226. * @param impostor defines the impostor to hide
  43227. */
  43228. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  43229. private _getDebugMaterial;
  43230. private _getDebugBoxMesh;
  43231. private _getDebugSphereMesh;
  43232. private _getDebugCylinderMesh;
  43233. private _getDebugMeshMesh;
  43234. private _getDebugMesh;
  43235. /** Releases all resources */
  43236. dispose(): void;
  43237. }
  43238. }
  43239. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  43240. import { Vector3, Color4 } from "babylonjs/Maths/math";
  43241. import { Nullable } from "babylonjs/types";
  43242. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  43243. import { Scene } from "babylonjs/scene";
  43244. /**
  43245. * Class containing static functions to help procedurally build meshes
  43246. */
  43247. export class LinesBuilder {
  43248. /**
  43249. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  43250. * * 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
  43251. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  43252. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  43253. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  43254. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  43255. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  43256. * * 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
  43257. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  43258. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43259. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  43260. * @param name defines the name of the new line system
  43261. * @param options defines the options used to create the line system
  43262. * @param scene defines the hosting scene
  43263. * @returns a new line system mesh
  43264. */
  43265. static CreateLineSystem(name: string, options: {
  43266. lines: Vector3[][];
  43267. updatable?: boolean;
  43268. instance?: Nullable<LinesMesh>;
  43269. colors?: Nullable<Color4[][]>;
  43270. useVertexAlpha?: boolean;
  43271. }, scene: Nullable<Scene>): LinesMesh;
  43272. /**
  43273. * Creates a line mesh
  43274. * 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
  43275. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43276. * * The parameter `points` is an array successive Vector3
  43277. * * 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
  43278. * * The optional parameter `colors` is an array of successive Color4, one per line point
  43279. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  43280. * * When updating an instance, remember that only point positions can change, not the number of points
  43281. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43282. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  43283. * @param name defines the name of the new line system
  43284. * @param options defines the options used to create the line system
  43285. * @param scene defines the hosting scene
  43286. * @returns a new line mesh
  43287. */
  43288. static CreateLines(name: string, options: {
  43289. points: Vector3[];
  43290. updatable?: boolean;
  43291. instance?: Nullable<LinesMesh>;
  43292. colors?: Color4[];
  43293. useVertexAlpha?: boolean;
  43294. }, scene?: Nullable<Scene>): LinesMesh;
  43295. /**
  43296. * Creates a dashed line mesh
  43297. * * 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
  43298. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43299. * * The parameter `points` is an array successive Vector3
  43300. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  43301. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  43302. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  43303. * * 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
  43304. * * When updating an instance, remember that only point positions can change, not the number of points
  43305. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43306. * @param name defines the name of the mesh
  43307. * @param options defines the options used to create the mesh
  43308. * @param scene defines the hosting scene
  43309. * @returns the dashed line mesh
  43310. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  43311. */
  43312. static CreateDashedLines(name: string, options: {
  43313. points: Vector3[];
  43314. dashSize?: number;
  43315. gapSize?: number;
  43316. dashNb?: number;
  43317. updatable?: boolean;
  43318. instance?: LinesMesh;
  43319. }, scene?: Nullable<Scene>): LinesMesh;
  43320. }
  43321. }
  43322. declare module "babylonjs/Debug/rayHelper" {
  43323. import { Nullable } from "babylonjs/types";
  43324. import { Ray } from "babylonjs/Culling/ray";
  43325. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43326. import { Scene } from "babylonjs/scene";
  43327. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43328. import "babylonjs/Meshes/Builders/linesBuilder";
  43329. /**
  43330. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43331. * in order to better appreciate the issue one might have.
  43332. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43333. */
  43334. export class RayHelper {
  43335. /**
  43336. * Defines the ray we are currently tryin to visualize.
  43337. */
  43338. ray: Nullable<Ray>;
  43339. private _renderPoints;
  43340. private _renderLine;
  43341. private _renderFunction;
  43342. private _scene;
  43343. private _updateToMeshFunction;
  43344. private _attachedToMesh;
  43345. private _meshSpaceDirection;
  43346. private _meshSpaceOrigin;
  43347. /**
  43348. * Helper function to create a colored helper in a scene in one line.
  43349. * @param ray Defines the ray we are currently tryin to visualize
  43350. * @param scene Defines the scene the ray is used in
  43351. * @param color Defines the color we want to see the ray in
  43352. * @returns The newly created ray helper.
  43353. */
  43354. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  43355. /**
  43356. * Instantiate a new ray helper.
  43357. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43358. * in order to better appreciate the issue one might have.
  43359. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43360. * @param ray Defines the ray we are currently tryin to visualize
  43361. */
  43362. constructor(ray: Ray);
  43363. /**
  43364. * Shows the ray we are willing to debug.
  43365. * @param scene Defines the scene the ray needs to be rendered in
  43366. * @param color Defines the color the ray needs to be rendered in
  43367. */
  43368. show(scene: Scene, color?: Color3): void;
  43369. /**
  43370. * Hides the ray we are debugging.
  43371. */
  43372. hide(): void;
  43373. private _render;
  43374. /**
  43375. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  43376. * @param mesh Defines the mesh we want the helper attached to
  43377. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  43378. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  43379. * @param length Defines the length of the ray
  43380. */
  43381. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  43382. /**
  43383. * Detach the ray helper from the mesh it has previously been attached to.
  43384. */
  43385. detachFromMesh(): void;
  43386. private _updateToMesh;
  43387. /**
  43388. * Dispose the helper and release its associated resources.
  43389. */
  43390. dispose(): void;
  43391. }
  43392. }
  43393. declare module "babylonjs/Debug/skeletonViewer" {
  43394. import { Color3 } from "babylonjs/Maths/math";
  43395. import { Scene } from "babylonjs/scene";
  43396. import { Nullable } from "babylonjs/types";
  43397. import { Skeleton } from "babylonjs/Bones/skeleton";
  43398. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43399. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  43400. /**
  43401. * Class used to render a debug view of a given skeleton
  43402. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  43403. */
  43404. export class SkeletonViewer {
  43405. /** defines the skeleton to render */
  43406. skeleton: Skeleton;
  43407. /** defines the mesh attached to the skeleton */
  43408. mesh: AbstractMesh;
  43409. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43410. autoUpdateBonesMatrices: boolean;
  43411. /** defines the rendering group id to use with the viewer */
  43412. renderingGroupId: number;
  43413. /** Gets or sets the color used to render the skeleton */
  43414. color: Color3;
  43415. private _scene;
  43416. private _debugLines;
  43417. private _debugMesh;
  43418. private _isEnabled;
  43419. private _renderFunction;
  43420. private _utilityLayer;
  43421. /**
  43422. * Returns the mesh used to render the bones
  43423. */
  43424. readonly debugMesh: Nullable<LinesMesh>;
  43425. /**
  43426. * Creates a new SkeletonViewer
  43427. * @param skeleton defines the skeleton to render
  43428. * @param mesh defines the mesh attached to the skeleton
  43429. * @param scene defines the hosting scene
  43430. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  43431. * @param renderingGroupId defines the rendering group id to use with the viewer
  43432. */
  43433. constructor(
  43434. /** defines the skeleton to render */
  43435. skeleton: Skeleton,
  43436. /** defines the mesh attached to the skeleton */
  43437. mesh: AbstractMesh, scene: Scene,
  43438. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43439. autoUpdateBonesMatrices?: boolean,
  43440. /** defines the rendering group id to use with the viewer */
  43441. renderingGroupId?: number);
  43442. /** Gets or sets a boolean indicating if the viewer is enabled */
  43443. isEnabled: boolean;
  43444. private _getBonePosition;
  43445. private _getLinesForBonesWithLength;
  43446. private _getLinesForBonesNoLength;
  43447. /** Update the viewer to sync with current skeleton state */
  43448. update(): void;
  43449. /** Release associated resources */
  43450. dispose(): void;
  43451. }
  43452. }
  43453. declare module "babylonjs/Debug/index" {
  43454. export * from "babylonjs/Debug/axesViewer";
  43455. export * from "babylonjs/Debug/boneAxesViewer";
  43456. export * from "babylonjs/Debug/debugLayer";
  43457. export * from "babylonjs/Debug/physicsViewer";
  43458. export * from "babylonjs/Debug/rayHelper";
  43459. export * from "babylonjs/Debug/skeletonViewer";
  43460. }
  43461. declare module "babylonjs/Engines/nullEngine" {
  43462. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  43463. import { Scene } from "babylonjs/scene";
  43464. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  43465. import { Engine } from "babylonjs/Engines/engine";
  43466. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  43467. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  43468. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  43469. import { Effect } from "babylonjs/Materials/effect";
  43470. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  43471. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  43472. /**
  43473. * Options to create the null engine
  43474. */
  43475. export class NullEngineOptions {
  43476. /**
  43477. * Render width (Default: 512)
  43478. */
  43479. renderWidth: number;
  43480. /**
  43481. * Render height (Default: 256)
  43482. */
  43483. renderHeight: number;
  43484. /**
  43485. * Texture size (Default: 512)
  43486. */
  43487. textureSize: number;
  43488. /**
  43489. * If delta time between frames should be constant
  43490. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43491. */
  43492. deterministicLockstep: boolean;
  43493. /**
  43494. * Maximum about of steps between frames (Default: 4)
  43495. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43496. */
  43497. lockstepMaxSteps: number;
  43498. }
  43499. /**
  43500. * The null engine class provides support for headless version of babylon.js.
  43501. * This can be used in server side scenario or for testing purposes
  43502. */
  43503. export class NullEngine extends Engine {
  43504. private _options;
  43505. /**
  43506. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43507. */
  43508. isDeterministicLockStep(): boolean;
  43509. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  43510. getLockstepMaxSteps(): number;
  43511. /**
  43512. * Sets hardware scaling, used to save performance if needed
  43513. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  43514. */
  43515. getHardwareScalingLevel(): number;
  43516. constructor(options?: NullEngineOptions);
  43517. createVertexBuffer(vertices: FloatArray): DataBuffer;
  43518. createIndexBuffer(indices: IndicesArray): DataBuffer;
  43519. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  43520. getRenderWidth(useScreen?: boolean): number;
  43521. getRenderHeight(useScreen?: boolean): number;
  43522. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  43523. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  43524. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  43525. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  43526. bindSamplers(effect: Effect): void;
  43527. enableEffect(effect: Effect): void;
  43528. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  43529. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  43530. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  43531. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  43532. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  43533. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  43534. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  43535. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  43536. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  43537. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  43538. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  43539. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  43540. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  43541. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  43542. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  43543. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43544. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43545. setFloat(uniform: WebGLUniformLocation, value: number): void;
  43546. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  43547. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  43548. setBool(uniform: WebGLUniformLocation, bool: number): void;
  43549. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  43550. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  43551. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  43552. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  43553. bindBuffers(vertexBuffers: {
  43554. [key: string]: VertexBuffer;
  43555. }, indexBuffer: DataBuffer, effect: Effect): void;
  43556. wipeCaches(bruteForce?: boolean): void;
  43557. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  43558. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  43559. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  43560. /** @hidden */
  43561. _createTexture(): WebGLTexture;
  43562. /** @hidden */
  43563. _releaseTexture(texture: InternalTexture): void;
  43564. 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;
  43565. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  43566. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  43567. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  43568. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  43569. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  43570. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  43571. areAllEffectsReady(): boolean;
  43572. /**
  43573. * @hidden
  43574. * Get the current error code of the webGL context
  43575. * @returns the error code
  43576. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  43577. */
  43578. getError(): number;
  43579. /** @hidden */
  43580. _getUnpackAlignement(): number;
  43581. /** @hidden */
  43582. _unpackFlipY(value: boolean): void;
  43583. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  43584. /**
  43585. * Updates a dynamic vertex buffer.
  43586. * @param vertexBuffer the vertex buffer to update
  43587. * @param data the data used to update the vertex buffer
  43588. * @param byteOffset the byte offset of the data (optional)
  43589. * @param byteLength the byte length of the data (optional)
  43590. */
  43591. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  43592. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  43593. /** @hidden */
  43594. _bindTexture(channel: number, texture: InternalTexture): void;
  43595. /** @hidden */
  43596. _releaseBuffer(buffer: DataBuffer): boolean;
  43597. releaseEffects(): void;
  43598. displayLoadingUI(): void;
  43599. hideLoadingUI(): void;
  43600. /** @hidden */
  43601. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43602. /** @hidden */
  43603. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43604. /** @hidden */
  43605. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43606. /** @hidden */
  43607. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  43608. }
  43609. }
  43610. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  43611. import { Nullable, int } from "babylonjs/types";
  43612. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  43613. /** @hidden */
  43614. export class _OcclusionDataStorage {
  43615. /** @hidden */
  43616. occlusionInternalRetryCounter: number;
  43617. /** @hidden */
  43618. isOcclusionQueryInProgress: boolean;
  43619. /** @hidden */
  43620. isOccluded: boolean;
  43621. /** @hidden */
  43622. occlusionRetryCount: number;
  43623. /** @hidden */
  43624. occlusionType: number;
  43625. /** @hidden */
  43626. occlusionQueryAlgorithmType: number;
  43627. }
  43628. module "babylonjs/Engines/engine" {
  43629. interface Engine {
  43630. /**
  43631. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  43632. * @return the new query
  43633. */
  43634. createQuery(): WebGLQuery;
  43635. /**
  43636. * Delete and release a webGL query
  43637. * @param query defines the query to delete
  43638. * @return the current engine
  43639. */
  43640. deleteQuery(query: WebGLQuery): Engine;
  43641. /**
  43642. * Check if a given query has resolved and got its value
  43643. * @param query defines the query to check
  43644. * @returns true if the query got its value
  43645. */
  43646. isQueryResultAvailable(query: WebGLQuery): boolean;
  43647. /**
  43648. * Gets the value of a given query
  43649. * @param query defines the query to check
  43650. * @returns the value of the query
  43651. */
  43652. getQueryResult(query: WebGLQuery): number;
  43653. /**
  43654. * Initiates an occlusion query
  43655. * @param algorithmType defines the algorithm to use
  43656. * @param query defines the query to use
  43657. * @returns the current engine
  43658. * @see http://doc.babylonjs.com/features/occlusionquery
  43659. */
  43660. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  43661. /**
  43662. * Ends an occlusion query
  43663. * @see http://doc.babylonjs.com/features/occlusionquery
  43664. * @param algorithmType defines the algorithm to use
  43665. * @returns the current engine
  43666. */
  43667. endOcclusionQuery(algorithmType: number): Engine;
  43668. /**
  43669. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  43670. * Please note that only one query can be issued at a time
  43671. * @returns a time token used to track the time span
  43672. */
  43673. startTimeQuery(): Nullable<_TimeToken>;
  43674. /**
  43675. * Ends a time query
  43676. * @param token defines the token used to measure the time span
  43677. * @returns the time spent (in ns)
  43678. */
  43679. endTimeQuery(token: _TimeToken): int;
  43680. /** @hidden */
  43681. _currentNonTimestampToken: Nullable<_TimeToken>;
  43682. /** @hidden */
  43683. _createTimeQuery(): WebGLQuery;
  43684. /** @hidden */
  43685. _deleteTimeQuery(query: WebGLQuery): void;
  43686. /** @hidden */
  43687. _getGlAlgorithmType(algorithmType: number): number;
  43688. /** @hidden */
  43689. _getTimeQueryResult(query: WebGLQuery): any;
  43690. /** @hidden */
  43691. _getTimeQueryAvailability(query: WebGLQuery): any;
  43692. }
  43693. }
  43694. module "babylonjs/Meshes/abstractMesh" {
  43695. interface AbstractMesh {
  43696. /**
  43697. * Backing filed
  43698. * @hidden
  43699. */
  43700. __occlusionDataStorage: _OcclusionDataStorage;
  43701. /**
  43702. * Access property
  43703. * @hidden
  43704. */
  43705. _occlusionDataStorage: _OcclusionDataStorage;
  43706. /**
  43707. * 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.
  43708. * The default value is -1 which means don't break the query and wait till the result
  43709. * @see http://doc.babylonjs.com/features/occlusionquery
  43710. */
  43711. occlusionRetryCount: number;
  43712. /**
  43713. * 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:
  43714. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  43715. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  43716. * * 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.
  43717. * @see http://doc.babylonjs.com/features/occlusionquery
  43718. */
  43719. occlusionType: number;
  43720. /**
  43721. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  43722. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  43723. * * 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.
  43724. * @see http://doc.babylonjs.com/features/occlusionquery
  43725. */
  43726. occlusionQueryAlgorithmType: number;
  43727. /**
  43728. * 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
  43729. * @see http://doc.babylonjs.com/features/occlusionquery
  43730. */
  43731. isOccluded: boolean;
  43732. /**
  43733. * Flag to check the progress status of the query
  43734. * @see http://doc.babylonjs.com/features/occlusionquery
  43735. */
  43736. isOcclusionQueryInProgress: boolean;
  43737. }
  43738. }
  43739. }
  43740. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  43741. import { Nullable } from "babylonjs/types";
  43742. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  43743. /** @hidden */
  43744. export var _forceTransformFeedbackToBundle: boolean;
  43745. module "babylonjs/Engines/engine" {
  43746. interface Engine {
  43747. /**
  43748. * Creates a webGL transform feedback object
  43749. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  43750. * @returns the webGL transform feedback object
  43751. */
  43752. createTransformFeedback(): WebGLTransformFeedback;
  43753. /**
  43754. * Delete a webGL transform feedback object
  43755. * @param value defines the webGL transform feedback object to delete
  43756. */
  43757. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  43758. /**
  43759. * Bind a webGL transform feedback object to the webgl context
  43760. * @param value defines the webGL transform feedback object to bind
  43761. */
  43762. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  43763. /**
  43764. * Begins a transform feedback operation
  43765. * @param usePoints defines if points or triangles must be used
  43766. */
  43767. beginTransformFeedback(usePoints: boolean): void;
  43768. /**
  43769. * Ends a transform feedback operation
  43770. */
  43771. endTransformFeedback(): void;
  43772. /**
  43773. * Specify the varyings to use with transform feedback
  43774. * @param program defines the associated webGL program
  43775. * @param value defines the list of strings representing the varying names
  43776. */
  43777. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  43778. /**
  43779. * Bind a webGL buffer for a transform feedback operation
  43780. * @param value defines the webGL buffer to bind
  43781. */
  43782. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  43783. }
  43784. }
  43785. }
  43786. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  43787. import { Scene } from "babylonjs/scene";
  43788. import { Engine } from "babylonjs/Engines/engine";
  43789. import { Texture } from "babylonjs/Materials/Textures/texture";
  43790. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  43791. import "babylonjs/Engines/Extensions/engine.multiRender";
  43792. /**
  43793. * Creation options of the multi render target texture.
  43794. */
  43795. export interface IMultiRenderTargetOptions {
  43796. /**
  43797. * Define if the texture needs to create mip maps after render.
  43798. */
  43799. generateMipMaps?: boolean;
  43800. /**
  43801. * Define the types of all the draw buffers we want to create
  43802. */
  43803. types?: number[];
  43804. /**
  43805. * Define the sampling modes of all the draw buffers we want to create
  43806. */
  43807. samplingModes?: number[];
  43808. /**
  43809. * Define if a depth buffer is required
  43810. */
  43811. generateDepthBuffer?: boolean;
  43812. /**
  43813. * Define if a stencil buffer is required
  43814. */
  43815. generateStencilBuffer?: boolean;
  43816. /**
  43817. * Define if a depth texture is required instead of a depth buffer
  43818. */
  43819. generateDepthTexture?: boolean;
  43820. /**
  43821. * Define the number of desired draw buffers
  43822. */
  43823. textureCount?: number;
  43824. /**
  43825. * Define if aspect ratio should be adapted to the texture or stay the scene one
  43826. */
  43827. doNotChangeAspectRatio?: boolean;
  43828. /**
  43829. * Define the default type of the buffers we are creating
  43830. */
  43831. defaultType?: number;
  43832. }
  43833. /**
  43834. * A multi render target, like a render target provides the ability to render to a texture.
  43835. * Unlike the render target, it can render to several draw buffers in one draw.
  43836. * This is specially interesting in deferred rendering or for any effects requiring more than
  43837. * just one color from a single pass.
  43838. */
  43839. export class MultiRenderTarget extends RenderTargetTexture {
  43840. private _internalTextures;
  43841. private _textures;
  43842. private _multiRenderTargetOptions;
  43843. /**
  43844. * Get if draw buffers are currently supported by the used hardware and browser.
  43845. */
  43846. readonly isSupported: boolean;
  43847. /**
  43848. * Get the list of textures generated by the multi render target.
  43849. */
  43850. readonly textures: Texture[];
  43851. /**
  43852. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  43853. */
  43854. readonly depthTexture: Texture;
  43855. /**
  43856. * Set the wrapping mode on U of all the textures we are rendering to.
  43857. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43858. */
  43859. wrapU: number;
  43860. /**
  43861. * Set the wrapping mode on V of all the textures we are rendering to.
  43862. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43863. */
  43864. wrapV: number;
  43865. /**
  43866. * Instantiate a new multi render target texture.
  43867. * A multi render target, like a render target provides the ability to render to a texture.
  43868. * Unlike the render target, it can render to several draw buffers in one draw.
  43869. * This is specially interesting in deferred rendering or for any effects requiring more than
  43870. * just one color from a single pass.
  43871. * @param name Define the name of the texture
  43872. * @param size Define the size of the buffers to render to
  43873. * @param count Define the number of target we are rendering into
  43874. * @param scene Define the scene the texture belongs to
  43875. * @param options Define the options used to create the multi render target
  43876. */
  43877. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  43878. /** @hidden */
  43879. _rebuild(): void;
  43880. private _createInternalTextures;
  43881. private _createTextures;
  43882. /**
  43883. * Define the number of samples used if MSAA is enabled.
  43884. */
  43885. samples: number;
  43886. /**
  43887. * Resize all the textures in the multi render target.
  43888. * Be carrefull as it will recreate all the data in the new texture.
  43889. * @param size Define the new size
  43890. */
  43891. resize(size: any): void;
  43892. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  43893. /**
  43894. * Dispose the render targets and their associated resources
  43895. */
  43896. dispose(): void;
  43897. /**
  43898. * Release all the underlying texture used as draw buffers.
  43899. */
  43900. releaseInternalTextures(): void;
  43901. }
  43902. }
  43903. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  43904. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  43905. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  43906. import { Nullable } from "babylonjs/types";
  43907. module "babylonjs/Engines/engine" {
  43908. interface Engine {
  43909. /**
  43910. * Unbind a list of render target textures from the webGL context
  43911. * This is used only when drawBuffer extension or webGL2 are active
  43912. * @param textures defines the render target textures to unbind
  43913. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  43914. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  43915. */
  43916. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  43917. /**
  43918. * Create a multi render target texture
  43919. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  43920. * @param size defines the size of the texture
  43921. * @param options defines the creation options
  43922. * @returns the cube texture as an InternalTexture
  43923. */
  43924. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  43925. /**
  43926. * Update the sample count for a given multiple render target texture
  43927. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  43928. * @param textures defines the textures to update
  43929. * @param samples defines the sample count to set
  43930. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  43931. */
  43932. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  43933. }
  43934. }
  43935. }
  43936. declare module "babylonjs/Engines/Extensions/index" {
  43937. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  43938. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  43939. export * from "babylonjs/Engines/Extensions/engine.multiview";
  43940. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  43941. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  43942. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  43943. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  43944. export * from "babylonjs/Engines/Extensions/engine.webVR";
  43945. }
  43946. declare module "babylonjs/Engines/index" {
  43947. export * from "babylonjs/Engines/constants";
  43948. export * from "babylonjs/Engines/engine";
  43949. export * from "babylonjs/Engines/engineStore";
  43950. export * from "babylonjs/Engines/nullEngine";
  43951. export * from "babylonjs/Engines/Extensions/index";
  43952. export * from "babylonjs/Engines/IPipelineContext";
  43953. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  43954. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  43955. }
  43956. declare module "babylonjs/Events/clipboardEvents" {
  43957. /**
  43958. * Gather the list of clipboard event types as constants.
  43959. */
  43960. export class ClipboardEventTypes {
  43961. /**
  43962. * The clipboard event is fired when a copy command is active (pressed).
  43963. */
  43964. static readonly COPY: number;
  43965. /**
  43966. * The clipboard event is fired when a cut command is active (pressed).
  43967. */
  43968. static readonly CUT: number;
  43969. /**
  43970. * The clipboard event is fired when a paste command is active (pressed).
  43971. */
  43972. static readonly PASTE: number;
  43973. }
  43974. /**
  43975. * This class is used to store clipboard related info for the onClipboardObservable event.
  43976. */
  43977. export class ClipboardInfo {
  43978. /**
  43979. * Defines the type of event (BABYLON.ClipboardEventTypes)
  43980. */
  43981. type: number;
  43982. /**
  43983. * Defines the related dom event
  43984. */
  43985. event: ClipboardEvent;
  43986. /**
  43987. *Creates an instance of ClipboardInfo.
  43988. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  43989. * @param event Defines the related dom event
  43990. */
  43991. constructor(
  43992. /**
  43993. * Defines the type of event (BABYLON.ClipboardEventTypes)
  43994. */
  43995. type: number,
  43996. /**
  43997. * Defines the related dom event
  43998. */
  43999. event: ClipboardEvent);
  44000. /**
  44001. * Get the clipboard event's type from the keycode.
  44002. * @param keyCode Defines the keyCode for the current keyboard event.
  44003. * @return {number}
  44004. */
  44005. static GetTypeFromCharacter(keyCode: number): number;
  44006. }
  44007. }
  44008. declare module "babylonjs/Events/index" {
  44009. export * from "babylonjs/Events/keyboardEvents";
  44010. export * from "babylonjs/Events/pointerEvents";
  44011. export * from "babylonjs/Events/clipboardEvents";
  44012. }
  44013. declare module "babylonjs/Loading/sceneLoader" {
  44014. import { Observable } from "babylonjs/Misc/observable";
  44015. import { Nullable } from "babylonjs/types";
  44016. import { Scene } from "babylonjs/scene";
  44017. import { Engine } from "babylonjs/Engines/engine";
  44018. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44019. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  44020. import { AssetContainer } from "babylonjs/assetContainer";
  44021. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  44022. import { Skeleton } from "babylonjs/Bones/skeleton";
  44023. /**
  44024. * Class used to represent data loading progression
  44025. */
  44026. export class SceneLoaderProgressEvent {
  44027. /** defines if data length to load can be evaluated */
  44028. readonly lengthComputable: boolean;
  44029. /** defines the loaded data length */
  44030. readonly loaded: number;
  44031. /** defines the data length to load */
  44032. readonly total: number;
  44033. /**
  44034. * Create a new progress event
  44035. * @param lengthComputable defines if data length to load can be evaluated
  44036. * @param loaded defines the loaded data length
  44037. * @param total defines the data length to load
  44038. */
  44039. constructor(
  44040. /** defines if data length to load can be evaluated */
  44041. lengthComputable: boolean,
  44042. /** defines the loaded data length */
  44043. loaded: number,
  44044. /** defines the data length to load */
  44045. total: number);
  44046. /**
  44047. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  44048. * @param event defines the source event
  44049. * @returns a new SceneLoaderProgressEvent
  44050. */
  44051. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  44052. }
  44053. /**
  44054. * Interface used by SceneLoader plugins to define supported file extensions
  44055. */
  44056. export interface ISceneLoaderPluginExtensions {
  44057. /**
  44058. * Defines the list of supported extensions
  44059. */
  44060. [extension: string]: {
  44061. isBinary: boolean;
  44062. };
  44063. }
  44064. /**
  44065. * Interface used by SceneLoader plugin factory
  44066. */
  44067. export interface ISceneLoaderPluginFactory {
  44068. /**
  44069. * Defines the name of the factory
  44070. */
  44071. name: string;
  44072. /**
  44073. * Function called to create a new plugin
  44074. * @return the new plugin
  44075. */
  44076. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  44077. /**
  44078. * Boolean indicating if the plugin can direct load specific data
  44079. */
  44080. canDirectLoad?: (data: string) => boolean;
  44081. }
  44082. /**
  44083. * Interface used to define a SceneLoader plugin
  44084. */
  44085. export interface ISceneLoaderPlugin {
  44086. /**
  44087. * The friendly name of this plugin.
  44088. */
  44089. name: string;
  44090. /**
  44091. * The file extensions supported by this plugin.
  44092. */
  44093. extensions: string | ISceneLoaderPluginExtensions;
  44094. /**
  44095. * Import meshes into a scene.
  44096. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44097. * @param scene The scene to import into
  44098. * @param data The data to import
  44099. * @param rootUrl The root url for scene and resources
  44100. * @param meshes The meshes array to import into
  44101. * @param particleSystems The particle systems array to import into
  44102. * @param skeletons The skeletons array to import into
  44103. * @param onError The callback when import fails
  44104. * @returns True if successful or false otherwise
  44105. */
  44106. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  44107. /**
  44108. * Load into a scene.
  44109. * @param scene The scene to load into
  44110. * @param data The data to import
  44111. * @param rootUrl The root url for scene and resources
  44112. * @param onError The callback when import fails
  44113. * @returns true if successful or false otherwise
  44114. */
  44115. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  44116. /**
  44117. * The callback that returns true if the data can be directly loaded.
  44118. */
  44119. canDirectLoad?: (data: string) => boolean;
  44120. /**
  44121. * The callback that allows custom handling of the root url based on the response url.
  44122. */
  44123. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  44124. /**
  44125. * Load into an asset container.
  44126. * @param scene The scene to load into
  44127. * @param data The data to import
  44128. * @param rootUrl The root url for scene and resources
  44129. * @param onError The callback when import fails
  44130. * @returns The loaded asset container
  44131. */
  44132. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  44133. }
  44134. /**
  44135. * Interface used to define an async SceneLoader plugin
  44136. */
  44137. export interface ISceneLoaderPluginAsync {
  44138. /**
  44139. * The friendly name of this plugin.
  44140. */
  44141. name: string;
  44142. /**
  44143. * The file extensions supported by this plugin.
  44144. */
  44145. extensions: string | ISceneLoaderPluginExtensions;
  44146. /**
  44147. * Import meshes into a scene.
  44148. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44149. * @param scene The scene to import into
  44150. * @param data The data to import
  44151. * @param rootUrl The root url for scene and resources
  44152. * @param onProgress The callback when the load progresses
  44153. * @param fileName Defines the name of the file to load
  44154. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  44155. */
  44156. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  44157. meshes: AbstractMesh[];
  44158. particleSystems: IParticleSystem[];
  44159. skeletons: Skeleton[];
  44160. animationGroups: AnimationGroup[];
  44161. }>;
  44162. /**
  44163. * Load into a scene.
  44164. * @param scene The scene to load into
  44165. * @param data The data to import
  44166. * @param rootUrl The root url for scene and resources
  44167. * @param onProgress The callback when the load progresses
  44168. * @param fileName Defines the name of the file to load
  44169. * @returns Nothing
  44170. */
  44171. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  44172. /**
  44173. * The callback that returns true if the data can be directly loaded.
  44174. */
  44175. canDirectLoad?: (data: string) => boolean;
  44176. /**
  44177. * The callback that allows custom handling of the root url based on the response url.
  44178. */
  44179. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  44180. /**
  44181. * Load into an asset container.
  44182. * @param scene The scene to load into
  44183. * @param data The data to import
  44184. * @param rootUrl The root url for scene and resources
  44185. * @param onProgress The callback when the load progresses
  44186. * @param fileName Defines the name of the file to load
  44187. * @returns The loaded asset container
  44188. */
  44189. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  44190. }
  44191. /**
  44192. * Class used to load scene from various file formats using registered plugins
  44193. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  44194. */
  44195. export class SceneLoader {
  44196. /**
  44197. * No logging while loading
  44198. */
  44199. static readonly NO_LOGGING: number;
  44200. /**
  44201. * Minimal logging while loading
  44202. */
  44203. static readonly MINIMAL_LOGGING: number;
  44204. /**
  44205. * Summary logging while loading
  44206. */
  44207. static readonly SUMMARY_LOGGING: number;
  44208. /**
  44209. * Detailled logging while loading
  44210. */
  44211. static readonly DETAILED_LOGGING: number;
  44212. /**
  44213. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  44214. */
  44215. static ForceFullSceneLoadingForIncremental: boolean;
  44216. /**
  44217. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  44218. */
  44219. static ShowLoadingScreen: boolean;
  44220. /**
  44221. * Defines the current logging level (while loading the scene)
  44222. * @ignorenaming
  44223. */
  44224. static loggingLevel: number;
  44225. /**
  44226. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  44227. */
  44228. static CleanBoneMatrixWeights: boolean;
  44229. /**
  44230. * Event raised when a plugin is used to load a scene
  44231. */
  44232. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  44233. private static _registeredPlugins;
  44234. private static _getDefaultPlugin;
  44235. private static _getPluginForExtension;
  44236. private static _getPluginForDirectLoad;
  44237. private static _getPluginForFilename;
  44238. private static _getDirectLoad;
  44239. private static _loadData;
  44240. private static _getFileInfo;
  44241. /**
  44242. * Gets a plugin that can load the given extension
  44243. * @param extension defines the extension to load
  44244. * @returns a plugin or null if none works
  44245. */
  44246. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  44247. /**
  44248. * Gets a boolean indicating that the given extension can be loaded
  44249. * @param extension defines the extension to load
  44250. * @returns true if the extension is supported
  44251. */
  44252. static IsPluginForExtensionAvailable(extension: string): boolean;
  44253. /**
  44254. * Adds a new plugin to the list of registered plugins
  44255. * @param plugin defines the plugin to add
  44256. */
  44257. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  44258. /**
  44259. * Import meshes into a scene
  44260. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44261. * @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)
  44262. * @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)
  44263. * @param scene the instance of BABYLON.Scene to append to
  44264. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  44265. * @param onProgress a callback with a progress event for each file being loaded
  44266. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44267. * @param pluginExtension the extension used to determine the plugin
  44268. * @returns The loaded plugin
  44269. */
  44270. 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>;
  44271. /**
  44272. * Import meshes into a scene
  44273. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44274. * @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)
  44275. * @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)
  44276. * @param scene the instance of BABYLON.Scene to append to
  44277. * @param onProgress a callback with a progress event for each file being loaded
  44278. * @param pluginExtension the extension used to determine the plugin
  44279. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  44280. */
  44281. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  44282. meshes: AbstractMesh[];
  44283. particleSystems: IParticleSystem[];
  44284. skeletons: Skeleton[];
  44285. animationGroups: AnimationGroup[];
  44286. }>;
  44287. /**
  44288. * Load a scene
  44289. * @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)
  44290. * @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)
  44291. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44292. * @param onSuccess a callback with the scene when import succeeds
  44293. * @param onProgress a callback with a progress event for each file being loaded
  44294. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44295. * @param pluginExtension the extension used to determine the plugin
  44296. * @returns The loaded plugin
  44297. */
  44298. 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>;
  44299. /**
  44300. * Load a scene
  44301. * @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)
  44302. * @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)
  44303. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44304. * @param onProgress a callback with a progress event for each file being loaded
  44305. * @param pluginExtension the extension used to determine the plugin
  44306. * @returns The loaded scene
  44307. */
  44308. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44309. /**
  44310. * Append a scene
  44311. * @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)
  44312. * @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)
  44313. * @param scene is the instance of BABYLON.Scene to append to
  44314. * @param onSuccess a callback with the scene when import succeeds
  44315. * @param onProgress a callback with a progress event for each file being loaded
  44316. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44317. * @param pluginExtension the extension used to determine the plugin
  44318. * @returns The loaded plugin
  44319. */
  44320. 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>;
  44321. /**
  44322. * Append a scene
  44323. * @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)
  44324. * @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)
  44325. * @param scene is the instance of BABYLON.Scene to append to
  44326. * @param onProgress a callback with a progress event for each file being loaded
  44327. * @param pluginExtension the extension used to determine the plugin
  44328. * @returns The given scene
  44329. */
  44330. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44331. /**
  44332. * Load a scene into an asset container
  44333. * @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)
  44334. * @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)
  44335. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44336. * @param onSuccess a callback with the scene when import succeeds
  44337. * @param onProgress a callback with a progress event for each file being loaded
  44338. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44339. * @param pluginExtension the extension used to determine the plugin
  44340. * @returns The loaded plugin
  44341. */
  44342. 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>;
  44343. /**
  44344. * Load a scene into an asset container
  44345. * @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)
  44346. * @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)
  44347. * @param scene is the instance of Scene to append to
  44348. * @param onProgress a callback with a progress event for each file being loaded
  44349. * @param pluginExtension the extension used to determine the plugin
  44350. * @returns The loaded asset container
  44351. */
  44352. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  44353. }
  44354. }
  44355. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  44356. import { Scene } from "babylonjs/scene";
  44357. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44358. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44359. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44360. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44361. /**
  44362. * Google Daydream controller
  44363. */
  44364. export class DaydreamController extends WebVRController {
  44365. /**
  44366. * Base Url for the controller model.
  44367. */
  44368. static MODEL_BASE_URL: string;
  44369. /**
  44370. * File name for the controller model.
  44371. */
  44372. static MODEL_FILENAME: string;
  44373. /**
  44374. * Gamepad Id prefix used to identify Daydream Controller.
  44375. */
  44376. static readonly GAMEPAD_ID_PREFIX: string;
  44377. /**
  44378. * Creates a new DaydreamController from a gamepad
  44379. * @param vrGamepad the gamepad that the controller should be created from
  44380. */
  44381. constructor(vrGamepad: any);
  44382. /**
  44383. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44384. * @param scene scene in which to add meshes
  44385. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44386. */
  44387. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44388. /**
  44389. * Called once for each button that changed state since the last frame
  44390. * @param buttonIdx Which button index changed
  44391. * @param state New state of the button
  44392. * @param changes Which properties on the state changed since last frame
  44393. */
  44394. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44395. }
  44396. }
  44397. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  44398. import { Scene } from "babylonjs/scene";
  44399. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44400. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44401. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44402. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44403. /**
  44404. * Gear VR Controller
  44405. */
  44406. export class GearVRController extends WebVRController {
  44407. /**
  44408. * Base Url for the controller model.
  44409. */
  44410. static MODEL_BASE_URL: string;
  44411. /**
  44412. * File name for the controller model.
  44413. */
  44414. static MODEL_FILENAME: string;
  44415. /**
  44416. * Gamepad Id prefix used to identify this controller.
  44417. */
  44418. static readonly GAMEPAD_ID_PREFIX: string;
  44419. private readonly _buttonIndexToObservableNameMap;
  44420. /**
  44421. * Creates a new GearVRController from a gamepad
  44422. * @param vrGamepad the gamepad that the controller should be created from
  44423. */
  44424. constructor(vrGamepad: any);
  44425. /**
  44426. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44427. * @param scene scene in which to add meshes
  44428. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44429. */
  44430. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44431. /**
  44432. * Called once for each button that changed state since the last frame
  44433. * @param buttonIdx Which button index changed
  44434. * @param state New state of the button
  44435. * @param changes Which properties on the state changed since last frame
  44436. */
  44437. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44438. }
  44439. }
  44440. declare module "babylonjs/Gamepads/Controllers/genericController" {
  44441. import { Scene } from "babylonjs/scene";
  44442. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44443. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44444. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44445. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44446. /**
  44447. * Generic Controller
  44448. */
  44449. export class GenericController extends WebVRController {
  44450. /**
  44451. * Base Url for the controller model.
  44452. */
  44453. static readonly MODEL_BASE_URL: string;
  44454. /**
  44455. * File name for the controller model.
  44456. */
  44457. static readonly MODEL_FILENAME: string;
  44458. /**
  44459. * Creates a new GenericController from a gamepad
  44460. * @param vrGamepad the gamepad that the controller should be created from
  44461. */
  44462. constructor(vrGamepad: any);
  44463. /**
  44464. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44465. * @param scene scene in which to add meshes
  44466. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44467. */
  44468. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44469. /**
  44470. * Called once for each button that changed state since the last frame
  44471. * @param buttonIdx Which button index changed
  44472. * @param state New state of the button
  44473. * @param changes Which properties on the state changed since last frame
  44474. */
  44475. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44476. }
  44477. }
  44478. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  44479. import { Observable } from "babylonjs/Misc/observable";
  44480. import { Scene } from "babylonjs/scene";
  44481. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44482. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44483. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44484. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44485. /**
  44486. * Oculus Touch Controller
  44487. */
  44488. export class OculusTouchController extends WebVRController {
  44489. /**
  44490. * Base Url for the controller model.
  44491. */
  44492. static MODEL_BASE_URL: string;
  44493. /**
  44494. * File name for the left controller model.
  44495. */
  44496. static MODEL_LEFT_FILENAME: string;
  44497. /**
  44498. * File name for the right controller model.
  44499. */
  44500. static MODEL_RIGHT_FILENAME: string;
  44501. /**
  44502. * Base Url for the Quest controller model.
  44503. */
  44504. static QUEST_MODEL_BASE_URL: string;
  44505. /**
  44506. * @hidden
  44507. * If the controllers are running on a device that needs the updated Quest controller models
  44508. */
  44509. static _IsQuest: boolean;
  44510. /**
  44511. * Fired when the secondary trigger on this controller is modified
  44512. */
  44513. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  44514. /**
  44515. * Fired when the thumb rest on this controller is modified
  44516. */
  44517. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  44518. /**
  44519. * Creates a new OculusTouchController from a gamepad
  44520. * @param vrGamepad the gamepad that the controller should be created from
  44521. */
  44522. constructor(vrGamepad: any);
  44523. /**
  44524. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44525. * @param scene scene in which to add meshes
  44526. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44527. */
  44528. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44529. /**
  44530. * Fired when the A button on this controller is modified
  44531. */
  44532. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44533. /**
  44534. * Fired when the B button on this controller is modified
  44535. */
  44536. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44537. /**
  44538. * Fired when the X button on this controller is modified
  44539. */
  44540. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44541. /**
  44542. * Fired when the Y button on this controller is modified
  44543. */
  44544. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44545. /**
  44546. * Called once for each button that changed state since the last frame
  44547. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  44548. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  44549. * 2) secondary trigger (same)
  44550. * 3) A (right) X (left), touch, pressed = value
  44551. * 4) B / Y
  44552. * 5) thumb rest
  44553. * @param buttonIdx Which button index changed
  44554. * @param state New state of the button
  44555. * @param changes Which properties on the state changed since last frame
  44556. */
  44557. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44558. }
  44559. }
  44560. declare module "babylonjs/Gamepads/Controllers/viveController" {
  44561. import { Scene } from "babylonjs/scene";
  44562. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44563. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44564. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44565. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44566. import { Observable } from "babylonjs/Misc/observable";
  44567. /**
  44568. * Vive Controller
  44569. */
  44570. export class ViveController extends WebVRController {
  44571. /**
  44572. * Base Url for the controller model.
  44573. */
  44574. static MODEL_BASE_URL: string;
  44575. /**
  44576. * File name for the controller model.
  44577. */
  44578. static MODEL_FILENAME: string;
  44579. /**
  44580. * Creates a new ViveController from a gamepad
  44581. * @param vrGamepad the gamepad that the controller should be created from
  44582. */
  44583. constructor(vrGamepad: any);
  44584. /**
  44585. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44586. * @param scene scene in which to add meshes
  44587. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44588. */
  44589. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44590. /**
  44591. * Fired when the left button on this controller is modified
  44592. */
  44593. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44594. /**
  44595. * Fired when the right button on this controller is modified
  44596. */
  44597. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44598. /**
  44599. * Fired when the menu button on this controller is modified
  44600. */
  44601. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44602. /**
  44603. * Called once for each button that changed state since the last frame
  44604. * Vive mapping:
  44605. * 0: touchpad
  44606. * 1: trigger
  44607. * 2: left AND right buttons
  44608. * 3: menu button
  44609. * @param buttonIdx Which button index changed
  44610. * @param state New state of the button
  44611. * @param changes Which properties on the state changed since last frame
  44612. */
  44613. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44614. }
  44615. }
  44616. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  44617. import { Observable } from "babylonjs/Misc/observable";
  44618. import { Scene } from "babylonjs/scene";
  44619. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44620. import { Ray } from "babylonjs/Culling/ray";
  44621. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44622. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44623. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44624. /**
  44625. * Defines the WindowsMotionController object that the state of the windows motion controller
  44626. */
  44627. export class WindowsMotionController extends WebVRController {
  44628. /**
  44629. * The base url used to load the left and right controller models
  44630. */
  44631. static MODEL_BASE_URL: string;
  44632. /**
  44633. * The name of the left controller model file
  44634. */
  44635. static MODEL_LEFT_FILENAME: string;
  44636. /**
  44637. * The name of the right controller model file
  44638. */
  44639. static MODEL_RIGHT_FILENAME: string;
  44640. /**
  44641. * The controller name prefix for this controller type
  44642. */
  44643. static readonly GAMEPAD_ID_PREFIX: string;
  44644. /**
  44645. * The controller id pattern for this controller type
  44646. */
  44647. private static readonly GAMEPAD_ID_PATTERN;
  44648. private _loadedMeshInfo;
  44649. private readonly _mapping;
  44650. /**
  44651. * Fired when the trackpad on this controller is clicked
  44652. */
  44653. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44654. /**
  44655. * Fired when the trackpad on this controller is modified
  44656. */
  44657. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44658. /**
  44659. * The current x and y values of this controller's trackpad
  44660. */
  44661. trackpad: StickValues;
  44662. /**
  44663. * Creates a new WindowsMotionController from a gamepad
  44664. * @param vrGamepad the gamepad that the controller should be created from
  44665. */
  44666. constructor(vrGamepad: any);
  44667. /**
  44668. * Fired when the trigger on this controller is modified
  44669. */
  44670. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44671. /**
  44672. * Fired when the menu button on this controller is modified
  44673. */
  44674. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44675. /**
  44676. * Fired when the grip button on this controller is modified
  44677. */
  44678. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44679. /**
  44680. * Fired when the thumbstick button on this controller is modified
  44681. */
  44682. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44683. /**
  44684. * Fired when the touchpad button on this controller is modified
  44685. */
  44686. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44687. /**
  44688. * Fired when the touchpad values on this controller are modified
  44689. */
  44690. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  44691. private _updateTrackpad;
  44692. /**
  44693. * Called once per frame by the engine.
  44694. */
  44695. update(): void;
  44696. /**
  44697. * Called once for each button that changed state since the last frame
  44698. * @param buttonIdx Which button index changed
  44699. * @param state New state of the button
  44700. * @param changes Which properties on the state changed since last frame
  44701. */
  44702. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44703. /**
  44704. * Moves the buttons on the controller mesh based on their current state
  44705. * @param buttonName the name of the button to move
  44706. * @param buttonValue the value of the button which determines the buttons new position
  44707. */
  44708. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  44709. /**
  44710. * Moves the axis on the controller mesh based on its current state
  44711. * @param axis the index of the axis
  44712. * @param axisValue the value of the axis which determines the meshes new position
  44713. * @hidden
  44714. */
  44715. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  44716. /**
  44717. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44718. * @param scene scene in which to add meshes
  44719. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44720. */
  44721. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  44722. /**
  44723. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  44724. * can be transformed by button presses and axes values, based on this._mapping.
  44725. *
  44726. * @param scene scene in which the meshes exist
  44727. * @param meshes list of meshes that make up the controller model to process
  44728. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  44729. */
  44730. private processModel;
  44731. private createMeshInfo;
  44732. /**
  44733. * Gets the ray of the controller in the direction the controller is pointing
  44734. * @param length the length the resulting ray should be
  44735. * @returns a ray in the direction the controller is pointing
  44736. */
  44737. getForwardRay(length?: number): Ray;
  44738. /**
  44739. * Disposes of the controller
  44740. */
  44741. dispose(): void;
  44742. }
  44743. }
  44744. declare module "babylonjs/Gamepads/Controllers/index" {
  44745. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  44746. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  44747. export * from "babylonjs/Gamepads/Controllers/genericController";
  44748. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  44749. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44750. export * from "babylonjs/Gamepads/Controllers/viveController";
  44751. export * from "babylonjs/Gamepads/Controllers/webVRController";
  44752. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  44753. }
  44754. declare module "babylonjs/Gamepads/index" {
  44755. export * from "babylonjs/Gamepads/Controllers/index";
  44756. export * from "babylonjs/Gamepads/gamepad";
  44757. export * from "babylonjs/Gamepads/gamepadManager";
  44758. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  44759. export * from "babylonjs/Gamepads/xboxGamepad";
  44760. }
  44761. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  44762. import { Scene } from "babylonjs/scene";
  44763. import { Color4, Vector4 } from "babylonjs/Maths/math";
  44764. import { Mesh } from "babylonjs/Meshes/mesh";
  44765. import { Nullable } from "babylonjs/types";
  44766. /**
  44767. * Class containing static functions to help procedurally build meshes
  44768. */
  44769. export class PolyhedronBuilder {
  44770. /**
  44771. * Creates a polyhedron mesh
  44772. * * 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
  44773. * * The parameter `size` (positive float, default 1) sets the polygon size
  44774. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  44775. * * 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`
  44776. * * 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
  44777. * * 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)`)
  44778. * * 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
  44779. * * 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
  44780. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44781. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44782. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44783. * @param name defines the name of the mesh
  44784. * @param options defines the options used to create the mesh
  44785. * @param scene defines the hosting scene
  44786. * @returns the polyhedron mesh
  44787. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  44788. */
  44789. static CreatePolyhedron(name: string, options: {
  44790. type?: number;
  44791. size?: number;
  44792. sizeX?: number;
  44793. sizeY?: number;
  44794. sizeZ?: number;
  44795. custom?: any;
  44796. faceUV?: Vector4[];
  44797. faceColors?: Color4[];
  44798. flat?: boolean;
  44799. updatable?: boolean;
  44800. sideOrientation?: number;
  44801. frontUVs?: Vector4;
  44802. backUVs?: Vector4;
  44803. }, scene?: Nullable<Scene>): Mesh;
  44804. }
  44805. }
  44806. declare module "babylonjs/Gizmos/scaleGizmo" {
  44807. import { Observable } from "babylonjs/Misc/observable";
  44808. import { Nullable } from "babylonjs/types";
  44809. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44810. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44811. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  44812. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44813. /**
  44814. * Gizmo that enables scaling a mesh along 3 axis
  44815. */
  44816. export class ScaleGizmo extends Gizmo {
  44817. /**
  44818. * Internal gizmo used for interactions on the x axis
  44819. */
  44820. xGizmo: AxisScaleGizmo;
  44821. /**
  44822. * Internal gizmo used for interactions on the y axis
  44823. */
  44824. yGizmo: AxisScaleGizmo;
  44825. /**
  44826. * Internal gizmo used for interactions on the z axis
  44827. */
  44828. zGizmo: AxisScaleGizmo;
  44829. /**
  44830. * Internal gizmo used to scale all axis equally
  44831. */
  44832. uniformScaleGizmo: AxisScaleGizmo;
  44833. private _meshAttached;
  44834. private _updateGizmoRotationToMatchAttachedMesh;
  44835. private _snapDistance;
  44836. private _scaleRatio;
  44837. private _uniformScalingMesh;
  44838. private _octahedron;
  44839. /** Fires an event when any of it's sub gizmos are dragged */
  44840. onDragStartObservable: Observable<unknown>;
  44841. /** Fires an event when any of it's sub gizmos are released from dragging */
  44842. onDragEndObservable: Observable<unknown>;
  44843. attachedMesh: Nullable<AbstractMesh>;
  44844. /**
  44845. * Creates a ScaleGizmo
  44846. * @param gizmoLayer The utility layer the gizmo will be added to
  44847. */
  44848. constructor(gizmoLayer?: UtilityLayerRenderer);
  44849. updateGizmoRotationToMatchAttachedMesh: boolean;
  44850. /**
  44851. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44852. */
  44853. snapDistance: number;
  44854. /**
  44855. * Ratio for the scale of the gizmo (Default: 1)
  44856. */
  44857. scaleRatio: number;
  44858. /**
  44859. * Disposes of the gizmo
  44860. */
  44861. dispose(): void;
  44862. }
  44863. }
  44864. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  44865. import { Observable } from "babylonjs/Misc/observable";
  44866. import { Nullable } from "babylonjs/types";
  44867. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44868. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44869. import { Mesh } from "babylonjs/Meshes/mesh";
  44870. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44871. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44872. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44873. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  44874. /**
  44875. * Single axis scale gizmo
  44876. */
  44877. export class AxisScaleGizmo extends Gizmo {
  44878. /**
  44879. * Drag behavior responsible for the gizmos dragging interactions
  44880. */
  44881. dragBehavior: PointerDragBehavior;
  44882. private _pointerObserver;
  44883. /**
  44884. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44885. */
  44886. snapDistance: number;
  44887. /**
  44888. * Event that fires each time the gizmo snaps to a new location.
  44889. * * snapDistance is the the change in distance
  44890. */
  44891. onSnapObservable: Observable<{
  44892. snapDistance: number;
  44893. }>;
  44894. /**
  44895. * If the scaling operation should be done on all axis (default: false)
  44896. */
  44897. uniformScaling: boolean;
  44898. private _isEnabled;
  44899. private _parent;
  44900. private _arrow;
  44901. private _coloredMaterial;
  44902. private _hoverMaterial;
  44903. /**
  44904. * Creates an AxisScaleGizmo
  44905. * @param gizmoLayer The utility layer the gizmo will be added to
  44906. * @param dragAxis The axis which the gizmo will be able to scale on
  44907. * @param color The color of the gizmo
  44908. */
  44909. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  44910. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44911. /**
  44912. * If the gizmo is enabled
  44913. */
  44914. isEnabled: boolean;
  44915. /**
  44916. * Disposes of the gizmo
  44917. */
  44918. dispose(): void;
  44919. /**
  44920. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44921. * @param mesh The mesh to replace the default mesh of the gizmo
  44922. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  44923. */
  44924. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  44925. }
  44926. }
  44927. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  44928. import { Observable } from "babylonjs/Misc/observable";
  44929. import { Nullable } from "babylonjs/types";
  44930. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44931. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44932. import { Mesh } from "babylonjs/Meshes/mesh";
  44933. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44934. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44935. import "babylonjs/Meshes/Builders/boxBuilder";
  44936. /**
  44937. * Bounding box gizmo
  44938. */
  44939. export class BoundingBoxGizmo extends Gizmo {
  44940. private _lineBoundingBox;
  44941. private _rotateSpheresParent;
  44942. private _scaleBoxesParent;
  44943. private _boundingDimensions;
  44944. private _renderObserver;
  44945. private _pointerObserver;
  44946. private _scaleDragSpeed;
  44947. private _tmpQuaternion;
  44948. private _tmpVector;
  44949. private _tmpRotationMatrix;
  44950. /**
  44951. * 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)
  44952. */
  44953. ignoreChildren: boolean;
  44954. /**
  44955. * 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)
  44956. */
  44957. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  44958. /**
  44959. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  44960. */
  44961. rotationSphereSize: number;
  44962. /**
  44963. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  44964. */
  44965. scaleBoxSize: number;
  44966. /**
  44967. * 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)
  44968. */
  44969. fixedDragMeshScreenSize: boolean;
  44970. /**
  44971. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  44972. */
  44973. fixedDragMeshScreenSizeDistanceFactor: number;
  44974. /**
  44975. * Fired when a rotation sphere or scale box is dragged
  44976. */
  44977. onDragStartObservable: Observable<{}>;
  44978. /**
  44979. * Fired when a scale box is dragged
  44980. */
  44981. onScaleBoxDragObservable: Observable<{}>;
  44982. /**
  44983. * Fired when a scale box drag is ended
  44984. */
  44985. onScaleBoxDragEndObservable: Observable<{}>;
  44986. /**
  44987. * Fired when a rotation sphere is dragged
  44988. */
  44989. onRotationSphereDragObservable: Observable<{}>;
  44990. /**
  44991. * Fired when a rotation sphere drag is ended
  44992. */
  44993. onRotationSphereDragEndObservable: Observable<{}>;
  44994. /**
  44995. * 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)
  44996. */
  44997. scalePivot: Nullable<Vector3>;
  44998. /**
  44999. * Mesh used as a pivot to rotate the attached mesh
  45000. */
  45001. private _anchorMesh;
  45002. private _existingMeshScale;
  45003. private _dragMesh;
  45004. private pointerDragBehavior;
  45005. private coloredMaterial;
  45006. private hoverColoredMaterial;
  45007. /**
  45008. * Sets the color of the bounding box gizmo
  45009. * @param color the color to set
  45010. */
  45011. setColor(color: Color3): void;
  45012. /**
  45013. * Creates an BoundingBoxGizmo
  45014. * @param gizmoLayer The utility layer the gizmo will be added to
  45015. * @param color The color of the gizmo
  45016. */
  45017. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  45018. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45019. private _selectNode;
  45020. /**
  45021. * Updates the bounding box information for the Gizmo
  45022. */
  45023. updateBoundingBox(): void;
  45024. private _updateRotationSpheres;
  45025. private _updateScaleBoxes;
  45026. /**
  45027. * Enables rotation on the specified axis and disables rotation on the others
  45028. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  45029. */
  45030. setEnabledRotationAxis(axis: string): void;
  45031. /**
  45032. * Enables/disables scaling
  45033. * @param enable if scaling should be enabled
  45034. */
  45035. setEnabledScaling(enable: boolean): void;
  45036. private _updateDummy;
  45037. /**
  45038. * Enables a pointer drag behavior on the bounding box of the gizmo
  45039. */
  45040. enableDragBehavior(): void;
  45041. /**
  45042. * Disposes of the gizmo
  45043. */
  45044. dispose(): void;
  45045. /**
  45046. * 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)
  45047. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  45048. * @returns the bounding box mesh with the passed in mesh as a child
  45049. */
  45050. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  45051. /**
  45052. * CustomMeshes are not supported by this gizmo
  45053. * @param mesh The mesh to replace the default mesh of the gizmo
  45054. */
  45055. setCustomMesh(mesh: Mesh): void;
  45056. }
  45057. }
  45058. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  45059. import { Observable } from "babylonjs/Misc/observable";
  45060. import { Nullable } from "babylonjs/types";
  45061. import { Vector3, Color3 } from "babylonjs/Maths/math";
  45062. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45063. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45064. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45065. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45066. import "babylonjs/Meshes/Builders/linesBuilder";
  45067. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  45068. /**
  45069. * Single plane rotation gizmo
  45070. */
  45071. export class PlaneRotationGizmo extends Gizmo {
  45072. /**
  45073. * Drag behavior responsible for the gizmos dragging interactions
  45074. */
  45075. dragBehavior: PointerDragBehavior;
  45076. private _pointerObserver;
  45077. /**
  45078. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  45079. */
  45080. snapDistance: number;
  45081. /**
  45082. * Event that fires each time the gizmo snaps to a new location.
  45083. * * snapDistance is the the change in distance
  45084. */
  45085. onSnapObservable: Observable<{
  45086. snapDistance: number;
  45087. }>;
  45088. private _isEnabled;
  45089. private _parent;
  45090. /**
  45091. * Creates a PlaneRotationGizmo
  45092. * @param gizmoLayer The utility layer the gizmo will be added to
  45093. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  45094. * @param color The color of the gizmo
  45095. * @param tessellation Amount of tessellation to be used when creating rotation circles
  45096. */
  45097. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>);
  45098. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45099. /**
  45100. * If the gizmo is enabled
  45101. */
  45102. isEnabled: boolean;
  45103. /**
  45104. * Disposes of the gizmo
  45105. */
  45106. dispose(): void;
  45107. }
  45108. }
  45109. declare module "babylonjs/Gizmos/rotationGizmo" {
  45110. import { Observable } from "babylonjs/Misc/observable";
  45111. import { Nullable } from "babylonjs/types";
  45112. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45113. import { Mesh } from "babylonjs/Meshes/mesh";
  45114. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45115. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  45116. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45117. /**
  45118. * Gizmo that enables rotating a mesh along 3 axis
  45119. */
  45120. export class RotationGizmo extends Gizmo {
  45121. /**
  45122. * Internal gizmo used for interactions on the x axis
  45123. */
  45124. xGizmo: PlaneRotationGizmo;
  45125. /**
  45126. * Internal gizmo used for interactions on the y axis
  45127. */
  45128. yGizmo: PlaneRotationGizmo;
  45129. /**
  45130. * Internal gizmo used for interactions on the z axis
  45131. */
  45132. zGizmo: PlaneRotationGizmo;
  45133. /** Fires an event when any of it's sub gizmos are dragged */
  45134. onDragStartObservable: Observable<unknown>;
  45135. /** Fires an event when any of it's sub gizmos are released from dragging */
  45136. onDragEndObservable: Observable<unknown>;
  45137. private _meshAttached;
  45138. attachedMesh: Nullable<AbstractMesh>;
  45139. /**
  45140. * Creates a RotationGizmo
  45141. * @param gizmoLayer The utility layer the gizmo will be added to
  45142. * @param tessellation Amount of tessellation to be used when creating rotation circles
  45143. */
  45144. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  45145. updateGizmoRotationToMatchAttachedMesh: boolean;
  45146. /**
  45147. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45148. */
  45149. snapDistance: number;
  45150. /**
  45151. * Ratio for the scale of the gizmo (Default: 1)
  45152. */
  45153. scaleRatio: number;
  45154. /**
  45155. * Disposes of the gizmo
  45156. */
  45157. dispose(): void;
  45158. /**
  45159. * CustomMeshes are not supported by this gizmo
  45160. * @param mesh The mesh to replace the default mesh of the gizmo
  45161. */
  45162. setCustomMesh(mesh: Mesh): void;
  45163. }
  45164. }
  45165. declare module "babylonjs/Gizmos/gizmoManager" {
  45166. import { Observable } from "babylonjs/Misc/observable";
  45167. import { Nullable } from "babylonjs/types";
  45168. import { Scene, IDisposable } from "babylonjs/scene";
  45169. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45170. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45171. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  45172. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  45173. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  45174. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  45175. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  45176. /**
  45177. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  45178. */
  45179. export class GizmoManager implements IDisposable {
  45180. private scene;
  45181. /**
  45182. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  45183. */
  45184. gizmos: {
  45185. positionGizmo: Nullable<PositionGizmo>;
  45186. rotationGizmo: Nullable<RotationGizmo>;
  45187. scaleGizmo: Nullable<ScaleGizmo>;
  45188. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  45189. };
  45190. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  45191. clearGizmoOnEmptyPointerEvent: boolean;
  45192. /** Fires an event when the manager is attached to a mesh */
  45193. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  45194. private _gizmosEnabled;
  45195. private _pointerObserver;
  45196. private _attachedMesh;
  45197. private _boundingBoxColor;
  45198. private _defaultUtilityLayer;
  45199. private _defaultKeepDepthUtilityLayer;
  45200. /**
  45201. * When bounding box gizmo is enabled, this can be used to track drag/end events
  45202. */
  45203. boundingBoxDragBehavior: SixDofDragBehavior;
  45204. /**
  45205. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  45206. */
  45207. attachableMeshes: Nullable<Array<AbstractMesh>>;
  45208. /**
  45209. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  45210. */
  45211. usePointerToAttachGizmos: boolean;
  45212. /**
  45213. * Utility layer that the bounding box gizmo belongs to
  45214. */
  45215. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  45216. /**
  45217. * Utility layer that all gizmos besides bounding box belong to
  45218. */
  45219. readonly utilityLayer: UtilityLayerRenderer;
  45220. /**
  45221. * Instatiates a gizmo manager
  45222. * @param scene the scene to overlay the gizmos on top of
  45223. */
  45224. constructor(scene: Scene);
  45225. /**
  45226. * Attaches a set of gizmos to the specified mesh
  45227. * @param mesh The mesh the gizmo's should be attached to
  45228. */
  45229. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  45230. /**
  45231. * If the position gizmo is enabled
  45232. */
  45233. positionGizmoEnabled: boolean;
  45234. /**
  45235. * If the rotation gizmo is enabled
  45236. */
  45237. rotationGizmoEnabled: boolean;
  45238. /**
  45239. * If the scale gizmo is enabled
  45240. */
  45241. scaleGizmoEnabled: boolean;
  45242. /**
  45243. * If the boundingBox gizmo is enabled
  45244. */
  45245. boundingBoxGizmoEnabled: boolean;
  45246. /**
  45247. * Disposes of the gizmo manager
  45248. */
  45249. dispose(): void;
  45250. }
  45251. }
  45252. declare module "babylonjs/Lights/directionalLight" {
  45253. import { Camera } from "babylonjs/Cameras/camera";
  45254. import { Scene } from "babylonjs/scene";
  45255. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  45256. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45257. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  45258. import { Effect } from "babylonjs/Materials/effect";
  45259. /**
  45260. * A directional light is defined by a direction (what a surprise!).
  45261. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  45262. * 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.
  45263. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45264. */
  45265. export class DirectionalLight extends ShadowLight {
  45266. private _shadowFrustumSize;
  45267. /**
  45268. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  45269. */
  45270. /**
  45271. * Specifies a fix frustum size for the shadow generation.
  45272. */
  45273. shadowFrustumSize: number;
  45274. private _shadowOrthoScale;
  45275. /**
  45276. * Gets the shadow projection scale against the optimal computed one.
  45277. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45278. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45279. */
  45280. /**
  45281. * Sets the shadow projection scale against the optimal computed one.
  45282. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45283. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45284. */
  45285. shadowOrthoScale: number;
  45286. /**
  45287. * Automatically compute the projection matrix to best fit (including all the casters)
  45288. * on each frame.
  45289. */
  45290. autoUpdateExtends: boolean;
  45291. private _orthoLeft;
  45292. private _orthoRight;
  45293. private _orthoTop;
  45294. private _orthoBottom;
  45295. /**
  45296. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  45297. * The directional light is emitted from everywhere in the given direction.
  45298. * It can cast shadows.
  45299. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45300. * @param name The friendly name of the light
  45301. * @param direction The direction of the light
  45302. * @param scene The scene the light belongs to
  45303. */
  45304. constructor(name: string, direction: Vector3, scene: Scene);
  45305. /**
  45306. * Returns the string "DirectionalLight".
  45307. * @return The class name
  45308. */
  45309. getClassName(): string;
  45310. /**
  45311. * Returns the integer 1.
  45312. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45313. */
  45314. getTypeID(): number;
  45315. /**
  45316. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  45317. * Returns the DirectionalLight Shadow projection matrix.
  45318. */
  45319. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45320. /**
  45321. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  45322. * Returns the DirectionalLight Shadow projection matrix.
  45323. */
  45324. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  45325. /**
  45326. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  45327. * Returns the DirectionalLight Shadow projection matrix.
  45328. */
  45329. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45330. protected _buildUniformLayout(): void;
  45331. /**
  45332. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  45333. * @param effect The effect to update
  45334. * @param lightIndex The index of the light in the effect to update
  45335. * @returns The directional light
  45336. */
  45337. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  45338. /**
  45339. * Gets the minZ used for shadow according to both the scene and the light.
  45340. *
  45341. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45342. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45343. * @param activeCamera The camera we are returning the min for
  45344. * @returns the depth min z
  45345. */
  45346. getDepthMinZ(activeCamera: Camera): number;
  45347. /**
  45348. * Gets the maxZ used for shadow according to both the scene and the light.
  45349. *
  45350. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45351. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45352. * @param activeCamera The camera we are returning the max for
  45353. * @returns the depth max z
  45354. */
  45355. getDepthMaxZ(activeCamera: Camera): number;
  45356. /**
  45357. * Prepares the list of defines specific to the light type.
  45358. * @param defines the list of defines
  45359. * @param lightIndex defines the index of the light for the effect
  45360. */
  45361. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45362. }
  45363. }
  45364. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  45365. import { Mesh } from "babylonjs/Meshes/mesh";
  45366. /**
  45367. * Class containing static functions to help procedurally build meshes
  45368. */
  45369. export class HemisphereBuilder {
  45370. /**
  45371. * Creates a hemisphere mesh
  45372. * @param name defines the name of the mesh
  45373. * @param options defines the options used to create the mesh
  45374. * @param scene defines the hosting scene
  45375. * @returns the hemisphere mesh
  45376. */
  45377. static CreateHemisphere(name: string, options: {
  45378. segments?: number;
  45379. diameter?: number;
  45380. sideOrientation?: number;
  45381. }, scene: any): Mesh;
  45382. }
  45383. }
  45384. declare module "babylonjs/Lights/spotLight" {
  45385. import { Nullable } from "babylonjs/types";
  45386. import { Scene } from "babylonjs/scene";
  45387. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  45388. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45389. import { Effect } from "babylonjs/Materials/effect";
  45390. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45391. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  45392. /**
  45393. * A spot light is defined by a position, a direction, an angle, and an exponent.
  45394. * These values define a cone of light starting from the position, emitting toward the direction.
  45395. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  45396. * and the exponent defines the speed of the decay of the light with distance (reach).
  45397. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45398. */
  45399. export class SpotLight extends ShadowLight {
  45400. private _angle;
  45401. private _innerAngle;
  45402. private _cosHalfAngle;
  45403. private _lightAngleScale;
  45404. private _lightAngleOffset;
  45405. /**
  45406. * Gets the cone angle of the spot light in Radians.
  45407. */
  45408. /**
  45409. * Sets the cone angle of the spot light in Radians.
  45410. */
  45411. angle: number;
  45412. /**
  45413. * Only used in gltf falloff mode, this defines the angle where
  45414. * the directional falloff will start before cutting at angle which could be seen
  45415. * as outer angle.
  45416. */
  45417. /**
  45418. * Only used in gltf falloff mode, this defines the angle where
  45419. * the directional falloff will start before cutting at angle which could be seen
  45420. * as outer angle.
  45421. */
  45422. innerAngle: number;
  45423. private _shadowAngleScale;
  45424. /**
  45425. * Allows scaling the angle of the light for shadow generation only.
  45426. */
  45427. /**
  45428. * Allows scaling the angle of the light for shadow generation only.
  45429. */
  45430. shadowAngleScale: number;
  45431. /**
  45432. * The light decay speed with the distance from the emission spot.
  45433. */
  45434. exponent: number;
  45435. private _projectionTextureMatrix;
  45436. /**
  45437. * Allows reading the projecton texture
  45438. */
  45439. readonly projectionTextureMatrix: Matrix;
  45440. protected _projectionTextureLightNear: number;
  45441. /**
  45442. * Gets the near clip of the Spotlight for texture projection.
  45443. */
  45444. /**
  45445. * Sets the near clip of the Spotlight for texture projection.
  45446. */
  45447. projectionTextureLightNear: number;
  45448. protected _projectionTextureLightFar: number;
  45449. /**
  45450. * Gets the far clip of the Spotlight for texture projection.
  45451. */
  45452. /**
  45453. * Sets the far clip of the Spotlight for texture projection.
  45454. */
  45455. projectionTextureLightFar: number;
  45456. protected _projectionTextureUpDirection: Vector3;
  45457. /**
  45458. * Gets the Up vector of the Spotlight for texture projection.
  45459. */
  45460. /**
  45461. * Sets the Up vector of the Spotlight for texture projection.
  45462. */
  45463. projectionTextureUpDirection: Vector3;
  45464. private _projectionTexture;
  45465. /**
  45466. * Gets the projection texture of the light.
  45467. */
  45468. /**
  45469. * Sets the projection texture of the light.
  45470. */
  45471. projectionTexture: Nullable<BaseTexture>;
  45472. private _projectionTextureViewLightDirty;
  45473. private _projectionTextureProjectionLightDirty;
  45474. private _projectionTextureDirty;
  45475. private _projectionTextureViewTargetVector;
  45476. private _projectionTextureViewLightMatrix;
  45477. private _projectionTextureProjectionLightMatrix;
  45478. private _projectionTextureScalingMatrix;
  45479. /**
  45480. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  45481. * It can cast shadows.
  45482. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45483. * @param name The light friendly name
  45484. * @param position The position of the spot light in the scene
  45485. * @param direction The direction of the light in the scene
  45486. * @param angle The cone angle of the light in Radians
  45487. * @param exponent The light decay speed with the distance from the emission spot
  45488. * @param scene The scene the lights belongs to
  45489. */
  45490. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  45491. /**
  45492. * Returns the string "SpotLight".
  45493. * @returns the class name
  45494. */
  45495. getClassName(): string;
  45496. /**
  45497. * Returns the integer 2.
  45498. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45499. */
  45500. getTypeID(): number;
  45501. /**
  45502. * Overrides the direction setter to recompute the projection texture view light Matrix.
  45503. */
  45504. protected _setDirection(value: Vector3): void;
  45505. /**
  45506. * Overrides the position setter to recompute the projection texture view light Matrix.
  45507. */
  45508. protected _setPosition(value: Vector3): void;
  45509. /**
  45510. * 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.
  45511. * Returns the SpotLight.
  45512. */
  45513. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45514. protected _computeProjectionTextureViewLightMatrix(): void;
  45515. protected _computeProjectionTextureProjectionLightMatrix(): void;
  45516. /**
  45517. * Main function for light texture projection matrix computing.
  45518. */
  45519. protected _computeProjectionTextureMatrix(): void;
  45520. protected _buildUniformLayout(): void;
  45521. private _computeAngleValues;
  45522. /**
  45523. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  45524. * @param effect The effect to update
  45525. * @param lightIndex The index of the light in the effect to update
  45526. * @returns The spot light
  45527. */
  45528. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  45529. /**
  45530. * Disposes the light and the associated resources.
  45531. */
  45532. dispose(): void;
  45533. /**
  45534. * Prepares the list of defines specific to the light type.
  45535. * @param defines the list of defines
  45536. * @param lightIndex defines the index of the light for the effect
  45537. */
  45538. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45539. }
  45540. }
  45541. declare module "babylonjs/Gizmos/lightGizmo" {
  45542. import { Nullable } from "babylonjs/types";
  45543. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45544. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45545. import { Light } from "babylonjs/Lights/light";
  45546. /**
  45547. * Gizmo that enables viewing a light
  45548. */
  45549. export class LightGizmo extends Gizmo {
  45550. private _lightMesh;
  45551. private _material;
  45552. private cachedPosition;
  45553. private cachedForward;
  45554. /**
  45555. * Creates a LightGizmo
  45556. * @param gizmoLayer The utility layer the gizmo will be added to
  45557. */
  45558. constructor(gizmoLayer?: UtilityLayerRenderer);
  45559. private _light;
  45560. /**
  45561. * The light that the gizmo is attached to
  45562. */
  45563. light: Nullable<Light>;
  45564. /**
  45565. * @hidden
  45566. * Updates the gizmo to match the attached mesh's position/rotation
  45567. */
  45568. protected _update(): void;
  45569. private static _Scale;
  45570. /**
  45571. * Creates the lines for a light mesh
  45572. */
  45573. private static _createLightLines;
  45574. /**
  45575. * Disposes of the light gizmo
  45576. */
  45577. dispose(): void;
  45578. private static _CreateHemisphericLightMesh;
  45579. private static _CreatePointLightMesh;
  45580. private static _CreateSpotLightMesh;
  45581. private static _CreateDirectionalLightMesh;
  45582. }
  45583. }
  45584. declare module "babylonjs/Gizmos/index" {
  45585. export * from "babylonjs/Gizmos/axisDragGizmo";
  45586. export * from "babylonjs/Gizmos/axisScaleGizmo";
  45587. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  45588. export * from "babylonjs/Gizmos/gizmo";
  45589. export * from "babylonjs/Gizmos/gizmoManager";
  45590. export * from "babylonjs/Gizmos/planeRotationGizmo";
  45591. export * from "babylonjs/Gizmos/positionGizmo";
  45592. export * from "babylonjs/Gizmos/rotationGizmo";
  45593. export * from "babylonjs/Gizmos/scaleGizmo";
  45594. export * from "babylonjs/Gizmos/lightGizmo";
  45595. }
  45596. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  45597. /** @hidden */
  45598. export var backgroundFragmentDeclaration: {
  45599. name: string;
  45600. shader: string;
  45601. };
  45602. }
  45603. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  45604. /** @hidden */
  45605. export var backgroundUboDeclaration: {
  45606. name: string;
  45607. shader: string;
  45608. };
  45609. }
  45610. declare module "babylonjs/Shaders/background.fragment" {
  45611. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  45612. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  45613. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  45614. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  45615. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  45616. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  45617. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45618. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  45619. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  45620. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  45621. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  45622. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  45623. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  45624. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  45625. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  45626. /** @hidden */
  45627. export var backgroundPixelShader: {
  45628. name: string;
  45629. shader: string;
  45630. };
  45631. }
  45632. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  45633. /** @hidden */
  45634. export var backgroundVertexDeclaration: {
  45635. name: string;
  45636. shader: string;
  45637. };
  45638. }
  45639. declare module "babylonjs/Shaders/background.vertex" {
  45640. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  45641. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  45642. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45643. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  45644. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  45645. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  45646. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  45647. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  45648. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  45649. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  45650. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  45651. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  45652. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  45653. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  45654. /** @hidden */
  45655. export var backgroundVertexShader: {
  45656. name: string;
  45657. shader: string;
  45658. };
  45659. }
  45660. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  45661. import { Nullable, int, float } from "babylonjs/types";
  45662. import { Scene } from "babylonjs/scene";
  45663. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  45664. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45665. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45666. import { Mesh } from "babylonjs/Meshes/mesh";
  45667. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  45668. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  45669. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  45670. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45671. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  45672. import "babylonjs/Shaders/background.fragment";
  45673. import "babylonjs/Shaders/background.vertex";
  45674. /**
  45675. * Background material used to create an efficient environement around your scene.
  45676. */
  45677. export class BackgroundMaterial extends PushMaterial {
  45678. /**
  45679. * Standard reflectance value at parallel view angle.
  45680. */
  45681. static StandardReflectance0: number;
  45682. /**
  45683. * Standard reflectance value at grazing angle.
  45684. */
  45685. static StandardReflectance90: number;
  45686. protected _primaryColor: Color3;
  45687. /**
  45688. * Key light Color (multiply against the environement texture)
  45689. */
  45690. primaryColor: Color3;
  45691. protected __perceptualColor: Nullable<Color3>;
  45692. /**
  45693. * Experimental Internal Use Only.
  45694. *
  45695. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  45696. * This acts as a helper to set the primary color to a more "human friendly" value.
  45697. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  45698. * output color as close as possible from the chosen value.
  45699. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  45700. * part of lighting setup.)
  45701. */
  45702. _perceptualColor: Nullable<Color3>;
  45703. protected _primaryColorShadowLevel: float;
  45704. /**
  45705. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  45706. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  45707. */
  45708. primaryColorShadowLevel: float;
  45709. protected _primaryColorHighlightLevel: float;
  45710. /**
  45711. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  45712. * The primary color is used at the level chosen to define what the white area would look.
  45713. */
  45714. primaryColorHighlightLevel: float;
  45715. protected _reflectionTexture: Nullable<BaseTexture>;
  45716. /**
  45717. * Reflection Texture used in the material.
  45718. * Should be author in a specific way for the best result (refer to the documentation).
  45719. */
  45720. reflectionTexture: Nullable<BaseTexture>;
  45721. protected _reflectionBlur: float;
  45722. /**
  45723. * Reflection Texture level of blur.
  45724. *
  45725. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  45726. * texture twice.
  45727. */
  45728. reflectionBlur: float;
  45729. protected _diffuseTexture: Nullable<BaseTexture>;
  45730. /**
  45731. * Diffuse Texture used in the material.
  45732. * Should be author in a specific way for the best result (refer to the documentation).
  45733. */
  45734. diffuseTexture: Nullable<BaseTexture>;
  45735. protected _shadowLights: Nullable<IShadowLight[]>;
  45736. /**
  45737. * Specify the list of lights casting shadow on the material.
  45738. * All scene shadow lights will be included if null.
  45739. */
  45740. shadowLights: Nullable<IShadowLight[]>;
  45741. protected _shadowLevel: float;
  45742. /**
  45743. * Helps adjusting the shadow to a softer level if required.
  45744. * 0 means black shadows and 1 means no shadows.
  45745. */
  45746. shadowLevel: float;
  45747. protected _sceneCenter: Vector3;
  45748. /**
  45749. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  45750. * It is usually zero but might be interesting to modify according to your setup.
  45751. */
  45752. sceneCenter: Vector3;
  45753. protected _opacityFresnel: boolean;
  45754. /**
  45755. * This helps specifying that the material is falling off to the sky box at grazing angle.
  45756. * This helps ensuring a nice transition when the camera goes under the ground.
  45757. */
  45758. opacityFresnel: boolean;
  45759. protected _reflectionFresnel: boolean;
  45760. /**
  45761. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  45762. * This helps adding a mirror texture on the ground.
  45763. */
  45764. reflectionFresnel: boolean;
  45765. protected _reflectionFalloffDistance: number;
  45766. /**
  45767. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  45768. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  45769. */
  45770. reflectionFalloffDistance: number;
  45771. protected _reflectionAmount: number;
  45772. /**
  45773. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  45774. */
  45775. reflectionAmount: number;
  45776. protected _reflectionReflectance0: number;
  45777. /**
  45778. * This specifies the weight of the reflection at grazing angle.
  45779. */
  45780. reflectionReflectance0: number;
  45781. protected _reflectionReflectance90: number;
  45782. /**
  45783. * This specifies the weight of the reflection at a perpendicular point of view.
  45784. */
  45785. reflectionReflectance90: number;
  45786. /**
  45787. * Sets the reflection reflectance fresnel values according to the default standard
  45788. * empirically know to work well :-)
  45789. */
  45790. reflectionStandardFresnelWeight: number;
  45791. protected _useRGBColor: boolean;
  45792. /**
  45793. * Helps to directly use the maps channels instead of their level.
  45794. */
  45795. useRGBColor: boolean;
  45796. protected _enableNoise: boolean;
  45797. /**
  45798. * This helps reducing the banding effect that could occur on the background.
  45799. */
  45800. enableNoise: boolean;
  45801. /**
  45802. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45803. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  45804. * Recommended to be keep at 1.0 except for special cases.
  45805. */
  45806. fovMultiplier: number;
  45807. private _fovMultiplier;
  45808. /**
  45809. * Enable the FOV adjustment feature controlled by fovMultiplier.
  45810. */
  45811. useEquirectangularFOV: boolean;
  45812. private _maxSimultaneousLights;
  45813. /**
  45814. * Number of Simultaneous lights allowed on the material.
  45815. */
  45816. maxSimultaneousLights: int;
  45817. /**
  45818. * Default configuration related to image processing available in the Background Material.
  45819. */
  45820. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45821. /**
  45822. * Keep track of the image processing observer to allow dispose and replace.
  45823. */
  45824. private _imageProcessingObserver;
  45825. /**
  45826. * Attaches a new image processing configuration to the PBR Material.
  45827. * @param configuration (if null the scene configuration will be use)
  45828. */
  45829. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45830. /**
  45831. * Gets the image processing configuration used either in this material.
  45832. */
  45833. /**
  45834. * Sets the Default image processing configuration used either in the this material.
  45835. *
  45836. * If sets to null, the scene one is in use.
  45837. */
  45838. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  45839. /**
  45840. * Gets wether the color curves effect is enabled.
  45841. */
  45842. /**
  45843. * Sets wether the color curves effect is enabled.
  45844. */
  45845. cameraColorCurvesEnabled: boolean;
  45846. /**
  45847. * Gets wether the color grading effect is enabled.
  45848. */
  45849. /**
  45850. * Gets wether the color grading effect is enabled.
  45851. */
  45852. cameraColorGradingEnabled: boolean;
  45853. /**
  45854. * Gets wether tonemapping is enabled or not.
  45855. */
  45856. /**
  45857. * Sets wether tonemapping is enabled or not
  45858. */
  45859. cameraToneMappingEnabled: boolean;
  45860. /**
  45861. * The camera exposure used on this material.
  45862. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45863. * This corresponds to a photographic exposure.
  45864. */
  45865. /**
  45866. * The camera exposure used on this material.
  45867. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45868. * This corresponds to a photographic exposure.
  45869. */
  45870. cameraExposure: float;
  45871. /**
  45872. * Gets The camera contrast used on this material.
  45873. */
  45874. /**
  45875. * Sets The camera contrast used on this material.
  45876. */
  45877. cameraContrast: float;
  45878. /**
  45879. * Gets the Color Grading 2D Lookup Texture.
  45880. */
  45881. /**
  45882. * Sets the Color Grading 2D Lookup Texture.
  45883. */
  45884. cameraColorGradingTexture: Nullable<BaseTexture>;
  45885. /**
  45886. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45887. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45888. * 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;
  45889. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45890. */
  45891. /**
  45892. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45893. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45894. * 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;
  45895. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45896. */
  45897. cameraColorCurves: Nullable<ColorCurves>;
  45898. /**
  45899. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  45900. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  45901. */
  45902. switchToBGR: boolean;
  45903. private _renderTargets;
  45904. private _reflectionControls;
  45905. private _white;
  45906. private _primaryShadowColor;
  45907. private _primaryHighlightColor;
  45908. /**
  45909. * Instantiates a Background Material in the given scene
  45910. * @param name The friendly name of the material
  45911. * @param scene The scene to add the material to
  45912. */
  45913. constructor(name: string, scene: Scene);
  45914. /**
  45915. * Gets a boolean indicating that current material needs to register RTT
  45916. */
  45917. readonly hasRenderTargetTextures: boolean;
  45918. /**
  45919. * The entire material has been created in order to prevent overdraw.
  45920. * @returns false
  45921. */
  45922. needAlphaTesting(): boolean;
  45923. /**
  45924. * The entire material has been created in order to prevent overdraw.
  45925. * @returns true if blending is enable
  45926. */
  45927. needAlphaBlending(): boolean;
  45928. /**
  45929. * Checks wether the material is ready to be rendered for a given mesh.
  45930. * @param mesh The mesh to render
  45931. * @param subMesh The submesh to check against
  45932. * @param useInstances Specify wether or not the material is used with instances
  45933. * @returns true if all the dependencies are ready (Textures, Effects...)
  45934. */
  45935. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45936. /**
  45937. * Compute the primary color according to the chosen perceptual color.
  45938. */
  45939. private _computePrimaryColorFromPerceptualColor;
  45940. /**
  45941. * Compute the highlights and shadow colors according to their chosen levels.
  45942. */
  45943. private _computePrimaryColors;
  45944. /**
  45945. * Build the uniform buffer used in the material.
  45946. */
  45947. buildUniformLayout(): void;
  45948. /**
  45949. * Unbind the material.
  45950. */
  45951. unbind(): void;
  45952. /**
  45953. * Bind only the world matrix to the material.
  45954. * @param world The world matrix to bind.
  45955. */
  45956. bindOnlyWorldMatrix(world: Matrix): void;
  45957. /**
  45958. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  45959. * @param world The world matrix to bind.
  45960. * @param subMesh The submesh to bind for.
  45961. */
  45962. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45963. /**
  45964. * Dispose the material.
  45965. * @param forceDisposeEffect Force disposal of the associated effect.
  45966. * @param forceDisposeTextures Force disposal of the associated textures.
  45967. */
  45968. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45969. /**
  45970. * Clones the material.
  45971. * @param name The cloned name.
  45972. * @returns The cloned material.
  45973. */
  45974. clone(name: string): BackgroundMaterial;
  45975. /**
  45976. * Serializes the current material to its JSON representation.
  45977. * @returns The JSON representation.
  45978. */
  45979. serialize(): any;
  45980. /**
  45981. * Gets the class name of the material
  45982. * @returns "BackgroundMaterial"
  45983. */
  45984. getClassName(): string;
  45985. /**
  45986. * Parse a JSON input to create back a background material.
  45987. * @param source The JSON data to parse
  45988. * @param scene The scene to create the parsed material in
  45989. * @param rootUrl The root url of the assets the material depends upon
  45990. * @returns the instantiated BackgroundMaterial.
  45991. */
  45992. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  45993. }
  45994. }
  45995. declare module "babylonjs/Helpers/environmentHelper" {
  45996. import { Observable } from "babylonjs/Misc/observable";
  45997. import { Nullable } from "babylonjs/types";
  45998. import { Scene } from "babylonjs/scene";
  45999. import { Vector3, Color3 } from "babylonjs/Maths/math";
  46000. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46001. import { Mesh } from "babylonjs/Meshes/mesh";
  46002. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46003. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  46004. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  46005. import "babylonjs/Meshes/Builders/planeBuilder";
  46006. import "babylonjs/Meshes/Builders/boxBuilder";
  46007. /**
  46008. * Represents the different options available during the creation of
  46009. * a Environment helper.
  46010. *
  46011. * This can control the default ground, skybox and image processing setup of your scene.
  46012. */
  46013. export interface IEnvironmentHelperOptions {
  46014. /**
  46015. * Specifies wether or not to create a ground.
  46016. * True by default.
  46017. */
  46018. createGround: boolean;
  46019. /**
  46020. * Specifies the ground size.
  46021. * 15 by default.
  46022. */
  46023. groundSize: number;
  46024. /**
  46025. * The texture used on the ground for the main color.
  46026. * Comes from the BabylonJS CDN by default.
  46027. *
  46028. * Remarks: Can be either a texture or a url.
  46029. */
  46030. groundTexture: string | BaseTexture;
  46031. /**
  46032. * The color mixed in the ground texture by default.
  46033. * BabylonJS clearColor by default.
  46034. */
  46035. groundColor: Color3;
  46036. /**
  46037. * Specifies the ground opacity.
  46038. * 1 by default.
  46039. */
  46040. groundOpacity: number;
  46041. /**
  46042. * Enables the ground to receive shadows.
  46043. * True by default.
  46044. */
  46045. enableGroundShadow: boolean;
  46046. /**
  46047. * Helps preventing the shadow to be fully black on the ground.
  46048. * 0.5 by default.
  46049. */
  46050. groundShadowLevel: number;
  46051. /**
  46052. * Creates a mirror texture attach to the ground.
  46053. * false by default.
  46054. */
  46055. enableGroundMirror: boolean;
  46056. /**
  46057. * Specifies the ground mirror size ratio.
  46058. * 0.3 by default as the default kernel is 64.
  46059. */
  46060. groundMirrorSizeRatio: number;
  46061. /**
  46062. * Specifies the ground mirror blur kernel size.
  46063. * 64 by default.
  46064. */
  46065. groundMirrorBlurKernel: number;
  46066. /**
  46067. * Specifies the ground mirror visibility amount.
  46068. * 1 by default
  46069. */
  46070. groundMirrorAmount: number;
  46071. /**
  46072. * Specifies the ground mirror reflectance weight.
  46073. * This uses the standard weight of the background material to setup the fresnel effect
  46074. * of the mirror.
  46075. * 1 by default.
  46076. */
  46077. groundMirrorFresnelWeight: number;
  46078. /**
  46079. * Specifies the ground mirror Falloff distance.
  46080. * This can helps reducing the size of the reflection.
  46081. * 0 by Default.
  46082. */
  46083. groundMirrorFallOffDistance: number;
  46084. /**
  46085. * Specifies the ground mirror texture type.
  46086. * Unsigned Int by Default.
  46087. */
  46088. groundMirrorTextureType: number;
  46089. /**
  46090. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  46091. * the shown objects.
  46092. */
  46093. groundYBias: number;
  46094. /**
  46095. * Specifies wether or not to create a skybox.
  46096. * True by default.
  46097. */
  46098. createSkybox: boolean;
  46099. /**
  46100. * Specifies the skybox size.
  46101. * 20 by default.
  46102. */
  46103. skyboxSize: number;
  46104. /**
  46105. * The texture used on the skybox for the main color.
  46106. * Comes from the BabylonJS CDN by default.
  46107. *
  46108. * Remarks: Can be either a texture or a url.
  46109. */
  46110. skyboxTexture: string | BaseTexture;
  46111. /**
  46112. * The color mixed in the skybox texture by default.
  46113. * BabylonJS clearColor by default.
  46114. */
  46115. skyboxColor: Color3;
  46116. /**
  46117. * The background rotation around the Y axis of the scene.
  46118. * This helps aligning the key lights of your scene with the background.
  46119. * 0 by default.
  46120. */
  46121. backgroundYRotation: number;
  46122. /**
  46123. * Compute automatically the size of the elements to best fit with the scene.
  46124. */
  46125. sizeAuto: boolean;
  46126. /**
  46127. * Default position of the rootMesh if autoSize is not true.
  46128. */
  46129. rootPosition: Vector3;
  46130. /**
  46131. * Sets up the image processing in the scene.
  46132. * true by default.
  46133. */
  46134. setupImageProcessing: boolean;
  46135. /**
  46136. * The texture used as your environment texture in the scene.
  46137. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  46138. *
  46139. * Remarks: Can be either a texture or a url.
  46140. */
  46141. environmentTexture: string | BaseTexture;
  46142. /**
  46143. * The value of the exposure to apply to the scene.
  46144. * 0.6 by default if setupImageProcessing is true.
  46145. */
  46146. cameraExposure: number;
  46147. /**
  46148. * The value of the contrast to apply to the scene.
  46149. * 1.6 by default if setupImageProcessing is true.
  46150. */
  46151. cameraContrast: number;
  46152. /**
  46153. * Specifies wether or not tonemapping should be enabled in the scene.
  46154. * true by default if setupImageProcessing is true.
  46155. */
  46156. toneMappingEnabled: boolean;
  46157. }
  46158. /**
  46159. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  46160. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  46161. * It also helps with the default setup of your imageProcessing configuration.
  46162. */
  46163. export class EnvironmentHelper {
  46164. /**
  46165. * Default ground texture URL.
  46166. */
  46167. private static _groundTextureCDNUrl;
  46168. /**
  46169. * Default skybox texture URL.
  46170. */
  46171. private static _skyboxTextureCDNUrl;
  46172. /**
  46173. * Default environment texture URL.
  46174. */
  46175. private static _environmentTextureCDNUrl;
  46176. /**
  46177. * Creates the default options for the helper.
  46178. */
  46179. private static _getDefaultOptions;
  46180. private _rootMesh;
  46181. /**
  46182. * Gets the root mesh created by the helper.
  46183. */
  46184. readonly rootMesh: Mesh;
  46185. private _skybox;
  46186. /**
  46187. * Gets the skybox created by the helper.
  46188. */
  46189. readonly skybox: Nullable<Mesh>;
  46190. private _skyboxTexture;
  46191. /**
  46192. * Gets the skybox texture created by the helper.
  46193. */
  46194. readonly skyboxTexture: Nullable<BaseTexture>;
  46195. private _skyboxMaterial;
  46196. /**
  46197. * Gets the skybox material created by the helper.
  46198. */
  46199. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  46200. private _ground;
  46201. /**
  46202. * Gets the ground mesh created by the helper.
  46203. */
  46204. readonly ground: Nullable<Mesh>;
  46205. private _groundTexture;
  46206. /**
  46207. * Gets the ground texture created by the helper.
  46208. */
  46209. readonly groundTexture: Nullable<BaseTexture>;
  46210. private _groundMirror;
  46211. /**
  46212. * Gets the ground mirror created by the helper.
  46213. */
  46214. readonly groundMirror: Nullable<MirrorTexture>;
  46215. /**
  46216. * Gets the ground mirror render list to helps pushing the meshes
  46217. * you wish in the ground reflection.
  46218. */
  46219. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  46220. private _groundMaterial;
  46221. /**
  46222. * Gets the ground material created by the helper.
  46223. */
  46224. readonly groundMaterial: Nullable<BackgroundMaterial>;
  46225. /**
  46226. * Stores the creation options.
  46227. */
  46228. private readonly _scene;
  46229. private _options;
  46230. /**
  46231. * This observable will be notified with any error during the creation of the environment,
  46232. * mainly texture creation errors.
  46233. */
  46234. onErrorObservable: Observable<{
  46235. message?: string;
  46236. exception?: any;
  46237. }>;
  46238. /**
  46239. * constructor
  46240. * @param options Defines the options we want to customize the helper
  46241. * @param scene The scene to add the material to
  46242. */
  46243. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  46244. /**
  46245. * Updates the background according to the new options
  46246. * @param options
  46247. */
  46248. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  46249. /**
  46250. * Sets the primary color of all the available elements.
  46251. * @param color the main color to affect to the ground and the background
  46252. */
  46253. setMainColor(color: Color3): void;
  46254. /**
  46255. * Setup the image processing according to the specified options.
  46256. */
  46257. private _setupImageProcessing;
  46258. /**
  46259. * Setup the environment texture according to the specified options.
  46260. */
  46261. private _setupEnvironmentTexture;
  46262. /**
  46263. * Setup the background according to the specified options.
  46264. */
  46265. private _setupBackground;
  46266. /**
  46267. * Get the scene sizes according to the setup.
  46268. */
  46269. private _getSceneSize;
  46270. /**
  46271. * Setup the ground according to the specified options.
  46272. */
  46273. private _setupGround;
  46274. /**
  46275. * Setup the ground material according to the specified options.
  46276. */
  46277. private _setupGroundMaterial;
  46278. /**
  46279. * Setup the ground diffuse texture according to the specified options.
  46280. */
  46281. private _setupGroundDiffuseTexture;
  46282. /**
  46283. * Setup the ground mirror texture according to the specified options.
  46284. */
  46285. private _setupGroundMirrorTexture;
  46286. /**
  46287. * Setup the ground to receive the mirror texture.
  46288. */
  46289. private _setupMirrorInGroundMaterial;
  46290. /**
  46291. * Setup the skybox according to the specified options.
  46292. */
  46293. private _setupSkybox;
  46294. /**
  46295. * Setup the skybox material according to the specified options.
  46296. */
  46297. private _setupSkyboxMaterial;
  46298. /**
  46299. * Setup the skybox reflection texture according to the specified options.
  46300. */
  46301. private _setupSkyboxReflectionTexture;
  46302. private _errorHandler;
  46303. /**
  46304. * Dispose all the elements created by the Helper.
  46305. */
  46306. dispose(): void;
  46307. }
  46308. }
  46309. declare module "babylonjs/Helpers/photoDome" {
  46310. import { Observable } from "babylonjs/Misc/observable";
  46311. import { Nullable } from "babylonjs/types";
  46312. import { Scene } from "babylonjs/scene";
  46313. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46314. import { Mesh } from "babylonjs/Meshes/mesh";
  46315. import { Texture } from "babylonjs/Materials/Textures/texture";
  46316. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  46317. import "babylonjs/Meshes/Builders/sphereBuilder";
  46318. /**
  46319. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  46320. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  46321. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  46322. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  46323. */
  46324. export class PhotoDome extends TransformNode {
  46325. /**
  46326. * Define the image as a Monoscopic panoramic 360 image.
  46327. */
  46328. static readonly MODE_MONOSCOPIC: number;
  46329. /**
  46330. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  46331. */
  46332. static readonly MODE_TOPBOTTOM: number;
  46333. /**
  46334. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  46335. */
  46336. static readonly MODE_SIDEBYSIDE: number;
  46337. private _useDirectMapping;
  46338. /**
  46339. * The texture being displayed on the sphere
  46340. */
  46341. protected _photoTexture: Texture;
  46342. /**
  46343. * Gets or sets the texture being displayed on the sphere
  46344. */
  46345. photoTexture: Texture;
  46346. /**
  46347. * Observable raised when an error occured while loading the 360 image
  46348. */
  46349. onLoadErrorObservable: Observable<string>;
  46350. /**
  46351. * The skybox material
  46352. */
  46353. protected _material: BackgroundMaterial;
  46354. /**
  46355. * The surface used for the skybox
  46356. */
  46357. protected _mesh: Mesh;
  46358. /**
  46359. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46360. * Also see the options.resolution property.
  46361. */
  46362. fovMultiplier: number;
  46363. private _imageMode;
  46364. /**
  46365. * Gets or set the current video mode for the video. It can be:
  46366. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  46367. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  46368. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  46369. */
  46370. imageMode: number;
  46371. /**
  46372. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  46373. * @param name Element's name, child elements will append suffixes for their own names.
  46374. * @param urlsOfPhoto defines the url of the photo to display
  46375. * @param options defines an object containing optional or exposed sub element properties
  46376. * @param onError defines a callback called when an error occured while loading the texture
  46377. */
  46378. constructor(name: string, urlOfPhoto: string, options: {
  46379. resolution?: number;
  46380. size?: number;
  46381. useDirectMapping?: boolean;
  46382. faceForward?: boolean;
  46383. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  46384. private _onBeforeCameraRenderObserver;
  46385. private _changeImageMode;
  46386. /**
  46387. * Releases resources associated with this node.
  46388. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  46389. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  46390. */
  46391. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  46392. }
  46393. }
  46394. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  46395. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46396. /** @hidden */
  46397. export var rgbdDecodePixelShader: {
  46398. name: string;
  46399. shader: string;
  46400. };
  46401. }
  46402. declare module "babylonjs/Misc/brdfTextureTools" {
  46403. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46404. import { Scene } from "babylonjs/scene";
  46405. import "babylonjs/Shaders/rgbdDecode.fragment";
  46406. /**
  46407. * Class used to host texture specific utilities
  46408. */
  46409. export class BRDFTextureTools {
  46410. /**
  46411. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  46412. * @param texture the texture to expand.
  46413. */
  46414. private static _ExpandDefaultBRDFTexture;
  46415. /**
  46416. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  46417. * @param scene defines the hosting scene
  46418. * @returns the environment BRDF texture
  46419. */
  46420. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  46421. private static _environmentBRDFBase64Texture;
  46422. }
  46423. }
  46424. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  46425. import { Nullable } from "babylonjs/types";
  46426. import { IAnimatable } from "babylonjs/Misc/tools";
  46427. import { Color3 } from "babylonjs/Maths/math";
  46428. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46429. import { EffectFallbacks } from "babylonjs/Materials/effect";
  46430. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46431. import { Engine } from "babylonjs/Engines/engine";
  46432. import { Scene } from "babylonjs/scene";
  46433. /**
  46434. * @hidden
  46435. */
  46436. export interface IMaterialClearCoatDefines {
  46437. CLEARCOAT: boolean;
  46438. CLEARCOAT_DEFAULTIOR: boolean;
  46439. CLEARCOAT_TEXTURE: boolean;
  46440. CLEARCOAT_TEXTUREDIRECTUV: number;
  46441. CLEARCOAT_BUMP: boolean;
  46442. CLEARCOAT_BUMPDIRECTUV: number;
  46443. CLEARCOAT_TINT: boolean;
  46444. CLEARCOAT_TINT_TEXTURE: boolean;
  46445. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46446. /** @hidden */
  46447. _areTexturesDirty: boolean;
  46448. }
  46449. /**
  46450. * Define the code related to the clear coat parameters of the pbr material.
  46451. */
  46452. export class PBRClearCoatConfiguration {
  46453. /**
  46454. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  46455. * The default fits with a polyurethane material.
  46456. */
  46457. private static readonly _DefaultIndexOfRefraction;
  46458. private _isEnabled;
  46459. /**
  46460. * Defines if the clear coat is enabled in the material.
  46461. */
  46462. isEnabled: boolean;
  46463. /**
  46464. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  46465. */
  46466. intensity: number;
  46467. /**
  46468. * Defines the clear coat layer roughness.
  46469. */
  46470. roughness: number;
  46471. private _indexOfRefraction;
  46472. /**
  46473. * Defines the index of refraction of the clear coat.
  46474. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  46475. * The default fits with a polyurethane material.
  46476. * Changing the default value is more performance intensive.
  46477. */
  46478. indexOfRefraction: number;
  46479. private _texture;
  46480. /**
  46481. * Stores the clear coat values in a texture.
  46482. */
  46483. texture: Nullable<BaseTexture>;
  46484. private _bumpTexture;
  46485. /**
  46486. * Define the clear coat specific bump texture.
  46487. */
  46488. bumpTexture: Nullable<BaseTexture>;
  46489. private _isTintEnabled;
  46490. /**
  46491. * Defines if the clear coat tint is enabled in the material.
  46492. */
  46493. isTintEnabled: boolean;
  46494. /**
  46495. * Defines the clear coat tint of the material.
  46496. * This is only use if tint is enabled
  46497. */
  46498. tintColor: Color3;
  46499. /**
  46500. * Defines the distance at which the tint color should be found in the
  46501. * clear coat media.
  46502. * This is only use if tint is enabled
  46503. */
  46504. tintColorAtDistance: number;
  46505. /**
  46506. * Defines the clear coat layer thickness.
  46507. * This is only use if tint is enabled
  46508. */
  46509. tintThickness: number;
  46510. private _tintTexture;
  46511. /**
  46512. * Stores the clear tint values in a texture.
  46513. * rgb is tint
  46514. * a is a thickness factor
  46515. */
  46516. tintTexture: Nullable<BaseTexture>;
  46517. /** @hidden */
  46518. private _internalMarkAllSubMeshesAsTexturesDirty;
  46519. /** @hidden */
  46520. _markAllSubMeshesAsTexturesDirty(): void;
  46521. /**
  46522. * Instantiate a new istance of clear coat configuration.
  46523. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46524. */
  46525. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46526. /**
  46527. * Gets wehter the submesh is ready to be used or not.
  46528. * @param defines the list of "defines" to update.
  46529. * @param scene defines the scene the material belongs to.
  46530. * @param engine defines the engine the material belongs to.
  46531. * @param disableBumpMap defines wether the material disables bump or not.
  46532. * @returns - boolean indicating that the submesh is ready or not.
  46533. */
  46534. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  46535. /**
  46536. * Checks to see if a texture is used in the material.
  46537. * @param defines the list of "defines" to update.
  46538. * @param scene defines the scene to the material belongs to.
  46539. */
  46540. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  46541. /**
  46542. * Binds the material data.
  46543. * @param uniformBuffer defines the Uniform buffer to fill in.
  46544. * @param scene defines the scene the material belongs to.
  46545. * @param engine defines the engine the material belongs to.
  46546. * @param disableBumpMap defines wether the material disables bump or not.
  46547. * @param isFrozen defines wether the material is frozen or not.
  46548. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  46549. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  46550. */
  46551. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  46552. /**
  46553. * Checks to see if a texture is used in the material.
  46554. * @param texture - Base texture to use.
  46555. * @returns - Boolean specifying if a texture is used in the material.
  46556. */
  46557. hasTexture(texture: BaseTexture): boolean;
  46558. /**
  46559. * Returns an array of the actively used textures.
  46560. * @param activeTextures Array of BaseTextures
  46561. */
  46562. getActiveTextures(activeTextures: BaseTexture[]): void;
  46563. /**
  46564. * Returns the animatable textures.
  46565. * @param animatables Array of animatable textures.
  46566. */
  46567. getAnimatables(animatables: IAnimatable[]): void;
  46568. /**
  46569. * Disposes the resources of the material.
  46570. * @param forceDisposeTextures - Forces the disposal of all textures.
  46571. */
  46572. dispose(forceDisposeTextures?: boolean): void;
  46573. /**
  46574. * Get the current class name of the texture useful for serialization or dynamic coding.
  46575. * @returns "PBRClearCoatConfiguration"
  46576. */
  46577. getClassName(): string;
  46578. /**
  46579. * Add fallbacks to the effect fallbacks list.
  46580. * @param defines defines the Base texture to use.
  46581. * @param fallbacks defines the current fallback list.
  46582. * @param currentRank defines the current fallback rank.
  46583. * @returns the new fallback rank.
  46584. */
  46585. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46586. /**
  46587. * Add the required uniforms to the current list.
  46588. * @param uniforms defines the current uniform list.
  46589. */
  46590. static AddUniforms(uniforms: string[]): void;
  46591. /**
  46592. * Add the required samplers to the current list.
  46593. * @param samplers defines the current sampler list.
  46594. */
  46595. static AddSamplers(samplers: string[]): void;
  46596. /**
  46597. * Add the required uniforms to the current buffer.
  46598. * @param uniformBuffer defines the current uniform buffer.
  46599. */
  46600. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46601. /**
  46602. * Makes a duplicate of the current configuration into another one.
  46603. * @param clearCoatConfiguration define the config where to copy the info
  46604. */
  46605. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  46606. /**
  46607. * Serializes this clear coat configuration.
  46608. * @returns - An object with the serialized config.
  46609. */
  46610. serialize(): any;
  46611. /**
  46612. * Parses a anisotropy Configuration from a serialized object.
  46613. * @param source - Serialized object.
  46614. * @param scene Defines the scene we are parsing for
  46615. * @param rootUrl Defines the rootUrl to load from
  46616. */
  46617. parse(source: any, scene: Scene, rootUrl: string): void;
  46618. }
  46619. }
  46620. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  46621. import { EffectFallbacks } from "babylonjs/Materials/effect";
  46622. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46623. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46624. import { Vector2 } from "babylonjs/Maths/math";
  46625. import { Scene } from "babylonjs/scene";
  46626. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46627. import { IAnimatable } from "babylonjs/Misc/tools";
  46628. import { Nullable } from "babylonjs/types";
  46629. /**
  46630. * @hidden
  46631. */
  46632. export interface IMaterialAnisotropicDefines {
  46633. ANISOTROPIC: boolean;
  46634. ANISOTROPIC_TEXTURE: boolean;
  46635. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46636. MAINUV1: boolean;
  46637. _areTexturesDirty: boolean;
  46638. _needUVs: boolean;
  46639. }
  46640. /**
  46641. * Define the code related to the anisotropic parameters of the pbr material.
  46642. */
  46643. export class PBRAnisotropicConfiguration {
  46644. private _isEnabled;
  46645. /**
  46646. * Defines if the anisotropy is enabled in the material.
  46647. */
  46648. isEnabled: boolean;
  46649. /**
  46650. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  46651. */
  46652. intensity: number;
  46653. /**
  46654. * Defines if the effect is along the tangents, bitangents or in between.
  46655. * By default, the effect is "strectching" the highlights along the tangents.
  46656. */
  46657. direction: Vector2;
  46658. private _texture;
  46659. /**
  46660. * Stores the anisotropy values in a texture.
  46661. * rg is direction (like normal from -1 to 1)
  46662. * b is a intensity
  46663. */
  46664. texture: Nullable<BaseTexture>;
  46665. /** @hidden */
  46666. private _internalMarkAllSubMeshesAsTexturesDirty;
  46667. /** @hidden */
  46668. _markAllSubMeshesAsTexturesDirty(): void;
  46669. /**
  46670. * Instantiate a new istance of anisotropy configuration.
  46671. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46672. */
  46673. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46674. /**
  46675. * Specifies that the submesh is ready to be used.
  46676. * @param defines the list of "defines" to update.
  46677. * @param scene defines the scene the material belongs to.
  46678. * @returns - boolean indicating that the submesh is ready or not.
  46679. */
  46680. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  46681. /**
  46682. * Checks to see if a texture is used in the material.
  46683. * @param defines the list of "defines" to update.
  46684. * @param mesh the mesh we are preparing the defines for.
  46685. * @param scene defines the scene the material belongs to.
  46686. */
  46687. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  46688. /**
  46689. * Binds the material data.
  46690. * @param uniformBuffer defines the Uniform buffer to fill in.
  46691. * @param scene defines the scene the material belongs to.
  46692. * @param isFrozen defines wether the material is frozen or not.
  46693. */
  46694. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46695. /**
  46696. * Checks to see if a texture is used in the material.
  46697. * @param texture - Base texture to use.
  46698. * @returns - Boolean specifying if a texture is used in the material.
  46699. */
  46700. hasTexture(texture: BaseTexture): boolean;
  46701. /**
  46702. * Returns an array of the actively used textures.
  46703. * @param activeTextures Array of BaseTextures
  46704. */
  46705. getActiveTextures(activeTextures: BaseTexture[]): void;
  46706. /**
  46707. * Returns the animatable textures.
  46708. * @param animatables Array of animatable textures.
  46709. */
  46710. getAnimatables(animatables: IAnimatable[]): void;
  46711. /**
  46712. * Disposes the resources of the material.
  46713. * @param forceDisposeTextures - Forces the disposal of all textures.
  46714. */
  46715. dispose(forceDisposeTextures?: boolean): void;
  46716. /**
  46717. * Get the current class name of the texture useful for serialization or dynamic coding.
  46718. * @returns "PBRAnisotropicConfiguration"
  46719. */
  46720. getClassName(): string;
  46721. /**
  46722. * Add fallbacks to the effect fallbacks list.
  46723. * @param defines defines the Base texture to use.
  46724. * @param fallbacks defines the current fallback list.
  46725. * @param currentRank defines the current fallback rank.
  46726. * @returns the new fallback rank.
  46727. */
  46728. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46729. /**
  46730. * Add the required uniforms to the current list.
  46731. * @param uniforms defines the current uniform list.
  46732. */
  46733. static AddUniforms(uniforms: string[]): void;
  46734. /**
  46735. * Add the required uniforms to the current buffer.
  46736. * @param uniformBuffer defines the current uniform buffer.
  46737. */
  46738. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46739. /**
  46740. * Add the required samplers to the current list.
  46741. * @param samplers defines the current sampler list.
  46742. */
  46743. static AddSamplers(samplers: string[]): void;
  46744. /**
  46745. * Makes a duplicate of the current configuration into another one.
  46746. * @param anisotropicConfiguration define the config where to copy the info
  46747. */
  46748. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  46749. /**
  46750. * Serializes this anisotropy configuration.
  46751. * @returns - An object with the serialized config.
  46752. */
  46753. serialize(): any;
  46754. /**
  46755. * Parses a anisotropy Configuration from a serialized object.
  46756. * @param source - Serialized object.
  46757. * @param scene Defines the scene we are parsing for
  46758. * @param rootUrl Defines the rootUrl to load from
  46759. */
  46760. parse(source: any, scene: Scene, rootUrl: string): void;
  46761. }
  46762. }
  46763. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  46764. import { Scene } from "babylonjs/scene";
  46765. /**
  46766. * @hidden
  46767. */
  46768. export interface IMaterialBRDFDefines {
  46769. BRDF_V_HEIGHT_CORRELATED: boolean;
  46770. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46771. SPHERICAL_HARMONICS: boolean;
  46772. /** @hidden */
  46773. _areMiscDirty: boolean;
  46774. }
  46775. /**
  46776. * Define the code related to the BRDF parameters of the pbr material.
  46777. */
  46778. export class PBRBRDFConfiguration {
  46779. /**
  46780. * Default value used for the energy conservation.
  46781. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46782. */
  46783. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  46784. /**
  46785. * Default value used for the Smith Visibility Height Correlated mode.
  46786. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46787. */
  46788. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  46789. /**
  46790. * Default value used for the IBL diffuse part.
  46791. * This can help switching back to the polynomials mode globally which is a tiny bit
  46792. * less GPU intensive at the drawback of a lower quality.
  46793. */
  46794. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  46795. private _useEnergyConservation;
  46796. /**
  46797. * Defines if the material uses energy conservation.
  46798. */
  46799. useEnergyConservation: boolean;
  46800. private _useSmithVisibilityHeightCorrelated;
  46801. /**
  46802. * LEGACY Mode set to false
  46803. * Defines if the material uses height smith correlated visibility term.
  46804. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  46805. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  46806. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  46807. * Not relying on height correlated will also disable energy conservation.
  46808. */
  46809. useSmithVisibilityHeightCorrelated: boolean;
  46810. private _useSphericalHarmonics;
  46811. /**
  46812. * LEGACY Mode set to false
  46813. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  46814. * diffuse part of the IBL.
  46815. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  46816. * to the ground truth.
  46817. */
  46818. useSphericalHarmonics: boolean;
  46819. /** @hidden */
  46820. private _internalMarkAllSubMeshesAsMiscDirty;
  46821. /** @hidden */
  46822. _markAllSubMeshesAsMiscDirty(): void;
  46823. /**
  46824. * Instantiate a new istance of clear coat configuration.
  46825. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  46826. */
  46827. constructor(markAllSubMeshesAsMiscDirty: () => void);
  46828. /**
  46829. * Checks to see if a texture is used in the material.
  46830. * @param defines the list of "defines" to update.
  46831. */
  46832. prepareDefines(defines: IMaterialBRDFDefines): void;
  46833. /**
  46834. * Get the current class name of the texture useful for serialization or dynamic coding.
  46835. * @returns "PBRClearCoatConfiguration"
  46836. */
  46837. getClassName(): string;
  46838. /**
  46839. * Makes a duplicate of the current configuration into another one.
  46840. * @param brdfConfiguration define the config where to copy the info
  46841. */
  46842. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  46843. /**
  46844. * Serializes this BRDF configuration.
  46845. * @returns - An object with the serialized config.
  46846. */
  46847. serialize(): any;
  46848. /**
  46849. * Parses a anisotropy Configuration from a serialized object.
  46850. * @param source - Serialized object.
  46851. * @param scene Defines the scene we are parsing for
  46852. * @param rootUrl Defines the rootUrl to load from
  46853. */
  46854. parse(source: any, scene: Scene, rootUrl: string): void;
  46855. }
  46856. }
  46857. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  46858. import { EffectFallbacks } from "babylonjs/Materials/effect";
  46859. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46860. import { Color3 } from "babylonjs/Maths/math";
  46861. import { Scene } from "babylonjs/scene";
  46862. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46863. import { IAnimatable } from "babylonjs/Misc/tools";
  46864. import { Nullable } from "babylonjs/types";
  46865. /**
  46866. * @hidden
  46867. */
  46868. export interface IMaterialSheenDefines {
  46869. SHEEN: boolean;
  46870. SHEEN_TEXTURE: boolean;
  46871. SHEEN_TEXTUREDIRECTUV: number;
  46872. SHEEN_LINKWITHALBEDO: boolean;
  46873. /** @hidden */
  46874. _areTexturesDirty: boolean;
  46875. }
  46876. /**
  46877. * Define the code related to the Sheen parameters of the pbr material.
  46878. */
  46879. export class PBRSheenConfiguration {
  46880. private _isEnabled;
  46881. /**
  46882. * Defines if the material uses sheen.
  46883. */
  46884. isEnabled: boolean;
  46885. private _linkSheenWithAlbedo;
  46886. /**
  46887. * Defines if the sheen is linked to the sheen color.
  46888. */
  46889. linkSheenWithAlbedo: boolean;
  46890. /**
  46891. * Defines the sheen intensity.
  46892. */
  46893. intensity: number;
  46894. /**
  46895. * Defines the sheen color.
  46896. */
  46897. color: Color3;
  46898. private _texture;
  46899. /**
  46900. * Stores the sheen tint values in a texture.
  46901. * rgb is tint
  46902. * a is a intensity
  46903. */
  46904. texture: Nullable<BaseTexture>;
  46905. /** @hidden */
  46906. private _internalMarkAllSubMeshesAsTexturesDirty;
  46907. /** @hidden */
  46908. _markAllSubMeshesAsTexturesDirty(): void;
  46909. /**
  46910. * Instantiate a new istance of clear coat configuration.
  46911. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46912. */
  46913. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46914. /**
  46915. * Specifies that the submesh is ready to be used.
  46916. * @param defines the list of "defines" to update.
  46917. * @param scene defines the scene the material belongs to.
  46918. * @returns - boolean indicating that the submesh is ready or not.
  46919. */
  46920. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  46921. /**
  46922. * Checks to see if a texture is used in the material.
  46923. * @param defines the list of "defines" to update.
  46924. * @param scene defines the scene the material belongs to.
  46925. */
  46926. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  46927. /**
  46928. * Binds the material data.
  46929. * @param uniformBuffer defines the Uniform buffer to fill in.
  46930. * @param scene defines the scene the material belongs to.
  46931. * @param isFrozen defines wether the material is frozen or not.
  46932. */
  46933. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46934. /**
  46935. * Checks to see if a texture is used in the material.
  46936. * @param texture - Base texture to use.
  46937. * @returns - Boolean specifying if a texture is used in the material.
  46938. */
  46939. hasTexture(texture: BaseTexture): boolean;
  46940. /**
  46941. * Returns an array of the actively used textures.
  46942. * @param activeTextures Array of BaseTextures
  46943. */
  46944. getActiveTextures(activeTextures: BaseTexture[]): void;
  46945. /**
  46946. * Returns the animatable textures.
  46947. * @param animatables Array of animatable textures.
  46948. */
  46949. getAnimatables(animatables: IAnimatable[]): void;
  46950. /**
  46951. * Disposes the resources of the material.
  46952. * @param forceDisposeTextures - Forces the disposal of all textures.
  46953. */
  46954. dispose(forceDisposeTextures?: boolean): void;
  46955. /**
  46956. * Get the current class name of the texture useful for serialization or dynamic coding.
  46957. * @returns "PBRSheenConfiguration"
  46958. */
  46959. getClassName(): string;
  46960. /**
  46961. * Add fallbacks to the effect fallbacks list.
  46962. * @param defines defines the Base texture to use.
  46963. * @param fallbacks defines the current fallback list.
  46964. * @param currentRank defines the current fallback rank.
  46965. * @returns the new fallback rank.
  46966. */
  46967. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46968. /**
  46969. * Add the required uniforms to the current list.
  46970. * @param uniforms defines the current uniform list.
  46971. */
  46972. static AddUniforms(uniforms: string[]): void;
  46973. /**
  46974. * Add the required uniforms to the current buffer.
  46975. * @param uniformBuffer defines the current uniform buffer.
  46976. */
  46977. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46978. /**
  46979. * Add the required samplers to the current list.
  46980. * @param samplers defines the current sampler list.
  46981. */
  46982. static AddSamplers(samplers: string[]): void;
  46983. /**
  46984. * Makes a duplicate of the current configuration into another one.
  46985. * @param sheenConfiguration define the config where to copy the info
  46986. */
  46987. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  46988. /**
  46989. * Serializes this BRDF configuration.
  46990. * @returns - An object with the serialized config.
  46991. */
  46992. serialize(): any;
  46993. /**
  46994. * Parses a anisotropy Configuration from a serialized object.
  46995. * @param source - Serialized object.
  46996. * @param scene Defines the scene we are parsing for
  46997. * @param rootUrl Defines the rootUrl to load from
  46998. */
  46999. parse(source: any, scene: Scene, rootUrl: string): void;
  47000. }
  47001. }
  47002. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  47003. import { Nullable } from "babylonjs/types";
  47004. import { IAnimatable } from "babylonjs/Misc/tools";
  47005. import { Color3 } from "babylonjs/Maths/math";
  47006. import { SmartArray } from "babylonjs/Misc/smartArray";
  47007. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47008. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  47009. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  47010. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47011. import { Engine } from "babylonjs/Engines/engine";
  47012. import { Scene } from "babylonjs/scene";
  47013. /**
  47014. * @hidden
  47015. */
  47016. export interface IMaterialSubSurfaceDefines {
  47017. SUBSURFACE: boolean;
  47018. SS_REFRACTION: boolean;
  47019. SS_TRANSLUCENCY: boolean;
  47020. SS_SCATERRING: boolean;
  47021. SS_THICKNESSANDMASK_TEXTURE: boolean;
  47022. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  47023. SS_REFRACTIONMAP_3D: boolean;
  47024. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  47025. SS_LODINREFRACTIONALPHA: boolean;
  47026. SS_GAMMAREFRACTION: boolean;
  47027. SS_RGBDREFRACTION: boolean;
  47028. SS_LINEARSPECULARREFRACTION: boolean;
  47029. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  47030. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  47031. /** @hidden */
  47032. _areTexturesDirty: boolean;
  47033. }
  47034. /**
  47035. * Define the code related to the sub surface parameters of the pbr material.
  47036. */
  47037. export class PBRSubSurfaceConfiguration {
  47038. private _isRefractionEnabled;
  47039. /**
  47040. * Defines if the refraction is enabled in the material.
  47041. */
  47042. isRefractionEnabled: boolean;
  47043. private _isTranslucencyEnabled;
  47044. /**
  47045. * Defines if the translucency is enabled in the material.
  47046. */
  47047. isTranslucencyEnabled: boolean;
  47048. private _isScatteringEnabled;
  47049. /**
  47050. * Defines the refraction intensity of the material.
  47051. * The refraction when enabled replaces the Diffuse part of the material.
  47052. * The intensity helps transitionning between diffuse and refraction.
  47053. */
  47054. refractionIntensity: number;
  47055. /**
  47056. * Defines the translucency intensity of the material.
  47057. * When translucency has been enabled, this defines how much of the "translucency"
  47058. * is addded to the diffuse part of the material.
  47059. */
  47060. translucencyIntensity: number;
  47061. /**
  47062. * Defines the scattering intensity of the material.
  47063. * When scattering has been enabled, this defines how much of the "scattered light"
  47064. * is addded to the diffuse part of the material.
  47065. */
  47066. scatteringIntensity: number;
  47067. private _thicknessTexture;
  47068. /**
  47069. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  47070. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  47071. * 0 would mean minimumThickness
  47072. * 1 would mean maximumThickness
  47073. * The other channels might be use as a mask to vary the different effects intensity.
  47074. */
  47075. thicknessTexture: Nullable<BaseTexture>;
  47076. private _refractionTexture;
  47077. /**
  47078. * Defines the texture to use for refraction.
  47079. */
  47080. refractionTexture: Nullable<BaseTexture>;
  47081. private _indexOfRefraction;
  47082. /**
  47083. * Defines the index of refraction used in the material.
  47084. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  47085. */
  47086. indexOfRefraction: number;
  47087. private _invertRefractionY;
  47088. /**
  47089. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47090. */
  47091. invertRefractionY: boolean;
  47092. private _linkRefractionWithTransparency;
  47093. /**
  47094. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47095. * Materials half opaque for instance using refraction could benefit from this control.
  47096. */
  47097. linkRefractionWithTransparency: boolean;
  47098. /**
  47099. * Defines the minimum thickness stored in the thickness map.
  47100. * If no thickness map is defined, this value will be used to simulate thickness.
  47101. */
  47102. minimumThickness: number;
  47103. /**
  47104. * Defines the maximum thickness stored in the thickness map.
  47105. */
  47106. maximumThickness: number;
  47107. /**
  47108. * Defines the volume tint of the material.
  47109. * This is used for both translucency and scattering.
  47110. */
  47111. tintColor: Color3;
  47112. /**
  47113. * Defines the distance at which the tint color should be found in the media.
  47114. * This is used for refraction only.
  47115. */
  47116. tintColorAtDistance: number;
  47117. /**
  47118. * Defines how far each channel transmit through the media.
  47119. * It is defined as a color to simplify it selection.
  47120. */
  47121. diffusionDistance: Color3;
  47122. private _useMaskFromThicknessTexture;
  47123. /**
  47124. * Stores the intensity of the different subsurface effects in the thickness texture.
  47125. * * the green channel is the translucency intensity.
  47126. * * the blue channel is the scattering intensity.
  47127. * * the alpha channel is the refraction intensity.
  47128. */
  47129. useMaskFromThicknessTexture: boolean;
  47130. /** @hidden */
  47131. private _internalMarkAllSubMeshesAsTexturesDirty;
  47132. /** @hidden */
  47133. _markAllSubMeshesAsTexturesDirty(): void;
  47134. /**
  47135. * Instantiate a new istance of sub surface configuration.
  47136. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47137. */
  47138. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47139. /**
  47140. * Gets wehter the submesh is ready to be used or not.
  47141. * @param defines the list of "defines" to update.
  47142. * @param scene defines the scene the material belongs to.
  47143. * @returns - boolean indicating that the submesh is ready or not.
  47144. */
  47145. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  47146. /**
  47147. * Checks to see if a texture is used in the material.
  47148. * @param defines the list of "defines" to update.
  47149. * @param scene defines the scene to the material belongs to.
  47150. */
  47151. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  47152. /**
  47153. * Binds the material data.
  47154. * @param uniformBuffer defines the Uniform buffer to fill in.
  47155. * @param scene defines the scene the material belongs to.
  47156. * @param engine defines the engine the material belongs to.
  47157. * @param isFrozen defines wether the material is frozen or not.
  47158. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  47159. */
  47160. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  47161. /**
  47162. * Unbinds the material from the mesh.
  47163. * @param activeEffect defines the effect that should be unbound from.
  47164. * @returns true if unbound, otherwise false
  47165. */
  47166. unbind(activeEffect: Effect): boolean;
  47167. /**
  47168. * Returns the texture used for refraction or null if none is used.
  47169. * @param scene defines the scene the material belongs to.
  47170. * @returns - Refraction texture if present. If no refraction texture and refraction
  47171. * is linked with transparency, returns environment texture. Otherwise, returns null.
  47172. */
  47173. private _getRefractionTexture;
  47174. /**
  47175. * Returns true if alpha blending should be disabled.
  47176. */
  47177. readonly disableAlphaBlending: boolean;
  47178. /**
  47179. * Fills the list of render target textures.
  47180. * @param renderTargets the list of render targets to update
  47181. */
  47182. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  47183. /**
  47184. * Checks to see if a texture is used in the material.
  47185. * @param texture - Base texture to use.
  47186. * @returns - Boolean specifying if a texture is used in the material.
  47187. */
  47188. hasTexture(texture: BaseTexture): boolean;
  47189. /**
  47190. * Gets a boolean indicating that current material needs to register RTT
  47191. * @returns true if this uses a render target otherwise false.
  47192. */
  47193. hasRenderTargetTextures(): boolean;
  47194. /**
  47195. * Returns an array of the actively used textures.
  47196. * @param activeTextures Array of BaseTextures
  47197. */
  47198. getActiveTextures(activeTextures: BaseTexture[]): void;
  47199. /**
  47200. * Returns the animatable textures.
  47201. * @param animatables Array of animatable textures.
  47202. */
  47203. getAnimatables(animatables: IAnimatable[]): void;
  47204. /**
  47205. * Disposes the resources of the material.
  47206. * @param forceDisposeTextures - Forces the disposal of all textures.
  47207. */
  47208. dispose(forceDisposeTextures?: boolean): void;
  47209. /**
  47210. * Get the current class name of the texture useful for serialization or dynamic coding.
  47211. * @returns "PBRSubSurfaceConfiguration"
  47212. */
  47213. getClassName(): string;
  47214. /**
  47215. * Add fallbacks to the effect fallbacks list.
  47216. * @param defines defines the Base texture to use.
  47217. * @param fallbacks defines the current fallback list.
  47218. * @param currentRank defines the current fallback rank.
  47219. * @returns the new fallback rank.
  47220. */
  47221. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47222. /**
  47223. * Add the required uniforms to the current list.
  47224. * @param uniforms defines the current uniform list.
  47225. */
  47226. static AddUniforms(uniforms: string[]): void;
  47227. /**
  47228. * Add the required samplers to the current list.
  47229. * @param samplers defines the current sampler list.
  47230. */
  47231. static AddSamplers(samplers: string[]): void;
  47232. /**
  47233. * Add the required uniforms to the current buffer.
  47234. * @param uniformBuffer defines the current uniform buffer.
  47235. */
  47236. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47237. /**
  47238. * Makes a duplicate of the current configuration into another one.
  47239. * @param configuration define the config where to copy the info
  47240. */
  47241. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  47242. /**
  47243. * Serializes this Sub Surface configuration.
  47244. * @returns - An object with the serialized config.
  47245. */
  47246. serialize(): any;
  47247. /**
  47248. * Parses a anisotropy Configuration from a serialized object.
  47249. * @param source - Serialized object.
  47250. * @param scene Defines the scene we are parsing for
  47251. * @param rootUrl Defines the rootUrl to load from
  47252. */
  47253. parse(source: any, scene: Scene, rootUrl: string): void;
  47254. }
  47255. }
  47256. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  47257. /** @hidden */
  47258. export var pbrFragmentDeclaration: {
  47259. name: string;
  47260. shader: string;
  47261. };
  47262. }
  47263. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  47264. /** @hidden */
  47265. export var pbrUboDeclaration: {
  47266. name: string;
  47267. shader: string;
  47268. };
  47269. }
  47270. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  47271. /** @hidden */
  47272. export var pbrFragmentExtraDeclaration: {
  47273. name: string;
  47274. shader: string;
  47275. };
  47276. }
  47277. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  47278. /** @hidden */
  47279. export var pbrFragmentSamplersDeclaration: {
  47280. name: string;
  47281. shader: string;
  47282. };
  47283. }
  47284. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  47285. /** @hidden */
  47286. export var pbrHelperFunctions: {
  47287. name: string;
  47288. shader: string;
  47289. };
  47290. }
  47291. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  47292. /** @hidden */
  47293. export var harmonicsFunctions: {
  47294. name: string;
  47295. shader: string;
  47296. };
  47297. }
  47298. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  47299. /** @hidden */
  47300. export var pbrDirectLightingSetupFunctions: {
  47301. name: string;
  47302. shader: string;
  47303. };
  47304. }
  47305. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  47306. /** @hidden */
  47307. export var pbrDirectLightingFalloffFunctions: {
  47308. name: string;
  47309. shader: string;
  47310. };
  47311. }
  47312. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  47313. /** @hidden */
  47314. export var pbrBRDFFunctions: {
  47315. name: string;
  47316. shader: string;
  47317. };
  47318. }
  47319. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  47320. /** @hidden */
  47321. export var pbrDirectLightingFunctions: {
  47322. name: string;
  47323. shader: string;
  47324. };
  47325. }
  47326. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  47327. /** @hidden */
  47328. export var pbrIBLFunctions: {
  47329. name: string;
  47330. shader: string;
  47331. };
  47332. }
  47333. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  47334. /** @hidden */
  47335. export var pbrDebug: {
  47336. name: string;
  47337. shader: string;
  47338. };
  47339. }
  47340. declare module "babylonjs/Shaders/pbr.fragment" {
  47341. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  47342. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  47343. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  47344. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47345. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47346. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  47347. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  47348. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  47349. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  47350. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  47351. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47352. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  47353. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  47354. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  47355. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  47356. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  47357. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  47358. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  47359. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  47360. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  47361. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  47362. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  47363. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  47364. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  47365. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  47366. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  47367. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  47368. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  47369. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  47370. /** @hidden */
  47371. export var pbrPixelShader: {
  47372. name: string;
  47373. shader: string;
  47374. };
  47375. }
  47376. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  47377. /** @hidden */
  47378. export var pbrVertexDeclaration: {
  47379. name: string;
  47380. shader: string;
  47381. };
  47382. }
  47383. declare module "babylonjs/Shaders/pbr.vertex" {
  47384. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  47385. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  47386. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47387. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  47388. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  47389. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  47390. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  47391. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  47392. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  47393. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47394. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47395. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  47396. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  47397. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  47398. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  47399. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  47400. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  47401. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  47402. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  47403. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  47404. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  47405. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  47406. /** @hidden */
  47407. export var pbrVertexShader: {
  47408. name: string;
  47409. shader: string;
  47410. };
  47411. }
  47412. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  47413. import { IAnimatable } from "babylonjs/Misc/tools";
  47414. import { Nullable } from "babylonjs/types";
  47415. import { Scene } from "babylonjs/scene";
  47416. import { Matrix, Color3 } from "babylonjs/Maths/math";
  47417. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47418. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47419. import { Mesh } from "babylonjs/Meshes/mesh";
  47420. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  47421. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  47422. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  47423. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  47424. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  47425. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  47426. import { Material } from "babylonjs/Materials/material";
  47427. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  47428. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  47429. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47430. import "babylonjs/Shaders/pbr.fragment";
  47431. import "babylonjs/Shaders/pbr.vertex";
  47432. /**
  47433. * Manages the defines for the PBR Material.
  47434. * @hidden
  47435. */
  47436. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  47437. PBR: boolean;
  47438. MAINUV1: boolean;
  47439. MAINUV2: boolean;
  47440. UV1: boolean;
  47441. UV2: boolean;
  47442. ALBEDO: boolean;
  47443. ALBEDODIRECTUV: number;
  47444. VERTEXCOLOR: boolean;
  47445. AMBIENT: boolean;
  47446. AMBIENTDIRECTUV: number;
  47447. AMBIENTINGRAYSCALE: boolean;
  47448. OPACITY: boolean;
  47449. VERTEXALPHA: boolean;
  47450. OPACITYDIRECTUV: number;
  47451. OPACITYRGB: boolean;
  47452. ALPHATEST: boolean;
  47453. DEPTHPREPASS: boolean;
  47454. ALPHABLEND: boolean;
  47455. ALPHAFROMALBEDO: boolean;
  47456. ALPHATESTVALUE: string;
  47457. SPECULAROVERALPHA: boolean;
  47458. RADIANCEOVERALPHA: boolean;
  47459. ALPHAFRESNEL: boolean;
  47460. LINEARALPHAFRESNEL: boolean;
  47461. PREMULTIPLYALPHA: boolean;
  47462. EMISSIVE: boolean;
  47463. EMISSIVEDIRECTUV: number;
  47464. REFLECTIVITY: boolean;
  47465. REFLECTIVITYDIRECTUV: number;
  47466. SPECULARTERM: boolean;
  47467. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  47468. MICROSURFACEAUTOMATIC: boolean;
  47469. LODBASEDMICROSFURACE: boolean;
  47470. MICROSURFACEMAP: boolean;
  47471. MICROSURFACEMAPDIRECTUV: number;
  47472. METALLICWORKFLOW: boolean;
  47473. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  47474. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  47475. METALLNESSSTOREINMETALMAPBLUE: boolean;
  47476. AOSTOREINMETALMAPRED: boolean;
  47477. ENVIRONMENTBRDF: boolean;
  47478. ENVIRONMENTBRDF_RGBD: boolean;
  47479. NORMAL: boolean;
  47480. TANGENT: boolean;
  47481. BUMP: boolean;
  47482. BUMPDIRECTUV: number;
  47483. OBJECTSPACE_NORMALMAP: boolean;
  47484. PARALLAX: boolean;
  47485. PARALLAXOCCLUSION: boolean;
  47486. NORMALXYSCALE: boolean;
  47487. LIGHTMAP: boolean;
  47488. LIGHTMAPDIRECTUV: number;
  47489. USELIGHTMAPASSHADOWMAP: boolean;
  47490. GAMMALIGHTMAP: boolean;
  47491. REFLECTION: boolean;
  47492. REFLECTIONMAP_3D: boolean;
  47493. REFLECTIONMAP_SPHERICAL: boolean;
  47494. REFLECTIONMAP_PLANAR: boolean;
  47495. REFLECTIONMAP_CUBIC: boolean;
  47496. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  47497. REFLECTIONMAP_PROJECTION: boolean;
  47498. REFLECTIONMAP_SKYBOX: boolean;
  47499. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  47500. REFLECTIONMAP_EXPLICIT: boolean;
  47501. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  47502. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  47503. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  47504. INVERTCUBICMAP: boolean;
  47505. USESPHERICALFROMREFLECTIONMAP: boolean;
  47506. USEIRRADIANCEMAP: boolean;
  47507. SPHERICAL_HARMONICS: boolean;
  47508. USESPHERICALINVERTEX: boolean;
  47509. REFLECTIONMAP_OPPOSITEZ: boolean;
  47510. LODINREFLECTIONALPHA: boolean;
  47511. GAMMAREFLECTION: boolean;
  47512. RGBDREFLECTION: boolean;
  47513. LINEARSPECULARREFLECTION: boolean;
  47514. RADIANCEOCCLUSION: boolean;
  47515. HORIZONOCCLUSION: boolean;
  47516. INSTANCES: boolean;
  47517. NUM_BONE_INFLUENCERS: number;
  47518. BonesPerMesh: number;
  47519. BONETEXTURE: boolean;
  47520. NONUNIFORMSCALING: boolean;
  47521. MORPHTARGETS: boolean;
  47522. MORPHTARGETS_NORMAL: boolean;
  47523. MORPHTARGETS_TANGENT: boolean;
  47524. MORPHTARGETS_UV: boolean;
  47525. NUM_MORPH_INFLUENCERS: number;
  47526. IMAGEPROCESSING: boolean;
  47527. VIGNETTE: boolean;
  47528. VIGNETTEBLENDMODEMULTIPLY: boolean;
  47529. VIGNETTEBLENDMODEOPAQUE: boolean;
  47530. TONEMAPPING: boolean;
  47531. TONEMAPPING_ACES: boolean;
  47532. CONTRAST: boolean;
  47533. COLORCURVES: boolean;
  47534. COLORGRADING: boolean;
  47535. COLORGRADING3D: boolean;
  47536. SAMPLER3DGREENDEPTH: boolean;
  47537. SAMPLER3DBGRMAP: boolean;
  47538. IMAGEPROCESSINGPOSTPROCESS: boolean;
  47539. EXPOSURE: boolean;
  47540. MULTIVIEW: boolean;
  47541. USEPHYSICALLIGHTFALLOFF: boolean;
  47542. USEGLTFLIGHTFALLOFF: boolean;
  47543. TWOSIDEDLIGHTING: boolean;
  47544. SHADOWFLOAT: boolean;
  47545. CLIPPLANE: boolean;
  47546. CLIPPLANE2: boolean;
  47547. CLIPPLANE3: boolean;
  47548. CLIPPLANE4: boolean;
  47549. POINTSIZE: boolean;
  47550. FOG: boolean;
  47551. LOGARITHMICDEPTH: boolean;
  47552. FORCENORMALFORWARD: boolean;
  47553. SPECULARAA: boolean;
  47554. CLEARCOAT: boolean;
  47555. CLEARCOAT_DEFAULTIOR: boolean;
  47556. CLEARCOAT_TEXTURE: boolean;
  47557. CLEARCOAT_TEXTUREDIRECTUV: number;
  47558. CLEARCOAT_BUMP: boolean;
  47559. CLEARCOAT_BUMPDIRECTUV: number;
  47560. CLEARCOAT_TINT: boolean;
  47561. CLEARCOAT_TINT_TEXTURE: boolean;
  47562. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  47563. ANISOTROPIC: boolean;
  47564. ANISOTROPIC_TEXTURE: boolean;
  47565. ANISOTROPIC_TEXTUREDIRECTUV: number;
  47566. BRDF_V_HEIGHT_CORRELATED: boolean;
  47567. MS_BRDF_ENERGY_CONSERVATION: boolean;
  47568. SHEEN: boolean;
  47569. SHEEN_TEXTURE: boolean;
  47570. SHEEN_TEXTUREDIRECTUV: number;
  47571. SHEEN_LINKWITHALBEDO: boolean;
  47572. SUBSURFACE: boolean;
  47573. SS_REFRACTION: boolean;
  47574. SS_TRANSLUCENCY: boolean;
  47575. SS_SCATERRING: boolean;
  47576. SS_THICKNESSANDMASK_TEXTURE: boolean;
  47577. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  47578. SS_REFRACTIONMAP_3D: boolean;
  47579. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  47580. SS_LODINREFRACTIONALPHA: boolean;
  47581. SS_GAMMAREFRACTION: boolean;
  47582. SS_RGBDREFRACTION: boolean;
  47583. SS_LINEARSPECULARREFRACTION: boolean;
  47584. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  47585. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  47586. UNLIT: boolean;
  47587. DEBUGMODE: number;
  47588. /**
  47589. * Initializes the PBR Material defines.
  47590. */
  47591. constructor();
  47592. /**
  47593. * Resets the PBR Material defines.
  47594. */
  47595. reset(): void;
  47596. }
  47597. /**
  47598. * The Physically based material base class of BJS.
  47599. *
  47600. * This offers the main features of a standard PBR material.
  47601. * For more information, please refer to the documentation :
  47602. * https://doc.babylonjs.com/how_to/physically_based_rendering
  47603. */
  47604. export abstract class PBRBaseMaterial extends PushMaterial {
  47605. /**
  47606. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47607. */
  47608. static readonly PBRMATERIAL_OPAQUE: number;
  47609. /**
  47610. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47611. */
  47612. static readonly PBRMATERIAL_ALPHATEST: number;
  47613. /**
  47614. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47615. */
  47616. static readonly PBRMATERIAL_ALPHABLEND: number;
  47617. /**
  47618. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47619. * They are also discarded below the alpha cutoff threshold to improve performances.
  47620. */
  47621. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47622. /**
  47623. * Defines the default value of how much AO map is occluding the analytical lights
  47624. * (point spot...).
  47625. */
  47626. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47627. /**
  47628. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  47629. */
  47630. static readonly LIGHTFALLOFF_PHYSICAL: number;
  47631. /**
  47632. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  47633. * to enhance interoperability with other engines.
  47634. */
  47635. static readonly LIGHTFALLOFF_GLTF: number;
  47636. /**
  47637. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  47638. * to enhance interoperability with other materials.
  47639. */
  47640. static readonly LIGHTFALLOFF_STANDARD: number;
  47641. /**
  47642. * Intensity of the direct lights e.g. the four lights available in your scene.
  47643. * This impacts both the direct diffuse and specular highlights.
  47644. */
  47645. protected _directIntensity: number;
  47646. /**
  47647. * Intensity of the emissive part of the material.
  47648. * This helps controlling the emissive effect without modifying the emissive color.
  47649. */
  47650. protected _emissiveIntensity: number;
  47651. /**
  47652. * Intensity of the environment e.g. how much the environment will light the object
  47653. * either through harmonics for rough material or through the refelction for shiny ones.
  47654. */
  47655. protected _environmentIntensity: number;
  47656. /**
  47657. * This is a special control allowing the reduction of the specular highlights coming from the
  47658. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47659. */
  47660. protected _specularIntensity: number;
  47661. /**
  47662. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  47663. */
  47664. private _lightingInfos;
  47665. /**
  47666. * Debug Control allowing disabling the bump map on this material.
  47667. */
  47668. protected _disableBumpMap: boolean;
  47669. /**
  47670. * AKA Diffuse Texture in standard nomenclature.
  47671. */
  47672. protected _albedoTexture: Nullable<BaseTexture>;
  47673. /**
  47674. * AKA Occlusion Texture in other nomenclature.
  47675. */
  47676. protected _ambientTexture: Nullable<BaseTexture>;
  47677. /**
  47678. * AKA Occlusion Texture Intensity in other nomenclature.
  47679. */
  47680. protected _ambientTextureStrength: number;
  47681. /**
  47682. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47683. * 1 means it completely occludes it
  47684. * 0 mean it has no impact
  47685. */
  47686. protected _ambientTextureImpactOnAnalyticalLights: number;
  47687. /**
  47688. * Stores the alpha values in a texture.
  47689. */
  47690. protected _opacityTexture: Nullable<BaseTexture>;
  47691. /**
  47692. * Stores the reflection values in a texture.
  47693. */
  47694. protected _reflectionTexture: Nullable<BaseTexture>;
  47695. /**
  47696. * Stores the emissive values in a texture.
  47697. */
  47698. protected _emissiveTexture: Nullable<BaseTexture>;
  47699. /**
  47700. * AKA Specular texture in other nomenclature.
  47701. */
  47702. protected _reflectivityTexture: Nullable<BaseTexture>;
  47703. /**
  47704. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47705. */
  47706. protected _metallicTexture: Nullable<BaseTexture>;
  47707. /**
  47708. * Specifies the metallic scalar of the metallic/roughness workflow.
  47709. * Can also be used to scale the metalness values of the metallic texture.
  47710. */
  47711. protected _metallic: Nullable<number>;
  47712. /**
  47713. * Specifies the roughness scalar of the metallic/roughness workflow.
  47714. * Can also be used to scale the roughness values of the metallic texture.
  47715. */
  47716. protected _roughness: Nullable<number>;
  47717. /**
  47718. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47719. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47720. */
  47721. protected _microSurfaceTexture: Nullable<BaseTexture>;
  47722. /**
  47723. * Stores surface normal data used to displace a mesh in a texture.
  47724. */
  47725. protected _bumpTexture: Nullable<BaseTexture>;
  47726. /**
  47727. * Stores the pre-calculated light information of a mesh in a texture.
  47728. */
  47729. protected _lightmapTexture: Nullable<BaseTexture>;
  47730. /**
  47731. * The color of a material in ambient lighting.
  47732. */
  47733. protected _ambientColor: Color3;
  47734. /**
  47735. * AKA Diffuse Color in other nomenclature.
  47736. */
  47737. protected _albedoColor: Color3;
  47738. /**
  47739. * AKA Specular Color in other nomenclature.
  47740. */
  47741. protected _reflectivityColor: Color3;
  47742. /**
  47743. * The color applied when light is reflected from a material.
  47744. */
  47745. protected _reflectionColor: Color3;
  47746. /**
  47747. * The color applied when light is emitted from a material.
  47748. */
  47749. protected _emissiveColor: Color3;
  47750. /**
  47751. * AKA Glossiness in other nomenclature.
  47752. */
  47753. protected _microSurface: number;
  47754. /**
  47755. * Specifies that the material will use the light map as a show map.
  47756. */
  47757. protected _useLightmapAsShadowmap: boolean;
  47758. /**
  47759. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47760. * makes the reflect vector face the model (under horizon).
  47761. */
  47762. protected _useHorizonOcclusion: boolean;
  47763. /**
  47764. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47765. * too much the area relying on ambient texture to define their ambient occlusion.
  47766. */
  47767. protected _useRadianceOcclusion: boolean;
  47768. /**
  47769. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47770. */
  47771. protected _useAlphaFromAlbedoTexture: boolean;
  47772. /**
  47773. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  47774. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47775. */
  47776. protected _useSpecularOverAlpha: boolean;
  47777. /**
  47778. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47779. */
  47780. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47781. /**
  47782. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47783. */
  47784. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  47785. /**
  47786. * Specifies if the metallic texture contains the roughness information in its green channel.
  47787. */
  47788. protected _useRoughnessFromMetallicTextureGreen: boolean;
  47789. /**
  47790. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47791. */
  47792. protected _useMetallnessFromMetallicTextureBlue: boolean;
  47793. /**
  47794. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47795. */
  47796. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  47797. /**
  47798. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47799. */
  47800. protected _useAmbientInGrayScale: boolean;
  47801. /**
  47802. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47803. * The material will try to infer what glossiness each pixel should be.
  47804. */
  47805. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  47806. /**
  47807. * Defines the falloff type used in this material.
  47808. * It by default is Physical.
  47809. */
  47810. protected _lightFalloff: number;
  47811. /**
  47812. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47813. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47814. */
  47815. protected _useRadianceOverAlpha: boolean;
  47816. /**
  47817. * Allows using an object space normal map (instead of tangent space).
  47818. */
  47819. protected _useObjectSpaceNormalMap: boolean;
  47820. /**
  47821. * Allows using the bump map in parallax mode.
  47822. */
  47823. protected _useParallax: boolean;
  47824. /**
  47825. * Allows using the bump map in parallax occlusion mode.
  47826. */
  47827. protected _useParallaxOcclusion: boolean;
  47828. /**
  47829. * Controls the scale bias of the parallax mode.
  47830. */
  47831. protected _parallaxScaleBias: number;
  47832. /**
  47833. * If sets to true, disables all the lights affecting the material.
  47834. */
  47835. protected _disableLighting: boolean;
  47836. /**
  47837. * Number of Simultaneous lights allowed on the material.
  47838. */
  47839. protected _maxSimultaneousLights: number;
  47840. /**
  47841. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  47842. */
  47843. protected _invertNormalMapX: boolean;
  47844. /**
  47845. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  47846. */
  47847. protected _invertNormalMapY: boolean;
  47848. /**
  47849. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47850. */
  47851. protected _twoSidedLighting: boolean;
  47852. /**
  47853. * Defines the alpha limits in alpha test mode.
  47854. */
  47855. protected _alphaCutOff: number;
  47856. /**
  47857. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47858. */
  47859. protected _forceAlphaTest: boolean;
  47860. /**
  47861. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47862. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47863. */
  47864. protected _useAlphaFresnel: boolean;
  47865. /**
  47866. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47867. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47868. */
  47869. protected _useLinearAlphaFresnel: boolean;
  47870. /**
  47871. * The transparency mode of the material.
  47872. */
  47873. protected _transparencyMode: Nullable<number>;
  47874. /**
  47875. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  47876. * from cos thetav and roughness:
  47877. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  47878. */
  47879. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  47880. /**
  47881. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47882. */
  47883. protected _forceIrradianceInFragment: boolean;
  47884. /**
  47885. * Force normal to face away from face.
  47886. */
  47887. protected _forceNormalForward: boolean;
  47888. /**
  47889. * Enables specular anti aliasing in the PBR shader.
  47890. * It will both interacts on the Geometry for analytical and IBL lighting.
  47891. * It also prefilter the roughness map based on the bump values.
  47892. */
  47893. protected _enableSpecularAntiAliasing: boolean;
  47894. /**
  47895. * Default configuration related to image processing available in the PBR Material.
  47896. */
  47897. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47898. /**
  47899. * Keep track of the image processing observer to allow dispose and replace.
  47900. */
  47901. private _imageProcessingObserver;
  47902. /**
  47903. * Attaches a new image processing configuration to the PBR Material.
  47904. * @param configuration
  47905. */
  47906. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47907. /**
  47908. * Stores the available render targets.
  47909. */
  47910. private _renderTargets;
  47911. /**
  47912. * Sets the global ambient color for the material used in lighting calculations.
  47913. */
  47914. private _globalAmbientColor;
  47915. /**
  47916. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  47917. */
  47918. private _useLogarithmicDepth;
  47919. /**
  47920. * If set to true, no lighting calculations will be applied.
  47921. */
  47922. private _unlit;
  47923. private _debugMode;
  47924. /**
  47925. * @hidden
  47926. * This is reserved for the inspector.
  47927. * Defines the material debug mode.
  47928. * It helps seeing only some components of the material while troubleshooting.
  47929. */
  47930. debugMode: number;
  47931. /**
  47932. * @hidden
  47933. * This is reserved for the inspector.
  47934. * Specify from where on screen the debug mode should start.
  47935. * The value goes from -1 (full screen) to 1 (not visible)
  47936. * It helps with side by side comparison against the final render
  47937. * This defaults to -1
  47938. */
  47939. private debugLimit;
  47940. /**
  47941. * @hidden
  47942. * This is reserved for the inspector.
  47943. * As the default viewing range might not be enough (if the ambient is really small for instance)
  47944. * You can use the factor to better multiply the final value.
  47945. */
  47946. private debugFactor;
  47947. /**
  47948. * Defines the clear coat layer parameters for the material.
  47949. */
  47950. readonly clearCoat: PBRClearCoatConfiguration;
  47951. /**
  47952. * Defines the anisotropic parameters for the material.
  47953. */
  47954. readonly anisotropy: PBRAnisotropicConfiguration;
  47955. /**
  47956. * Defines the BRDF parameters for the material.
  47957. */
  47958. readonly brdf: PBRBRDFConfiguration;
  47959. /**
  47960. * Defines the Sheen parameters for the material.
  47961. */
  47962. readonly sheen: PBRSheenConfiguration;
  47963. /**
  47964. * Defines the SubSurface parameters for the material.
  47965. */
  47966. readonly subSurface: PBRSubSurfaceConfiguration;
  47967. /**
  47968. * Custom callback helping to override the default shader used in the material.
  47969. */
  47970. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  47971. /**
  47972. * Instantiates a new PBRMaterial instance.
  47973. *
  47974. * @param name The material name
  47975. * @param scene The scene the material will be use in.
  47976. */
  47977. constructor(name: string, scene: Scene);
  47978. /**
  47979. * Gets a boolean indicating that current material needs to register RTT
  47980. */
  47981. readonly hasRenderTargetTextures: boolean;
  47982. /**
  47983. * Gets the name of the material class.
  47984. */
  47985. getClassName(): string;
  47986. /**
  47987. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47988. */
  47989. /**
  47990. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47991. */
  47992. useLogarithmicDepth: boolean;
  47993. /**
  47994. * Gets the current transparency mode.
  47995. */
  47996. /**
  47997. * Sets the transparency mode of the material.
  47998. *
  47999. * | Value | Type | Description |
  48000. * | ----- | ----------------------------------- | ----------- |
  48001. * | 0 | OPAQUE | |
  48002. * | 1 | ALPHATEST | |
  48003. * | 2 | ALPHABLEND | |
  48004. * | 3 | ALPHATESTANDBLEND | |
  48005. *
  48006. */
  48007. transparencyMode: Nullable<number>;
  48008. /**
  48009. * Returns true if alpha blending should be disabled.
  48010. */
  48011. private readonly _disableAlphaBlending;
  48012. /**
  48013. * Specifies whether or not this material should be rendered in alpha blend mode.
  48014. */
  48015. needAlphaBlending(): boolean;
  48016. /**
  48017. * Specifies if the mesh will require alpha blending.
  48018. * @param mesh - BJS mesh.
  48019. */
  48020. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  48021. /**
  48022. * Specifies whether or not this material should be rendered in alpha test mode.
  48023. */
  48024. needAlphaTesting(): boolean;
  48025. /**
  48026. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  48027. */
  48028. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  48029. /**
  48030. * Gets the texture used for the alpha test.
  48031. */
  48032. getAlphaTestTexture(): Nullable<BaseTexture>;
  48033. /**
  48034. * Specifies that the submesh is ready to be used.
  48035. * @param mesh - BJS mesh.
  48036. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  48037. * @param useInstances - Specifies that instances should be used.
  48038. * @returns - boolean indicating that the submesh is ready or not.
  48039. */
  48040. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  48041. /**
  48042. * Specifies if the material uses metallic roughness workflow.
  48043. * @returns boolean specifiying if the material uses metallic roughness workflow.
  48044. */
  48045. isMetallicWorkflow(): boolean;
  48046. private _prepareEffect;
  48047. private _prepareDefines;
  48048. /**
  48049. * Force shader compilation
  48050. */
  48051. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  48052. clipPlane: boolean;
  48053. }>): void;
  48054. /**
  48055. * Initializes the uniform buffer layout for the shader.
  48056. */
  48057. buildUniformLayout(): void;
  48058. /**
  48059. * Unbinds the material from the mesh
  48060. */
  48061. unbind(): void;
  48062. /**
  48063. * Binds the submesh data.
  48064. * @param world - The world matrix.
  48065. * @param mesh - The BJS mesh.
  48066. * @param subMesh - A submesh of the BJS mesh.
  48067. */
  48068. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  48069. /**
  48070. * Returns the animatable textures.
  48071. * @returns - Array of animatable textures.
  48072. */
  48073. getAnimatables(): IAnimatable[];
  48074. /**
  48075. * Returns the texture used for reflections.
  48076. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  48077. */
  48078. private _getReflectionTexture;
  48079. /**
  48080. * Returns an array of the actively used textures.
  48081. * @returns - Array of BaseTextures
  48082. */
  48083. getActiveTextures(): BaseTexture[];
  48084. /**
  48085. * Checks to see if a texture is used in the material.
  48086. * @param texture - Base texture to use.
  48087. * @returns - Boolean specifying if a texture is used in the material.
  48088. */
  48089. hasTexture(texture: BaseTexture): boolean;
  48090. /**
  48091. * Disposes the resources of the material.
  48092. * @param forceDisposeEffect - Forces the disposal of effects.
  48093. * @param forceDisposeTextures - Forces the disposal of all textures.
  48094. */
  48095. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  48096. }
  48097. }
  48098. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  48099. import { Nullable } from "babylonjs/types";
  48100. import { Scene } from "babylonjs/scene";
  48101. import { Color3 } from "babylonjs/Maths/math";
  48102. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  48103. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  48104. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48105. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  48106. /**
  48107. * The Physically based material of BJS.
  48108. *
  48109. * This offers the main features of a standard PBR material.
  48110. * For more information, please refer to the documentation :
  48111. * https://doc.babylonjs.com/how_to/physically_based_rendering
  48112. */
  48113. export class PBRMaterial extends PBRBaseMaterial {
  48114. /**
  48115. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  48116. */
  48117. static readonly PBRMATERIAL_OPAQUE: number;
  48118. /**
  48119. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  48120. */
  48121. static readonly PBRMATERIAL_ALPHATEST: number;
  48122. /**
  48123. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48124. */
  48125. static readonly PBRMATERIAL_ALPHABLEND: number;
  48126. /**
  48127. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48128. * They are also discarded below the alpha cutoff threshold to improve performances.
  48129. */
  48130. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  48131. /**
  48132. * Defines the default value of how much AO map is occluding the analytical lights
  48133. * (point spot...).
  48134. */
  48135. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  48136. /**
  48137. * Intensity of the direct lights e.g. the four lights available in your scene.
  48138. * This impacts both the direct diffuse and specular highlights.
  48139. */
  48140. directIntensity: number;
  48141. /**
  48142. * Intensity of the emissive part of the material.
  48143. * This helps controlling the emissive effect without modifying the emissive color.
  48144. */
  48145. emissiveIntensity: number;
  48146. /**
  48147. * Intensity of the environment e.g. how much the environment will light the object
  48148. * either through harmonics for rough material or through the refelction for shiny ones.
  48149. */
  48150. environmentIntensity: number;
  48151. /**
  48152. * This is a special control allowing the reduction of the specular highlights coming from the
  48153. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  48154. */
  48155. specularIntensity: number;
  48156. /**
  48157. * Debug Control allowing disabling the bump map on this material.
  48158. */
  48159. disableBumpMap: boolean;
  48160. /**
  48161. * AKA Diffuse Texture in standard nomenclature.
  48162. */
  48163. albedoTexture: BaseTexture;
  48164. /**
  48165. * AKA Occlusion Texture in other nomenclature.
  48166. */
  48167. ambientTexture: BaseTexture;
  48168. /**
  48169. * AKA Occlusion Texture Intensity in other nomenclature.
  48170. */
  48171. ambientTextureStrength: number;
  48172. /**
  48173. * Defines how much the AO map is occluding the analytical lights (point spot...).
  48174. * 1 means it completely occludes it
  48175. * 0 mean it has no impact
  48176. */
  48177. ambientTextureImpactOnAnalyticalLights: number;
  48178. /**
  48179. * Stores the alpha values in a texture.
  48180. */
  48181. opacityTexture: BaseTexture;
  48182. /**
  48183. * Stores the reflection values in a texture.
  48184. */
  48185. reflectionTexture: Nullable<BaseTexture>;
  48186. /**
  48187. * Stores the emissive values in a texture.
  48188. */
  48189. emissiveTexture: BaseTexture;
  48190. /**
  48191. * AKA Specular texture in other nomenclature.
  48192. */
  48193. reflectivityTexture: BaseTexture;
  48194. /**
  48195. * Used to switch from specular/glossiness to metallic/roughness workflow.
  48196. */
  48197. metallicTexture: BaseTexture;
  48198. /**
  48199. * Specifies the metallic scalar of the metallic/roughness workflow.
  48200. * Can also be used to scale the metalness values of the metallic texture.
  48201. */
  48202. metallic: Nullable<number>;
  48203. /**
  48204. * Specifies the roughness scalar of the metallic/roughness workflow.
  48205. * Can also be used to scale the roughness values of the metallic texture.
  48206. */
  48207. roughness: Nullable<number>;
  48208. /**
  48209. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  48210. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  48211. */
  48212. microSurfaceTexture: BaseTexture;
  48213. /**
  48214. * Stores surface normal data used to displace a mesh in a texture.
  48215. */
  48216. bumpTexture: BaseTexture;
  48217. /**
  48218. * Stores the pre-calculated light information of a mesh in a texture.
  48219. */
  48220. lightmapTexture: BaseTexture;
  48221. /**
  48222. * Stores the refracted light information in a texture.
  48223. */
  48224. refractionTexture: Nullable<BaseTexture>;
  48225. /**
  48226. * The color of a material in ambient lighting.
  48227. */
  48228. ambientColor: Color3;
  48229. /**
  48230. * AKA Diffuse Color in other nomenclature.
  48231. */
  48232. albedoColor: Color3;
  48233. /**
  48234. * AKA Specular Color in other nomenclature.
  48235. */
  48236. reflectivityColor: Color3;
  48237. /**
  48238. * The color reflected from the material.
  48239. */
  48240. reflectionColor: Color3;
  48241. /**
  48242. * The color emitted from the material.
  48243. */
  48244. emissiveColor: Color3;
  48245. /**
  48246. * AKA Glossiness in other nomenclature.
  48247. */
  48248. microSurface: number;
  48249. /**
  48250. * source material index of refraction (IOR)' / 'destination material IOR.
  48251. */
  48252. indexOfRefraction: number;
  48253. /**
  48254. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  48255. */
  48256. invertRefractionY: boolean;
  48257. /**
  48258. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  48259. * Materials half opaque for instance using refraction could benefit from this control.
  48260. */
  48261. linkRefractionWithTransparency: boolean;
  48262. /**
  48263. * If true, the light map contains occlusion information instead of lighting info.
  48264. */
  48265. useLightmapAsShadowmap: boolean;
  48266. /**
  48267. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  48268. */
  48269. useAlphaFromAlbedoTexture: boolean;
  48270. /**
  48271. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  48272. */
  48273. forceAlphaTest: boolean;
  48274. /**
  48275. * Defines the alpha limits in alpha test mode.
  48276. */
  48277. alphaCutOff: number;
  48278. /**
  48279. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  48280. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  48281. */
  48282. useSpecularOverAlpha: boolean;
  48283. /**
  48284. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  48285. */
  48286. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  48287. /**
  48288. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  48289. */
  48290. useRoughnessFromMetallicTextureAlpha: boolean;
  48291. /**
  48292. * Specifies if the metallic texture contains the roughness information in its green channel.
  48293. */
  48294. useRoughnessFromMetallicTextureGreen: boolean;
  48295. /**
  48296. * Specifies if the metallic texture contains the metallness information in its blue channel.
  48297. */
  48298. useMetallnessFromMetallicTextureBlue: boolean;
  48299. /**
  48300. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  48301. */
  48302. useAmbientOcclusionFromMetallicTextureRed: boolean;
  48303. /**
  48304. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  48305. */
  48306. useAmbientInGrayScale: boolean;
  48307. /**
  48308. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  48309. * The material will try to infer what glossiness each pixel should be.
  48310. */
  48311. useAutoMicroSurfaceFromReflectivityMap: boolean;
  48312. /**
  48313. * BJS is using an harcoded light falloff based on a manually sets up range.
  48314. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  48315. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  48316. */
  48317. /**
  48318. * BJS is using an harcoded light falloff based on a manually sets up range.
  48319. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  48320. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  48321. */
  48322. usePhysicalLightFalloff: boolean;
  48323. /**
  48324. * In order to support the falloff compatibility with gltf, a special mode has been added
  48325. * to reproduce the gltf light falloff.
  48326. */
  48327. /**
  48328. * In order to support the falloff compatibility with gltf, a special mode has been added
  48329. * to reproduce the gltf light falloff.
  48330. */
  48331. useGLTFLightFalloff: boolean;
  48332. /**
  48333. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  48334. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  48335. */
  48336. useRadianceOverAlpha: boolean;
  48337. /**
  48338. * Allows using an object space normal map (instead of tangent space).
  48339. */
  48340. useObjectSpaceNormalMap: boolean;
  48341. /**
  48342. * Allows using the bump map in parallax mode.
  48343. */
  48344. useParallax: boolean;
  48345. /**
  48346. * Allows using the bump map in parallax occlusion mode.
  48347. */
  48348. useParallaxOcclusion: boolean;
  48349. /**
  48350. * Controls the scale bias of the parallax mode.
  48351. */
  48352. parallaxScaleBias: number;
  48353. /**
  48354. * If sets to true, disables all the lights affecting the material.
  48355. */
  48356. disableLighting: boolean;
  48357. /**
  48358. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  48359. */
  48360. forceIrradianceInFragment: boolean;
  48361. /**
  48362. * Number of Simultaneous lights allowed on the material.
  48363. */
  48364. maxSimultaneousLights: number;
  48365. /**
  48366. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  48367. */
  48368. invertNormalMapX: boolean;
  48369. /**
  48370. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  48371. */
  48372. invertNormalMapY: boolean;
  48373. /**
  48374. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48375. */
  48376. twoSidedLighting: boolean;
  48377. /**
  48378. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48379. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  48380. */
  48381. useAlphaFresnel: boolean;
  48382. /**
  48383. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48384. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  48385. */
  48386. useLinearAlphaFresnel: boolean;
  48387. /**
  48388. * Let user defines the brdf lookup texture used for IBL.
  48389. * A default 8bit version is embedded but you could point at :
  48390. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  48391. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  48392. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  48393. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  48394. */
  48395. environmentBRDFTexture: Nullable<BaseTexture>;
  48396. /**
  48397. * Force normal to face away from face.
  48398. */
  48399. forceNormalForward: boolean;
  48400. /**
  48401. * Enables specular anti aliasing in the PBR shader.
  48402. * It will both interacts on the Geometry for analytical and IBL lighting.
  48403. * It also prefilter the roughness map based on the bump values.
  48404. */
  48405. enableSpecularAntiAliasing: boolean;
  48406. /**
  48407. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  48408. * makes the reflect vector face the model (under horizon).
  48409. */
  48410. useHorizonOcclusion: boolean;
  48411. /**
  48412. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  48413. * too much the area relying on ambient texture to define their ambient occlusion.
  48414. */
  48415. useRadianceOcclusion: boolean;
  48416. /**
  48417. * If set to true, no lighting calculations will be applied.
  48418. */
  48419. unlit: boolean;
  48420. /**
  48421. * Gets the image processing configuration used either in this material.
  48422. */
  48423. /**
  48424. * Sets the Default image processing configuration used either in the this material.
  48425. *
  48426. * If sets to null, the scene one is in use.
  48427. */
  48428. imageProcessingConfiguration: ImageProcessingConfiguration;
  48429. /**
  48430. * Gets wether the color curves effect is enabled.
  48431. */
  48432. /**
  48433. * Sets wether the color curves effect is enabled.
  48434. */
  48435. cameraColorCurvesEnabled: boolean;
  48436. /**
  48437. * Gets wether the color grading effect is enabled.
  48438. */
  48439. /**
  48440. * Gets wether the color grading effect is enabled.
  48441. */
  48442. cameraColorGradingEnabled: boolean;
  48443. /**
  48444. * Gets wether tonemapping is enabled or not.
  48445. */
  48446. /**
  48447. * Sets wether tonemapping is enabled or not
  48448. */
  48449. cameraToneMappingEnabled: boolean;
  48450. /**
  48451. * The camera exposure used on this material.
  48452. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48453. * This corresponds to a photographic exposure.
  48454. */
  48455. /**
  48456. * The camera exposure used on this material.
  48457. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48458. * This corresponds to a photographic exposure.
  48459. */
  48460. cameraExposure: number;
  48461. /**
  48462. * Gets The camera contrast used on this material.
  48463. */
  48464. /**
  48465. * Sets The camera contrast used on this material.
  48466. */
  48467. cameraContrast: number;
  48468. /**
  48469. * Gets the Color Grading 2D Lookup Texture.
  48470. */
  48471. /**
  48472. * Sets the Color Grading 2D Lookup Texture.
  48473. */
  48474. cameraColorGradingTexture: Nullable<BaseTexture>;
  48475. /**
  48476. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48477. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48478. * 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;
  48479. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48480. */
  48481. /**
  48482. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48483. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48484. * 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;
  48485. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48486. */
  48487. cameraColorCurves: Nullable<ColorCurves>;
  48488. /**
  48489. * Instantiates a new PBRMaterial instance.
  48490. *
  48491. * @param name The material name
  48492. * @param scene The scene the material will be use in.
  48493. */
  48494. constructor(name: string, scene: Scene);
  48495. /**
  48496. * Returns the name of this material class.
  48497. */
  48498. getClassName(): string;
  48499. /**
  48500. * Makes a duplicate of the current material.
  48501. * @param name - name to use for the new material.
  48502. */
  48503. clone(name: string): PBRMaterial;
  48504. /**
  48505. * Serializes this PBR Material.
  48506. * @returns - An object with the serialized material.
  48507. */
  48508. serialize(): any;
  48509. /**
  48510. * Parses a PBR Material from a serialized object.
  48511. * @param source - Serialized object.
  48512. * @param scene - BJS scene instance.
  48513. * @param rootUrl - url for the scene object
  48514. * @returns - PBRMaterial
  48515. */
  48516. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  48517. }
  48518. }
  48519. declare module "babylonjs/Misc/dds" {
  48520. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48521. import { Engine } from "babylonjs/Engines/engine";
  48522. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48523. import { Nullable } from "babylonjs/types";
  48524. import { Scene } from "babylonjs/scene";
  48525. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  48526. /**
  48527. * Direct draw surface info
  48528. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  48529. */
  48530. export interface DDSInfo {
  48531. /**
  48532. * Width of the texture
  48533. */
  48534. width: number;
  48535. /**
  48536. * Width of the texture
  48537. */
  48538. height: number;
  48539. /**
  48540. * Number of Mipmaps for the texture
  48541. * @see https://en.wikipedia.org/wiki/Mipmap
  48542. */
  48543. mipmapCount: number;
  48544. /**
  48545. * If the textures format is a known fourCC format
  48546. * @see https://www.fourcc.org/
  48547. */
  48548. isFourCC: boolean;
  48549. /**
  48550. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  48551. */
  48552. isRGB: boolean;
  48553. /**
  48554. * If the texture is a lumincance format
  48555. */
  48556. isLuminance: boolean;
  48557. /**
  48558. * If this is a cube texture
  48559. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  48560. */
  48561. isCube: boolean;
  48562. /**
  48563. * If the texture is a compressed format eg. FOURCC_DXT1
  48564. */
  48565. isCompressed: boolean;
  48566. /**
  48567. * The dxgiFormat of the texture
  48568. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  48569. */
  48570. dxgiFormat: number;
  48571. /**
  48572. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  48573. */
  48574. textureType: number;
  48575. /**
  48576. * Sphericle polynomial created for the dds texture
  48577. */
  48578. sphericalPolynomial?: SphericalPolynomial;
  48579. }
  48580. /**
  48581. * Class used to provide DDS decompression tools
  48582. */
  48583. export class DDSTools {
  48584. /**
  48585. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  48586. */
  48587. static StoreLODInAlphaChannel: boolean;
  48588. /**
  48589. * Gets DDS information from an array buffer
  48590. * @param arrayBuffer defines the array buffer to read data from
  48591. * @returns the DDS information
  48592. */
  48593. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  48594. private static _FloatView;
  48595. private static _Int32View;
  48596. private static _ToHalfFloat;
  48597. private static _FromHalfFloat;
  48598. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  48599. private static _GetHalfFloatRGBAArrayBuffer;
  48600. private static _GetFloatRGBAArrayBuffer;
  48601. private static _GetFloatAsUIntRGBAArrayBuffer;
  48602. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  48603. private static _GetRGBAArrayBuffer;
  48604. private static _ExtractLongWordOrder;
  48605. private static _GetRGBArrayBuffer;
  48606. private static _GetLuminanceArrayBuffer;
  48607. /**
  48608. * Uploads DDS Levels to a Babylon Texture
  48609. * @hidden
  48610. */
  48611. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  48612. }
  48613. module "babylonjs/Engines/engine" {
  48614. interface Engine {
  48615. /**
  48616. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  48617. * @param rootUrl defines the url where the file to load is located
  48618. * @param scene defines the current scene
  48619. * @param lodScale defines scale to apply to the mip map selection
  48620. * @param lodOffset defines offset to apply to the mip map selection
  48621. * @param onLoad defines an optional callback raised when the texture is loaded
  48622. * @param onError defines an optional callback raised if there is an issue to load the texture
  48623. * @param format defines the format of the data
  48624. * @param forcedExtension defines the extension to use to pick the right loader
  48625. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  48626. * @returns the cube texture as an InternalTexture
  48627. */
  48628. 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;
  48629. }
  48630. }
  48631. }
  48632. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  48633. import { Nullable } from "babylonjs/types";
  48634. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48635. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48636. /**
  48637. * Implementation of the DDS Texture Loader.
  48638. * @hidden
  48639. */
  48640. export class _DDSTextureLoader implements IInternalTextureLoader {
  48641. /**
  48642. * Defines wether the loader supports cascade loading the different faces.
  48643. */
  48644. readonly supportCascades: boolean;
  48645. /**
  48646. * This returns if the loader support the current file information.
  48647. * @param extension defines the file extension of the file being loaded
  48648. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48649. * @param fallback defines the fallback internal texture if any
  48650. * @param isBase64 defines whether the texture is encoded as a base64
  48651. * @param isBuffer defines whether the texture data are stored as a buffer
  48652. * @returns true if the loader can load the specified file
  48653. */
  48654. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48655. /**
  48656. * Transform the url before loading if required.
  48657. * @param rootUrl the url of the texture
  48658. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48659. * @returns the transformed texture
  48660. */
  48661. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48662. /**
  48663. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48664. * @param rootUrl the url of the texture
  48665. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48666. * @returns the fallback texture
  48667. */
  48668. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48669. /**
  48670. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48671. * @param data contains the texture data
  48672. * @param texture defines the BabylonJS internal texture
  48673. * @param createPolynomials will be true if polynomials have been requested
  48674. * @param onLoad defines the callback to trigger once the texture is ready
  48675. * @param onError defines the callback to trigger in case of error
  48676. */
  48677. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48678. /**
  48679. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48680. * @param data contains the texture data
  48681. * @param texture defines the BabylonJS internal texture
  48682. * @param callback defines the method to call once ready to upload
  48683. */
  48684. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48685. }
  48686. }
  48687. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  48688. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48689. /** @hidden */
  48690. export var rgbdEncodePixelShader: {
  48691. name: string;
  48692. shader: string;
  48693. };
  48694. }
  48695. declare module "babylonjs/Misc/environmentTextureTools" {
  48696. import { Nullable } from "babylonjs/types";
  48697. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48698. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48699. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  48700. import "babylonjs/Engines/Extensions/engine.renderTarget";
  48701. import "babylonjs/Shaders/rgbdEncode.fragment";
  48702. import "babylonjs/Shaders/rgbdDecode.fragment";
  48703. /**
  48704. * Raw texture data and descriptor sufficient for WebGL texture upload
  48705. */
  48706. export interface EnvironmentTextureInfo {
  48707. /**
  48708. * Version of the environment map
  48709. */
  48710. version: number;
  48711. /**
  48712. * Width of image
  48713. */
  48714. width: number;
  48715. /**
  48716. * Irradiance information stored in the file.
  48717. */
  48718. irradiance: any;
  48719. /**
  48720. * Specular information stored in the file.
  48721. */
  48722. specular: any;
  48723. }
  48724. /**
  48725. * Sets of helpers addressing the serialization and deserialization of environment texture
  48726. * stored in a BabylonJS env file.
  48727. * Those files are usually stored as .env files.
  48728. */
  48729. export class EnvironmentTextureTools {
  48730. /**
  48731. * Magic number identifying the env file.
  48732. */
  48733. private static _MagicBytes;
  48734. /**
  48735. * Gets the environment info from an env file.
  48736. * @param data The array buffer containing the .env bytes.
  48737. * @returns the environment file info (the json header) if successfully parsed.
  48738. */
  48739. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  48740. /**
  48741. * Creates an environment texture from a loaded cube texture.
  48742. * @param texture defines the cube texture to convert in env file
  48743. * @return a promise containing the environment data if succesfull.
  48744. */
  48745. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  48746. /**
  48747. * Creates a JSON representation of the spherical data.
  48748. * @param texture defines the texture containing the polynomials
  48749. * @return the JSON representation of the spherical info
  48750. */
  48751. private static _CreateEnvTextureIrradiance;
  48752. /**
  48753. * Uploads the texture info contained in the env file to the GPU.
  48754. * @param texture defines the internal texture to upload to
  48755. * @param arrayBuffer defines the buffer cotaining the data to load
  48756. * @param info defines the texture info retrieved through the GetEnvInfo method
  48757. * @returns a promise
  48758. */
  48759. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  48760. /**
  48761. * Uploads the levels of image data to the GPU.
  48762. * @param texture defines the internal texture to upload to
  48763. * @param imageData defines the array buffer views of image data [mipmap][face]
  48764. * @returns a promise
  48765. */
  48766. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  48767. /**
  48768. * Uploads spherical polynomials information to the texture.
  48769. * @param texture defines the texture we are trying to upload the information to
  48770. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  48771. */
  48772. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  48773. /** @hidden */
  48774. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48775. }
  48776. }
  48777. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  48778. import { Nullable } from "babylonjs/types";
  48779. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48780. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48781. /**
  48782. * Implementation of the ENV Texture Loader.
  48783. * @hidden
  48784. */
  48785. export class _ENVTextureLoader implements IInternalTextureLoader {
  48786. /**
  48787. * Defines wether the loader supports cascade loading the different faces.
  48788. */
  48789. readonly supportCascades: boolean;
  48790. /**
  48791. * This returns if the loader support the current file information.
  48792. * @param extension defines the file extension of the file being loaded
  48793. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48794. * @param fallback defines the fallback internal texture if any
  48795. * @param isBase64 defines whether the texture is encoded as a base64
  48796. * @param isBuffer defines whether the texture data are stored as a buffer
  48797. * @returns true if the loader can load the specified file
  48798. */
  48799. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48800. /**
  48801. * Transform the url before loading if required.
  48802. * @param rootUrl the url of the texture
  48803. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48804. * @returns the transformed texture
  48805. */
  48806. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48807. /**
  48808. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48809. * @param rootUrl the url of the texture
  48810. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48811. * @returns the fallback texture
  48812. */
  48813. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48814. /**
  48815. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48816. * @param data contains the texture data
  48817. * @param texture defines the BabylonJS internal texture
  48818. * @param createPolynomials will be true if polynomials have been requested
  48819. * @param onLoad defines the callback to trigger once the texture is ready
  48820. * @param onError defines the callback to trigger in case of error
  48821. */
  48822. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48823. /**
  48824. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48825. * @param data contains the texture data
  48826. * @param texture defines the BabylonJS internal texture
  48827. * @param callback defines the method to call once ready to upload
  48828. */
  48829. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48830. }
  48831. }
  48832. declare module "babylonjs/Misc/khronosTextureContainer" {
  48833. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48834. /**
  48835. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  48836. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  48837. */
  48838. export class KhronosTextureContainer {
  48839. /** contents of the KTX container file */
  48840. arrayBuffer: any;
  48841. private static HEADER_LEN;
  48842. private static COMPRESSED_2D;
  48843. private static COMPRESSED_3D;
  48844. private static TEX_2D;
  48845. private static TEX_3D;
  48846. /**
  48847. * Gets the openGL type
  48848. */
  48849. glType: number;
  48850. /**
  48851. * Gets the openGL type size
  48852. */
  48853. glTypeSize: number;
  48854. /**
  48855. * Gets the openGL format
  48856. */
  48857. glFormat: number;
  48858. /**
  48859. * Gets the openGL internal format
  48860. */
  48861. glInternalFormat: number;
  48862. /**
  48863. * Gets the base internal format
  48864. */
  48865. glBaseInternalFormat: number;
  48866. /**
  48867. * Gets image width in pixel
  48868. */
  48869. pixelWidth: number;
  48870. /**
  48871. * Gets image height in pixel
  48872. */
  48873. pixelHeight: number;
  48874. /**
  48875. * Gets image depth in pixels
  48876. */
  48877. pixelDepth: number;
  48878. /**
  48879. * Gets the number of array elements
  48880. */
  48881. numberOfArrayElements: number;
  48882. /**
  48883. * Gets the number of faces
  48884. */
  48885. numberOfFaces: number;
  48886. /**
  48887. * Gets the number of mipmap levels
  48888. */
  48889. numberOfMipmapLevels: number;
  48890. /**
  48891. * Gets the bytes of key value data
  48892. */
  48893. bytesOfKeyValueData: number;
  48894. /**
  48895. * Gets the load type
  48896. */
  48897. loadType: number;
  48898. /**
  48899. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  48900. */
  48901. isInvalid: boolean;
  48902. /**
  48903. * Creates a new KhronosTextureContainer
  48904. * @param arrayBuffer contents of the KTX container file
  48905. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  48906. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  48907. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  48908. */
  48909. constructor(
  48910. /** contents of the KTX container file */
  48911. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  48912. /**
  48913. * Uploads KTX content to a Babylon Texture.
  48914. * It is assumed that the texture has already been created & is currently bound
  48915. * @hidden
  48916. */
  48917. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  48918. private _upload2DCompressedLevels;
  48919. }
  48920. }
  48921. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  48922. import { Nullable } from "babylonjs/types";
  48923. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48924. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48925. /**
  48926. * Implementation of the KTX Texture Loader.
  48927. * @hidden
  48928. */
  48929. export class _KTXTextureLoader implements IInternalTextureLoader {
  48930. /**
  48931. * Defines wether the loader supports cascade loading the different faces.
  48932. */
  48933. readonly supportCascades: boolean;
  48934. /**
  48935. * This returns if the loader support the current file information.
  48936. * @param extension defines the file extension of the file being loaded
  48937. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48938. * @param fallback defines the fallback internal texture if any
  48939. * @param isBase64 defines whether the texture is encoded as a base64
  48940. * @param isBuffer defines whether the texture data are stored as a buffer
  48941. * @returns true if the loader can load the specified file
  48942. */
  48943. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48944. /**
  48945. * Transform the url before loading if required.
  48946. * @param rootUrl the url of the texture
  48947. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48948. * @returns the transformed texture
  48949. */
  48950. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48951. /**
  48952. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48953. * @param rootUrl the url of the texture
  48954. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48955. * @returns the fallback texture
  48956. */
  48957. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48958. /**
  48959. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48960. * @param data contains the texture data
  48961. * @param texture defines the BabylonJS internal texture
  48962. * @param createPolynomials will be true if polynomials have been requested
  48963. * @param onLoad defines the callback to trigger once the texture is ready
  48964. * @param onError defines the callback to trigger in case of error
  48965. */
  48966. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48967. /**
  48968. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48969. * @param data contains the texture data
  48970. * @param texture defines the BabylonJS internal texture
  48971. * @param callback defines the method to call once ready to upload
  48972. */
  48973. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  48974. }
  48975. }
  48976. declare module "babylonjs/Helpers/sceneHelpers" {
  48977. import { Nullable } from "babylonjs/types";
  48978. import { Mesh } from "babylonjs/Meshes/mesh";
  48979. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48980. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  48981. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  48982. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  48983. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  48984. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  48985. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  48986. import "babylonjs/Meshes/Builders/boxBuilder";
  48987. /** @hidden */
  48988. export var _forceSceneHelpersToBundle: boolean;
  48989. module "babylonjs/scene" {
  48990. interface Scene {
  48991. /**
  48992. * Creates a default light for the scene.
  48993. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  48994. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  48995. */
  48996. createDefaultLight(replace?: boolean): void;
  48997. /**
  48998. * Creates a default camera for the scene.
  48999. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  49000. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  49001. * @param replace has default false, when true replaces the active camera in the scene
  49002. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  49003. */
  49004. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  49005. /**
  49006. * Creates a default camera and a default light.
  49007. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  49008. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  49009. * @param replace has the default false, when true replaces the active camera/light in the scene
  49010. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  49011. */
  49012. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  49013. /**
  49014. * Creates a new sky box
  49015. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  49016. * @param environmentTexture defines the texture to use as environment texture
  49017. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  49018. * @param scale defines the overall scale of the skybox
  49019. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  49020. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  49021. * @returns a new mesh holding the sky box
  49022. */
  49023. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  49024. /**
  49025. * Creates a new environment
  49026. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  49027. * @param options defines the options you can use to configure the environment
  49028. * @returns the new EnvironmentHelper
  49029. */
  49030. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  49031. /**
  49032. * Creates a new VREXperienceHelper
  49033. * @see http://doc.babylonjs.com/how_to/webvr_helper
  49034. * @param webVROptions defines the options used to create the new VREXperienceHelper
  49035. * @returns a new VREXperienceHelper
  49036. */
  49037. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  49038. /**
  49039. * Creates a new XREXperienceHelper
  49040. * @see http://doc.babylonjs.com/how_to/webxr
  49041. * @returns a promise for a new XREXperienceHelper
  49042. */
  49043. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  49044. }
  49045. }
  49046. }
  49047. declare module "babylonjs/Helpers/videoDome" {
  49048. import { Scene } from "babylonjs/scene";
  49049. import { TransformNode } from "babylonjs/Meshes/transformNode";
  49050. import { Mesh } from "babylonjs/Meshes/mesh";
  49051. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  49052. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  49053. import "babylonjs/Meshes/Builders/sphereBuilder";
  49054. /**
  49055. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  49056. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  49057. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  49058. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  49059. */
  49060. export class VideoDome extends TransformNode {
  49061. /**
  49062. * Define the video source as a Monoscopic panoramic 360 video.
  49063. */
  49064. static readonly MODE_MONOSCOPIC: number;
  49065. /**
  49066. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  49067. */
  49068. static readonly MODE_TOPBOTTOM: number;
  49069. /**
  49070. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  49071. */
  49072. static readonly MODE_SIDEBYSIDE: number;
  49073. private _useDirectMapping;
  49074. /**
  49075. * The video texture being displayed on the sphere
  49076. */
  49077. protected _videoTexture: VideoTexture;
  49078. /**
  49079. * Gets the video texture being displayed on the sphere
  49080. */
  49081. readonly videoTexture: VideoTexture;
  49082. /**
  49083. * The skybox material
  49084. */
  49085. protected _material: BackgroundMaterial;
  49086. /**
  49087. * The surface used for the skybox
  49088. */
  49089. protected _mesh: Mesh;
  49090. /**
  49091. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49092. * Also see the options.resolution property.
  49093. */
  49094. fovMultiplier: number;
  49095. private _videoMode;
  49096. /**
  49097. * Gets or set the current video mode for the video. It can be:
  49098. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  49099. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  49100. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  49101. */
  49102. videoMode: number;
  49103. /**
  49104. * Oberserver used in Stereoscopic VR Mode.
  49105. */
  49106. private _onBeforeCameraRenderObserver;
  49107. /**
  49108. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  49109. * @param name Element's name, child elements will append suffixes for their own names.
  49110. * @param urlsOrVideo defines the url(s) or the video element to use
  49111. * @param options An object containing optional or exposed sub element properties
  49112. */
  49113. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  49114. resolution?: number;
  49115. clickToPlay?: boolean;
  49116. autoPlay?: boolean;
  49117. loop?: boolean;
  49118. size?: number;
  49119. poster?: string;
  49120. faceForward?: boolean;
  49121. useDirectMapping?: boolean;
  49122. }, scene: Scene);
  49123. private _changeVideoMode;
  49124. /**
  49125. * Releases resources associated with this node.
  49126. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  49127. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  49128. */
  49129. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  49130. }
  49131. }
  49132. declare module "babylonjs/Helpers/index" {
  49133. export * from "babylonjs/Helpers/environmentHelper";
  49134. export * from "babylonjs/Helpers/photoDome";
  49135. export * from "babylonjs/Helpers/sceneHelpers";
  49136. export * from "babylonjs/Helpers/videoDome";
  49137. }
  49138. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  49139. import { PerfCounter } from "babylonjs/Misc/tools";
  49140. import { IDisposable } from "babylonjs/scene";
  49141. import { Engine } from "babylonjs/Engines/engine";
  49142. /**
  49143. * This class can be used to get instrumentation data from a Babylon engine
  49144. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  49145. */
  49146. export class EngineInstrumentation implements IDisposable {
  49147. /**
  49148. * Define the instrumented engine.
  49149. */
  49150. engine: Engine;
  49151. private _captureGPUFrameTime;
  49152. private _gpuFrameTimeToken;
  49153. private _gpuFrameTime;
  49154. private _captureShaderCompilationTime;
  49155. private _shaderCompilationTime;
  49156. private _onBeginFrameObserver;
  49157. private _onEndFrameObserver;
  49158. private _onBeforeShaderCompilationObserver;
  49159. private _onAfterShaderCompilationObserver;
  49160. /**
  49161. * Gets the perf counter used for GPU frame time
  49162. */
  49163. readonly gpuFrameTimeCounter: PerfCounter;
  49164. /**
  49165. * Gets the GPU frame time capture status
  49166. */
  49167. /**
  49168. * Enable or disable the GPU frame time capture
  49169. */
  49170. captureGPUFrameTime: boolean;
  49171. /**
  49172. * Gets the perf counter used for shader compilation time
  49173. */
  49174. readonly shaderCompilationTimeCounter: PerfCounter;
  49175. /**
  49176. * Gets the shader compilation time capture status
  49177. */
  49178. /**
  49179. * Enable or disable the shader compilation time capture
  49180. */
  49181. captureShaderCompilationTime: boolean;
  49182. /**
  49183. * Instantiates a new engine instrumentation.
  49184. * This class can be used to get instrumentation data from a Babylon engine
  49185. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  49186. * @param engine Defines the engine to instrument
  49187. */
  49188. constructor(
  49189. /**
  49190. * Define the instrumented engine.
  49191. */
  49192. engine: Engine);
  49193. /**
  49194. * Dispose and release associated resources.
  49195. */
  49196. dispose(): void;
  49197. }
  49198. }
  49199. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  49200. import { PerfCounter } from "babylonjs/Misc/tools";
  49201. import { Scene, IDisposable } from "babylonjs/scene";
  49202. /**
  49203. * This class can be used to get instrumentation data from a Babylon engine
  49204. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  49205. */
  49206. export class SceneInstrumentation implements IDisposable {
  49207. /**
  49208. * Defines the scene to instrument
  49209. */
  49210. scene: Scene;
  49211. private _captureActiveMeshesEvaluationTime;
  49212. private _activeMeshesEvaluationTime;
  49213. private _captureRenderTargetsRenderTime;
  49214. private _renderTargetsRenderTime;
  49215. private _captureFrameTime;
  49216. private _frameTime;
  49217. private _captureRenderTime;
  49218. private _renderTime;
  49219. private _captureInterFrameTime;
  49220. private _interFrameTime;
  49221. private _captureParticlesRenderTime;
  49222. private _particlesRenderTime;
  49223. private _captureSpritesRenderTime;
  49224. private _spritesRenderTime;
  49225. private _capturePhysicsTime;
  49226. private _physicsTime;
  49227. private _captureAnimationsTime;
  49228. private _animationsTime;
  49229. private _captureCameraRenderTime;
  49230. private _cameraRenderTime;
  49231. private _onBeforeActiveMeshesEvaluationObserver;
  49232. private _onAfterActiveMeshesEvaluationObserver;
  49233. private _onBeforeRenderTargetsRenderObserver;
  49234. private _onAfterRenderTargetsRenderObserver;
  49235. private _onAfterRenderObserver;
  49236. private _onBeforeDrawPhaseObserver;
  49237. private _onAfterDrawPhaseObserver;
  49238. private _onBeforeAnimationsObserver;
  49239. private _onBeforeParticlesRenderingObserver;
  49240. private _onAfterParticlesRenderingObserver;
  49241. private _onBeforeSpritesRenderingObserver;
  49242. private _onAfterSpritesRenderingObserver;
  49243. private _onBeforePhysicsObserver;
  49244. private _onAfterPhysicsObserver;
  49245. private _onAfterAnimationsObserver;
  49246. private _onBeforeCameraRenderObserver;
  49247. private _onAfterCameraRenderObserver;
  49248. /**
  49249. * Gets the perf counter used for active meshes evaluation time
  49250. */
  49251. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  49252. /**
  49253. * Gets the active meshes evaluation time capture status
  49254. */
  49255. /**
  49256. * Enable or disable the active meshes evaluation time capture
  49257. */
  49258. captureActiveMeshesEvaluationTime: boolean;
  49259. /**
  49260. * Gets the perf counter used for render targets render time
  49261. */
  49262. readonly renderTargetsRenderTimeCounter: PerfCounter;
  49263. /**
  49264. * Gets the render targets render time capture status
  49265. */
  49266. /**
  49267. * Enable or disable the render targets render time capture
  49268. */
  49269. captureRenderTargetsRenderTime: boolean;
  49270. /**
  49271. * Gets the perf counter used for particles render time
  49272. */
  49273. readonly particlesRenderTimeCounter: PerfCounter;
  49274. /**
  49275. * Gets the particles render time capture status
  49276. */
  49277. /**
  49278. * Enable or disable the particles render time capture
  49279. */
  49280. captureParticlesRenderTime: boolean;
  49281. /**
  49282. * Gets the perf counter used for sprites render time
  49283. */
  49284. readonly spritesRenderTimeCounter: PerfCounter;
  49285. /**
  49286. * Gets the sprites render time capture status
  49287. */
  49288. /**
  49289. * Enable or disable the sprites render time capture
  49290. */
  49291. captureSpritesRenderTime: boolean;
  49292. /**
  49293. * Gets the perf counter used for physics time
  49294. */
  49295. readonly physicsTimeCounter: PerfCounter;
  49296. /**
  49297. * Gets the physics time capture status
  49298. */
  49299. /**
  49300. * Enable or disable the physics time capture
  49301. */
  49302. capturePhysicsTime: boolean;
  49303. /**
  49304. * Gets the perf counter used for animations time
  49305. */
  49306. readonly animationsTimeCounter: PerfCounter;
  49307. /**
  49308. * Gets the animations time capture status
  49309. */
  49310. /**
  49311. * Enable or disable the animations time capture
  49312. */
  49313. captureAnimationsTime: boolean;
  49314. /**
  49315. * Gets the perf counter used for frame time capture
  49316. */
  49317. readonly frameTimeCounter: PerfCounter;
  49318. /**
  49319. * Gets the frame time capture status
  49320. */
  49321. /**
  49322. * Enable or disable the frame time capture
  49323. */
  49324. captureFrameTime: boolean;
  49325. /**
  49326. * Gets the perf counter used for inter-frames time capture
  49327. */
  49328. readonly interFrameTimeCounter: PerfCounter;
  49329. /**
  49330. * Gets the inter-frames time capture status
  49331. */
  49332. /**
  49333. * Enable or disable the inter-frames time capture
  49334. */
  49335. captureInterFrameTime: boolean;
  49336. /**
  49337. * Gets the perf counter used for render time capture
  49338. */
  49339. readonly renderTimeCounter: PerfCounter;
  49340. /**
  49341. * Gets the render time capture status
  49342. */
  49343. /**
  49344. * Enable or disable the render time capture
  49345. */
  49346. captureRenderTime: boolean;
  49347. /**
  49348. * Gets the perf counter used for camera render time capture
  49349. */
  49350. readonly cameraRenderTimeCounter: PerfCounter;
  49351. /**
  49352. * Gets the camera render time capture status
  49353. */
  49354. /**
  49355. * Enable or disable the camera render time capture
  49356. */
  49357. captureCameraRenderTime: boolean;
  49358. /**
  49359. * Gets the perf counter used for draw calls
  49360. */
  49361. readonly drawCallsCounter: PerfCounter;
  49362. /**
  49363. * Instantiates a new scene instrumentation.
  49364. * This class can be used to get instrumentation data from a Babylon engine
  49365. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  49366. * @param scene Defines the scene to instrument
  49367. */
  49368. constructor(
  49369. /**
  49370. * Defines the scene to instrument
  49371. */
  49372. scene: Scene);
  49373. /**
  49374. * Dispose and release associated resources.
  49375. */
  49376. dispose(): void;
  49377. }
  49378. }
  49379. declare module "babylonjs/Instrumentation/index" {
  49380. export * from "babylonjs/Instrumentation/engineInstrumentation";
  49381. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  49382. export * from "babylonjs/Instrumentation/timeToken";
  49383. }
  49384. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  49385. /** @hidden */
  49386. export var glowMapGenerationPixelShader: {
  49387. name: string;
  49388. shader: string;
  49389. };
  49390. }
  49391. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  49392. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  49393. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  49394. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  49395. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  49396. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  49397. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  49398. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  49399. /** @hidden */
  49400. export var glowMapGenerationVertexShader: {
  49401. name: string;
  49402. shader: string;
  49403. };
  49404. }
  49405. declare module "babylonjs/Layers/effectLayer" {
  49406. import { Observable } from "babylonjs/Misc/observable";
  49407. import { Nullable } from "babylonjs/types";
  49408. import { Camera } from "babylonjs/Cameras/camera";
  49409. import { Scene } from "babylonjs/scene";
  49410. import { Color4, ISize } from "babylonjs/Maths/math";
  49411. import { Engine } from "babylonjs/Engines/engine";
  49412. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49413. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49414. import { Mesh } from "babylonjs/Meshes/mesh";
  49415. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  49416. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49417. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49418. import { Effect } from "babylonjs/Materials/effect";
  49419. import { Material } from "babylonjs/Materials/material";
  49420. import "babylonjs/Shaders/glowMapGeneration.fragment";
  49421. import "babylonjs/Shaders/glowMapGeneration.vertex";
  49422. /**
  49423. * Effect layer options. This helps customizing the behaviour
  49424. * of the effect layer.
  49425. */
  49426. export interface IEffectLayerOptions {
  49427. /**
  49428. * Multiplication factor apply to the canvas size to compute the render target size
  49429. * used to generated the objects (the smaller the faster).
  49430. */
  49431. mainTextureRatio: number;
  49432. /**
  49433. * Enforces a fixed size texture to ensure effect stability across devices.
  49434. */
  49435. mainTextureFixedSize?: number;
  49436. /**
  49437. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  49438. */
  49439. alphaBlendingMode: number;
  49440. /**
  49441. * The camera attached to the layer.
  49442. */
  49443. camera: Nullable<Camera>;
  49444. /**
  49445. * The rendering group to draw the layer in.
  49446. */
  49447. renderingGroupId: number;
  49448. }
  49449. /**
  49450. * The effect layer Helps adding post process effect blended with the main pass.
  49451. *
  49452. * This can be for instance use to generate glow or higlight effects on the scene.
  49453. *
  49454. * The effect layer class can not be used directly and is intented to inherited from to be
  49455. * customized per effects.
  49456. */
  49457. export abstract class EffectLayer {
  49458. private _vertexBuffers;
  49459. private _indexBuffer;
  49460. private _cachedDefines;
  49461. private _effectLayerMapGenerationEffect;
  49462. private _effectLayerOptions;
  49463. private _mergeEffect;
  49464. protected _scene: Scene;
  49465. protected _engine: Engine;
  49466. protected _maxSize: number;
  49467. protected _mainTextureDesiredSize: ISize;
  49468. protected _mainTexture: RenderTargetTexture;
  49469. protected _shouldRender: boolean;
  49470. protected _postProcesses: PostProcess[];
  49471. protected _textures: BaseTexture[];
  49472. protected _emissiveTextureAndColor: {
  49473. texture: Nullable<BaseTexture>;
  49474. color: Color4;
  49475. };
  49476. /**
  49477. * The name of the layer
  49478. */
  49479. name: string;
  49480. /**
  49481. * The clear color of the texture used to generate the glow map.
  49482. */
  49483. neutralColor: Color4;
  49484. /**
  49485. * Specifies wether the highlight layer is enabled or not.
  49486. */
  49487. isEnabled: boolean;
  49488. /**
  49489. * Gets the camera attached to the layer.
  49490. */
  49491. readonly camera: Nullable<Camera>;
  49492. /**
  49493. * Gets the rendering group id the layer should render in.
  49494. */
  49495. readonly renderingGroupId: number;
  49496. /**
  49497. * An event triggered when the effect layer has been disposed.
  49498. */
  49499. onDisposeObservable: Observable<EffectLayer>;
  49500. /**
  49501. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  49502. */
  49503. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  49504. /**
  49505. * An event triggered when the generated texture is being merged in the scene.
  49506. */
  49507. onBeforeComposeObservable: Observable<EffectLayer>;
  49508. /**
  49509. * An event triggered when the generated texture has been merged in the scene.
  49510. */
  49511. onAfterComposeObservable: Observable<EffectLayer>;
  49512. /**
  49513. * An event triggered when the efffect layer changes its size.
  49514. */
  49515. onSizeChangedObservable: Observable<EffectLayer>;
  49516. /** @hidden */
  49517. static _SceneComponentInitialization: (scene: Scene) => void;
  49518. /**
  49519. * Instantiates a new effect Layer and references it in the scene.
  49520. * @param name The name of the layer
  49521. * @param scene The scene to use the layer in
  49522. */
  49523. constructor(
  49524. /** The Friendly of the effect in the scene */
  49525. name: string, scene: Scene);
  49526. /**
  49527. * Get the effect name of the layer.
  49528. * @return The effect name
  49529. */
  49530. abstract getEffectName(): string;
  49531. /**
  49532. * Checks for the readiness of the element composing the layer.
  49533. * @param subMesh the mesh to check for
  49534. * @param useInstances specify wether or not to use instances to render the mesh
  49535. * @return true if ready otherwise, false
  49536. */
  49537. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49538. /**
  49539. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49540. * @returns true if the effect requires stencil during the main canvas render pass.
  49541. */
  49542. abstract needStencil(): boolean;
  49543. /**
  49544. * Create the merge effect. This is the shader use to blit the information back
  49545. * to the main canvas at the end of the scene rendering.
  49546. * @returns The effect containing the shader used to merge the effect on the main canvas
  49547. */
  49548. protected abstract _createMergeEffect(): Effect;
  49549. /**
  49550. * Creates the render target textures and post processes used in the effect layer.
  49551. */
  49552. protected abstract _createTextureAndPostProcesses(): void;
  49553. /**
  49554. * Implementation specific of rendering the generating effect on the main canvas.
  49555. * @param effect The effect used to render through
  49556. */
  49557. protected abstract _internalRender(effect: Effect): void;
  49558. /**
  49559. * Sets the required values for both the emissive texture and and the main color.
  49560. */
  49561. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49562. /**
  49563. * Free any resources and references associated to a mesh.
  49564. * Internal use
  49565. * @param mesh The mesh to free.
  49566. */
  49567. abstract _disposeMesh(mesh: Mesh): void;
  49568. /**
  49569. * Serializes this layer (Glow or Highlight for example)
  49570. * @returns a serialized layer object
  49571. */
  49572. abstract serialize?(): any;
  49573. /**
  49574. * Initializes the effect layer with the required options.
  49575. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  49576. */
  49577. protected _init(options: Partial<IEffectLayerOptions>): void;
  49578. /**
  49579. * Generates the index buffer of the full screen quad blending to the main canvas.
  49580. */
  49581. private _generateIndexBuffer;
  49582. /**
  49583. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  49584. */
  49585. private _generateVertexBuffer;
  49586. /**
  49587. * Sets the main texture desired size which is the closest power of two
  49588. * of the engine canvas size.
  49589. */
  49590. private _setMainTextureSize;
  49591. /**
  49592. * Creates the main texture for the effect layer.
  49593. */
  49594. protected _createMainTexture(): void;
  49595. /**
  49596. * Adds specific effects defines.
  49597. * @param defines The defines to add specifics to.
  49598. */
  49599. protected _addCustomEffectDefines(defines: string[]): void;
  49600. /**
  49601. * Checks for the readiness of the element composing the layer.
  49602. * @param subMesh the mesh to check for
  49603. * @param useInstances specify wether or not to use instances to render the mesh
  49604. * @param emissiveTexture the associated emissive texture used to generate the glow
  49605. * @return true if ready otherwise, false
  49606. */
  49607. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  49608. /**
  49609. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  49610. */
  49611. render(): void;
  49612. /**
  49613. * Determine if a given mesh will be used in the current effect.
  49614. * @param mesh mesh to test
  49615. * @returns true if the mesh will be used
  49616. */
  49617. hasMesh(mesh: AbstractMesh): boolean;
  49618. /**
  49619. * Returns true if the layer contains information to display, otherwise false.
  49620. * @returns true if the glow layer should be rendered
  49621. */
  49622. shouldRender(): boolean;
  49623. /**
  49624. * Returns true if the mesh should render, otherwise false.
  49625. * @param mesh The mesh to render
  49626. * @returns true if it should render otherwise false
  49627. */
  49628. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  49629. /**
  49630. * Returns true if the mesh can be rendered, otherwise false.
  49631. * @param mesh The mesh to render
  49632. * @param material The material used on the mesh
  49633. * @returns true if it can be rendered otherwise false
  49634. */
  49635. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49636. /**
  49637. * Returns true if the mesh should render, otherwise false.
  49638. * @param mesh The mesh to render
  49639. * @returns true if it should render otherwise false
  49640. */
  49641. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  49642. /**
  49643. * Renders the submesh passed in parameter to the generation map.
  49644. */
  49645. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  49646. /**
  49647. * Rebuild the required buffers.
  49648. * @hidden Internal use only.
  49649. */
  49650. _rebuild(): void;
  49651. /**
  49652. * Dispose only the render target textures and post process.
  49653. */
  49654. private _disposeTextureAndPostProcesses;
  49655. /**
  49656. * Dispose the highlight layer and free resources.
  49657. */
  49658. dispose(): void;
  49659. /**
  49660. * Gets the class name of the effect layer
  49661. * @returns the string with the class name of the effect layer
  49662. */
  49663. getClassName(): string;
  49664. /**
  49665. * Creates an effect layer from parsed effect layer data
  49666. * @param parsedEffectLayer defines effect layer data
  49667. * @param scene defines the current scene
  49668. * @param rootUrl defines the root URL containing the effect layer information
  49669. * @returns a parsed effect Layer
  49670. */
  49671. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  49672. }
  49673. }
  49674. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  49675. import { Scene } from "babylonjs/scene";
  49676. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  49677. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  49678. import { AbstractScene } from "babylonjs/abstractScene";
  49679. module "babylonjs/abstractScene" {
  49680. interface AbstractScene {
  49681. /**
  49682. * The list of effect layers (highlights/glow) added to the scene
  49683. * @see http://doc.babylonjs.com/how_to/highlight_layer
  49684. * @see http://doc.babylonjs.com/how_to/glow_layer
  49685. */
  49686. effectLayers: Array<EffectLayer>;
  49687. /**
  49688. * Removes the given effect layer from this scene.
  49689. * @param toRemove defines the effect layer to remove
  49690. * @returns the index of the removed effect layer
  49691. */
  49692. removeEffectLayer(toRemove: EffectLayer): number;
  49693. /**
  49694. * Adds the given effect layer to this scene
  49695. * @param newEffectLayer defines the effect layer to add
  49696. */
  49697. addEffectLayer(newEffectLayer: EffectLayer): void;
  49698. }
  49699. }
  49700. /**
  49701. * Defines the layer scene component responsible to manage any effect layers
  49702. * in a given scene.
  49703. */
  49704. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  49705. /**
  49706. * The component name helpfull to identify the component in the list of scene components.
  49707. */
  49708. readonly name: string;
  49709. /**
  49710. * The scene the component belongs to.
  49711. */
  49712. scene: Scene;
  49713. private _engine;
  49714. private _renderEffects;
  49715. private _needStencil;
  49716. private _previousStencilState;
  49717. /**
  49718. * Creates a new instance of the component for the given scene
  49719. * @param scene Defines the scene to register the component in
  49720. */
  49721. constructor(scene: Scene);
  49722. /**
  49723. * Registers the component in a given scene
  49724. */
  49725. register(): void;
  49726. /**
  49727. * Rebuilds the elements related to this component in case of
  49728. * context lost for instance.
  49729. */
  49730. rebuild(): void;
  49731. /**
  49732. * Serializes the component data to the specified json object
  49733. * @param serializationObject The object to serialize to
  49734. */
  49735. serialize(serializationObject: any): void;
  49736. /**
  49737. * Adds all the elements from the container to the scene
  49738. * @param container the container holding the elements
  49739. */
  49740. addFromContainer(container: AbstractScene): void;
  49741. /**
  49742. * Removes all the elements in the container from the scene
  49743. * @param container contains the elements to remove
  49744. * @param dispose if the removed element should be disposed (default: false)
  49745. */
  49746. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49747. /**
  49748. * Disposes the component and the associated ressources.
  49749. */
  49750. dispose(): void;
  49751. private _isReadyForMesh;
  49752. private _renderMainTexture;
  49753. private _setStencil;
  49754. private _setStencilBack;
  49755. private _draw;
  49756. private _drawCamera;
  49757. private _drawRenderingGroup;
  49758. }
  49759. }
  49760. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  49761. /** @hidden */
  49762. export var glowMapMergePixelShader: {
  49763. name: string;
  49764. shader: string;
  49765. };
  49766. }
  49767. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  49768. /** @hidden */
  49769. export var glowMapMergeVertexShader: {
  49770. name: string;
  49771. shader: string;
  49772. };
  49773. }
  49774. declare module "babylonjs/Layers/glowLayer" {
  49775. import { Nullable } from "babylonjs/types";
  49776. import { Camera } from "babylonjs/Cameras/camera";
  49777. import { Scene } from "babylonjs/scene";
  49778. import { Color4 } from "babylonjs/Maths/math";
  49779. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49780. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49781. import { Mesh } from "babylonjs/Meshes/mesh";
  49782. import { Texture } from "babylonjs/Materials/Textures/texture";
  49783. import { Effect } from "babylonjs/Materials/effect";
  49784. import { Material } from "babylonjs/Materials/material";
  49785. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  49786. import "babylonjs/Shaders/glowMapMerge.fragment";
  49787. import "babylonjs/Shaders/glowMapMerge.vertex";
  49788. import "babylonjs/Layers/effectLayerSceneComponent";
  49789. module "babylonjs/abstractScene" {
  49790. interface AbstractScene {
  49791. /**
  49792. * Return a the first highlight layer of the scene with a given name.
  49793. * @param name The name of the highlight layer to look for.
  49794. * @return The highlight layer if found otherwise null.
  49795. */
  49796. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  49797. }
  49798. }
  49799. /**
  49800. * Glow layer options. This helps customizing the behaviour
  49801. * of the glow layer.
  49802. */
  49803. export interface IGlowLayerOptions {
  49804. /**
  49805. * Multiplication factor apply to the canvas size to compute the render target size
  49806. * used to generated the glowing objects (the smaller the faster).
  49807. */
  49808. mainTextureRatio: number;
  49809. /**
  49810. * Enforces a fixed size texture to ensure resize independant blur.
  49811. */
  49812. mainTextureFixedSize?: number;
  49813. /**
  49814. * How big is the kernel of the blur texture.
  49815. */
  49816. blurKernelSize: number;
  49817. /**
  49818. * The camera attached to the layer.
  49819. */
  49820. camera: Nullable<Camera>;
  49821. /**
  49822. * Enable MSAA by chosing the number of samples.
  49823. */
  49824. mainTextureSamples?: number;
  49825. /**
  49826. * The rendering group to draw the layer in.
  49827. */
  49828. renderingGroupId: number;
  49829. }
  49830. /**
  49831. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  49832. *
  49833. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49834. * glowy meshes to your scene.
  49835. *
  49836. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  49837. */
  49838. export class GlowLayer extends EffectLayer {
  49839. /**
  49840. * Effect Name of the layer.
  49841. */
  49842. static readonly EffectName: string;
  49843. /**
  49844. * The default blur kernel size used for the glow.
  49845. */
  49846. static DefaultBlurKernelSize: number;
  49847. /**
  49848. * The default texture size ratio used for the glow.
  49849. */
  49850. static DefaultTextureRatio: number;
  49851. /**
  49852. * Sets the kernel size of the blur.
  49853. */
  49854. /**
  49855. * Gets the kernel size of the blur.
  49856. */
  49857. blurKernelSize: number;
  49858. /**
  49859. * Sets the glow intensity.
  49860. */
  49861. /**
  49862. * Gets the glow intensity.
  49863. */
  49864. intensity: number;
  49865. private _options;
  49866. private _intensity;
  49867. private _horizontalBlurPostprocess1;
  49868. private _verticalBlurPostprocess1;
  49869. private _horizontalBlurPostprocess2;
  49870. private _verticalBlurPostprocess2;
  49871. private _blurTexture1;
  49872. private _blurTexture2;
  49873. private _postProcesses1;
  49874. private _postProcesses2;
  49875. private _includedOnlyMeshes;
  49876. private _excludedMeshes;
  49877. /**
  49878. * Callback used to let the user override the color selection on a per mesh basis
  49879. */
  49880. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  49881. /**
  49882. * Callback used to let the user override the texture selection on a per mesh basis
  49883. */
  49884. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  49885. /**
  49886. * Instantiates a new glow Layer and references it to the scene.
  49887. * @param name The name of the layer
  49888. * @param scene The scene to use the layer in
  49889. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  49890. */
  49891. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  49892. /**
  49893. * Get the effect name of the layer.
  49894. * @return The effect name
  49895. */
  49896. getEffectName(): string;
  49897. /**
  49898. * Create the merge effect. This is the shader use to blit the information back
  49899. * to the main canvas at the end of the scene rendering.
  49900. */
  49901. protected _createMergeEffect(): Effect;
  49902. /**
  49903. * Creates the render target textures and post processes used in the glow layer.
  49904. */
  49905. protected _createTextureAndPostProcesses(): void;
  49906. /**
  49907. * Checks for the readiness of the element composing the layer.
  49908. * @param subMesh the mesh to check for
  49909. * @param useInstances specify wether or not to use instances to render the mesh
  49910. * @param emissiveTexture the associated emissive texture used to generate the glow
  49911. * @return true if ready otherwise, false
  49912. */
  49913. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49914. /**
  49915. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49916. */
  49917. needStencil(): boolean;
  49918. /**
  49919. * Returns true if the mesh can be rendered, otherwise false.
  49920. * @param mesh The mesh to render
  49921. * @param material The material used on the mesh
  49922. * @returns true if it can be rendered otherwise false
  49923. */
  49924. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49925. /**
  49926. * Implementation specific of rendering the generating effect on the main canvas.
  49927. * @param effect The effect used to render through
  49928. */
  49929. protected _internalRender(effect: Effect): void;
  49930. /**
  49931. * Sets the required values for both the emissive texture and and the main color.
  49932. */
  49933. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49934. /**
  49935. * Returns true if the mesh should render, otherwise false.
  49936. * @param mesh The mesh to render
  49937. * @returns true if it should render otherwise false
  49938. */
  49939. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49940. /**
  49941. * Adds specific effects defines.
  49942. * @param defines The defines to add specifics to.
  49943. */
  49944. protected _addCustomEffectDefines(defines: string[]): void;
  49945. /**
  49946. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  49947. * @param mesh The mesh to exclude from the glow layer
  49948. */
  49949. addExcludedMesh(mesh: Mesh): void;
  49950. /**
  49951. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  49952. * @param mesh The mesh to remove
  49953. */
  49954. removeExcludedMesh(mesh: Mesh): void;
  49955. /**
  49956. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  49957. * @param mesh The mesh to include in the glow layer
  49958. */
  49959. addIncludedOnlyMesh(mesh: Mesh): void;
  49960. /**
  49961. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  49962. * @param mesh The mesh to remove
  49963. */
  49964. removeIncludedOnlyMesh(mesh: Mesh): void;
  49965. /**
  49966. * Determine if a given mesh will be used in the glow layer
  49967. * @param mesh The mesh to test
  49968. * @returns true if the mesh will be highlighted by the current glow layer
  49969. */
  49970. hasMesh(mesh: AbstractMesh): boolean;
  49971. /**
  49972. * Free any resources and references associated to a mesh.
  49973. * Internal use
  49974. * @param mesh The mesh to free.
  49975. * @hidden
  49976. */
  49977. _disposeMesh(mesh: Mesh): void;
  49978. /**
  49979. * Gets the class name of the effect layer
  49980. * @returns the string with the class name of the effect layer
  49981. */
  49982. getClassName(): string;
  49983. /**
  49984. * Serializes this glow layer
  49985. * @returns a serialized glow layer object
  49986. */
  49987. serialize(): any;
  49988. /**
  49989. * Creates a Glow Layer from parsed glow layer data
  49990. * @param parsedGlowLayer defines glow layer data
  49991. * @param scene defines the current scene
  49992. * @param rootUrl defines the root URL containing the glow layer information
  49993. * @returns a parsed Glow Layer
  49994. */
  49995. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  49996. }
  49997. }
  49998. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  49999. /** @hidden */
  50000. export var glowBlurPostProcessPixelShader: {
  50001. name: string;
  50002. shader: string;
  50003. };
  50004. }
  50005. declare module "babylonjs/Layers/highlightLayer" {
  50006. import { Observable } from "babylonjs/Misc/observable";
  50007. import { Nullable } from "babylonjs/types";
  50008. import { Camera } from "babylonjs/Cameras/camera";
  50009. import { Scene } from "babylonjs/scene";
  50010. import { Color3, Color4 } from "babylonjs/Maths/math";
  50011. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50012. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50013. import { Mesh } from "babylonjs/Meshes/mesh";
  50014. import { Effect } from "babylonjs/Materials/effect";
  50015. import { Material } from "babylonjs/Materials/material";
  50016. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  50017. import "babylonjs/Shaders/glowMapMerge.fragment";
  50018. import "babylonjs/Shaders/glowMapMerge.vertex";
  50019. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  50020. module "babylonjs/abstractScene" {
  50021. interface AbstractScene {
  50022. /**
  50023. * Return a the first highlight layer of the scene with a given name.
  50024. * @param name The name of the highlight layer to look for.
  50025. * @return The highlight layer if found otherwise null.
  50026. */
  50027. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  50028. }
  50029. }
  50030. /**
  50031. * Highlight layer options. This helps customizing the behaviour
  50032. * of the highlight layer.
  50033. */
  50034. export interface IHighlightLayerOptions {
  50035. /**
  50036. * Multiplication factor apply to the canvas size to compute the render target size
  50037. * used to generated the glowing objects (the smaller the faster).
  50038. */
  50039. mainTextureRatio: number;
  50040. /**
  50041. * Enforces a fixed size texture to ensure resize independant blur.
  50042. */
  50043. mainTextureFixedSize?: number;
  50044. /**
  50045. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  50046. * of the picture to blur (the smaller the faster).
  50047. */
  50048. blurTextureSizeRatio: number;
  50049. /**
  50050. * How big in texel of the blur texture is the vertical blur.
  50051. */
  50052. blurVerticalSize: number;
  50053. /**
  50054. * How big in texel of the blur texture is the horizontal blur.
  50055. */
  50056. blurHorizontalSize: number;
  50057. /**
  50058. * Alpha blending mode used to apply the blur. Default is combine.
  50059. */
  50060. alphaBlendingMode: number;
  50061. /**
  50062. * The camera attached to the layer.
  50063. */
  50064. camera: Nullable<Camera>;
  50065. /**
  50066. * Should we display highlight as a solid stroke?
  50067. */
  50068. isStroke?: boolean;
  50069. /**
  50070. * The rendering group to draw the layer in.
  50071. */
  50072. renderingGroupId: number;
  50073. }
  50074. /**
  50075. * The highlight layer Helps adding a glow effect around a mesh.
  50076. *
  50077. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  50078. * glowy meshes to your scene.
  50079. *
  50080. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  50081. */
  50082. export class HighlightLayer extends EffectLayer {
  50083. name: string;
  50084. /**
  50085. * Effect Name of the highlight layer.
  50086. */
  50087. static readonly EffectName: string;
  50088. /**
  50089. * The neutral color used during the preparation of the glow effect.
  50090. * This is black by default as the blend operation is a blend operation.
  50091. */
  50092. static NeutralColor: Color4;
  50093. /**
  50094. * Stencil value used for glowing meshes.
  50095. */
  50096. static GlowingMeshStencilReference: number;
  50097. /**
  50098. * Stencil value used for the other meshes in the scene.
  50099. */
  50100. static NormalMeshStencilReference: number;
  50101. /**
  50102. * Specifies whether or not the inner glow is ACTIVE in the layer.
  50103. */
  50104. innerGlow: boolean;
  50105. /**
  50106. * Specifies whether or not the outer glow is ACTIVE in the layer.
  50107. */
  50108. outerGlow: boolean;
  50109. /**
  50110. * Specifies the horizontal size of the blur.
  50111. */
  50112. /**
  50113. * Gets the horizontal size of the blur.
  50114. */
  50115. blurHorizontalSize: number;
  50116. /**
  50117. * Specifies the vertical size of the blur.
  50118. */
  50119. /**
  50120. * Gets the vertical size of the blur.
  50121. */
  50122. blurVerticalSize: number;
  50123. /**
  50124. * An event triggered when the highlight layer is being blurred.
  50125. */
  50126. onBeforeBlurObservable: Observable<HighlightLayer>;
  50127. /**
  50128. * An event triggered when the highlight layer has been blurred.
  50129. */
  50130. onAfterBlurObservable: Observable<HighlightLayer>;
  50131. private _instanceGlowingMeshStencilReference;
  50132. private _options;
  50133. private _downSamplePostprocess;
  50134. private _horizontalBlurPostprocess;
  50135. private _verticalBlurPostprocess;
  50136. private _blurTexture;
  50137. private _meshes;
  50138. private _excludedMeshes;
  50139. /**
  50140. * Instantiates a new highlight Layer and references it to the scene..
  50141. * @param name The name of the layer
  50142. * @param scene The scene to use the layer in
  50143. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  50144. */
  50145. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  50146. /**
  50147. * Get the effect name of the layer.
  50148. * @return The effect name
  50149. */
  50150. getEffectName(): string;
  50151. /**
  50152. * Create the merge effect. This is the shader use to blit the information back
  50153. * to the main canvas at the end of the scene rendering.
  50154. */
  50155. protected _createMergeEffect(): Effect;
  50156. /**
  50157. * Creates the render target textures and post processes used in the highlight layer.
  50158. */
  50159. protected _createTextureAndPostProcesses(): void;
  50160. /**
  50161. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  50162. */
  50163. needStencil(): boolean;
  50164. /**
  50165. * Checks for the readiness of the element composing the layer.
  50166. * @param subMesh the mesh to check for
  50167. * @param useInstances specify wether or not to use instances to render the mesh
  50168. * @param emissiveTexture the associated emissive texture used to generate the glow
  50169. * @return true if ready otherwise, false
  50170. */
  50171. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50172. /**
  50173. * Implementation specific of rendering the generating effect on the main canvas.
  50174. * @param effect The effect used to render through
  50175. */
  50176. protected _internalRender(effect: Effect): void;
  50177. /**
  50178. * Returns true if the layer contains information to display, otherwise false.
  50179. */
  50180. shouldRender(): boolean;
  50181. /**
  50182. * Returns true if the mesh should render, otherwise false.
  50183. * @param mesh The mesh to render
  50184. * @returns true if it should render otherwise false
  50185. */
  50186. protected _shouldRenderMesh(mesh: Mesh): boolean;
  50187. /**
  50188. * Sets the required values for both the emissive texture and and the main color.
  50189. */
  50190. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  50191. /**
  50192. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  50193. * @param mesh The mesh to exclude from the highlight layer
  50194. */
  50195. addExcludedMesh(mesh: Mesh): void;
  50196. /**
  50197. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  50198. * @param mesh The mesh to highlight
  50199. */
  50200. removeExcludedMesh(mesh: Mesh): void;
  50201. /**
  50202. * Determine if a given mesh will be highlighted by the current HighlightLayer
  50203. * @param mesh mesh to test
  50204. * @returns true if the mesh will be highlighted by the current HighlightLayer
  50205. */
  50206. hasMesh(mesh: AbstractMesh): boolean;
  50207. /**
  50208. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  50209. * @param mesh The mesh to highlight
  50210. * @param color The color of the highlight
  50211. * @param glowEmissiveOnly Extract the glow from the emissive texture
  50212. */
  50213. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  50214. /**
  50215. * Remove a mesh from the highlight layer in order to make it stop glowing.
  50216. * @param mesh The mesh to highlight
  50217. */
  50218. removeMesh(mesh: Mesh): void;
  50219. /**
  50220. * Force the stencil to the normal expected value for none glowing parts
  50221. */
  50222. private _defaultStencilReference;
  50223. /**
  50224. * Free any resources and references associated to a mesh.
  50225. * Internal use
  50226. * @param mesh The mesh to free.
  50227. * @hidden
  50228. */
  50229. _disposeMesh(mesh: Mesh): void;
  50230. /**
  50231. * Dispose the highlight layer and free resources.
  50232. */
  50233. dispose(): void;
  50234. /**
  50235. * Gets the class name of the effect layer
  50236. * @returns the string with the class name of the effect layer
  50237. */
  50238. getClassName(): string;
  50239. /**
  50240. * Serializes this Highlight layer
  50241. * @returns a serialized Highlight layer object
  50242. */
  50243. serialize(): any;
  50244. /**
  50245. * Creates a Highlight layer from parsed Highlight layer data
  50246. * @param parsedHightlightLayer defines the Highlight layer data
  50247. * @param scene defines the current scene
  50248. * @param rootUrl defines the root URL containing the Highlight layer information
  50249. * @returns a parsed Highlight layer
  50250. */
  50251. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  50252. }
  50253. }
  50254. declare module "babylonjs/Layers/layerSceneComponent" {
  50255. import { Scene } from "babylonjs/scene";
  50256. import { ISceneComponent } from "babylonjs/sceneComponent";
  50257. import { Layer } from "babylonjs/Layers/layer";
  50258. import { AbstractScene } from "babylonjs/abstractScene";
  50259. module "babylonjs/abstractScene" {
  50260. interface AbstractScene {
  50261. /**
  50262. * The list of layers (background and foreground) of the scene
  50263. */
  50264. layers: Array<Layer>;
  50265. }
  50266. }
  50267. /**
  50268. * Defines the layer scene component responsible to manage any layers
  50269. * in a given scene.
  50270. */
  50271. export class LayerSceneComponent implements ISceneComponent {
  50272. /**
  50273. * The component name helpfull to identify the component in the list of scene components.
  50274. */
  50275. readonly name: string;
  50276. /**
  50277. * The scene the component belongs to.
  50278. */
  50279. scene: Scene;
  50280. private _engine;
  50281. /**
  50282. * Creates a new instance of the component for the given scene
  50283. * @param scene Defines the scene to register the component in
  50284. */
  50285. constructor(scene: Scene);
  50286. /**
  50287. * Registers the component in a given scene
  50288. */
  50289. register(): void;
  50290. /**
  50291. * Rebuilds the elements related to this component in case of
  50292. * context lost for instance.
  50293. */
  50294. rebuild(): void;
  50295. /**
  50296. * Disposes the component and the associated ressources.
  50297. */
  50298. dispose(): void;
  50299. private _draw;
  50300. private _drawCameraPredicate;
  50301. private _drawCameraBackground;
  50302. private _drawCameraForeground;
  50303. private _drawRenderTargetPredicate;
  50304. private _drawRenderTargetBackground;
  50305. private _drawRenderTargetForeground;
  50306. /**
  50307. * Adds all the elements from the container to the scene
  50308. * @param container the container holding the elements
  50309. */
  50310. addFromContainer(container: AbstractScene): void;
  50311. /**
  50312. * Removes all the elements in the container from the scene
  50313. * @param container contains the elements to remove
  50314. * @param dispose if the removed element should be disposed (default: false)
  50315. */
  50316. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50317. }
  50318. }
  50319. declare module "babylonjs/Shaders/layer.fragment" {
  50320. /** @hidden */
  50321. export var layerPixelShader: {
  50322. name: string;
  50323. shader: string;
  50324. };
  50325. }
  50326. declare module "babylonjs/Shaders/layer.vertex" {
  50327. /** @hidden */
  50328. export var layerVertexShader: {
  50329. name: string;
  50330. shader: string;
  50331. };
  50332. }
  50333. declare module "babylonjs/Layers/layer" {
  50334. import { Observable } from "babylonjs/Misc/observable";
  50335. import { Nullable } from "babylonjs/types";
  50336. import { Scene } from "babylonjs/scene";
  50337. import { Vector2, Color4 } from "babylonjs/Maths/math";
  50338. import { Texture } from "babylonjs/Materials/Textures/texture";
  50339. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50340. import "babylonjs/Shaders/layer.fragment";
  50341. import "babylonjs/Shaders/layer.vertex";
  50342. /**
  50343. * This represents a full screen 2d layer.
  50344. * This can be useful to display a picture in the background of your scene for instance.
  50345. * @see https://www.babylonjs-playground.com/#08A2BS#1
  50346. */
  50347. export class Layer {
  50348. /**
  50349. * Define the name of the layer.
  50350. */
  50351. name: string;
  50352. /**
  50353. * Define the texture the layer should display.
  50354. */
  50355. texture: Nullable<Texture>;
  50356. /**
  50357. * Is the layer in background or foreground.
  50358. */
  50359. isBackground: boolean;
  50360. /**
  50361. * Define the color of the layer (instead of texture).
  50362. */
  50363. color: Color4;
  50364. /**
  50365. * Define the scale of the layer in order to zoom in out of the texture.
  50366. */
  50367. scale: Vector2;
  50368. /**
  50369. * Define an offset for the layer in order to shift the texture.
  50370. */
  50371. offset: Vector2;
  50372. /**
  50373. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  50374. */
  50375. alphaBlendingMode: number;
  50376. /**
  50377. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  50378. * Alpha test will not mix with the background color in case of transparency.
  50379. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  50380. */
  50381. alphaTest: boolean;
  50382. /**
  50383. * Define a mask to restrict the layer to only some of the scene cameras.
  50384. */
  50385. layerMask: number;
  50386. /**
  50387. * Define the list of render target the layer is visible into.
  50388. */
  50389. renderTargetTextures: RenderTargetTexture[];
  50390. /**
  50391. * Define if the layer is only used in renderTarget or if it also
  50392. * renders in the main frame buffer of the canvas.
  50393. */
  50394. renderOnlyInRenderTargetTextures: boolean;
  50395. private _scene;
  50396. private _vertexBuffers;
  50397. private _indexBuffer;
  50398. private _effect;
  50399. private _alphaTestEffect;
  50400. /**
  50401. * An event triggered when the layer is disposed.
  50402. */
  50403. onDisposeObservable: Observable<Layer>;
  50404. private _onDisposeObserver;
  50405. /**
  50406. * Back compatibility with callback before the onDisposeObservable existed.
  50407. * The set callback will be triggered when the layer has been disposed.
  50408. */
  50409. onDispose: () => void;
  50410. /**
  50411. * An event triggered before rendering the scene
  50412. */
  50413. onBeforeRenderObservable: Observable<Layer>;
  50414. private _onBeforeRenderObserver;
  50415. /**
  50416. * Back compatibility with callback before the onBeforeRenderObservable existed.
  50417. * The set callback will be triggered just before rendering the layer.
  50418. */
  50419. onBeforeRender: () => void;
  50420. /**
  50421. * An event triggered after rendering the scene
  50422. */
  50423. onAfterRenderObservable: Observable<Layer>;
  50424. private _onAfterRenderObserver;
  50425. /**
  50426. * Back compatibility with callback before the onAfterRenderObservable existed.
  50427. * The set callback will be triggered just after rendering the layer.
  50428. */
  50429. onAfterRender: () => void;
  50430. /**
  50431. * Instantiates a new layer.
  50432. * This represents a full screen 2d layer.
  50433. * This can be useful to display a picture in the background of your scene for instance.
  50434. * @see https://www.babylonjs-playground.com/#08A2BS#1
  50435. * @param name Define the name of the layer in the scene
  50436. * @param imgUrl Define the url of the texture to display in the layer
  50437. * @param scene Define the scene the layer belongs to
  50438. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  50439. * @param color Defines a color for the layer
  50440. */
  50441. constructor(
  50442. /**
  50443. * Define the name of the layer.
  50444. */
  50445. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  50446. private _createIndexBuffer;
  50447. /** @hidden */
  50448. _rebuild(): void;
  50449. /**
  50450. * Renders the layer in the scene.
  50451. */
  50452. render(): void;
  50453. /**
  50454. * Disposes and releases the associated ressources.
  50455. */
  50456. dispose(): void;
  50457. }
  50458. }
  50459. declare module "babylonjs/Layers/index" {
  50460. export * from "babylonjs/Layers/effectLayer";
  50461. export * from "babylonjs/Layers/effectLayerSceneComponent";
  50462. export * from "babylonjs/Layers/glowLayer";
  50463. export * from "babylonjs/Layers/highlightLayer";
  50464. export * from "babylonjs/Layers/layer";
  50465. export * from "babylonjs/Layers/layerSceneComponent";
  50466. }
  50467. declare module "babylonjs/Shaders/lensFlare.fragment" {
  50468. /** @hidden */
  50469. export var lensFlarePixelShader: {
  50470. name: string;
  50471. shader: string;
  50472. };
  50473. }
  50474. declare module "babylonjs/Shaders/lensFlare.vertex" {
  50475. /** @hidden */
  50476. export var lensFlareVertexShader: {
  50477. name: string;
  50478. shader: string;
  50479. };
  50480. }
  50481. declare module "babylonjs/LensFlares/lensFlareSystem" {
  50482. import { Scene } from "babylonjs/scene";
  50483. import { Vector3, Viewport } from "babylonjs/Maths/math";
  50484. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50485. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  50486. import "babylonjs/Shaders/lensFlare.fragment";
  50487. import "babylonjs/Shaders/lensFlare.vertex";
  50488. /**
  50489. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  50490. * It is usually composed of several `lensFlare`.
  50491. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50492. */
  50493. export class LensFlareSystem {
  50494. /**
  50495. * Define the name of the lens flare system
  50496. */
  50497. name: string;
  50498. /**
  50499. * List of lens flares used in this system.
  50500. */
  50501. lensFlares: LensFlare[];
  50502. /**
  50503. * Define a limit from the border the lens flare can be visible.
  50504. */
  50505. borderLimit: number;
  50506. /**
  50507. * Define a viewport border we do not want to see the lens flare in.
  50508. */
  50509. viewportBorder: number;
  50510. /**
  50511. * Define a predicate which could limit the list of meshes able to occlude the effect.
  50512. */
  50513. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  50514. /**
  50515. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  50516. */
  50517. layerMask: number;
  50518. /**
  50519. * Define the id of the lens flare system in the scene.
  50520. * (equal to name by default)
  50521. */
  50522. id: string;
  50523. private _scene;
  50524. private _emitter;
  50525. private _vertexBuffers;
  50526. private _indexBuffer;
  50527. private _effect;
  50528. private _positionX;
  50529. private _positionY;
  50530. private _isEnabled;
  50531. /** @hidden */
  50532. static _SceneComponentInitialization: (scene: Scene) => void;
  50533. /**
  50534. * Instantiates a lens flare system.
  50535. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  50536. * It is usually composed of several `lensFlare`.
  50537. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50538. * @param name Define the name of the lens flare system in the scene
  50539. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  50540. * @param scene Define the scene the lens flare system belongs to
  50541. */
  50542. constructor(
  50543. /**
  50544. * Define the name of the lens flare system
  50545. */
  50546. name: string, emitter: any, scene: Scene);
  50547. /**
  50548. * Define if the lens flare system is enabled.
  50549. */
  50550. isEnabled: boolean;
  50551. /**
  50552. * Get the scene the effects belongs to.
  50553. * @returns the scene holding the lens flare system
  50554. */
  50555. getScene(): Scene;
  50556. /**
  50557. * Get the emitter of the lens flare system.
  50558. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  50559. * @returns the emitter of the lens flare system
  50560. */
  50561. getEmitter(): any;
  50562. /**
  50563. * Set the emitter of the lens flare system.
  50564. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  50565. * @param newEmitter Define the new emitter of the system
  50566. */
  50567. setEmitter(newEmitter: any): void;
  50568. /**
  50569. * Get the lens flare system emitter position.
  50570. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  50571. * @returns the position
  50572. */
  50573. getEmitterPosition(): Vector3;
  50574. /**
  50575. * @hidden
  50576. */
  50577. computeEffectivePosition(globalViewport: Viewport): boolean;
  50578. /** @hidden */
  50579. _isVisible(): boolean;
  50580. /**
  50581. * @hidden
  50582. */
  50583. render(): boolean;
  50584. /**
  50585. * Dispose and release the lens flare with its associated resources.
  50586. */
  50587. dispose(): void;
  50588. /**
  50589. * Parse a lens flare system from a JSON repressentation
  50590. * @param parsedLensFlareSystem Define the JSON to parse
  50591. * @param scene Define the scene the parsed system should be instantiated in
  50592. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  50593. * @returns the parsed system
  50594. */
  50595. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  50596. /**
  50597. * Serialize the current Lens Flare System into a JSON representation.
  50598. * @returns the serialized JSON
  50599. */
  50600. serialize(): any;
  50601. }
  50602. }
  50603. declare module "babylonjs/LensFlares/lensFlare" {
  50604. import { Nullable } from "babylonjs/types";
  50605. import { Color3 } from "babylonjs/Maths/math";
  50606. import { Texture } from "babylonjs/Materials/Textures/texture";
  50607. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  50608. /**
  50609. * This represents one of the lens effect in a `lensFlareSystem`.
  50610. * It controls one of the indiviual texture used in the effect.
  50611. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50612. */
  50613. export class LensFlare {
  50614. /**
  50615. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  50616. */
  50617. size: number;
  50618. /**
  50619. * 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.
  50620. */
  50621. position: number;
  50622. /**
  50623. * Define the lens color.
  50624. */
  50625. color: Color3;
  50626. /**
  50627. * Define the lens texture.
  50628. */
  50629. texture: Nullable<Texture>;
  50630. /**
  50631. * Define the alpha mode to render this particular lens.
  50632. */
  50633. alphaMode: number;
  50634. private _system;
  50635. /**
  50636. * Creates a new Lens Flare.
  50637. * This represents one of the lens effect in a `lensFlareSystem`.
  50638. * It controls one of the indiviual texture used in the effect.
  50639. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50640. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  50641. * @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.
  50642. * @param color Define the lens color
  50643. * @param imgUrl Define the lens texture url
  50644. * @param system Define the `lensFlareSystem` this flare is part of
  50645. * @returns The newly created Lens Flare
  50646. */
  50647. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  50648. /**
  50649. * Instantiates a new Lens Flare.
  50650. * This represents one of the lens effect in a `lensFlareSystem`.
  50651. * It controls one of the indiviual texture used in the effect.
  50652. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50653. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  50654. * @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.
  50655. * @param color Define the lens color
  50656. * @param imgUrl Define the lens texture url
  50657. * @param system Define the `lensFlareSystem` this flare is part of
  50658. */
  50659. constructor(
  50660. /**
  50661. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  50662. */
  50663. size: number,
  50664. /**
  50665. * 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.
  50666. */
  50667. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  50668. /**
  50669. * Dispose and release the lens flare with its associated resources.
  50670. */
  50671. dispose(): void;
  50672. }
  50673. }
  50674. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  50675. import { Nullable } from "babylonjs/types";
  50676. import { Scene } from "babylonjs/scene";
  50677. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  50678. import { AbstractScene } from "babylonjs/abstractScene";
  50679. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  50680. module "babylonjs/abstractScene" {
  50681. interface AbstractScene {
  50682. /**
  50683. * The list of lens flare system added to the scene
  50684. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50685. */
  50686. lensFlareSystems: Array<LensFlareSystem>;
  50687. /**
  50688. * Removes the given lens flare system from this scene.
  50689. * @param toRemove The lens flare system to remove
  50690. * @returns The index of the removed lens flare system
  50691. */
  50692. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  50693. /**
  50694. * Adds the given lens flare system to this scene
  50695. * @param newLensFlareSystem The lens flare system to add
  50696. */
  50697. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  50698. /**
  50699. * Gets a lens flare system using its name
  50700. * @param name defines the name to look for
  50701. * @returns the lens flare system or null if not found
  50702. */
  50703. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  50704. /**
  50705. * Gets a lens flare system using its id
  50706. * @param id defines the id to look for
  50707. * @returns the lens flare system or null if not found
  50708. */
  50709. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  50710. }
  50711. }
  50712. /**
  50713. * Defines the lens flare scene component responsible to manage any lens flares
  50714. * in a given scene.
  50715. */
  50716. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  50717. /**
  50718. * The component name helpfull to identify the component in the list of scene components.
  50719. */
  50720. readonly name: string;
  50721. /**
  50722. * The scene the component belongs to.
  50723. */
  50724. scene: Scene;
  50725. /**
  50726. * Creates a new instance of the component for the given scene
  50727. * @param scene Defines the scene to register the component in
  50728. */
  50729. constructor(scene: Scene);
  50730. /**
  50731. * Registers the component in a given scene
  50732. */
  50733. register(): void;
  50734. /**
  50735. * Rebuilds the elements related to this component in case of
  50736. * context lost for instance.
  50737. */
  50738. rebuild(): void;
  50739. /**
  50740. * Adds all the elements from the container to the scene
  50741. * @param container the container holding the elements
  50742. */
  50743. addFromContainer(container: AbstractScene): void;
  50744. /**
  50745. * Removes all the elements in the container from the scene
  50746. * @param container contains the elements to remove
  50747. * @param dispose if the removed element should be disposed (default: false)
  50748. */
  50749. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50750. /**
  50751. * Serializes the component data to the specified json object
  50752. * @param serializationObject The object to serialize to
  50753. */
  50754. serialize(serializationObject: any): void;
  50755. /**
  50756. * Disposes the component and the associated ressources.
  50757. */
  50758. dispose(): void;
  50759. private _draw;
  50760. }
  50761. }
  50762. declare module "babylonjs/LensFlares/index" {
  50763. export * from "babylonjs/LensFlares/lensFlare";
  50764. export * from "babylonjs/LensFlares/lensFlareSystem";
  50765. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  50766. }
  50767. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  50768. import { Scene } from "babylonjs/scene";
  50769. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  50770. import { AbstractScene } from "babylonjs/abstractScene";
  50771. /**
  50772. * Defines the shadow generator component responsible to manage any shadow generators
  50773. * in a given scene.
  50774. */
  50775. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  50776. /**
  50777. * The component name helpfull to identify the component in the list of scene components.
  50778. */
  50779. readonly name: string;
  50780. /**
  50781. * The scene the component belongs to.
  50782. */
  50783. scene: Scene;
  50784. /**
  50785. * Creates a new instance of the component for the given scene
  50786. * @param scene Defines the scene to register the component in
  50787. */
  50788. constructor(scene: Scene);
  50789. /**
  50790. * Registers the component in a given scene
  50791. */
  50792. register(): void;
  50793. /**
  50794. * Rebuilds the elements related to this component in case of
  50795. * context lost for instance.
  50796. */
  50797. rebuild(): void;
  50798. /**
  50799. * Serializes the component data to the specified json object
  50800. * @param serializationObject The object to serialize to
  50801. */
  50802. serialize(serializationObject: any): void;
  50803. /**
  50804. * Adds all the elements from the container to the scene
  50805. * @param container the container holding the elements
  50806. */
  50807. addFromContainer(container: AbstractScene): void;
  50808. /**
  50809. * Removes all the elements in the container from the scene
  50810. * @param container contains the elements to remove
  50811. * @param dispose if the removed element should be disposed (default: false)
  50812. */
  50813. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50814. /**
  50815. * Rebuilds the elements related to this component in case of
  50816. * context lost for instance.
  50817. */
  50818. dispose(): void;
  50819. private _gatherRenderTargets;
  50820. }
  50821. }
  50822. declare module "babylonjs/Lights/Shadows/index" {
  50823. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  50824. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  50825. }
  50826. declare module "babylonjs/Lights/pointLight" {
  50827. import { Scene } from "babylonjs/scene";
  50828. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  50829. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50830. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  50831. import { Effect } from "babylonjs/Materials/effect";
  50832. /**
  50833. * A point light is a light defined by an unique point in world space.
  50834. * The light is emitted in every direction from this point.
  50835. * A good example of a point light is a standard light bulb.
  50836. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50837. */
  50838. export class PointLight extends ShadowLight {
  50839. private _shadowAngle;
  50840. /**
  50841. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50842. * This specifies what angle the shadow will use to be created.
  50843. *
  50844. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50845. */
  50846. /**
  50847. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50848. * This specifies what angle the shadow will use to be created.
  50849. *
  50850. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50851. */
  50852. shadowAngle: number;
  50853. /**
  50854. * Gets the direction if it has been set.
  50855. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50856. */
  50857. /**
  50858. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50859. */
  50860. direction: Vector3;
  50861. /**
  50862. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  50863. * A PointLight emits the light in every direction.
  50864. * It can cast shadows.
  50865. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  50866. * ```javascript
  50867. * var pointLight = new PointLight("pl", camera.position, scene);
  50868. * ```
  50869. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50870. * @param name The light friendly name
  50871. * @param position The position of the point light in the scene
  50872. * @param scene The scene the lights belongs to
  50873. */
  50874. constructor(name: string, position: Vector3, scene: Scene);
  50875. /**
  50876. * Returns the string "PointLight"
  50877. * @returns the class name
  50878. */
  50879. getClassName(): string;
  50880. /**
  50881. * Returns the integer 0.
  50882. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50883. */
  50884. getTypeID(): number;
  50885. /**
  50886. * Specifies wether or not the shadowmap should be a cube texture.
  50887. * @returns true if the shadowmap needs to be a cube texture.
  50888. */
  50889. needCube(): boolean;
  50890. /**
  50891. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  50892. * @param faceIndex The index of the face we are computed the direction to generate shadow
  50893. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  50894. */
  50895. getShadowDirection(faceIndex?: number): Vector3;
  50896. /**
  50897. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  50898. * - fov = PI / 2
  50899. * - aspect ratio : 1.0
  50900. * - z-near and far equal to the active camera minZ and maxZ.
  50901. * Returns the PointLight.
  50902. */
  50903. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50904. protected _buildUniformLayout(): void;
  50905. /**
  50906. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  50907. * @param effect The effect to update
  50908. * @param lightIndex The index of the light in the effect to update
  50909. * @returns The point light
  50910. */
  50911. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  50912. /**
  50913. * Prepares the list of defines specific to the light type.
  50914. * @param defines the list of defines
  50915. * @param lightIndex defines the index of the light for the effect
  50916. */
  50917. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50918. }
  50919. }
  50920. declare module "babylonjs/Lights/index" {
  50921. export * from "babylonjs/Lights/light";
  50922. export * from "babylonjs/Lights/shadowLight";
  50923. export * from "babylonjs/Lights/Shadows/index";
  50924. export * from "babylonjs/Lights/directionalLight";
  50925. export * from "babylonjs/Lights/hemisphericLight";
  50926. export * from "babylonjs/Lights/pointLight";
  50927. export * from "babylonjs/Lights/spotLight";
  50928. }
  50929. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  50930. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  50931. /**
  50932. * Header information of HDR texture files.
  50933. */
  50934. export interface HDRInfo {
  50935. /**
  50936. * The height of the texture in pixels.
  50937. */
  50938. height: number;
  50939. /**
  50940. * The width of the texture in pixels.
  50941. */
  50942. width: number;
  50943. /**
  50944. * The index of the beginning of the data in the binary file.
  50945. */
  50946. dataPosition: number;
  50947. }
  50948. /**
  50949. * This groups tools to convert HDR texture to native colors array.
  50950. */
  50951. export class HDRTools {
  50952. private static Ldexp;
  50953. private static Rgbe2float;
  50954. private static readStringLine;
  50955. /**
  50956. * Reads header information from an RGBE texture stored in a native array.
  50957. * More information on this format are available here:
  50958. * https://en.wikipedia.org/wiki/RGBE_image_format
  50959. *
  50960. * @param uint8array The binary file stored in native array.
  50961. * @return The header information.
  50962. */
  50963. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  50964. /**
  50965. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  50966. * This RGBE texture needs to store the information as a panorama.
  50967. *
  50968. * More information on this format are available here:
  50969. * https://en.wikipedia.org/wiki/RGBE_image_format
  50970. *
  50971. * @param buffer The binary file stored in an array buffer.
  50972. * @param size The expected size of the extracted cubemap.
  50973. * @return The Cube Map information.
  50974. */
  50975. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  50976. /**
  50977. * Returns the pixels data extracted from an RGBE texture.
  50978. * This pixels will be stored left to right up to down in the R G B order in one array.
  50979. *
  50980. * More information on this format are available here:
  50981. * https://en.wikipedia.org/wiki/RGBE_image_format
  50982. *
  50983. * @param uint8array The binary file stored in an array buffer.
  50984. * @param hdrInfo The header information of the file.
  50985. * @return The pixels data in RGB right to left up to down order.
  50986. */
  50987. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  50988. private static RGBE_ReadPixels_RLE;
  50989. }
  50990. }
  50991. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  50992. import { Nullable } from "babylonjs/types";
  50993. import { Scene } from "babylonjs/scene";
  50994. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  50995. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50996. import "babylonjs/Engines/Extensions/engine.rawTexture";
  50997. /**
  50998. * This represents a texture coming from an HDR input.
  50999. *
  51000. * The only supported format is currently panorama picture stored in RGBE format.
  51001. * Example of such files can be found on HDRLib: http://hdrlib.com/
  51002. */
  51003. export class HDRCubeTexture extends BaseTexture {
  51004. private static _facesMapping;
  51005. private _generateHarmonics;
  51006. private _noMipmap;
  51007. private _textureMatrix;
  51008. private _size;
  51009. private _onLoad;
  51010. private _onError;
  51011. /**
  51012. * The texture URL.
  51013. */
  51014. url: string;
  51015. /**
  51016. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  51017. */
  51018. coordinatesMode: number;
  51019. protected _isBlocking: boolean;
  51020. /**
  51021. * Sets wether or not the texture is blocking during loading.
  51022. */
  51023. /**
  51024. * Gets wether or not the texture is blocking during loading.
  51025. */
  51026. isBlocking: boolean;
  51027. protected _rotationY: number;
  51028. /**
  51029. * Sets texture matrix rotation angle around Y axis in radians.
  51030. */
  51031. /**
  51032. * Gets texture matrix rotation angle around Y axis radians.
  51033. */
  51034. rotationY: number;
  51035. /**
  51036. * Gets or sets the center of the bounding box associated with the cube texture
  51037. * It must define where the camera used to render the texture was set
  51038. */
  51039. boundingBoxPosition: Vector3;
  51040. private _boundingBoxSize;
  51041. /**
  51042. * Gets or sets the size of the bounding box associated with the cube texture
  51043. * When defined, the cubemap will switch to local mode
  51044. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  51045. * @example https://www.babylonjs-playground.com/#RNASML
  51046. */
  51047. boundingBoxSize: Vector3;
  51048. /**
  51049. * Instantiates an HDRTexture from the following parameters.
  51050. *
  51051. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  51052. * @param scene The scene the texture will be used in
  51053. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  51054. * @param noMipmap Forces to not generate the mipmap if true
  51055. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  51056. * @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)
  51057. * @param reserved Reserved flag for internal use.
  51058. */
  51059. 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>);
  51060. /**
  51061. * Get the current class name of the texture useful for serialization or dynamic coding.
  51062. * @returns "HDRCubeTexture"
  51063. */
  51064. getClassName(): string;
  51065. /**
  51066. * Occurs when the file is raw .hdr file.
  51067. */
  51068. private loadTexture;
  51069. clone(): HDRCubeTexture;
  51070. delayLoad(): void;
  51071. /**
  51072. * Get the texture reflection matrix used to rotate/transform the reflection.
  51073. * @returns the reflection matrix
  51074. */
  51075. getReflectionTextureMatrix(): Matrix;
  51076. /**
  51077. * Set the texture reflection matrix used to rotate/transform the reflection.
  51078. * @param value Define the reflection matrix to set
  51079. */
  51080. setReflectionTextureMatrix(value: Matrix): void;
  51081. /**
  51082. * Parses a JSON representation of an HDR Texture in order to create the texture
  51083. * @param parsedTexture Define the JSON representation
  51084. * @param scene Define the scene the texture should be created in
  51085. * @param rootUrl Define the root url in case we need to load relative dependencies
  51086. * @returns the newly created texture after parsing
  51087. */
  51088. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  51089. serialize(): any;
  51090. }
  51091. }
  51092. declare module "babylonjs/Physics/physicsEngine" {
  51093. import { Nullable } from "babylonjs/types";
  51094. import { Vector3 } from "babylonjs/Maths/math";
  51095. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  51096. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  51097. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  51098. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  51099. /**
  51100. * Class used to control physics engine
  51101. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  51102. */
  51103. export class PhysicsEngine implements IPhysicsEngine {
  51104. private _physicsPlugin;
  51105. /**
  51106. * Global value used to control the smallest number supported by the simulation
  51107. */
  51108. static Epsilon: number;
  51109. private _impostors;
  51110. private _joints;
  51111. /**
  51112. * Gets the gravity vector used by the simulation
  51113. */
  51114. gravity: Vector3;
  51115. /**
  51116. * Factory used to create the default physics plugin.
  51117. * @returns The default physics plugin
  51118. */
  51119. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  51120. /**
  51121. * Creates a new Physics Engine
  51122. * @param gravity defines the gravity vector used by the simulation
  51123. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  51124. */
  51125. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  51126. /**
  51127. * Sets the gravity vector used by the simulation
  51128. * @param gravity defines the gravity vector to use
  51129. */
  51130. setGravity(gravity: Vector3): void;
  51131. /**
  51132. * Set the time step of the physics engine.
  51133. * Default is 1/60.
  51134. * To slow it down, enter 1/600 for example.
  51135. * To speed it up, 1/30
  51136. * @param newTimeStep defines the new timestep to apply to this world.
  51137. */
  51138. setTimeStep(newTimeStep?: number): void;
  51139. /**
  51140. * Get the time step of the physics engine.
  51141. * @returns the current time step
  51142. */
  51143. getTimeStep(): number;
  51144. /**
  51145. * Release all resources
  51146. */
  51147. dispose(): void;
  51148. /**
  51149. * Gets the name of the current physics plugin
  51150. * @returns the name of the plugin
  51151. */
  51152. getPhysicsPluginName(): string;
  51153. /**
  51154. * Adding a new impostor for the impostor tracking.
  51155. * This will be done by the impostor itself.
  51156. * @param impostor the impostor to add
  51157. */
  51158. addImpostor(impostor: PhysicsImpostor): void;
  51159. /**
  51160. * Remove an impostor from the engine.
  51161. * This impostor and its mesh will not longer be updated by the physics engine.
  51162. * @param impostor the impostor to remove
  51163. */
  51164. removeImpostor(impostor: PhysicsImpostor): void;
  51165. /**
  51166. * Add a joint to the physics engine
  51167. * @param mainImpostor defines the main impostor to which the joint is added.
  51168. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  51169. * @param joint defines the joint that will connect both impostors.
  51170. */
  51171. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  51172. /**
  51173. * Removes a joint from the simulation
  51174. * @param mainImpostor defines the impostor used with the joint
  51175. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  51176. * @param joint defines the joint to remove
  51177. */
  51178. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  51179. /**
  51180. * Called by the scene. No need to call it.
  51181. * @param delta defines the timespam between frames
  51182. */
  51183. _step(delta: number): void;
  51184. /**
  51185. * Gets the current plugin used to run the simulation
  51186. * @returns current plugin
  51187. */
  51188. getPhysicsPlugin(): IPhysicsEnginePlugin;
  51189. /**
  51190. * Gets the list of physic impostors
  51191. * @returns an array of PhysicsImpostor
  51192. */
  51193. getImpostors(): Array<PhysicsImpostor>;
  51194. /**
  51195. * Gets the impostor for a physics enabled object
  51196. * @param object defines the object impersonated by the impostor
  51197. * @returns the PhysicsImpostor or null if not found
  51198. */
  51199. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  51200. /**
  51201. * Gets the impostor for a physics body object
  51202. * @param body defines physics body used by the impostor
  51203. * @returns the PhysicsImpostor or null if not found
  51204. */
  51205. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  51206. /**
  51207. * Does a raycast in the physics world
  51208. * @param from when should the ray start?
  51209. * @param to when should the ray end?
  51210. * @returns PhysicsRaycastResult
  51211. */
  51212. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51213. }
  51214. }
  51215. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  51216. import { Nullable } from "babylonjs/types";
  51217. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  51218. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51219. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  51220. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51221. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  51222. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  51223. /** @hidden */
  51224. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  51225. private _useDeltaForWorldStep;
  51226. world: any;
  51227. name: string;
  51228. private _physicsMaterials;
  51229. private _fixedTimeStep;
  51230. private _cannonRaycastResult;
  51231. private _raycastResult;
  51232. private _physicsBodysToRemoveAfterStep;
  51233. BJSCANNON: any;
  51234. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  51235. setGravity(gravity: Vector3): void;
  51236. setTimeStep(timeStep: number): void;
  51237. getTimeStep(): number;
  51238. executeStep(delta: number): void;
  51239. private _removeMarkedPhysicsBodiesFromWorld;
  51240. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51241. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51242. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51243. private _processChildMeshes;
  51244. removePhysicsBody(impostor: PhysicsImpostor): void;
  51245. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51246. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51247. private _addMaterial;
  51248. private _checkWithEpsilon;
  51249. private _createShape;
  51250. private _createHeightmap;
  51251. private _minus90X;
  51252. private _plus90X;
  51253. private _tmpPosition;
  51254. private _tmpDeltaPosition;
  51255. private _tmpUnityRotation;
  51256. private _updatePhysicsBodyTransformation;
  51257. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51258. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51259. isSupported(): boolean;
  51260. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51261. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51262. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51263. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51264. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51265. getBodyMass(impostor: PhysicsImpostor): number;
  51266. getBodyFriction(impostor: PhysicsImpostor): number;
  51267. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51268. getBodyRestitution(impostor: PhysicsImpostor): number;
  51269. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51270. sleepBody(impostor: PhysicsImpostor): void;
  51271. wakeUpBody(impostor: PhysicsImpostor): void;
  51272. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  51273. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  51274. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51275. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51276. getRadius(impostor: PhysicsImpostor): number;
  51277. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51278. dispose(): void;
  51279. private _extendNamespace;
  51280. /**
  51281. * Does a raycast in the physics world
  51282. * @param from when should the ray start?
  51283. * @param to when should the ray end?
  51284. * @returns PhysicsRaycastResult
  51285. */
  51286. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51287. }
  51288. }
  51289. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  51290. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  51291. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51292. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  51293. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51294. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  51295. import { Nullable } from "babylonjs/types";
  51296. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  51297. /** @hidden */
  51298. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  51299. world: any;
  51300. name: string;
  51301. BJSOIMO: any;
  51302. private _raycastResult;
  51303. constructor(iterations?: number, oimoInjection?: any);
  51304. setGravity(gravity: Vector3): void;
  51305. setTimeStep(timeStep: number): void;
  51306. getTimeStep(): number;
  51307. private _tmpImpostorsArray;
  51308. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  51309. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51310. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51311. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51312. private _tmpPositionVector;
  51313. removePhysicsBody(impostor: PhysicsImpostor): void;
  51314. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51315. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51316. isSupported(): boolean;
  51317. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51318. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51319. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51320. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51321. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51322. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51323. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51324. getBodyMass(impostor: PhysicsImpostor): number;
  51325. getBodyFriction(impostor: PhysicsImpostor): number;
  51326. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51327. getBodyRestitution(impostor: PhysicsImpostor): number;
  51328. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51329. sleepBody(impostor: PhysicsImpostor): void;
  51330. wakeUpBody(impostor: PhysicsImpostor): void;
  51331. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51332. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  51333. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  51334. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51335. getRadius(impostor: PhysicsImpostor): number;
  51336. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51337. dispose(): void;
  51338. /**
  51339. * Does a raycast in the physics world
  51340. * @param from when should the ray start?
  51341. * @param to when should the ray end?
  51342. * @returns PhysicsRaycastResult
  51343. */
  51344. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51345. }
  51346. }
  51347. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  51348. import { Nullable } from "babylonjs/types";
  51349. import { Scene } from "babylonjs/scene";
  51350. import { Vector3, Vector2, Color4, Vector4 } from "babylonjs/Maths/math";
  51351. import { Mesh } from "babylonjs/Meshes/mesh";
  51352. /**
  51353. * Class containing static functions to help procedurally build meshes
  51354. */
  51355. export class RibbonBuilder {
  51356. /**
  51357. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51358. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  51359. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  51360. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  51361. * * 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
  51362. * * 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
  51363. * * 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
  51364. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51365. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51366. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51367. * * 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
  51368. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  51369. * * 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
  51370. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  51371. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51372. * @param name defines the name of the mesh
  51373. * @param options defines the options used to create the mesh
  51374. * @param scene defines the hosting scene
  51375. * @returns the ribbon mesh
  51376. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  51377. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51378. */
  51379. static CreateRibbon(name: string, options: {
  51380. pathArray: Vector3[][];
  51381. closeArray?: boolean;
  51382. closePath?: boolean;
  51383. offset?: number;
  51384. updatable?: boolean;
  51385. sideOrientation?: number;
  51386. frontUVs?: Vector4;
  51387. backUVs?: Vector4;
  51388. instance?: Mesh;
  51389. invertUV?: boolean;
  51390. uvs?: Vector2[];
  51391. colors?: Color4[];
  51392. }, scene?: Nullable<Scene>): Mesh;
  51393. }
  51394. }
  51395. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  51396. import { Nullable } from "babylonjs/types";
  51397. import { Scene } from "babylonjs/scene";
  51398. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  51399. import { Mesh } from "babylonjs/Meshes/mesh";
  51400. /**
  51401. * Class containing static functions to help procedurally build meshes
  51402. */
  51403. export class ShapeBuilder {
  51404. /**
  51405. * 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.
  51406. * * 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.
  51407. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51408. * * 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.
  51409. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  51410. * * 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
  51411. * * 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
  51412. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  51413. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51414. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51415. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  51416. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51417. * @param name defines the name of the mesh
  51418. * @param options defines the options used to create the mesh
  51419. * @param scene defines the hosting scene
  51420. * @returns the extruded shape mesh
  51421. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51422. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51423. */
  51424. static ExtrudeShape(name: string, options: {
  51425. shape: Vector3[];
  51426. path: Vector3[];
  51427. scale?: number;
  51428. rotation?: number;
  51429. cap?: number;
  51430. updatable?: boolean;
  51431. sideOrientation?: number;
  51432. frontUVs?: Vector4;
  51433. backUVs?: Vector4;
  51434. instance?: Mesh;
  51435. invertUV?: boolean;
  51436. }, scene?: Nullable<Scene>): Mesh;
  51437. /**
  51438. * Creates an custom extruded shape mesh.
  51439. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  51440. * * 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.
  51441. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51442. * * 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
  51443. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  51444. * * 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
  51445. * * It must returns a float value that will be the scale value applied to the shape on each path point
  51446. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  51447. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  51448. * * 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
  51449. * * 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
  51450. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  51451. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51452. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51453. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51454. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51455. * @param name defines the name of the mesh
  51456. * @param options defines the options used to create the mesh
  51457. * @param scene defines the hosting scene
  51458. * @returns the custom extruded shape mesh
  51459. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  51460. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51461. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51462. */
  51463. static ExtrudeShapeCustom(name: string, options: {
  51464. shape: Vector3[];
  51465. path: Vector3[];
  51466. scaleFunction?: any;
  51467. rotationFunction?: any;
  51468. ribbonCloseArray?: boolean;
  51469. ribbonClosePath?: boolean;
  51470. cap?: number;
  51471. updatable?: boolean;
  51472. sideOrientation?: number;
  51473. frontUVs?: Vector4;
  51474. backUVs?: Vector4;
  51475. instance?: Mesh;
  51476. invertUV?: boolean;
  51477. }, scene?: Nullable<Scene>): Mesh;
  51478. private static _ExtrudeShapeGeneric;
  51479. }
  51480. }
  51481. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  51482. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  51483. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  51484. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51485. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  51486. import { Nullable } from "babylonjs/types";
  51487. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51488. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  51489. /**
  51490. * AmmoJS Physics plugin
  51491. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51492. * @see https://github.com/kripken/ammo.js/
  51493. */
  51494. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  51495. private _useDeltaForWorldStep;
  51496. /**
  51497. * Reference to the Ammo library
  51498. */
  51499. bjsAMMO: any;
  51500. /**
  51501. * Created ammoJS world which physics bodies are added to
  51502. */
  51503. world: any;
  51504. /**
  51505. * Name of the plugin
  51506. */
  51507. name: string;
  51508. private _timeStep;
  51509. private _fixedTimeStep;
  51510. private _maxSteps;
  51511. private _tmpQuaternion;
  51512. private _tmpAmmoTransform;
  51513. private _tmpAmmoQuaternion;
  51514. private _tmpAmmoConcreteContactResultCallback;
  51515. private _collisionConfiguration;
  51516. private _dispatcher;
  51517. private _overlappingPairCache;
  51518. private _solver;
  51519. private _softBodySolver;
  51520. private _tmpAmmoVectorA;
  51521. private _tmpAmmoVectorB;
  51522. private _tmpAmmoVectorC;
  51523. private _tmpAmmoVectorD;
  51524. private _tmpContactCallbackResult;
  51525. private _tmpAmmoVectorRCA;
  51526. private _tmpAmmoVectorRCB;
  51527. private _raycastResult;
  51528. private static readonly DISABLE_COLLISION_FLAG;
  51529. private static readonly KINEMATIC_FLAG;
  51530. private static readonly DISABLE_DEACTIVATION_FLAG;
  51531. /**
  51532. * Initializes the ammoJS plugin
  51533. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  51534. * @param ammoInjection can be used to inject your own ammo reference
  51535. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  51536. */
  51537. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  51538. /**
  51539. * Sets the gravity of the physics world (m/(s^2))
  51540. * @param gravity Gravity to set
  51541. */
  51542. setGravity(gravity: Vector3): void;
  51543. /**
  51544. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  51545. * @param timeStep timestep to use in seconds
  51546. */
  51547. setTimeStep(timeStep: number): void;
  51548. /**
  51549. * 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)
  51550. * @param fixedTimeStep fixedTimeStep to use in seconds
  51551. */
  51552. setFixedTimeStep(fixedTimeStep: number): void;
  51553. /**
  51554. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  51555. * @param maxSteps the maximum number of steps by the physics engine per frame
  51556. */
  51557. setMaxSteps(maxSteps: number): void;
  51558. /**
  51559. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  51560. * @returns the current timestep in seconds
  51561. */
  51562. getTimeStep(): number;
  51563. private _isImpostorInContact;
  51564. private _isImpostorPairInContact;
  51565. private _stepSimulation;
  51566. /**
  51567. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  51568. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  51569. * After the step the babylon meshes are set to the position of the physics imposters
  51570. * @param delta amount of time to step forward
  51571. * @param impostors array of imposters to update before/after the step
  51572. */
  51573. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  51574. /**
  51575. * Update babylon mesh to match physics world object
  51576. * @param impostor imposter to match
  51577. */
  51578. private _afterSoftStep;
  51579. /**
  51580. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  51581. * @param impostor imposter to match
  51582. */
  51583. private _ropeStep;
  51584. /**
  51585. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  51586. * @param impostor imposter to match
  51587. */
  51588. private _softbodyOrClothStep;
  51589. private _tmpVector;
  51590. private _tmpMatrix;
  51591. /**
  51592. * Applies an impulse on the imposter
  51593. * @param impostor imposter to apply impulse to
  51594. * @param force amount of force to be applied to the imposter
  51595. * @param contactPoint the location to apply the impulse on the imposter
  51596. */
  51597. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51598. /**
  51599. * Applies a force on the imposter
  51600. * @param impostor imposter to apply force
  51601. * @param force amount of force to be applied to the imposter
  51602. * @param contactPoint the location to apply the force on the imposter
  51603. */
  51604. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51605. /**
  51606. * Creates a physics body using the plugin
  51607. * @param impostor the imposter to create the physics body on
  51608. */
  51609. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51610. /**
  51611. * Removes the physics body from the imposter and disposes of the body's memory
  51612. * @param impostor imposter to remove the physics body from
  51613. */
  51614. removePhysicsBody(impostor: PhysicsImpostor): void;
  51615. /**
  51616. * Generates a joint
  51617. * @param impostorJoint the imposter joint to create the joint with
  51618. */
  51619. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51620. /**
  51621. * Removes a joint
  51622. * @param impostorJoint the imposter joint to remove the joint from
  51623. */
  51624. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51625. private _addMeshVerts;
  51626. /**
  51627. * Initialise the soft body vertices to match its object's (mesh) vertices
  51628. * Softbody vertices (nodes) are in world space and to match this
  51629. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  51630. * @param impostor to create the softbody for
  51631. */
  51632. private _softVertexData;
  51633. /**
  51634. * Create an impostor's soft body
  51635. * @param impostor to create the softbody for
  51636. */
  51637. private _createSoftbody;
  51638. /**
  51639. * Create cloth for an impostor
  51640. * @param impostor to create the softbody for
  51641. */
  51642. private _createCloth;
  51643. /**
  51644. * Create rope for an impostor
  51645. * @param impostor to create the softbody for
  51646. */
  51647. private _createRope;
  51648. private _addHullVerts;
  51649. private _createShape;
  51650. /**
  51651. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  51652. * @param impostor imposter containing the physics body and babylon object
  51653. */
  51654. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51655. /**
  51656. * Sets the babylon object's position/rotation from the physics body's position/rotation
  51657. * @param impostor imposter containing the physics body and babylon object
  51658. * @param newPosition new position
  51659. * @param newRotation new rotation
  51660. */
  51661. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51662. /**
  51663. * If this plugin is supported
  51664. * @returns true if its supported
  51665. */
  51666. isSupported(): boolean;
  51667. /**
  51668. * Sets the linear velocity of the physics body
  51669. * @param impostor imposter to set the velocity on
  51670. * @param velocity velocity to set
  51671. */
  51672. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51673. /**
  51674. * Sets the angular velocity of the physics body
  51675. * @param impostor imposter to set the velocity on
  51676. * @param velocity velocity to set
  51677. */
  51678. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51679. /**
  51680. * gets the linear velocity
  51681. * @param impostor imposter to get linear velocity from
  51682. * @returns linear velocity
  51683. */
  51684. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51685. /**
  51686. * gets the angular velocity
  51687. * @param impostor imposter to get angular velocity from
  51688. * @returns angular velocity
  51689. */
  51690. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51691. /**
  51692. * Sets the mass of physics body
  51693. * @param impostor imposter to set the mass on
  51694. * @param mass mass to set
  51695. */
  51696. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51697. /**
  51698. * Gets the mass of the physics body
  51699. * @param impostor imposter to get the mass from
  51700. * @returns mass
  51701. */
  51702. getBodyMass(impostor: PhysicsImpostor): number;
  51703. /**
  51704. * Gets friction of the impostor
  51705. * @param impostor impostor to get friction from
  51706. * @returns friction value
  51707. */
  51708. getBodyFriction(impostor: PhysicsImpostor): number;
  51709. /**
  51710. * Sets friction of the impostor
  51711. * @param impostor impostor to set friction on
  51712. * @param friction friction value
  51713. */
  51714. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51715. /**
  51716. * Gets restitution of the impostor
  51717. * @param impostor impostor to get restitution from
  51718. * @returns restitution value
  51719. */
  51720. getBodyRestitution(impostor: PhysicsImpostor): number;
  51721. /**
  51722. * Sets resitution of the impostor
  51723. * @param impostor impostor to set resitution on
  51724. * @param restitution resitution value
  51725. */
  51726. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51727. /**
  51728. * Gets pressure inside the impostor
  51729. * @param impostor impostor to get pressure from
  51730. * @returns pressure value
  51731. */
  51732. getBodyPressure(impostor: PhysicsImpostor): number;
  51733. /**
  51734. * Sets pressure inside a soft body impostor
  51735. * Cloth and rope must remain 0 pressure
  51736. * @param impostor impostor to set pressure on
  51737. * @param pressure pressure value
  51738. */
  51739. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  51740. /**
  51741. * Gets stiffness of the impostor
  51742. * @param impostor impostor to get stiffness from
  51743. * @returns pressure value
  51744. */
  51745. getBodyStiffness(impostor: PhysicsImpostor): number;
  51746. /**
  51747. * Sets stiffness of the impostor
  51748. * @param impostor impostor to set stiffness on
  51749. * @param stiffness stiffness value from 0 to 1
  51750. */
  51751. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  51752. /**
  51753. * Gets velocityIterations of the impostor
  51754. * @param impostor impostor to get velocity iterations from
  51755. * @returns velocityIterations value
  51756. */
  51757. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  51758. /**
  51759. * Sets velocityIterations of the impostor
  51760. * @param impostor impostor to set velocity iterations on
  51761. * @param velocityIterations velocityIterations value
  51762. */
  51763. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  51764. /**
  51765. * Gets positionIterations of the impostor
  51766. * @param impostor impostor to get position iterations from
  51767. * @returns positionIterations value
  51768. */
  51769. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  51770. /**
  51771. * Sets positionIterations of the impostor
  51772. * @param impostor impostor to set position on
  51773. * @param positionIterations positionIterations value
  51774. */
  51775. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  51776. /**
  51777. * Append an anchor to a cloth object
  51778. * @param impostor is the cloth impostor to add anchor to
  51779. * @param otherImpostor is the rigid impostor to anchor to
  51780. * @param width ratio across width from 0 to 1
  51781. * @param height ratio up height from 0 to 1
  51782. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  51783. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  51784. */
  51785. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  51786. /**
  51787. * Append an hook to a rope object
  51788. * @param impostor is the rope impostor to add hook to
  51789. * @param otherImpostor is the rigid impostor to hook to
  51790. * @param length ratio along the rope from 0 to 1
  51791. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  51792. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  51793. */
  51794. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  51795. /**
  51796. * Sleeps the physics body and stops it from being active
  51797. * @param impostor impostor to sleep
  51798. */
  51799. sleepBody(impostor: PhysicsImpostor): void;
  51800. /**
  51801. * Activates the physics body
  51802. * @param impostor impostor to activate
  51803. */
  51804. wakeUpBody(impostor: PhysicsImpostor): void;
  51805. /**
  51806. * Updates the distance parameters of the joint
  51807. * @param joint joint to update
  51808. * @param maxDistance maximum distance of the joint
  51809. * @param minDistance minimum distance of the joint
  51810. */
  51811. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51812. /**
  51813. * Sets a motor on the joint
  51814. * @param joint joint to set motor on
  51815. * @param speed speed of the motor
  51816. * @param maxForce maximum force of the motor
  51817. * @param motorIndex index of the motor
  51818. */
  51819. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  51820. /**
  51821. * Sets the motors limit
  51822. * @param joint joint to set limit on
  51823. * @param upperLimit upper limit
  51824. * @param lowerLimit lower limit
  51825. */
  51826. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51827. /**
  51828. * Syncs the position and rotation of a mesh with the impostor
  51829. * @param mesh mesh to sync
  51830. * @param impostor impostor to update the mesh with
  51831. */
  51832. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51833. /**
  51834. * Gets the radius of the impostor
  51835. * @param impostor impostor to get radius from
  51836. * @returns the radius
  51837. */
  51838. getRadius(impostor: PhysicsImpostor): number;
  51839. /**
  51840. * Gets the box size of the impostor
  51841. * @param impostor impostor to get box size from
  51842. * @param result the resulting box size
  51843. */
  51844. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51845. /**
  51846. * Disposes of the impostor
  51847. */
  51848. dispose(): void;
  51849. /**
  51850. * Does a raycast in the physics world
  51851. * @param from when should the ray start?
  51852. * @param to when should the ray end?
  51853. * @returns PhysicsRaycastResult
  51854. */
  51855. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51856. }
  51857. }
  51858. declare module "babylonjs/Probes/reflectionProbe" {
  51859. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51860. import { Vector3 } from "babylonjs/Maths/math";
  51861. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51862. import { Nullable } from "babylonjs/types";
  51863. import { Scene } from "babylonjs/scene";
  51864. module "babylonjs/abstractScene" {
  51865. interface AbstractScene {
  51866. /**
  51867. * The list of reflection probes added to the scene
  51868. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51869. */
  51870. reflectionProbes: Array<ReflectionProbe>;
  51871. /**
  51872. * Removes the given reflection probe from this scene.
  51873. * @param toRemove The reflection probe to remove
  51874. * @returns The index of the removed reflection probe
  51875. */
  51876. removeReflectionProbe(toRemove: ReflectionProbe): number;
  51877. /**
  51878. * Adds the given reflection probe to this scene.
  51879. * @param newReflectionProbe The reflection probe to add
  51880. */
  51881. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  51882. }
  51883. }
  51884. /**
  51885. * Class used to generate realtime reflection / refraction cube textures
  51886. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51887. */
  51888. export class ReflectionProbe {
  51889. /** defines the name of the probe */
  51890. name: string;
  51891. private _scene;
  51892. private _renderTargetTexture;
  51893. private _projectionMatrix;
  51894. private _viewMatrix;
  51895. private _target;
  51896. private _add;
  51897. private _attachedMesh;
  51898. private _invertYAxis;
  51899. /** Gets or sets probe position (center of the cube map) */
  51900. position: Vector3;
  51901. /**
  51902. * Creates a new reflection probe
  51903. * @param name defines the name of the probe
  51904. * @param size defines the texture resolution (for each face)
  51905. * @param scene defines the hosting scene
  51906. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  51907. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  51908. */
  51909. constructor(
  51910. /** defines the name of the probe */
  51911. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  51912. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  51913. samples: number;
  51914. /** Gets or sets the refresh rate to use (on every frame by default) */
  51915. refreshRate: number;
  51916. /**
  51917. * Gets the hosting scene
  51918. * @returns a Scene
  51919. */
  51920. getScene(): Scene;
  51921. /** Gets the internal CubeTexture used to render to */
  51922. readonly cubeTexture: RenderTargetTexture;
  51923. /** Gets the list of meshes to render */
  51924. readonly renderList: Nullable<AbstractMesh[]>;
  51925. /**
  51926. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  51927. * @param mesh defines the mesh to attach to
  51928. */
  51929. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  51930. /**
  51931. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  51932. * @param renderingGroupId The rendering group id corresponding to its index
  51933. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  51934. */
  51935. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  51936. /**
  51937. * Clean all associated resources
  51938. */
  51939. dispose(): void;
  51940. /**
  51941. * Converts the reflection probe information to a readable string for debug purpose.
  51942. * @param fullDetails Supports for multiple levels of logging within scene loading
  51943. * @returns the human readable reflection probe info
  51944. */
  51945. toString(fullDetails?: boolean): string;
  51946. /**
  51947. * Get the class name of the relfection probe.
  51948. * @returns "ReflectionProbe"
  51949. */
  51950. getClassName(): string;
  51951. /**
  51952. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  51953. * @returns The JSON representation of the texture
  51954. */
  51955. serialize(): any;
  51956. /**
  51957. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  51958. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  51959. * @param scene Define the scene the parsed reflection probe should be instantiated in
  51960. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  51961. * @returns The parsed reflection probe if successful
  51962. */
  51963. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  51964. }
  51965. }
  51966. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  51967. /** @hidden */
  51968. export var _BabylonLoaderRegistered: boolean;
  51969. }
  51970. declare module "babylonjs/Loading/Plugins/index" {
  51971. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  51972. }
  51973. declare module "babylonjs/Loading/index" {
  51974. export * from "babylonjs/Loading/loadingScreen";
  51975. export * from "babylonjs/Loading/Plugins/index";
  51976. export * from "babylonjs/Loading/sceneLoader";
  51977. export * from "babylonjs/Loading/sceneLoaderFlags";
  51978. }
  51979. declare module "babylonjs/Materials/Background/index" {
  51980. export * from "babylonjs/Materials/Background/backgroundMaterial";
  51981. }
  51982. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  51983. import { Scene } from "babylonjs/scene";
  51984. import { Color3 } from "babylonjs/Maths/math";
  51985. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  51986. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51987. /**
  51988. * The Physically based simple base material of BJS.
  51989. *
  51990. * This enables better naming and convention enforcements on top of the pbrMaterial.
  51991. * It is used as the base class for both the specGloss and metalRough conventions.
  51992. */
  51993. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  51994. /**
  51995. * Number of Simultaneous lights allowed on the material.
  51996. */
  51997. maxSimultaneousLights: number;
  51998. /**
  51999. * If sets to true, disables all the lights affecting the material.
  52000. */
  52001. disableLighting: boolean;
  52002. /**
  52003. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  52004. */
  52005. environmentTexture: BaseTexture;
  52006. /**
  52007. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  52008. */
  52009. invertNormalMapX: boolean;
  52010. /**
  52011. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  52012. */
  52013. invertNormalMapY: boolean;
  52014. /**
  52015. * Normal map used in the model.
  52016. */
  52017. normalTexture: BaseTexture;
  52018. /**
  52019. * Emissivie color used to self-illuminate the model.
  52020. */
  52021. emissiveColor: Color3;
  52022. /**
  52023. * Emissivie texture used to self-illuminate the model.
  52024. */
  52025. emissiveTexture: BaseTexture;
  52026. /**
  52027. * Occlusion Channel Strenght.
  52028. */
  52029. occlusionStrength: number;
  52030. /**
  52031. * Occlusion Texture of the material (adding extra occlusion effects).
  52032. */
  52033. occlusionTexture: BaseTexture;
  52034. /**
  52035. * Defines the alpha limits in alpha test mode.
  52036. */
  52037. alphaCutOff: number;
  52038. /**
  52039. * Gets the current double sided mode.
  52040. */
  52041. /**
  52042. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52043. */
  52044. doubleSided: boolean;
  52045. /**
  52046. * Stores the pre-calculated light information of a mesh in a texture.
  52047. */
  52048. lightmapTexture: BaseTexture;
  52049. /**
  52050. * If true, the light map contains occlusion information instead of lighting info.
  52051. */
  52052. useLightmapAsShadowmap: boolean;
  52053. /**
  52054. * Instantiates a new PBRMaterial instance.
  52055. *
  52056. * @param name The material name
  52057. * @param scene The scene the material will be use in.
  52058. */
  52059. constructor(name: string, scene: Scene);
  52060. getClassName(): string;
  52061. }
  52062. }
  52063. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  52064. import { Scene } from "babylonjs/scene";
  52065. import { Color3 } from "babylonjs/Maths/math";
  52066. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52067. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  52068. /**
  52069. * The PBR material of BJS following the metal roughness convention.
  52070. *
  52071. * This fits to the PBR convention in the GLTF definition:
  52072. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  52073. */
  52074. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  52075. /**
  52076. * The base color has two different interpretations depending on the value of metalness.
  52077. * When the material is a metal, the base color is the specific measured reflectance value
  52078. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  52079. * of the material.
  52080. */
  52081. baseColor: Color3;
  52082. /**
  52083. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  52084. * well as opacity information in the alpha channel.
  52085. */
  52086. baseTexture: BaseTexture;
  52087. /**
  52088. * Specifies the metallic scalar value of the material.
  52089. * Can also be used to scale the metalness values of the metallic texture.
  52090. */
  52091. metallic: number;
  52092. /**
  52093. * Specifies the roughness scalar value of the material.
  52094. * Can also be used to scale the roughness values of the metallic texture.
  52095. */
  52096. roughness: number;
  52097. /**
  52098. * Texture containing both the metallic value in the B channel and the
  52099. * roughness value in the G channel to keep better precision.
  52100. */
  52101. metallicRoughnessTexture: BaseTexture;
  52102. /**
  52103. * Instantiates a new PBRMetalRoughnessMaterial instance.
  52104. *
  52105. * @param name The material name
  52106. * @param scene The scene the material will be use in.
  52107. */
  52108. constructor(name: string, scene: Scene);
  52109. /**
  52110. * Return the currrent class name of the material.
  52111. */
  52112. getClassName(): string;
  52113. /**
  52114. * Makes a duplicate of the current material.
  52115. * @param name - name to use for the new material.
  52116. */
  52117. clone(name: string): PBRMetallicRoughnessMaterial;
  52118. /**
  52119. * Serialize the material to a parsable JSON object.
  52120. */
  52121. serialize(): any;
  52122. /**
  52123. * Parses a JSON object correponding to the serialize function.
  52124. */
  52125. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  52126. }
  52127. }
  52128. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  52129. import { Scene } from "babylonjs/scene";
  52130. import { Color3 } from "babylonjs/Maths/math";
  52131. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52132. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  52133. /**
  52134. * The PBR material of BJS following the specular glossiness convention.
  52135. *
  52136. * This fits to the PBR convention in the GLTF definition:
  52137. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  52138. */
  52139. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  52140. /**
  52141. * Specifies the diffuse color of the material.
  52142. */
  52143. diffuseColor: Color3;
  52144. /**
  52145. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  52146. * channel.
  52147. */
  52148. diffuseTexture: BaseTexture;
  52149. /**
  52150. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  52151. */
  52152. specularColor: Color3;
  52153. /**
  52154. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  52155. */
  52156. glossiness: number;
  52157. /**
  52158. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  52159. */
  52160. specularGlossinessTexture: BaseTexture;
  52161. /**
  52162. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  52163. *
  52164. * @param name The material name
  52165. * @param scene The scene the material will be use in.
  52166. */
  52167. constructor(name: string, scene: Scene);
  52168. /**
  52169. * Return the currrent class name of the material.
  52170. */
  52171. getClassName(): string;
  52172. /**
  52173. * Makes a duplicate of the current material.
  52174. * @param name - name to use for the new material.
  52175. */
  52176. clone(name: string): PBRSpecularGlossinessMaterial;
  52177. /**
  52178. * Serialize the material to a parsable JSON object.
  52179. */
  52180. serialize(): any;
  52181. /**
  52182. * Parses a JSON object correponding to the serialize function.
  52183. */
  52184. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  52185. }
  52186. }
  52187. declare module "babylonjs/Materials/PBR/index" {
  52188. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  52189. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  52190. export * from "babylonjs/Materials/PBR/pbrMaterial";
  52191. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  52192. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  52193. }
  52194. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  52195. import { Nullable } from "babylonjs/types";
  52196. import { Scene } from "babylonjs/scene";
  52197. import { Matrix } from "babylonjs/Maths/math";
  52198. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52199. /**
  52200. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  52201. * It can help converting any input color in a desired output one. This can then be used to create effects
  52202. * from sepia, black and white to sixties or futuristic rendering...
  52203. *
  52204. * The only supported format is currently 3dl.
  52205. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  52206. */
  52207. export class ColorGradingTexture extends BaseTexture {
  52208. /**
  52209. * The current texture matrix. (will always be identity in color grading texture)
  52210. */
  52211. private _textureMatrix;
  52212. /**
  52213. * The texture URL.
  52214. */
  52215. url: string;
  52216. /**
  52217. * Empty line regex stored for GC.
  52218. */
  52219. private static _noneEmptyLineRegex;
  52220. private _engine;
  52221. /**
  52222. * Instantiates a ColorGradingTexture from the following parameters.
  52223. *
  52224. * @param url The location of the color gradind data (currently only supporting 3dl)
  52225. * @param scene The scene the texture will be used in
  52226. */
  52227. constructor(url: string, scene: Scene);
  52228. /**
  52229. * Returns the texture matrix used in most of the material.
  52230. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  52231. */
  52232. getTextureMatrix(): Matrix;
  52233. /**
  52234. * Occurs when the file being loaded is a .3dl LUT file.
  52235. */
  52236. private load3dlTexture;
  52237. /**
  52238. * Starts the loading process of the texture.
  52239. */
  52240. private loadTexture;
  52241. /**
  52242. * Clones the color gradind texture.
  52243. */
  52244. clone(): ColorGradingTexture;
  52245. /**
  52246. * Called during delayed load for textures.
  52247. */
  52248. delayLoad(): void;
  52249. /**
  52250. * Parses a color grading texture serialized by Babylon.
  52251. * @param parsedTexture The texture information being parsedTexture
  52252. * @param scene The scene to load the texture in
  52253. * @param rootUrl The root url of the data assets to load
  52254. * @return A color gradind texture
  52255. */
  52256. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  52257. /**
  52258. * Serializes the LUT texture to json format.
  52259. */
  52260. serialize(): any;
  52261. }
  52262. }
  52263. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  52264. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52265. import { Scene } from "babylonjs/scene";
  52266. import { Nullable } from "babylonjs/types";
  52267. import "babylonjs/Engines/Extensions/engine.rawTexture";
  52268. /**
  52269. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  52270. */
  52271. export class EquiRectangularCubeTexture extends BaseTexture {
  52272. /** The six faces of the cube. */
  52273. private static _FacesMapping;
  52274. private _noMipmap;
  52275. private _onLoad;
  52276. private _onError;
  52277. /** The size of the cubemap. */
  52278. private _size;
  52279. /** The buffer of the image. */
  52280. private _buffer;
  52281. /** The width of the input image. */
  52282. private _width;
  52283. /** The height of the input image. */
  52284. private _height;
  52285. /** The URL to the image. */
  52286. url: string;
  52287. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  52288. coordinatesMode: number;
  52289. /**
  52290. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  52291. * @param url The location of the image
  52292. * @param scene The scene the texture will be used in
  52293. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  52294. * @param noMipmap Forces to not generate the mipmap if true
  52295. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  52296. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  52297. * @param onLoad — defines a callback called when texture is loaded
  52298. * @param onError — defines a callback called if there is an error
  52299. */
  52300. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  52301. /**
  52302. * Load the image data, by putting the image on a canvas and extracting its buffer.
  52303. */
  52304. private loadImage;
  52305. /**
  52306. * Convert the image buffer into a cubemap and create a CubeTexture.
  52307. */
  52308. private loadTexture;
  52309. /**
  52310. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  52311. * @param buffer The ArrayBuffer that should be converted.
  52312. * @returns The buffer as Float32Array.
  52313. */
  52314. private getFloat32ArrayFromArrayBuffer;
  52315. /**
  52316. * Get the current class name of the texture useful for serialization or dynamic coding.
  52317. * @returns "EquiRectangularCubeTexture"
  52318. */
  52319. getClassName(): string;
  52320. /**
  52321. * Create a clone of the current EquiRectangularCubeTexture and return it.
  52322. * @returns A clone of the current EquiRectangularCubeTexture.
  52323. */
  52324. clone(): EquiRectangularCubeTexture;
  52325. }
  52326. }
  52327. declare module "babylonjs/Misc/tga" {
  52328. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52329. /**
  52330. * Based on jsTGALoader - Javascript loader for TGA file
  52331. * By Vincent Thibault
  52332. * @see http://blog.robrowser.com/javascript-tga-loader.html
  52333. */
  52334. export class TGATools {
  52335. private static _TYPE_INDEXED;
  52336. private static _TYPE_RGB;
  52337. private static _TYPE_GREY;
  52338. private static _TYPE_RLE_INDEXED;
  52339. private static _TYPE_RLE_RGB;
  52340. private static _TYPE_RLE_GREY;
  52341. private static _ORIGIN_MASK;
  52342. private static _ORIGIN_SHIFT;
  52343. private static _ORIGIN_BL;
  52344. private static _ORIGIN_BR;
  52345. private static _ORIGIN_UL;
  52346. private static _ORIGIN_UR;
  52347. /**
  52348. * Gets the header of a TGA file
  52349. * @param data defines the TGA data
  52350. * @returns the header
  52351. */
  52352. static GetTGAHeader(data: Uint8Array): any;
  52353. /**
  52354. * Uploads TGA content to a Babylon Texture
  52355. * @hidden
  52356. */
  52357. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  52358. /** @hidden */
  52359. 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;
  52360. /** @hidden */
  52361. 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;
  52362. /** @hidden */
  52363. 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;
  52364. /** @hidden */
  52365. 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;
  52366. /** @hidden */
  52367. 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;
  52368. /** @hidden */
  52369. 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;
  52370. }
  52371. }
  52372. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  52373. import { Nullable } from "babylonjs/types";
  52374. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52375. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  52376. /**
  52377. * Implementation of the TGA Texture Loader.
  52378. * @hidden
  52379. */
  52380. export class _TGATextureLoader implements IInternalTextureLoader {
  52381. /**
  52382. * Defines wether the loader supports cascade loading the different faces.
  52383. */
  52384. readonly supportCascades: boolean;
  52385. /**
  52386. * This returns if the loader support the current file information.
  52387. * @param extension defines the file extension of the file being loaded
  52388. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52389. * @param fallback defines the fallback internal texture if any
  52390. * @param isBase64 defines whether the texture is encoded as a base64
  52391. * @param isBuffer defines whether the texture data are stored as a buffer
  52392. * @returns true if the loader can load the specified file
  52393. */
  52394. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52395. /**
  52396. * Transform the url before loading if required.
  52397. * @param rootUrl the url of the texture
  52398. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52399. * @returns the transformed texture
  52400. */
  52401. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52402. /**
  52403. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52404. * @param rootUrl the url of the texture
  52405. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52406. * @returns the fallback texture
  52407. */
  52408. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52409. /**
  52410. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52411. * @param data contains the texture data
  52412. * @param texture defines the BabylonJS internal texture
  52413. * @param createPolynomials will be true if polynomials have been requested
  52414. * @param onLoad defines the callback to trigger once the texture is ready
  52415. * @param onError defines the callback to trigger in case of error
  52416. */
  52417. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52418. /**
  52419. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52420. * @param data contains the texture data
  52421. * @param texture defines the BabylonJS internal texture
  52422. * @param callback defines the method to call once ready to upload
  52423. */
  52424. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52425. }
  52426. }
  52427. declare module "babylonjs/Misc/basis" {
  52428. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52429. /**
  52430. * Info about the .basis files
  52431. */
  52432. class BasisFileInfo {
  52433. /**
  52434. * If the file has alpha
  52435. */
  52436. hasAlpha: boolean;
  52437. /**
  52438. * Info about each image of the basis file
  52439. */
  52440. images: Array<{
  52441. levels: Array<{
  52442. width: number;
  52443. height: number;
  52444. transcodedPixels: ArrayBufferView;
  52445. }>;
  52446. }>;
  52447. }
  52448. /**
  52449. * Result of transcoding a basis file
  52450. */
  52451. class TranscodeResult {
  52452. /**
  52453. * Info about the .basis file
  52454. */
  52455. fileInfo: BasisFileInfo;
  52456. /**
  52457. * Format to use when loading the file
  52458. */
  52459. format: number;
  52460. }
  52461. /**
  52462. * Configuration options for the Basis transcoder
  52463. */
  52464. export class BasisTranscodeConfiguration {
  52465. /**
  52466. * Supported compression formats used to determine the supported output format of the transcoder
  52467. */
  52468. supportedCompressionFormats?: {
  52469. /**
  52470. * etc1 compression format
  52471. */
  52472. etc1?: boolean;
  52473. /**
  52474. * s3tc compression format
  52475. */
  52476. s3tc?: boolean;
  52477. /**
  52478. * pvrtc compression format
  52479. */
  52480. pvrtc?: boolean;
  52481. /**
  52482. * etc2 compression format
  52483. */
  52484. etc2?: boolean;
  52485. };
  52486. /**
  52487. * If mipmap levels should be loaded for transcoded images (Default: true)
  52488. */
  52489. loadMipmapLevels?: boolean;
  52490. /**
  52491. * Index of a single image to load (Default: all images)
  52492. */
  52493. loadSingleImage?: number;
  52494. }
  52495. /**
  52496. * Used to load .Basis files
  52497. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  52498. */
  52499. export class BasisTools {
  52500. private static _IgnoreSupportedFormats;
  52501. /**
  52502. * URL to use when loading the basis transcoder
  52503. */
  52504. static JSModuleURL: string;
  52505. /**
  52506. * URL to use when loading the wasm module for the transcoder
  52507. */
  52508. static WasmModuleURL: string;
  52509. /**
  52510. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  52511. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  52512. * @returns internal format corresponding to the Basis format
  52513. */
  52514. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  52515. private static _WorkerPromise;
  52516. private static _Worker;
  52517. private static _actionId;
  52518. private static _CreateWorkerAsync;
  52519. /**
  52520. * Transcodes a loaded image file to compressed pixel data
  52521. * @param imageData image data to transcode
  52522. * @param config configuration options for the transcoding
  52523. * @returns a promise resulting in the transcoded image
  52524. */
  52525. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  52526. /**
  52527. * Loads a texture from the transcode result
  52528. * @param texture texture load to
  52529. * @param transcodeResult the result of transcoding the basis file to load from
  52530. */
  52531. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  52532. }
  52533. }
  52534. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  52535. import { Nullable } from "babylonjs/types";
  52536. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52537. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  52538. /**
  52539. * Loader for .basis file format
  52540. */
  52541. export class _BasisTextureLoader implements IInternalTextureLoader {
  52542. /**
  52543. * Defines whether the loader supports cascade loading the different faces.
  52544. */
  52545. readonly supportCascades: boolean;
  52546. /**
  52547. * This returns if the loader support the current file information.
  52548. * @param extension defines the file extension of the file being loaded
  52549. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52550. * @param fallback defines the fallback internal texture if any
  52551. * @param isBase64 defines whether the texture is encoded as a base64
  52552. * @param isBuffer defines whether the texture data are stored as a buffer
  52553. * @returns true if the loader can load the specified file
  52554. */
  52555. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52556. /**
  52557. * Transform the url before loading if required.
  52558. * @param rootUrl the url of the texture
  52559. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52560. * @returns the transformed texture
  52561. */
  52562. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52563. /**
  52564. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52565. * @param rootUrl the url of the texture
  52566. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52567. * @returns the fallback texture
  52568. */
  52569. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52570. /**
  52571. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  52572. * @param data contains the texture data
  52573. * @param texture defines the BabylonJS internal texture
  52574. * @param createPolynomials will be true if polynomials have been requested
  52575. * @param onLoad defines the callback to trigger once the texture is ready
  52576. * @param onError defines the callback to trigger in case of error
  52577. */
  52578. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52579. /**
  52580. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52581. * @param data contains the texture data
  52582. * @param texture defines the BabylonJS internal texture
  52583. * @param callback defines the method to call once ready to upload
  52584. */
  52585. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52586. }
  52587. }
  52588. declare module "babylonjs/Materials/Textures/Loaders/index" {
  52589. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  52590. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  52591. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  52592. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  52593. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  52594. }
  52595. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  52596. import { Scene } from "babylonjs/scene";
  52597. import { Texture } from "babylonjs/Materials/Textures/texture";
  52598. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  52599. /**
  52600. * 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.
  52601. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  52602. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  52603. */
  52604. export class CustomProceduralTexture extends ProceduralTexture {
  52605. private _animate;
  52606. private _time;
  52607. private _config;
  52608. private _texturePath;
  52609. /**
  52610. * Instantiates a new Custom Procedural Texture.
  52611. * 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.
  52612. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  52613. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  52614. * @param name Define the name of the texture
  52615. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  52616. * @param size Define the size of the texture to create
  52617. * @param scene Define the scene the texture belongs to
  52618. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  52619. * @param generateMipMaps Define if the texture should creates mip maps or not
  52620. */
  52621. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  52622. private _loadJson;
  52623. /**
  52624. * Is the texture ready to be used ? (rendered at least once)
  52625. * @returns true if ready, otherwise, false.
  52626. */
  52627. isReady(): boolean;
  52628. /**
  52629. * Render the texture to its associated render target.
  52630. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  52631. */
  52632. render(useCameraPostProcess?: boolean): void;
  52633. /**
  52634. * Update the list of dependant textures samplers in the shader.
  52635. */
  52636. updateTextures(): void;
  52637. /**
  52638. * Update the uniform values of the procedural texture in the shader.
  52639. */
  52640. updateShaderUniforms(): void;
  52641. /**
  52642. * Define if the texture animates or not.
  52643. */
  52644. animate: boolean;
  52645. }
  52646. }
  52647. declare module "babylonjs/Shaders/noise.fragment" {
  52648. /** @hidden */
  52649. export var noisePixelShader: {
  52650. name: string;
  52651. shader: string;
  52652. };
  52653. }
  52654. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  52655. import { Nullable } from "babylonjs/types";
  52656. import { Scene } from "babylonjs/scene";
  52657. import { Texture } from "babylonjs/Materials/Textures/texture";
  52658. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  52659. import "babylonjs/Shaders/noise.fragment";
  52660. /**
  52661. * Class used to generate noise procedural textures
  52662. */
  52663. export class NoiseProceduralTexture extends ProceduralTexture {
  52664. private _time;
  52665. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  52666. brightness: number;
  52667. /** Defines the number of octaves to process */
  52668. octaves: number;
  52669. /** Defines the level of persistence (0.8 by default) */
  52670. persistence: number;
  52671. /** Gets or sets animation speed factor (default is 1) */
  52672. animationSpeedFactor: number;
  52673. /**
  52674. * Creates a new NoiseProceduralTexture
  52675. * @param name defines the name fo the texture
  52676. * @param size defines the size of the texture (default is 256)
  52677. * @param scene defines the hosting scene
  52678. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  52679. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  52680. */
  52681. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  52682. private _updateShaderUniforms;
  52683. protected _getDefines(): string;
  52684. /** Generate the current state of the procedural texture */
  52685. render(useCameraPostProcess?: boolean): void;
  52686. /**
  52687. * Serializes this noise procedural texture
  52688. * @returns a serialized noise procedural texture object
  52689. */
  52690. serialize(): any;
  52691. /**
  52692. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  52693. * @param parsedTexture defines parsed texture data
  52694. * @param scene defines the current scene
  52695. * @param rootUrl defines the root URL containing noise procedural texture information
  52696. * @returns a parsed NoiseProceduralTexture
  52697. */
  52698. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  52699. }
  52700. }
  52701. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  52702. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  52703. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  52704. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  52705. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  52706. }
  52707. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  52708. import { Nullable } from "babylonjs/types";
  52709. import { Scene } from "babylonjs/scene";
  52710. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  52711. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52712. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  52713. import "babylonjs/Engines/Extensions/engine.rawTexture";
  52714. /**
  52715. * Raw cube texture where the raw buffers are passed in
  52716. */
  52717. export class RawCubeTexture extends CubeTexture {
  52718. /**
  52719. * Creates a cube texture where the raw buffers are passed in.
  52720. * @param scene defines the scene the texture is attached to
  52721. * @param data defines the array of data to use to create each face
  52722. * @param size defines the size of the textures
  52723. * @param format defines the format of the data
  52724. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  52725. * @param generateMipMaps defines if the engine should generate the mip levels
  52726. * @param invertY defines if data must be stored with Y axis inverted
  52727. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  52728. * @param compression defines the compression used (null by default)
  52729. */
  52730. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  52731. /**
  52732. * Updates the raw cube texture.
  52733. * @param data defines the data to store
  52734. * @param format defines the data format
  52735. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  52736. * @param invertY defines if data must be stored with Y axis inverted
  52737. * @param compression defines the compression used (null by default)
  52738. * @param level defines which level of the texture to update
  52739. */
  52740. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  52741. /**
  52742. * Updates a raw cube texture with RGBD encoded data.
  52743. * @param data defines the array of data [mipmap][face] to use to create each face
  52744. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  52745. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  52746. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  52747. * @returns a promsie that resolves when the operation is complete
  52748. */
  52749. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  52750. /**
  52751. * Clones the raw cube texture.
  52752. * @return a new cube texture
  52753. */
  52754. clone(): CubeTexture;
  52755. /** @hidden */
  52756. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  52757. }
  52758. }
  52759. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  52760. import { Scene } from "babylonjs/scene";
  52761. import { Texture } from "babylonjs/Materials/Textures/texture";
  52762. import "babylonjs/Engines/Extensions/engine.rawTexture";
  52763. /**
  52764. * Class used to store 3D textures containing user data
  52765. */
  52766. export class RawTexture3D extends Texture {
  52767. /** Gets or sets the texture format to use */
  52768. format: number;
  52769. private _engine;
  52770. /**
  52771. * Create a new RawTexture3D
  52772. * @param data defines the data of the texture
  52773. * @param width defines the width of the texture
  52774. * @param height defines the height of the texture
  52775. * @param depth defines the depth of the texture
  52776. * @param format defines the texture format to use
  52777. * @param scene defines the hosting scene
  52778. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  52779. * @param invertY defines if texture must be stored with Y axis inverted
  52780. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  52781. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  52782. */
  52783. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  52784. /** Gets or sets the texture format to use */
  52785. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  52786. /**
  52787. * Update the texture with new data
  52788. * @param data defines the data to store in the texture
  52789. */
  52790. update(data: ArrayBufferView): void;
  52791. }
  52792. }
  52793. declare module "babylonjs/Materials/Textures/refractionTexture" {
  52794. import { Scene } from "babylonjs/scene";
  52795. import { Plane } from "babylonjs/Maths/math";
  52796. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52797. /**
  52798. * Creates a refraction texture used by refraction channel of the standard material.
  52799. * It is like a mirror but to see through a material.
  52800. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52801. */
  52802. export class RefractionTexture extends RenderTargetTexture {
  52803. /**
  52804. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  52805. * 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.
  52806. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52807. */
  52808. refractionPlane: Plane;
  52809. /**
  52810. * Define how deep under the surface we should see.
  52811. */
  52812. depth: number;
  52813. /**
  52814. * Creates a refraction texture used by refraction channel of the standard material.
  52815. * It is like a mirror but to see through a material.
  52816. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52817. * @param name Define the texture name
  52818. * @param size Define the size of the underlying texture
  52819. * @param scene Define the scene the refraction belongs to
  52820. * @param generateMipMaps Define if we need to generate mips level for the refraction
  52821. */
  52822. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  52823. /**
  52824. * Clone the refraction texture.
  52825. * @returns the cloned texture
  52826. */
  52827. clone(): RefractionTexture;
  52828. /**
  52829. * Serialize the texture to a JSON representation you could use in Parse later on
  52830. * @returns the serialized JSON representation
  52831. */
  52832. serialize(): any;
  52833. }
  52834. }
  52835. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  52836. import { Nullable } from "babylonjs/types";
  52837. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52838. import { Matrix } from "babylonjs/Maths/math";
  52839. import { Engine } from "babylonjs/Engines/engine";
  52840. import { Scene } from "babylonjs/scene";
  52841. /**
  52842. * Defines the options related to the creation of an HtmlElementTexture
  52843. */
  52844. export interface IHtmlElementTextureOptions {
  52845. /**
  52846. * Defines wether mip maps should be created or not.
  52847. */
  52848. generateMipMaps?: boolean;
  52849. /**
  52850. * Defines the sampling mode of the texture.
  52851. */
  52852. samplingMode?: number;
  52853. /**
  52854. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  52855. */
  52856. engine: Nullable<Engine>;
  52857. /**
  52858. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  52859. */
  52860. scene: Nullable<Scene>;
  52861. }
  52862. /**
  52863. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  52864. * To be as efficient as possible depending on your constraints nothing aside the first upload
  52865. * is automatically managed.
  52866. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  52867. * in your application.
  52868. *
  52869. * As the update is not automatic, you need to call them manually.
  52870. */
  52871. export class HtmlElementTexture extends BaseTexture {
  52872. /**
  52873. * The texture URL.
  52874. */
  52875. element: HTMLVideoElement | HTMLCanvasElement;
  52876. private static readonly DefaultOptions;
  52877. private _textureMatrix;
  52878. private _engine;
  52879. private _isVideo;
  52880. private _generateMipMaps;
  52881. private _samplingMode;
  52882. /**
  52883. * Instantiates a HtmlElementTexture from the following parameters.
  52884. *
  52885. * @param name Defines the name of the texture
  52886. * @param element Defines the video or canvas the texture is filled with
  52887. * @param options Defines the other none mandatory texture creation options
  52888. */
  52889. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  52890. private _createInternalTexture;
  52891. /**
  52892. * Returns the texture matrix used in most of the material.
  52893. */
  52894. getTextureMatrix(): Matrix;
  52895. /**
  52896. * Updates the content of the texture.
  52897. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  52898. */
  52899. update(invertY?: Nullable<boolean>): void;
  52900. }
  52901. }
  52902. declare module "babylonjs/Materials/Textures/index" {
  52903. export * from "babylonjs/Materials/Textures/baseTexture";
  52904. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  52905. export * from "babylonjs/Materials/Textures/cubeTexture";
  52906. export * from "babylonjs/Materials/Textures/dynamicTexture";
  52907. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  52908. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  52909. export * from "babylonjs/Materials/Textures/internalTexture";
  52910. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  52911. export * from "babylonjs/Materials/Textures/Loaders/index";
  52912. export * from "babylonjs/Materials/Textures/mirrorTexture";
  52913. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  52914. export * from "babylonjs/Materials/Textures/Procedurals/index";
  52915. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  52916. export * from "babylonjs/Materials/Textures/rawTexture";
  52917. export * from "babylonjs/Materials/Textures/rawTexture3D";
  52918. export * from "babylonjs/Materials/Textures/refractionTexture";
  52919. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  52920. export * from "babylonjs/Materials/Textures/texture";
  52921. export * from "babylonjs/Materials/Textures/videoTexture";
  52922. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  52923. }
  52924. declare module "babylonjs/Materials/Node/nodeMaterialBlockTargets" {
  52925. /**
  52926. * Enum used to define the target of a block
  52927. */
  52928. export enum NodeMaterialBlockTargets {
  52929. /** Vertex shader */
  52930. Vertex = 1,
  52931. /** Fragment shader */
  52932. Fragment = 2,
  52933. /** Vertex and Fragment */
  52934. VertexAndFragment = 3
  52935. }
  52936. }
  52937. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes" {
  52938. /**
  52939. * Defines the kind of connection point for node based material
  52940. */
  52941. export enum NodeMaterialBlockConnectionPointTypes {
  52942. /** Float */
  52943. Float = 1,
  52944. /** Int */
  52945. Int = 2,
  52946. /** Vector2 */
  52947. Vector2 = 4,
  52948. /** Vector3 */
  52949. Vector3 = 8,
  52950. /** Vector4 */
  52951. Vector4 = 16,
  52952. /** Color3 */
  52953. Color3 = 32,
  52954. /** Color4 */
  52955. Color4 = 64,
  52956. /** Matrix */
  52957. Matrix = 128,
  52958. /** Texture */
  52959. Texture = 256,
  52960. /** Texture3D */
  52961. Texture3D = 512,
  52962. /** Vector3 or Color3 */
  52963. Vector3OrColor3 = 40,
  52964. /** Vector3 or Vector4 */
  52965. Vector3OrVector4 = 24,
  52966. /** Vector4 or Color4 */
  52967. Vector4OrColor4 = 80,
  52968. /** Color3 or Color4 */
  52969. Color3OrColor4 = 96,
  52970. /** Vector3 or Color3 */
  52971. Vector3OrColor3OrVector4OrColor4 = 120,
  52972. /** Detect type based on connection */
  52973. AutoDetect = 1024,
  52974. /** Output type that will be defined by input type */
  52975. BasedOnInput = 2048,
  52976. /** Light */
  52977. Light = 4096
  52978. }
  52979. }
  52980. declare module "babylonjs/Materials/Node/nodeMaterialWellKnownValues" {
  52981. /**
  52982. * Enum used to define well known values e.g. values automatically provided by the system
  52983. */
  52984. export enum NodeMaterialWellKnownValues {
  52985. /** World */
  52986. World = 1,
  52987. /** View */
  52988. View = 2,
  52989. /** Projection */
  52990. Projection = 3,
  52991. /** ViewProjection */
  52992. ViewProjection = 4,
  52993. /** WorldView */
  52994. WorldView = 5,
  52995. /** WorldViewProjection */
  52996. WorldViewProjection = 6,
  52997. /** CameraPosition */
  52998. CameraPosition = 7,
  52999. /** Will be filled by the block itself */
  53000. Automatic = 8
  53001. }
  53002. }
  53003. declare module "babylonjs/Materials/Node/NodeMaterialBlockConnectionPointMode" {
  53004. /**
  53005. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  53006. */
  53007. export enum NodeMaterialBlockConnectionPointMode {
  53008. /** Value is an uniform */
  53009. Uniform = 0,
  53010. /** Value is a mesh attribute */
  53011. Attribute = 1,
  53012. /** Value is a varying between vertex and fragment shaders */
  53013. Varying = 2,
  53014. /** Mode is undefined */
  53015. Undefined = 3
  53016. }
  53017. }
  53018. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  53019. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53020. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53021. /**
  53022. * Class used to store shared data between 2 NodeMaterialBuildState
  53023. */
  53024. export class NodeMaterialBuildStateSharedData {
  53025. /**
  53026. * Gets the list of emitted varyings
  53027. */
  53028. varyings: string[];
  53029. /**
  53030. * Gets the varying declaration string
  53031. */
  53032. varyingDeclaration: string;
  53033. /**
  53034. * Uniform connection points
  53035. */
  53036. uniformConnectionPoints: NodeMaterialConnectionPoint[];
  53037. /**
  53038. * Bindable blocks (Blocks that need to set data to the effect)
  53039. */
  53040. bindableBlocks: NodeMaterialBlock[];
  53041. /**
  53042. * List of blocks that can provide a compilation fallback
  53043. */
  53044. blocksWithFallbacks: NodeMaterialBlock[];
  53045. /**
  53046. * List of blocks that can provide a define update
  53047. */
  53048. blocksWithDefines: NodeMaterialBlock[];
  53049. /**
  53050. * List of blocks that can provide a repeatable content
  53051. */
  53052. repeatableContentBlocks: NodeMaterialBlock[];
  53053. /**
  53054. * List of blocks that can block the isReady function for the material
  53055. */
  53056. blockingBlocks: NodeMaterialBlock[];
  53057. /**
  53058. * Build Id used to avoid multiple recompilations
  53059. */
  53060. buildId: number;
  53061. /** List of emitted variables */
  53062. variableNames: {
  53063. [key: string]: number;
  53064. };
  53065. /** List of emitted defines */
  53066. defineNames: {
  53067. [key: string]: number;
  53068. };
  53069. /** Should emit comments? */
  53070. emitComments: boolean;
  53071. /** Emit build activity */
  53072. verbose: boolean;
  53073. /**
  53074. * Gets the compilation hints emitted at compilation time
  53075. */
  53076. hints: {
  53077. needWorldViewMatrix: boolean;
  53078. needWorldViewProjectionMatrix: boolean;
  53079. needAlphaBlending: boolean;
  53080. needAlphaTesting: boolean;
  53081. };
  53082. /**
  53083. * List of compilation checks
  53084. */
  53085. checks: {
  53086. emitVertex: boolean;
  53087. emitFragment: boolean;
  53088. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  53089. };
  53090. /** Creates a new shared data */
  53091. constructor();
  53092. /**
  53093. * Emits console errors and exceptions if there is a failing check
  53094. */
  53095. emitErrors(): void;
  53096. }
  53097. }
  53098. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  53099. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53100. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  53101. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  53102. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  53103. import { Nullable } from "babylonjs/types";
  53104. /**
  53105. * Class used to store node based material build state
  53106. */
  53107. export class NodeMaterialBuildState {
  53108. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  53109. supportUniformBuffers: boolean;
  53110. /**
  53111. * Gets the list of emitted attributes
  53112. */
  53113. attributes: string[];
  53114. /**
  53115. * Gets the list of emitted uniforms
  53116. */
  53117. uniforms: string[];
  53118. /**
  53119. * Gets the list of emitted uniform buffers
  53120. */
  53121. uniformBuffers: string[];
  53122. /**
  53123. * Gets the list of emitted samplers
  53124. */
  53125. samplers: string[];
  53126. /**
  53127. * Gets the list of emitted functions
  53128. */
  53129. functions: {
  53130. [key: string]: string;
  53131. };
  53132. /**
  53133. * Gets the target of the compilation state
  53134. */
  53135. target: NodeMaterialBlockTargets;
  53136. /**
  53137. * Gets the list of emitted counters
  53138. */
  53139. counters: {
  53140. [key: string]: number;
  53141. };
  53142. /**
  53143. * Shared data between multiple NodeMaterialBuildState instances
  53144. */
  53145. sharedData: NodeMaterialBuildStateSharedData;
  53146. /** @hidden */
  53147. _vertexState: NodeMaterialBuildState;
  53148. private _attributeDeclaration;
  53149. private _uniformDeclaration;
  53150. private _samplerDeclaration;
  53151. private _varyingTransfer;
  53152. private _repeatableContentAnchorIndex;
  53153. /** @hidden */
  53154. _builtCompilationString: string;
  53155. /**
  53156. * Gets the emitted compilation strings
  53157. */
  53158. compilationString: string;
  53159. /**
  53160. * Finalize the compilation strings
  53161. * @param state defines the current compilation state
  53162. */
  53163. finalize(state: NodeMaterialBuildState): void;
  53164. /** @hidden */
  53165. readonly _repeatableContentAnchor: string;
  53166. /** @hidden */
  53167. _getFreeVariableName(prefix: string): string;
  53168. /** @hidden */
  53169. _getFreeDefineName(prefix: string): string;
  53170. /** @hidden */
  53171. _excludeVariableName(name: string): void;
  53172. /** @hidden */
  53173. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  53174. /** @hidden */
  53175. _emitFunction(name: string, code: string, comments: string): void;
  53176. /** @hidden */
  53177. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  53178. replaceStrings?: {
  53179. search: RegExp;
  53180. replace: string;
  53181. }[];
  53182. }): string;
  53183. /** @hidden */
  53184. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  53185. repeatKey?: string;
  53186. removeAttributes?: boolean;
  53187. removeUniforms?: boolean;
  53188. removeVaryings?: boolean;
  53189. removeIfDef?: boolean;
  53190. replaceStrings?: {
  53191. search: RegExp;
  53192. replace: string;
  53193. }[];
  53194. }, storeKey?: string): void;
  53195. /** @hidden */
  53196. _emitVaryings(point: NodeMaterialConnectionPoint, define?: string, force?: boolean, fromFragment?: boolean, replacementName?: string, type?: Nullable<NodeMaterialBlockConnectionPointTypes>): void;
  53197. private _emitDefine;
  53198. /** @hidden */
  53199. _emitUniformOrAttributes(point: NodeMaterialConnectionPoint, define?: string): void;
  53200. }
  53201. }
  53202. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  53203. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53204. /**
  53205. * Root class for all node material optimizers
  53206. */
  53207. export class NodeMaterialOptimizer {
  53208. /**
  53209. * Function used to optimize a NodeMaterial graph
  53210. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  53211. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  53212. */
  53213. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  53214. }
  53215. }
  53216. declare module "babylonjs/Materials/Node/Blocks/vector4TransformBlock" {
  53217. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53218. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53219. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53220. /**
  53221. * Block used to transform a vector4 with a matrix
  53222. */
  53223. export class Vector4TransformBlock extends NodeMaterialBlock {
  53224. /**
  53225. * Defines the value to use to complement Vector3 to transform it to a Vector4
  53226. */
  53227. complementW: number;
  53228. /**
  53229. * Creates a new Vector4TransformBlock
  53230. * @param name defines the block name
  53231. */
  53232. constructor(name: string);
  53233. /**
  53234. * Gets the current class name
  53235. * @returns the class name
  53236. */
  53237. getClassName(): string;
  53238. /**
  53239. * Gets the vector input
  53240. */
  53241. readonly vector: NodeMaterialConnectionPoint;
  53242. /**
  53243. * Gets the output component
  53244. */
  53245. readonly output: NodeMaterialConnectionPoint;
  53246. /**
  53247. * Gets the matrix transform input
  53248. */
  53249. readonly transform: NodeMaterialConnectionPoint;
  53250. protected _buildBlock(state: NodeMaterialBuildState): this;
  53251. }
  53252. }
  53253. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  53254. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53255. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53256. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53257. /**
  53258. * Block used to output the vertex position
  53259. */
  53260. export class VertexOutputBlock extends NodeMaterialBlock {
  53261. /**
  53262. * Creates a new VertexOutputBlock
  53263. * @param name defines the block name
  53264. */
  53265. constructor(name: string);
  53266. /**
  53267. * Gets the current class name
  53268. * @returns the class name
  53269. */
  53270. getClassName(): string;
  53271. /**
  53272. * Gets the vector input component
  53273. */
  53274. readonly vector: NodeMaterialConnectionPoint;
  53275. protected _buildBlock(state: NodeMaterialBuildState): this;
  53276. }
  53277. }
  53278. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  53279. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53280. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53281. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53282. /**
  53283. * Block used to output the final color
  53284. */
  53285. export class FragmentOutputBlock extends NodeMaterialBlock {
  53286. /**
  53287. * Gets or sets a boolean indicating if this block will output an alpha value
  53288. */
  53289. alphaBlendingEnabled: boolean;
  53290. /**
  53291. * Create a new FragmentOutputBlock
  53292. * @param name defines the block name
  53293. */
  53294. constructor(name: string);
  53295. /**
  53296. * Gets the current class name
  53297. * @returns the class name
  53298. */
  53299. getClassName(): string;
  53300. /**
  53301. * Gets the color input component
  53302. */
  53303. readonly color: NodeMaterialConnectionPoint;
  53304. protected _buildBlock(state: NodeMaterialBuildState): this;
  53305. }
  53306. }
  53307. declare module "babylonjs/Materials/Node/nodeMaterial" {
  53308. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53309. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  53310. import { Scene } from "babylonjs/scene";
  53311. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53312. import { Matrix } from "babylonjs/Maths/math";
  53313. import { Mesh } from "babylonjs/Meshes/mesh";
  53314. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53315. import { Observable } from "babylonjs/Misc/observable";
  53316. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53317. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  53318. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  53319. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  53320. import { Nullable } from "babylonjs/types";
  53321. /**
  53322. * Interface used to configure the node material editor
  53323. */
  53324. export interface INodeMaterialEditorOptions {
  53325. /** Define the URl to load node editor script */
  53326. editorURL?: string;
  53327. }
  53328. /** @hidden */
  53329. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  53330. /** BONES */
  53331. NUM_BONE_INFLUENCERS: number;
  53332. BonesPerMesh: number;
  53333. BONETEXTURE: boolean;
  53334. /** MORPH TARGETS */
  53335. MORPHTARGETS: boolean;
  53336. MORPHTARGETS_NORMAL: boolean;
  53337. MORPHTARGETS_TANGENT: boolean;
  53338. MORPHTARGETS_UV: boolean;
  53339. NUM_MORPH_INFLUENCERS: number;
  53340. /** IMAGE PROCESSING */
  53341. IMAGEPROCESSING: boolean;
  53342. VIGNETTE: boolean;
  53343. VIGNETTEBLENDMODEMULTIPLY: boolean;
  53344. VIGNETTEBLENDMODEOPAQUE: boolean;
  53345. TONEMAPPING: boolean;
  53346. TONEMAPPING_ACES: boolean;
  53347. CONTRAST: boolean;
  53348. EXPOSURE: boolean;
  53349. COLORCURVES: boolean;
  53350. COLORGRADING: boolean;
  53351. COLORGRADING3D: boolean;
  53352. SAMPLER3DGREENDEPTH: boolean;
  53353. SAMPLER3DBGRMAP: boolean;
  53354. IMAGEPROCESSINGPOSTPROCESS: boolean;
  53355. constructor();
  53356. setValue(name: string, value: boolean): void;
  53357. }
  53358. /**
  53359. * Class used to configure NodeMaterial
  53360. */
  53361. export interface INodeMaterialOptions {
  53362. /**
  53363. * Defines if blocks should emit comments
  53364. */
  53365. emitComments: boolean;
  53366. }
  53367. /**
  53368. * Class used to create a node based material built by assembling shader blocks
  53369. */
  53370. export class NodeMaterial extends PushMaterial {
  53371. private _options;
  53372. private _vertexCompilationState;
  53373. private _fragmentCompilationState;
  53374. private _sharedData;
  53375. private _buildId;
  53376. private _buildWasSuccessful;
  53377. private _cachedWorldViewMatrix;
  53378. private _cachedWorldViewProjectionMatrix;
  53379. private _textureConnectionPoints;
  53380. private _optimizers;
  53381. /** Define the URl to load node editor script */
  53382. static EditorURL: string;
  53383. private BJSNODEMATERIALEDITOR;
  53384. /** Get the inspector from bundle or global */
  53385. private _getGlobalNodeMaterialEditor;
  53386. /**
  53387. * Defines the maximum number of lights that can be used in the material
  53388. */
  53389. maxSimultaneousLights: number;
  53390. /**
  53391. * Observable raised when the material is built
  53392. */
  53393. onBuildObservable: Observable<NodeMaterial>;
  53394. /**
  53395. * Gets or sets the root nodes of the material vertex shader
  53396. */
  53397. _vertexOutputNodes: NodeMaterialBlock[];
  53398. /**
  53399. * Gets or sets the root nodes of the material fragment (pixel) shader
  53400. */
  53401. _fragmentOutputNodes: NodeMaterialBlock[];
  53402. /** Gets or sets options to control the node material overall behavior */
  53403. options: INodeMaterialOptions;
  53404. /**
  53405. * Default configuration related to image processing available in the standard Material.
  53406. */
  53407. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  53408. /**
  53409. * Gets the image processing configuration used either in this material.
  53410. */
  53411. /**
  53412. * Sets the Default image processing configuration used either in the this material.
  53413. *
  53414. * If sets to null, the scene one is in use.
  53415. */
  53416. imageProcessingConfiguration: ImageProcessingConfiguration;
  53417. /**
  53418. * Create a new node based material
  53419. * @param name defines the material name
  53420. * @param scene defines the hosting scene
  53421. * @param options defines creation option
  53422. */
  53423. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  53424. /**
  53425. * Gets the current class name of the material e.g. "NodeMaterial"
  53426. * @returns the class name
  53427. */
  53428. getClassName(): string;
  53429. /**
  53430. * Keep track of the image processing observer to allow dispose and replace.
  53431. */
  53432. private _imageProcessingObserver;
  53433. /**
  53434. * Attaches a new image processing configuration to the Standard Material.
  53435. * @param configuration
  53436. */
  53437. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  53438. /**
  53439. * Adds a new optimizer to the list of optimizers
  53440. * @param optimizer defines the optimizers to add
  53441. * @returns the current material
  53442. */
  53443. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  53444. /**
  53445. * Remove an optimizer from the list of optimizers
  53446. * @param optimizer defines the optimizers to remove
  53447. * @returns the current material
  53448. */
  53449. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  53450. /**
  53451. * Add a new block to the list of output nodes
  53452. * @param node defines the node to add
  53453. * @returns the current material
  53454. */
  53455. addOutputNode(node: NodeMaterialBlock): this;
  53456. /**
  53457. * Remove a block from the list of root nodes
  53458. * @param node defines the node to remove
  53459. * @returns the current material
  53460. */
  53461. removeOutputNode(node: NodeMaterialBlock): this;
  53462. private _addVertexOutputNode;
  53463. private _removeVertexOutputNode;
  53464. private _addFragmentOutputNode;
  53465. private _removeFragmentOutputNode;
  53466. /**
  53467. * Specifies if the material will require alpha blending
  53468. * @returns a boolean specifying if alpha blending is needed
  53469. */
  53470. needAlphaBlending(): boolean;
  53471. /**
  53472. * Specifies if this material should be rendered in alpha test mode
  53473. * @returns a boolean specifying if an alpha test is needed.
  53474. */
  53475. needAlphaTesting(): boolean;
  53476. private _initializeBlock;
  53477. private _resetDualBlocks;
  53478. /**
  53479. * Build the material and generates the inner effect
  53480. * @param verbose defines if the build should log activity
  53481. */
  53482. build(verbose?: boolean): void;
  53483. /**
  53484. * Runs an otpimization phase to try to improve the shader code
  53485. */
  53486. optimize(): void;
  53487. private _prepareDefinesForAttributes;
  53488. /**
  53489. * Get if the submesh is ready to be used and all its information available.
  53490. * Child classes can use it to update shaders
  53491. * @param mesh defines the mesh to check
  53492. * @param subMesh defines which submesh to check
  53493. * @param useInstances specifies that instances should be used
  53494. * @returns a boolean indicating that the submesh is ready or not
  53495. */
  53496. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  53497. /**
  53498. * Binds the world matrix to the material
  53499. * @param world defines the world transformation matrix
  53500. */
  53501. bindOnlyWorldMatrix(world: Matrix): void;
  53502. /**
  53503. * Binds the submesh to this material by preparing the effect and shader to draw
  53504. * @param world defines the world transformation matrix
  53505. * @param mesh defines the mesh containing the submesh
  53506. * @param subMesh defines the submesh to bind the material to
  53507. */
  53508. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  53509. /**
  53510. * Gets the active textures from the material
  53511. * @returns an array of textures
  53512. */
  53513. getActiveTextures(): BaseTexture[];
  53514. /**
  53515. * Specifies if the material uses a texture
  53516. * @param texture defines the texture to check against the material
  53517. * @returns a boolean specifying if the material uses the texture
  53518. */
  53519. hasTexture(texture: BaseTexture): boolean;
  53520. /**
  53521. * Disposes the material
  53522. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  53523. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  53524. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  53525. */
  53526. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  53527. /** Creates the node editor window. */
  53528. private _createNodeEditor;
  53529. /**
  53530. * Launch the node material editor
  53531. * @param config Define the configuration of the editor
  53532. * @return a promise fulfilled when the node editor is visible
  53533. */
  53534. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  53535. /**
  53536. * Clear the current material
  53537. */
  53538. clear(): void;
  53539. /**
  53540. * Clear the current material and set it to a default state
  53541. */
  53542. setToDefault(): void;
  53543. }
  53544. }
  53545. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  53546. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  53547. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53548. import { Nullable } from "babylonjs/types";
  53549. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53550. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  53551. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  53552. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53553. import { Mesh } from "babylonjs/Meshes/mesh";
  53554. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  53555. /**
  53556. * Defines a block that can be used inside a node based material
  53557. */
  53558. export class NodeMaterialBlock {
  53559. private _buildId;
  53560. private _target;
  53561. private _isFinalMerger;
  53562. /** @hidden */
  53563. _inputs: NodeMaterialConnectionPoint[];
  53564. /** @hidden */
  53565. _outputs: NodeMaterialConnectionPoint[];
  53566. /**
  53567. * Gets or sets the name of the block
  53568. */
  53569. name: string;
  53570. /**
  53571. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  53572. */
  53573. readonly isFinalMerger: boolean;
  53574. /**
  53575. * Gets or sets the build Id
  53576. */
  53577. buildId: number;
  53578. /**
  53579. * Gets or sets the target of the block
  53580. */
  53581. target: NodeMaterialBlockTargets;
  53582. /**
  53583. * Gets the list of input points
  53584. */
  53585. readonly inputs: NodeMaterialConnectionPoint[];
  53586. /** Gets the list of output points */
  53587. readonly outputs: NodeMaterialConnectionPoint[];
  53588. /**
  53589. * Find an input by its name
  53590. * @param name defines the name of the input to look for
  53591. * @returns the input or null if not found
  53592. */
  53593. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  53594. /**
  53595. * Find an output by its name
  53596. * @param name defines the name of the outputto look for
  53597. * @returns the output or null if not found
  53598. */
  53599. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  53600. /**
  53601. * Creates a new NodeMaterialBlock
  53602. * @param name defines the block name
  53603. * @param target defines the target of that block (Vertex by default)
  53604. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  53605. */
  53606. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean);
  53607. /**
  53608. * Initialize the block and prepare the context for build
  53609. * @param state defines the state that will be used for the build
  53610. */
  53611. initialize(state: NodeMaterialBuildState): void;
  53612. /**
  53613. * Bind data to effect. Will only be called for blocks with isBindable === true
  53614. * @param effect defines the effect to bind data to
  53615. * @param nodeMaterial defines the hosting NodeMaterial
  53616. * @param mesh defines the mesh that will be rendered
  53617. */
  53618. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53619. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  53620. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  53621. protected _writeFloat(value: number): string;
  53622. /**
  53623. * Gets the current class name e.g. "NodeMaterialBlock"
  53624. * @returns the class name
  53625. */
  53626. getClassName(): string;
  53627. /**
  53628. * Register a new input. Must be called inside a block constructor
  53629. * @param name defines the connection point name
  53630. * @param type defines the connection point type
  53631. * @param isOptional defines a boolean indicating that this input can be omitted
  53632. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  53633. * @returns the current block
  53634. */
  53635. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  53636. /**
  53637. * Register a new output. Must be called inside a block constructor
  53638. * @param name defines the connection point name
  53639. * @param type defines the connection point type
  53640. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  53641. * @returns the current block
  53642. */
  53643. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  53644. /**
  53645. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  53646. * @param forOutput defines an optional connection point to check compatibility with
  53647. * @returns the first available input or null
  53648. */
  53649. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  53650. /**
  53651. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  53652. * @param forBlock defines an optional block to check compatibility with
  53653. * @returns the first available input or null
  53654. */
  53655. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  53656. /**
  53657. * Connect current block with another block
  53658. * @param other defines the block to connect with
  53659. * @param options define the various options to help pick the right connections
  53660. * @returns the current block
  53661. */
  53662. connectTo(other: NodeMaterialBlock, options?: {
  53663. input?: string;
  53664. output?: string;
  53665. outputSwizzle?: string;
  53666. }): this | undefined;
  53667. protected _buildBlock(state: NodeMaterialBuildState): void;
  53668. /**
  53669. * Add potential fallbacks if shader compilation fails
  53670. * @param mesh defines the mesh to be rendered
  53671. * @param fallbacks defines the current prioritized list of fallbacks
  53672. */
  53673. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  53674. /**
  53675. * Update defines for shader compilation
  53676. * @param mesh defines the mesh to be rendered
  53677. * @param nodeMaterial defines the node material requesting the update
  53678. * @param defines defines the material defines to update
  53679. * @param useInstances specifies that instances should be used
  53680. */
  53681. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53682. /**
  53683. * Lets the block try to connect some inputs automatically
  53684. */
  53685. autoConfigure(): void;
  53686. /**
  53687. * Function called when a block is declared as repeatable content generator
  53688. * @param vertexShaderState defines the current compilation state for the vertex shader
  53689. * @param fragmentShaderState defines the current compilation state for the fragment shader
  53690. * @param mesh defines the mesh to be rendered
  53691. * @param defines defines the material defines to update
  53692. */
  53693. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  53694. /**
  53695. * Checks if the block is ready
  53696. * @param mesh defines the mesh to be rendered
  53697. * @param nodeMaterial defines the node material requesting the update
  53698. * @param defines defines the material defines to update
  53699. * @param useInstances specifies that instances should be used
  53700. * @returns true if the block is ready
  53701. */
  53702. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  53703. /**
  53704. * Compile the current node and generate the shader code
  53705. * @param state defines the current compilation state (uniforms, samplers, current string)
  53706. * @returns the current block
  53707. */
  53708. build(state: NodeMaterialBuildState): this | undefined;
  53709. }
  53710. }
  53711. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  53712. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  53713. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  53714. import { Nullable } from "babylonjs/types";
  53715. import { Effect } from "babylonjs/Materials/effect";
  53716. import { NodeMaterialWellKnownValues } from "babylonjs/Materials/Node/nodeMaterialWellKnownValues";
  53717. import { Scene } from "babylonjs/scene";
  53718. import { Matrix } from "babylonjs/Maths/math";
  53719. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53720. /**
  53721. * Defines a connection point for a block
  53722. */
  53723. export class NodeMaterialConnectionPoint {
  53724. /** @hidden */
  53725. _ownerBlock: NodeMaterialBlock;
  53726. /** @hidden */
  53727. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  53728. private _associatedVariableName;
  53729. private _endpoints;
  53730. private _storedValue;
  53731. private _valueCallback;
  53732. private _mode;
  53733. /** @hidden */
  53734. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  53735. /** @hidden */
  53736. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  53737. /** @hidden */
  53738. _needToEmitVarying: boolean;
  53739. /** @hidden */
  53740. _forceUniformInVertexShaderOnly: boolean;
  53741. private _type;
  53742. /**
  53743. * Gets or sets the connection point type (default is float)
  53744. */
  53745. type: NodeMaterialBlockConnectionPointTypes;
  53746. /**
  53747. * Gets or sets the connection point name
  53748. */
  53749. name: string;
  53750. /**
  53751. * Gets or sets the swizzle to apply to this connection point when reading or writing
  53752. */
  53753. swizzle: string;
  53754. /**
  53755. * Gets or sets a boolean indicating that this connection point can be omitted
  53756. */
  53757. isOptional: boolean;
  53758. /**
  53759. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  53760. */
  53761. define: string;
  53762. /** Gets or sets the target of that connection point */
  53763. target: NodeMaterialBlockTargets;
  53764. /**
  53765. * Gets or sets the value of that point.
  53766. * Please note that this value will be ignored if valueCallback is defined
  53767. */
  53768. value: any;
  53769. /**
  53770. * Gets or sets a callback used to get the value of that point.
  53771. * Please note that setting this value will force the connection point to ignore the value property
  53772. */
  53773. valueCallback: () => any;
  53774. /**
  53775. * Gets or sets the associated variable name in the shader
  53776. */
  53777. associatedVariableName: string;
  53778. /**
  53779. * Gets a boolean indicating that this connection point not defined yet
  53780. */
  53781. readonly isUndefined: boolean;
  53782. /**
  53783. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  53784. * In this case the connection point name must be the name of the uniform to use.
  53785. * Can only be set on inputs
  53786. */
  53787. isUniform: boolean;
  53788. /**
  53789. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  53790. * In this case the connection point name must be the name of the attribute to use
  53791. * Can only be set on inputs
  53792. */
  53793. isAttribute: boolean;
  53794. /**
  53795. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  53796. * Can only be set on exit points
  53797. */
  53798. isVarying: boolean;
  53799. /** Get the other side of the connection (if any) */
  53800. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  53801. /** Get the block that owns this connection point */
  53802. readonly ownerBlock: NodeMaterialBlock;
  53803. /** Get the block connected on the other side of this connection (if any) */
  53804. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  53805. /** Get the block connected on the endpoints of this connection (if any) */
  53806. readonly connectedBlocks: Array<NodeMaterialBlock>;
  53807. /**
  53808. * Creates a new connection point
  53809. * @param name defines the connection point name
  53810. * @param ownerBlock defines the block hosting this connection point
  53811. */
  53812. constructor(name: string, ownerBlock: NodeMaterialBlock);
  53813. /**
  53814. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  53815. * @returns the class name
  53816. */
  53817. getClassName(): string;
  53818. /**
  53819. * Set the source of this connection point to a vertex attribute
  53820. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  53821. * @returns the current connection point
  53822. */
  53823. setAsAttribute(attributeName?: string): NodeMaterialConnectionPoint;
  53824. /**
  53825. * Set the source of this connection point to a well known value
  53826. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  53827. * @returns the current connection point
  53828. */
  53829. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): NodeMaterialConnectionPoint;
  53830. /**
  53831. * Gets a boolean indicating that the current connection point is a well known value
  53832. */
  53833. readonly isWellKnownValue: boolean;
  53834. /**
  53835. * Gets or sets the current well known value or null if not defined as well know value
  53836. */
  53837. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  53838. private _getTypeLength;
  53839. /**
  53840. * Connect this point to another connection point
  53841. * @param connectionPoint defines the other connection point
  53842. * @returns the current connection point
  53843. */
  53844. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  53845. /**
  53846. * Disconnect this point from one of his endpoint
  53847. * @param endpoint defines the other connection point
  53848. * @returns the current connection point
  53849. */
  53850. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  53851. /**
  53852. * When connection point is an uniform, this function will send its value to the effect
  53853. * @param effect defines the effect to transmit value to
  53854. * @param world defines the world matrix
  53855. * @param worldView defines the worldxview matrix
  53856. * @param worldViewProjection defines the worldxviewxprojection matrix
  53857. */
  53858. transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  53859. /**
  53860. * When connection point is an uniform, this function will send its value to the effect
  53861. * @param effect defines the effect to transmit value to
  53862. * @param scene defines the hosting scene
  53863. */
  53864. transmit(effect: Effect, scene: Scene): void;
  53865. }
  53866. }
  53867. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  53868. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53869. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53870. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53871. import { Mesh } from "babylonjs/Meshes/mesh";
  53872. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  53873. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53874. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  53875. /**
  53876. * Block used to add support for vertex skinning (bones)
  53877. */
  53878. export class BonesBlock extends NodeMaterialBlock {
  53879. /**
  53880. * Creates a new BonesBlock
  53881. * @param name defines the block name
  53882. */
  53883. constructor(name: string);
  53884. /**
  53885. * Initialize the block and prepare the context for build
  53886. * @param state defines the state that will be used for the build
  53887. */
  53888. initialize(state: NodeMaterialBuildState): void;
  53889. /**
  53890. * Gets the current class name
  53891. * @returns the class name
  53892. */
  53893. getClassName(): string;
  53894. /**
  53895. * Gets the matrix indices input component
  53896. */
  53897. readonly matricesIndices: NodeMaterialConnectionPoint;
  53898. /**
  53899. * Gets the matrix weights input component
  53900. */
  53901. readonly matricesWeights: NodeMaterialConnectionPoint;
  53902. /**
  53903. * Gets the extra matrix indices input component
  53904. */
  53905. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  53906. /**
  53907. * Gets the extra matrix weights input component
  53908. */
  53909. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  53910. /**
  53911. * Gets the world input component
  53912. */
  53913. readonly world: NodeMaterialConnectionPoint;
  53914. /**
  53915. * Gets the output component
  53916. */
  53917. readonly output: NodeMaterialConnectionPoint;
  53918. autoConfigure(): void;
  53919. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  53920. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53921. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53922. protected _buildBlock(state: NodeMaterialBuildState): this;
  53923. }
  53924. }
  53925. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  53926. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53927. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53928. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53929. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53930. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  53931. /**
  53932. * Block used to add support for instances
  53933. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  53934. */
  53935. export class InstancesBlock extends NodeMaterialBlock {
  53936. /**
  53937. * Creates a new InstancesBlock
  53938. * @param name defines the block name
  53939. */
  53940. constructor(name: string);
  53941. /**
  53942. * Gets the current class name
  53943. * @returns the class name
  53944. */
  53945. getClassName(): string;
  53946. /**
  53947. * Gets the first world row input component
  53948. */
  53949. readonly world0: NodeMaterialConnectionPoint;
  53950. /**
  53951. * Gets the second world row input component
  53952. */
  53953. readonly world1: NodeMaterialConnectionPoint;
  53954. /**
  53955. * Gets the third world row input component
  53956. */
  53957. readonly world2: NodeMaterialConnectionPoint;
  53958. /**
  53959. * Gets the forth world row input component
  53960. */
  53961. readonly world3: NodeMaterialConnectionPoint;
  53962. /**
  53963. * Gets the world input component
  53964. */
  53965. readonly world: NodeMaterialConnectionPoint;
  53966. /**
  53967. * Gets the output component
  53968. */
  53969. readonly output: NodeMaterialConnectionPoint;
  53970. autoConfigure(): void;
  53971. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53972. protected _buildBlock(state: NodeMaterialBuildState): this;
  53973. }
  53974. }
  53975. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  53976. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53977. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53978. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53979. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53980. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  53981. import { Effect } from "babylonjs/Materials/effect";
  53982. import { Mesh } from "babylonjs/Meshes/mesh";
  53983. /**
  53984. * Block used to add morph targets support to vertex shader
  53985. */
  53986. export class MorphTargetsBlock extends NodeMaterialBlock {
  53987. private _repeatableContentAnchor;
  53988. private _repeatebleContentGenerated;
  53989. /**
  53990. * Create a new MorphTargetsBlock
  53991. * @param name defines the block name
  53992. */
  53993. constructor(name: string);
  53994. /**
  53995. * Gets the current class name
  53996. * @returns the class name
  53997. */
  53998. getClassName(): string;
  53999. /**
  54000. * Gets the position input component
  54001. */
  54002. readonly position: NodeMaterialConnectionPoint;
  54003. /**
  54004. * Gets the normal input component
  54005. */
  54006. readonly normal: NodeMaterialConnectionPoint;
  54007. /**
  54008. * Gets the tangent input component
  54009. */
  54010. readonly tangent: NodeMaterialConnectionPoint;
  54011. /**
  54012. * Gets the tangent input component
  54013. */
  54014. readonly uv: NodeMaterialConnectionPoint;
  54015. /**
  54016. * Gets the position output component
  54017. */
  54018. readonly positionOutput: NodeMaterialConnectionPoint;
  54019. /**
  54020. * Gets the normal output component
  54021. */
  54022. readonly normalOutput: NodeMaterialConnectionPoint;
  54023. /**
  54024. * Gets the tangent output component
  54025. */
  54026. readonly tangentOutput: NodeMaterialConnectionPoint;
  54027. /**
  54028. * Gets the tangent output component
  54029. */
  54030. readonly uvOutput: NodeMaterialConnectionPoint;
  54031. initialize(state: NodeMaterialBuildState): void;
  54032. autoConfigure(): void;
  54033. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54034. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54035. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  54036. protected _buildBlock(state: NodeMaterialBuildState): this;
  54037. }
  54038. }
  54039. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  54040. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  54041. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  54042. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  54043. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  54044. }
  54045. declare module "babylonjs/Materials/Node/Blocks/Fragment/alphaTestBlock" {
  54046. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54047. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54048. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54049. /**
  54050. * Block used to add an alpha test in the fragment shader
  54051. */
  54052. export class AlphaTestBlock extends NodeMaterialBlock {
  54053. /**
  54054. * Gets or sets the alpha value where alpha testing happens
  54055. */
  54056. alphaCutOff: number;
  54057. /**
  54058. * Create a new AlphaTestBlock
  54059. * @param name defines the block name
  54060. */
  54061. constructor(name: string);
  54062. /**
  54063. * Gets the current class name
  54064. * @returns the class name
  54065. */
  54066. getClassName(): string;
  54067. /**
  54068. * Gets the color input component
  54069. */
  54070. readonly color: NodeMaterialConnectionPoint;
  54071. protected _buildBlock(state: NodeMaterialBuildState): this;
  54072. }
  54073. }
  54074. declare module "babylonjs/Materials/Node/Blocks/Fragment/rgbaMergerBlock" {
  54075. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54076. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54077. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54078. /**
  54079. * Block used to create a Color4 out of 4 inputs (one for each component)
  54080. */
  54081. export class RGBAMergerBlock extends NodeMaterialBlock {
  54082. /**
  54083. * Create a new RGBAMergerBlock
  54084. * @param name defines the block name
  54085. */
  54086. constructor(name: string);
  54087. /**
  54088. * Gets the current class name
  54089. * @returns the class name
  54090. */
  54091. getClassName(): string;
  54092. /**
  54093. * Gets the R input component
  54094. */
  54095. readonly r: NodeMaterialConnectionPoint;
  54096. /**
  54097. * Gets the G input component
  54098. */
  54099. readonly g: NodeMaterialConnectionPoint;
  54100. /**
  54101. * Gets the B input component
  54102. */
  54103. readonly b: NodeMaterialConnectionPoint;
  54104. /**
  54105. * Gets the RGB input component
  54106. */
  54107. readonly rgb: NodeMaterialConnectionPoint;
  54108. /**
  54109. * Gets the R input component
  54110. */
  54111. readonly a: NodeMaterialConnectionPoint;
  54112. /**
  54113. * Gets the output component
  54114. */
  54115. readonly output: NodeMaterialConnectionPoint;
  54116. protected _buildBlock(state: NodeMaterialBuildState): this;
  54117. }
  54118. }
  54119. declare module "babylonjs/Materials/Node/Blocks/Fragment/rgbMergerBlock" {
  54120. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54121. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54122. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54123. /**
  54124. * Block used to create a Color3 out of 3 inputs (one for each component)
  54125. */
  54126. export class RGBMergerBlock extends NodeMaterialBlock {
  54127. /**
  54128. * Create a new RGBMergerBlock
  54129. * @param name defines the block name
  54130. */
  54131. constructor(name: string);
  54132. /**
  54133. * Gets the current class name
  54134. * @returns the class name
  54135. */
  54136. getClassName(): string;
  54137. /**
  54138. * Gets the R component input
  54139. */
  54140. readonly r: NodeMaterialConnectionPoint;
  54141. /**
  54142. * Gets the G component input
  54143. */
  54144. readonly g: NodeMaterialConnectionPoint;
  54145. /**
  54146. * Gets the B component input
  54147. */
  54148. readonly b: NodeMaterialConnectionPoint;
  54149. /**
  54150. * Gets the output component
  54151. */
  54152. readonly output: NodeMaterialConnectionPoint;
  54153. protected _buildBlock(state: NodeMaterialBuildState): this;
  54154. }
  54155. }
  54156. declare module "babylonjs/Materials/Node/Blocks/Fragment/rgbaSplitterBlock" {
  54157. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54158. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54159. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54160. /**
  54161. * Block used to expand a Color4 or a Vector4 into 4 outputs (one for each component)
  54162. */
  54163. export class RGBASplitterBlock extends NodeMaterialBlock {
  54164. /**
  54165. * Create a new RGBASplitterBlock
  54166. * @param name defines the block name
  54167. */
  54168. constructor(name: string);
  54169. /**
  54170. * Gets the current class name
  54171. * @returns the class name
  54172. */
  54173. getClassName(): string;
  54174. /**
  54175. * Gets the input component
  54176. */
  54177. readonly input: NodeMaterialConnectionPoint;
  54178. protected _buildBlock(state: NodeMaterialBuildState): this;
  54179. }
  54180. }
  54181. declare module "babylonjs/Materials/Node/Blocks/Fragment/rgbSplitterBlock" {
  54182. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54183. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54184. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54185. /**
  54186. * Block used to expand a Color3 or a Vector3 into 3 outputs (one for each component)
  54187. */
  54188. export class RGBSplitterBlock extends NodeMaterialBlock {
  54189. /**
  54190. * Create a new RGBSplitterBlock
  54191. * @param name defines the block name
  54192. */
  54193. constructor(name: string);
  54194. /**
  54195. * Gets the current class name
  54196. * @returns the class name
  54197. */
  54198. getClassName(): string;
  54199. /**
  54200. * Gets the input component
  54201. */
  54202. readonly input: NodeMaterialConnectionPoint;
  54203. protected _buildBlock(state: NodeMaterialBuildState): this;
  54204. }
  54205. }
  54206. declare module "babylonjs/Materials/Node/Blocks/Fragment/textureBlock" {
  54207. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54208. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54209. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54210. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54211. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54212. /**
  54213. * Block used to read a texture from a sampler
  54214. */
  54215. export class TextureBlock extends NodeMaterialBlock {
  54216. private _defineName;
  54217. /**
  54218. * Gets or sets a boolean indicating that the block can automatically fetch the texture matrix
  54219. */
  54220. autoConnectTextureMatrix: boolean;
  54221. /**
  54222. * Gets or sets a boolean indicating that the block can automatically select the uv channel based on texture
  54223. */
  54224. autoSelectUV: boolean;
  54225. /**
  54226. * Create a new TextureBlock
  54227. * @param name defines the block name
  54228. */
  54229. constructor(name: string);
  54230. /**
  54231. * Gets the current class name
  54232. * @returns the class name
  54233. */
  54234. getClassName(): string;
  54235. /**
  54236. * Gets the uv input component
  54237. */
  54238. readonly uv: NodeMaterialConnectionPoint;
  54239. /**
  54240. * Gets the texture information input component
  54241. */
  54242. readonly textureInfo: NodeMaterialConnectionPoint;
  54243. /**
  54244. * Gets the transformed uv input component
  54245. */
  54246. readonly transformedUV: NodeMaterialConnectionPoint;
  54247. /**
  54248. * Gets the texture input component
  54249. */
  54250. readonly texture: NodeMaterialConnectionPoint;
  54251. /**
  54252. * Gets the texture transform input component
  54253. */
  54254. readonly textureTransform: NodeMaterialConnectionPoint;
  54255. /**
  54256. * Gets the output component
  54257. */
  54258. readonly output: NodeMaterialConnectionPoint;
  54259. autoConfigure(): void;
  54260. initialize(state: NodeMaterialBuildState): void;
  54261. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54262. isReady(): boolean;
  54263. private _injectVertexCode;
  54264. protected _buildBlock(state: NodeMaterialBuildState): this;
  54265. }
  54266. }
  54267. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  54268. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54269. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54270. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54271. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54272. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54273. import { Effect } from "babylonjs/Materials/effect";
  54274. import { Mesh } from "babylonjs/Meshes/mesh";
  54275. /**
  54276. * Block used to add image processing support to fragment shader
  54277. */
  54278. export class ImageProcessingBlock extends NodeMaterialBlock {
  54279. /**
  54280. * Create a new ImageProcessingBlock
  54281. * @param name defines the block name
  54282. */
  54283. constructor(name: string);
  54284. /**
  54285. * Gets the current class name
  54286. * @returns the class name
  54287. */
  54288. getClassName(): string;
  54289. /**
  54290. * Gets the color input component
  54291. */
  54292. readonly color: NodeMaterialConnectionPoint;
  54293. /**
  54294. * Gets the output component
  54295. */
  54296. readonly output: NodeMaterialConnectionPoint;
  54297. /**
  54298. * Initialize the block and prepare the context for build
  54299. * @param state defines the state that will be used for the build
  54300. */
  54301. initialize(state: NodeMaterialBuildState): void;
  54302. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  54303. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54304. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54305. protected _buildBlock(state: NodeMaterialBuildState): this;
  54306. }
  54307. }
  54308. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  54309. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  54310. export * from "babylonjs/Materials/Node/Blocks/Fragment/alphaTestBlock";
  54311. export * from "babylonjs/Materials/Node/Blocks/Fragment/rgbaMergerBlock";
  54312. export * from "babylonjs/Materials/Node/Blocks/Fragment/rgbMergerBlock";
  54313. export * from "babylonjs/Materials/Node/Blocks/Fragment/rgbaSplitterBlock";
  54314. export * from "babylonjs/Materials/Node/Blocks/Fragment/rgbSplitterBlock";
  54315. export * from "babylonjs/Materials/Node/Blocks/Fragment/textureBlock";
  54316. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  54317. }
  54318. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  54319. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54320. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54321. import { Mesh } from "babylonjs/Meshes/mesh";
  54322. import { Effect } from "babylonjs/Materials/effect";
  54323. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54324. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54325. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54326. /**
  54327. * Block used to add support for scene fog
  54328. */
  54329. export class FogBlock extends NodeMaterialBlock {
  54330. /**
  54331. * Create a new FogBlock
  54332. * @param name defines the block name
  54333. */
  54334. constructor(name: string);
  54335. /**
  54336. * Gets the current class name
  54337. * @returns the class name
  54338. */
  54339. getClassName(): string;
  54340. /**
  54341. * Gets the world position input component
  54342. */
  54343. readonly worldPosition: NodeMaterialConnectionPoint;
  54344. /**
  54345. * Gets the view input component
  54346. */
  54347. readonly view: NodeMaterialConnectionPoint;
  54348. /**
  54349. * Gets the color input component
  54350. */
  54351. readonly color: NodeMaterialConnectionPoint;
  54352. /**
  54353. * Gets the fog color input component
  54354. */
  54355. readonly fogColor: NodeMaterialConnectionPoint;
  54356. /**
  54357. * Gets the for parameter input component
  54358. */
  54359. readonly fogParameters: NodeMaterialConnectionPoint;
  54360. /**
  54361. * Gets the output component
  54362. */
  54363. readonly output: NodeMaterialConnectionPoint;
  54364. autoConfigure(): void;
  54365. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54366. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54367. protected _buildBlock(state: NodeMaterialBuildState): this;
  54368. }
  54369. }
  54370. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  54371. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54372. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54373. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54374. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54375. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54376. import { Effect } from "babylonjs/Materials/effect";
  54377. import { Mesh } from "babylonjs/Meshes/mesh";
  54378. /**
  54379. * Block used to add light in the fragment shader
  54380. */
  54381. export class LightBlock extends NodeMaterialBlock {
  54382. private _lightId;
  54383. /**
  54384. * Create a new LightBlock
  54385. * @param name defines the block name
  54386. */
  54387. constructor(name: string);
  54388. /**
  54389. * Gets the current class name
  54390. * @returns the class name
  54391. */
  54392. getClassName(): string;
  54393. /**
  54394. * Gets the world position input component
  54395. */
  54396. readonly worldPosition: NodeMaterialConnectionPoint;
  54397. /**
  54398. * Gets the world normal input component
  54399. */
  54400. readonly worldNormal: NodeMaterialConnectionPoint;
  54401. /**
  54402. * Gets the light input component
  54403. */
  54404. readonly light: NodeMaterialConnectionPoint;
  54405. /**
  54406. * Gets the camera (or eye) position component
  54407. */
  54408. readonly cameraPosition: NodeMaterialConnectionPoint;
  54409. /**
  54410. * Gets the diffuse output component
  54411. */
  54412. readonly diffuseOutput: NodeMaterialConnectionPoint;
  54413. /**
  54414. * Gets the specular output component
  54415. */
  54416. readonly specularOutput: NodeMaterialConnectionPoint;
  54417. autoConfigure(): void;
  54418. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54419. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54420. private _injectVertexCode;
  54421. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54422. }
  54423. }
  54424. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  54425. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  54426. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  54427. }
  54428. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  54429. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54430. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54431. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54432. /**
  54433. * Block used to multiply 2 vector4
  54434. */
  54435. export class MultiplyBlock extends NodeMaterialBlock {
  54436. /**
  54437. * Creates a new MultiplyBlock
  54438. * @param name defines the block name
  54439. */
  54440. constructor(name: string);
  54441. /**
  54442. * Gets the current class name
  54443. * @returns the class name
  54444. */
  54445. getClassName(): string;
  54446. /**
  54447. * Gets the left operand input component
  54448. */
  54449. readonly left: NodeMaterialConnectionPoint;
  54450. /**
  54451. * Gets the right operand input component
  54452. */
  54453. readonly right: NodeMaterialConnectionPoint;
  54454. /**
  54455. * Gets the output component
  54456. */
  54457. readonly output: NodeMaterialConnectionPoint;
  54458. protected _buildBlock(state: NodeMaterialBuildState): this;
  54459. }
  54460. }
  54461. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  54462. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54463. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54464. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54465. /**
  54466. * Block used to add 2 vector4
  54467. */
  54468. export class AddBlock extends NodeMaterialBlock {
  54469. /**
  54470. * Creates a new AddBlock
  54471. * @param name defines the block name
  54472. */
  54473. constructor(name: string);
  54474. /**
  54475. * Gets the current class name
  54476. * @returns the class name
  54477. */
  54478. getClassName(): string;
  54479. /**
  54480. * Gets the left operand input component
  54481. */
  54482. readonly left: NodeMaterialConnectionPoint;
  54483. /**
  54484. * Gets the right operand input component
  54485. */
  54486. readonly right: NodeMaterialConnectionPoint;
  54487. /**
  54488. * Gets the output component
  54489. */
  54490. readonly output: NodeMaterialConnectionPoint;
  54491. protected _buildBlock(state: NodeMaterialBuildState): this;
  54492. }
  54493. }
  54494. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  54495. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54496. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54497. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54498. /**
  54499. * Block used to clamp a float
  54500. */
  54501. export class ClampBlock extends NodeMaterialBlock {
  54502. /** Gets or sets the minimum range */
  54503. minimum: number;
  54504. /** Gets or sets the maximum range */
  54505. maximum: number;
  54506. /**
  54507. * Creates a new ClampBlock
  54508. * @param name defines the block name
  54509. */
  54510. constructor(name: string);
  54511. /**
  54512. * Gets the current class name
  54513. * @returns the class name
  54514. */
  54515. getClassName(): string;
  54516. /**
  54517. * Gets the value input component
  54518. */
  54519. readonly value: NodeMaterialConnectionPoint;
  54520. /**
  54521. * Gets the output component
  54522. */
  54523. readonly output: NodeMaterialConnectionPoint;
  54524. protected _buildBlock(state: NodeMaterialBuildState): this;
  54525. }
  54526. }
  54527. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  54528. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54529. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54530. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54531. /**
  54532. * Block used to scale a value
  54533. */
  54534. export class ScaleBlock extends NodeMaterialBlock {
  54535. /**
  54536. * Creates a new ScaleBlock
  54537. * @param name defines the block name
  54538. */
  54539. constructor(name: string);
  54540. /**
  54541. * Gets the current class name
  54542. * @returns the class name
  54543. */
  54544. getClassName(): string;
  54545. /**
  54546. * Gets the value operand input component
  54547. */
  54548. readonly value: NodeMaterialConnectionPoint;
  54549. /**
  54550. * Gets the scale operand input component
  54551. */
  54552. readonly scale: NodeMaterialConnectionPoint;
  54553. /**
  54554. * Gets the output component
  54555. */
  54556. readonly output: NodeMaterialConnectionPoint;
  54557. protected _buildBlock(state: NodeMaterialBuildState): this;
  54558. }
  54559. }
  54560. declare module "babylonjs/Materials/Node/Blocks/vector2TransformBlock" {
  54561. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54562. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54563. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54564. /**
  54565. * Block used to transform a vector2 with a matrix
  54566. */
  54567. export class Vector2TransformBlock extends NodeMaterialBlock {
  54568. /**
  54569. * Defines the value to use to complement Vector2 to transform it to a Vector4
  54570. */
  54571. complementZ: number;
  54572. /**
  54573. * Defines the value to use to complement Vector2 to transform it to a Vector4
  54574. */
  54575. complementW: number;
  54576. /**
  54577. * Creates a new Vector2TransformBlock
  54578. * @param name defines the block name
  54579. */
  54580. constructor(name: string);
  54581. /**
  54582. * Gets the vector input
  54583. */
  54584. readonly vector: NodeMaterialConnectionPoint;
  54585. /**
  54586. * Gets the matrix transform input
  54587. */
  54588. readonly transform: NodeMaterialConnectionPoint;
  54589. /**
  54590. * Gets the output component
  54591. */
  54592. readonly output: NodeMaterialConnectionPoint;
  54593. /**
  54594. * Gets the current class name
  54595. * @returns the class name
  54596. */
  54597. getClassName(): string;
  54598. protected _buildBlock(state: NodeMaterialBuildState): this;
  54599. }
  54600. }
  54601. declare module "babylonjs/Materials/Node/Blocks/vector3TransformBlock" {
  54602. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54603. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54604. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54605. /**
  54606. * Block used to transform a vector3 with a matrix
  54607. */
  54608. export class Vector3TransformBlock extends NodeMaterialBlock {
  54609. /**
  54610. * Defines the value to use to complement Vector3 to transform it to a Vector4
  54611. */
  54612. complement: number;
  54613. /**
  54614. * Creates a new Vector3TransformBlock
  54615. * @param name defines the block name
  54616. */
  54617. constructor(name: string);
  54618. /**
  54619. * Gets the vector input
  54620. */
  54621. readonly vector: NodeMaterialConnectionPoint;
  54622. /**
  54623. * Gets the matrix transform input
  54624. */
  54625. readonly transform: NodeMaterialConnectionPoint;
  54626. /**
  54627. * Gets the output component
  54628. */
  54629. readonly output: NodeMaterialConnectionPoint;
  54630. /**
  54631. * Gets the current class name
  54632. * @returns the class name
  54633. */
  54634. getClassName(): string;
  54635. protected _buildBlock(state: NodeMaterialBuildState): this;
  54636. }
  54637. }
  54638. declare module "babylonjs/Materials/Node/Blocks/matrixMultiplicationBlock" {
  54639. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54640. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54641. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54642. /**
  54643. * Block used to multiply two matrices
  54644. */
  54645. export class MatrixMultiplicationBlock extends NodeMaterialBlock {
  54646. /**
  54647. * Creates a new MatrixMultiplicationBlock
  54648. * @param name defines the block name
  54649. */
  54650. constructor(name: string);
  54651. /**
  54652. * Gets the left operand
  54653. */
  54654. readonly left: NodeMaterialConnectionPoint;
  54655. /**
  54656. * Gets the right operand
  54657. */
  54658. readonly right: NodeMaterialConnectionPoint;
  54659. /**
  54660. * Gets the output component
  54661. */
  54662. readonly output: NodeMaterialConnectionPoint;
  54663. /**
  54664. * Gets the current class name
  54665. * @returns the class name
  54666. */
  54667. getClassName(): string;
  54668. protected _buildBlock(state: NodeMaterialBuildState): this;
  54669. }
  54670. }
  54671. declare module "babylonjs/Materials/Node/Blocks/index" {
  54672. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  54673. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  54674. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  54675. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  54676. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  54677. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  54678. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  54679. export * from "babylonjs/Materials/Node/Blocks/vector2TransformBlock";
  54680. export * from "babylonjs/Materials/Node/Blocks/vector3TransformBlock";
  54681. export * from "babylonjs/Materials/Node/Blocks/vector4TransformBlock";
  54682. export * from "babylonjs/Materials/Node/Blocks/matrixMultiplicationBlock";
  54683. }
  54684. declare module "babylonjs/Materials/Node/Optimizers/index" {
  54685. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  54686. }
  54687. declare module "babylonjs/Materials/Node/index" {
  54688. export * from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  54689. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  54690. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54691. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  54692. export * from "babylonjs/Materials/Node/nodeMaterial";
  54693. export * from "babylonjs/Materials/Node/nodeMaterialWellKnownValues";
  54694. export * from "babylonjs/Materials/Node/Blocks/index";
  54695. export * from "babylonjs/Materials/Node/Optimizers/index";
  54696. }
  54697. declare module "babylonjs/Materials/index" {
  54698. export * from "babylonjs/Materials/Background/index";
  54699. export * from "babylonjs/Materials/colorCurves";
  54700. export * from "babylonjs/Materials/effect";
  54701. export * from "babylonjs/Materials/fresnelParameters";
  54702. export * from "babylonjs/Materials/imageProcessingConfiguration";
  54703. export * from "babylonjs/Materials/material";
  54704. export * from "babylonjs/Materials/materialDefines";
  54705. export * from "babylonjs/Materials/materialHelper";
  54706. export * from "babylonjs/Materials/multiMaterial";
  54707. export * from "babylonjs/Materials/PBR/index";
  54708. export * from "babylonjs/Materials/pushMaterial";
  54709. export * from "babylonjs/Materials/shaderMaterial";
  54710. export * from "babylonjs/Materials/standardMaterial";
  54711. export * from "babylonjs/Materials/Textures/index";
  54712. export * from "babylonjs/Materials/uniformBuffer";
  54713. export * from "babylonjs/Materials/materialFlags";
  54714. export * from "babylonjs/Materials/Node/index";
  54715. }
  54716. declare module "babylonjs/Maths/index" {
  54717. export * from "babylonjs/Maths/math.scalar";
  54718. export * from "babylonjs/Maths/math";
  54719. export * from "babylonjs/Maths/sphericalPolynomial";
  54720. }
  54721. declare module "babylonjs/Misc/workerPool" {
  54722. import { IDisposable } from "babylonjs/scene";
  54723. /**
  54724. * Helper class to push actions to a pool of workers.
  54725. */
  54726. export class WorkerPool implements IDisposable {
  54727. private _workerInfos;
  54728. private _pendingActions;
  54729. /**
  54730. * Constructor
  54731. * @param workers Array of workers to use for actions
  54732. */
  54733. constructor(workers: Array<Worker>);
  54734. /**
  54735. * Terminates all workers and clears any pending actions.
  54736. */
  54737. dispose(): void;
  54738. /**
  54739. * Pushes an action to the worker pool. If all the workers are active, the action will be
  54740. * pended until a worker has completed its action.
  54741. * @param action The action to perform. Call onComplete when the action is complete.
  54742. */
  54743. push(action: (worker: Worker, onComplete: () => void) => void): void;
  54744. private _execute;
  54745. }
  54746. }
  54747. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  54748. import { IDisposable } from "babylonjs/scene";
  54749. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  54750. /**
  54751. * Configuration for Draco compression
  54752. */
  54753. export interface IDracoCompressionConfiguration {
  54754. /**
  54755. * Configuration for the decoder.
  54756. */
  54757. decoder: {
  54758. /**
  54759. * The url to the WebAssembly module.
  54760. */
  54761. wasmUrl?: string;
  54762. /**
  54763. * The url to the WebAssembly binary.
  54764. */
  54765. wasmBinaryUrl?: string;
  54766. /**
  54767. * The url to the fallback JavaScript module.
  54768. */
  54769. fallbackUrl?: string;
  54770. };
  54771. }
  54772. /**
  54773. * Draco compression (https://google.github.io/draco/)
  54774. *
  54775. * This class wraps the Draco module.
  54776. *
  54777. * **Encoder**
  54778. *
  54779. * The encoder is not currently implemented.
  54780. *
  54781. * **Decoder**
  54782. *
  54783. * 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.
  54784. *
  54785. * To update the configuration, use the following code:
  54786. * ```javascript
  54787. * DracoCompression.Configuration = {
  54788. * decoder: {
  54789. * wasmUrl: "<url to the WebAssembly library>",
  54790. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  54791. * fallbackUrl: "<url to the fallback JavaScript library>",
  54792. * }
  54793. * };
  54794. * ```
  54795. *
  54796. * 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.
  54797. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  54798. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  54799. *
  54800. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  54801. * ```javascript
  54802. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  54803. * ```
  54804. *
  54805. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  54806. */
  54807. export class DracoCompression implements IDisposable {
  54808. private _workerPoolPromise?;
  54809. private _decoderModulePromise?;
  54810. /**
  54811. * The configuration. Defaults to the following urls:
  54812. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  54813. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  54814. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  54815. */
  54816. static Configuration: IDracoCompressionConfiguration;
  54817. /**
  54818. * Returns true if the decoder configuration is available.
  54819. */
  54820. static readonly DecoderAvailable: boolean;
  54821. /**
  54822. * Default number of workers to create when creating the draco compression object.
  54823. */
  54824. static DefaultNumWorkers: number;
  54825. private static GetDefaultNumWorkers;
  54826. private static _Default;
  54827. /**
  54828. * Default instance for the draco compression object.
  54829. */
  54830. static readonly Default: DracoCompression;
  54831. /**
  54832. * Constructor
  54833. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  54834. */
  54835. constructor(numWorkers?: number);
  54836. /**
  54837. * Stop all async operations and release resources.
  54838. */
  54839. dispose(): void;
  54840. /**
  54841. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  54842. * @returns a promise that resolves when ready
  54843. */
  54844. whenReadyAsync(): Promise<void>;
  54845. /**
  54846. * Decode Draco compressed mesh data to vertex data.
  54847. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  54848. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  54849. * @returns A promise that resolves with the decoded vertex data
  54850. */
  54851. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  54852. [kind: string]: number;
  54853. }): Promise<VertexData>;
  54854. }
  54855. }
  54856. declare module "babylonjs/Meshes/Compression/index" {
  54857. export * from "babylonjs/Meshes/Compression/dracoCompression";
  54858. }
  54859. declare module "babylonjs/Meshes/csg" {
  54860. import { Nullable } from "babylonjs/types";
  54861. import { Scene } from "babylonjs/scene";
  54862. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  54863. import { Mesh } from "babylonjs/Meshes/mesh";
  54864. import { Material } from "babylonjs/Materials/material";
  54865. /**
  54866. * Class for building Constructive Solid Geometry
  54867. */
  54868. export class CSG {
  54869. private polygons;
  54870. /**
  54871. * The world matrix
  54872. */
  54873. matrix: Matrix;
  54874. /**
  54875. * Stores the position
  54876. */
  54877. position: Vector3;
  54878. /**
  54879. * Stores the rotation
  54880. */
  54881. rotation: Vector3;
  54882. /**
  54883. * Stores the rotation quaternion
  54884. */
  54885. rotationQuaternion: Nullable<Quaternion>;
  54886. /**
  54887. * Stores the scaling vector
  54888. */
  54889. scaling: Vector3;
  54890. /**
  54891. * Convert the Mesh to CSG
  54892. * @param mesh The Mesh to convert to CSG
  54893. * @returns A new CSG from the Mesh
  54894. */
  54895. static FromMesh(mesh: Mesh): CSG;
  54896. /**
  54897. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  54898. * @param polygons Polygons used to construct a CSG solid
  54899. */
  54900. private static FromPolygons;
  54901. /**
  54902. * Clones, or makes a deep copy, of the CSG
  54903. * @returns A new CSG
  54904. */
  54905. clone(): CSG;
  54906. /**
  54907. * Unions this CSG with another CSG
  54908. * @param csg The CSG to union against this CSG
  54909. * @returns The unioned CSG
  54910. */
  54911. union(csg: CSG): CSG;
  54912. /**
  54913. * Unions this CSG with another CSG in place
  54914. * @param csg The CSG to union against this CSG
  54915. */
  54916. unionInPlace(csg: CSG): void;
  54917. /**
  54918. * Subtracts this CSG with another CSG
  54919. * @param csg The CSG to subtract against this CSG
  54920. * @returns A new CSG
  54921. */
  54922. subtract(csg: CSG): CSG;
  54923. /**
  54924. * Subtracts this CSG with another CSG in place
  54925. * @param csg The CSG to subtact against this CSG
  54926. */
  54927. subtractInPlace(csg: CSG): void;
  54928. /**
  54929. * Intersect this CSG with another CSG
  54930. * @param csg The CSG to intersect against this CSG
  54931. * @returns A new CSG
  54932. */
  54933. intersect(csg: CSG): CSG;
  54934. /**
  54935. * Intersects this CSG with another CSG in place
  54936. * @param csg The CSG to intersect against this CSG
  54937. */
  54938. intersectInPlace(csg: CSG): void;
  54939. /**
  54940. * Return a new CSG solid with solid and empty space switched. This solid is
  54941. * not modified.
  54942. * @returns A new CSG solid with solid and empty space switched
  54943. */
  54944. inverse(): CSG;
  54945. /**
  54946. * Inverses the CSG in place
  54947. */
  54948. inverseInPlace(): void;
  54949. /**
  54950. * This is used to keep meshes transformations so they can be restored
  54951. * when we build back a Babylon Mesh
  54952. * NB : All CSG operations are performed in world coordinates
  54953. * @param csg The CSG to copy the transform attributes from
  54954. * @returns This CSG
  54955. */
  54956. copyTransformAttributes(csg: CSG): CSG;
  54957. /**
  54958. * Build Raw mesh from CSG
  54959. * Coordinates here are in world space
  54960. * @param name The name of the mesh geometry
  54961. * @param scene The Scene
  54962. * @param keepSubMeshes Specifies if the submeshes should be kept
  54963. * @returns A new Mesh
  54964. */
  54965. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  54966. /**
  54967. * Build Mesh from CSG taking material and transforms into account
  54968. * @param name The name of the Mesh
  54969. * @param material The material of the Mesh
  54970. * @param scene The Scene
  54971. * @param keepSubMeshes Specifies if submeshes should be kept
  54972. * @returns The new Mesh
  54973. */
  54974. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  54975. }
  54976. }
  54977. declare module "babylonjs/Meshes/trailMesh" {
  54978. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54979. import { Mesh } from "babylonjs/Meshes/mesh";
  54980. import { Scene } from "babylonjs/scene";
  54981. /**
  54982. * Class used to create a trail following a mesh
  54983. */
  54984. export class TrailMesh extends Mesh {
  54985. private _generator;
  54986. private _autoStart;
  54987. private _running;
  54988. private _diameter;
  54989. private _length;
  54990. private _sectionPolygonPointsCount;
  54991. private _sectionVectors;
  54992. private _sectionNormalVectors;
  54993. private _beforeRenderObserver;
  54994. /**
  54995. * @constructor
  54996. * @param name The value used by scene.getMeshByName() to do a lookup.
  54997. * @param generator The mesh to generate a trail.
  54998. * @param scene The scene to add this mesh to.
  54999. * @param diameter Diameter of trailing mesh. Default is 1.
  55000. * @param length Length of trailing mesh. Default is 60.
  55001. * @param autoStart Automatically start trailing mesh. Default true.
  55002. */
  55003. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  55004. /**
  55005. * "TrailMesh"
  55006. * @returns "TrailMesh"
  55007. */
  55008. getClassName(): string;
  55009. private _createMesh;
  55010. /**
  55011. * Start trailing mesh.
  55012. */
  55013. start(): void;
  55014. /**
  55015. * Stop trailing mesh.
  55016. */
  55017. stop(): void;
  55018. /**
  55019. * Update trailing mesh geometry.
  55020. */
  55021. update(): void;
  55022. /**
  55023. * Returns a new TrailMesh object.
  55024. * @param name is a string, the name given to the new mesh
  55025. * @param newGenerator use new generator object for cloned trail mesh
  55026. * @returns a new mesh
  55027. */
  55028. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  55029. /**
  55030. * Serializes this trail mesh
  55031. * @param serializationObject object to write serialization to
  55032. */
  55033. serialize(serializationObject: any): void;
  55034. /**
  55035. * Parses a serialized trail mesh
  55036. * @param parsedMesh the serialized mesh
  55037. * @param scene the scene to create the trail mesh in
  55038. * @returns the created trail mesh
  55039. */
  55040. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  55041. }
  55042. }
  55043. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  55044. import { Nullable } from "babylonjs/types";
  55045. import { Scene } from "babylonjs/scene";
  55046. import { Vector4, Color4 } from "babylonjs/Maths/math";
  55047. import { Mesh } from "babylonjs/Meshes/mesh";
  55048. /**
  55049. * Class containing static functions to help procedurally build meshes
  55050. */
  55051. export class TiledBoxBuilder {
  55052. /**
  55053. * Creates a box mesh
  55054. * 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)
  55055. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55056. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55057. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55058. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55059. * @param name defines the name of the mesh
  55060. * @param options defines the options used to create the mesh
  55061. * @param scene defines the hosting scene
  55062. * @returns the box mesh
  55063. */
  55064. static CreateTiledBox(name: string, options: {
  55065. pattern?: number;
  55066. width?: number;
  55067. height?: number;
  55068. depth?: number;
  55069. tileSize?: number;
  55070. tileWidth?: number;
  55071. tileHeight?: number;
  55072. alignHorizontal?: number;
  55073. alignVertical?: number;
  55074. faceUV?: Vector4[];
  55075. faceColors?: Color4[];
  55076. sideOrientation?: number;
  55077. updatable?: boolean;
  55078. }, scene?: Nullable<Scene>): Mesh;
  55079. }
  55080. }
  55081. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  55082. import { Vector4 } from "babylonjs/Maths/math";
  55083. import { Mesh } from "babylonjs/Meshes/mesh";
  55084. /**
  55085. * Class containing static functions to help procedurally build meshes
  55086. */
  55087. export class TorusKnotBuilder {
  55088. /**
  55089. * Creates a torus knot mesh
  55090. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  55091. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  55092. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  55093. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  55094. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55095. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55096. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55097. * @param name defines the name of the mesh
  55098. * @param options defines the options used to create the mesh
  55099. * @param scene defines the hosting scene
  55100. * @returns the torus knot mesh
  55101. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  55102. */
  55103. static CreateTorusKnot(name: string, options: {
  55104. radius?: number;
  55105. tube?: number;
  55106. radialSegments?: number;
  55107. tubularSegments?: number;
  55108. p?: number;
  55109. q?: number;
  55110. updatable?: boolean;
  55111. sideOrientation?: number;
  55112. frontUVs?: Vector4;
  55113. backUVs?: Vector4;
  55114. }, scene: any): Mesh;
  55115. }
  55116. }
  55117. declare module "babylonjs/Meshes/polygonMesh" {
  55118. import { Scene } from "babylonjs/scene";
  55119. import { Vector2, Path2 } from "babylonjs/Maths/math";
  55120. import { Mesh } from "babylonjs/Meshes/mesh";
  55121. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  55122. /**
  55123. * Polygon
  55124. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  55125. */
  55126. export class Polygon {
  55127. /**
  55128. * Creates a rectangle
  55129. * @param xmin bottom X coord
  55130. * @param ymin bottom Y coord
  55131. * @param xmax top X coord
  55132. * @param ymax top Y coord
  55133. * @returns points that make the resulting rectation
  55134. */
  55135. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  55136. /**
  55137. * Creates a circle
  55138. * @param radius radius of circle
  55139. * @param cx scale in x
  55140. * @param cy scale in y
  55141. * @param numberOfSides number of sides that make up the circle
  55142. * @returns points that make the resulting circle
  55143. */
  55144. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  55145. /**
  55146. * Creates a polygon from input string
  55147. * @param input Input polygon data
  55148. * @returns the parsed points
  55149. */
  55150. static Parse(input: string): Vector2[];
  55151. /**
  55152. * Starts building a polygon from x and y coordinates
  55153. * @param x x coordinate
  55154. * @param y y coordinate
  55155. * @returns the started path2
  55156. */
  55157. static StartingAt(x: number, y: number): Path2;
  55158. }
  55159. /**
  55160. * Builds a polygon
  55161. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  55162. */
  55163. export class PolygonMeshBuilder {
  55164. private _points;
  55165. private _outlinepoints;
  55166. private _holes;
  55167. private _name;
  55168. private _scene;
  55169. private _epoints;
  55170. private _eholes;
  55171. private _addToepoint;
  55172. /**
  55173. * Babylon reference to the earcut plugin.
  55174. */
  55175. bjsEarcut: any;
  55176. /**
  55177. * Creates a PolygonMeshBuilder
  55178. * @param name name of the builder
  55179. * @param contours Path of the polygon
  55180. * @param scene scene to add to when creating the mesh
  55181. * @param earcutInjection can be used to inject your own earcut reference
  55182. */
  55183. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  55184. /**
  55185. * Adds a whole within the polygon
  55186. * @param hole Array of points defining the hole
  55187. * @returns this
  55188. */
  55189. addHole(hole: Vector2[]): PolygonMeshBuilder;
  55190. /**
  55191. * Creates the polygon
  55192. * @param updatable If the mesh should be updatable
  55193. * @param depth The depth of the mesh created
  55194. * @returns the created mesh
  55195. */
  55196. build(updatable?: boolean, depth?: number): Mesh;
  55197. /**
  55198. * Creates the polygon
  55199. * @param depth The depth of the mesh created
  55200. * @returns the created VertexData
  55201. */
  55202. buildVertexData(depth?: number): VertexData;
  55203. /**
  55204. * Adds a side to the polygon
  55205. * @param positions points that make the polygon
  55206. * @param normals normals of the polygon
  55207. * @param uvs uvs of the polygon
  55208. * @param indices indices of the polygon
  55209. * @param bounds bounds of the polygon
  55210. * @param points points of the polygon
  55211. * @param depth depth of the polygon
  55212. * @param flip flip of the polygon
  55213. */
  55214. private addSide;
  55215. }
  55216. }
  55217. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  55218. import { Scene } from "babylonjs/scene";
  55219. import { Vector3, Color4, Vector4 } from "babylonjs/Maths/math";
  55220. import { Mesh } from "babylonjs/Meshes/mesh";
  55221. import { Nullable } from "babylonjs/types";
  55222. /**
  55223. * Class containing static functions to help procedurally build meshes
  55224. */
  55225. export class PolygonBuilder {
  55226. /**
  55227. * Creates a polygon mesh
  55228. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  55229. * * 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
  55230. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  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. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  55233. * * Remember you can only change the shape positions, not their number when updating a polygon
  55234. * @param name defines the name of the mesh
  55235. * @param options defines the options used to create the mesh
  55236. * @param scene defines the hosting scene
  55237. * @param earcutInjection can be used to inject your own earcut reference
  55238. * @returns the polygon mesh
  55239. */
  55240. static CreatePolygon(name: string, options: {
  55241. shape: Vector3[];
  55242. holes?: Vector3[][];
  55243. depth?: number;
  55244. faceUV?: Vector4[];
  55245. faceColors?: Color4[];
  55246. updatable?: boolean;
  55247. sideOrientation?: number;
  55248. frontUVs?: Vector4;
  55249. backUVs?: Vector4;
  55250. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55251. /**
  55252. * Creates an extruded polygon mesh, with depth in the Y direction.
  55253. * * 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)
  55254. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55255. * @param name defines the name of the mesh
  55256. * @param options defines the options used to create the mesh
  55257. * @param scene defines the hosting scene
  55258. * @param earcutInjection can be used to inject your own earcut reference
  55259. * @returns the polygon mesh
  55260. */
  55261. static ExtrudePolygon(name: string, options: {
  55262. shape: Vector3[];
  55263. holes?: Vector3[][];
  55264. depth?: number;
  55265. faceUV?: Vector4[];
  55266. faceColors?: Color4[];
  55267. updatable?: boolean;
  55268. sideOrientation?: number;
  55269. frontUVs?: Vector4;
  55270. backUVs?: Vector4;
  55271. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55272. }
  55273. }
  55274. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  55275. import { Scene } from "babylonjs/scene";
  55276. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  55277. import { Mesh } from "babylonjs/Meshes/mesh";
  55278. import { Nullable } from "babylonjs/types";
  55279. /**
  55280. * Class containing static functions to help procedurally build meshes
  55281. */
  55282. export class LatheBuilder {
  55283. /**
  55284. * Creates lathe mesh.
  55285. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  55286. * * 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
  55287. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  55288. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  55289. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  55290. * * 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
  55291. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  55292. * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  55293. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55294. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55295. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55296. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55297. * @param name defines the name of the mesh
  55298. * @param options defines the options used to create the mesh
  55299. * @param scene defines the hosting scene
  55300. * @returns the lathe mesh
  55301. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  55302. */
  55303. static CreateLathe(name: string, options: {
  55304. shape: Vector3[];
  55305. radius?: number;
  55306. tessellation?: number;
  55307. clip?: number;
  55308. arc?: number;
  55309. closed?: boolean;
  55310. updatable?: boolean;
  55311. sideOrientation?: number;
  55312. frontUVs?: Vector4;
  55313. backUVs?: Vector4;
  55314. cap?: number;
  55315. invertUV?: boolean;
  55316. }, scene?: Nullable<Scene>): Mesh;
  55317. }
  55318. }
  55319. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  55320. import { Nullable } from "babylonjs/types";
  55321. import { Scene } from "babylonjs/scene";
  55322. import { Vector4 } from "babylonjs/Maths/math";
  55323. import { Mesh } from "babylonjs/Meshes/mesh";
  55324. /**
  55325. * Class containing static functions to help procedurally build meshes
  55326. */
  55327. export class TiledPlaneBuilder {
  55328. /**
  55329. * Creates a tiled plane mesh
  55330. * * The parameter `pattern` will, depending on value, do nothing or
  55331. * * * flip (reflect about central vertical) alternate tiles across and up
  55332. * * * flip every tile on alternate rows
  55333. * * * rotate (180 degs) alternate tiles across and up
  55334. * * * rotate every tile on alternate rows
  55335. * * * flip and rotate alternate tiles across and up
  55336. * * * flip and rotate every tile on alternate rows
  55337. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  55338. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  55339. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55340. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  55341. * * 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)
  55342. * * 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)
  55343. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  55344. * @param name defines the name of the mesh
  55345. * @param options defines the options used to create the mesh
  55346. * @param scene defines the hosting scene
  55347. * @returns the box mesh
  55348. */
  55349. static CreateTiledPlane(name: string, options: {
  55350. pattern?: number;
  55351. tileSize?: number;
  55352. tileWidth?: number;
  55353. tileHeight?: number;
  55354. size?: number;
  55355. width?: number;
  55356. height?: number;
  55357. alignHorizontal?: number;
  55358. alignVertical?: number;
  55359. sideOrientation?: number;
  55360. frontUVs?: Vector4;
  55361. backUVs?: Vector4;
  55362. updatable?: boolean;
  55363. }, scene?: Nullable<Scene>): Mesh;
  55364. }
  55365. }
  55366. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  55367. import { Nullable } from "babylonjs/types";
  55368. import { Scene } from "babylonjs/scene";
  55369. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  55370. import { Mesh } from "babylonjs/Meshes/mesh";
  55371. /**
  55372. * Class containing static functions to help procedurally build meshes
  55373. */
  55374. export class TubeBuilder {
  55375. /**
  55376. * Creates a tube mesh.
  55377. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55378. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  55379. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  55380. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  55381. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  55382. * * 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)
  55383. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  55384. * * 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
  55385. * * 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
  55386. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55387. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55388. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55389. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55390. * @param name defines the name of the mesh
  55391. * @param options defines the options used to create the mesh
  55392. * @param scene defines the hosting scene
  55393. * @returns the tube mesh
  55394. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55395. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  55396. */
  55397. static CreateTube(name: string, options: {
  55398. path: Vector3[];
  55399. radius?: number;
  55400. tessellation?: number;
  55401. radiusFunction?: {
  55402. (i: number, distance: number): number;
  55403. };
  55404. cap?: number;
  55405. arc?: number;
  55406. updatable?: boolean;
  55407. sideOrientation?: number;
  55408. frontUVs?: Vector4;
  55409. backUVs?: Vector4;
  55410. instance?: Mesh;
  55411. invertUV?: boolean;
  55412. }, scene?: Nullable<Scene>): Mesh;
  55413. }
  55414. }
  55415. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  55416. import { Scene } from "babylonjs/scene";
  55417. import { Vector4 } from "babylonjs/Maths/math";
  55418. import { Mesh } from "babylonjs/Meshes/mesh";
  55419. import { Nullable } from "babylonjs/types";
  55420. /**
  55421. * Class containing static functions to help procedurally build meshes
  55422. */
  55423. export class IcoSphereBuilder {
  55424. /**
  55425. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  55426. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  55427. * * 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`)
  55428. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  55429. * * 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
  55430. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55431. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55432. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55433. * @param name defines the name of the mesh
  55434. * @param options defines the options used to create the mesh
  55435. * @param scene defines the hosting scene
  55436. * @returns the icosahedron mesh
  55437. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  55438. */
  55439. static CreateIcoSphere(name: string, options: {
  55440. radius?: number;
  55441. radiusX?: number;
  55442. radiusY?: number;
  55443. radiusZ?: number;
  55444. flat?: boolean;
  55445. subdivisions?: number;
  55446. sideOrientation?: number;
  55447. frontUVs?: Vector4;
  55448. backUVs?: Vector4;
  55449. updatable?: boolean;
  55450. }, scene?: Nullable<Scene>): Mesh;
  55451. }
  55452. }
  55453. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  55454. import { Vector3 } from "babylonjs/Maths/math";
  55455. import { Mesh } from "babylonjs/Meshes/mesh";
  55456. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55457. /**
  55458. * Class containing static functions to help procedurally build meshes
  55459. */
  55460. export class DecalBuilder {
  55461. /**
  55462. * Creates a decal mesh.
  55463. * 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
  55464. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  55465. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  55466. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  55467. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  55468. * @param name defines the name of the mesh
  55469. * @param sourceMesh defines the mesh where the decal must be applied
  55470. * @param options defines the options used to create the mesh
  55471. * @param scene defines the hosting scene
  55472. * @returns the decal mesh
  55473. * @see https://doc.babylonjs.com/how_to/decals
  55474. */
  55475. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  55476. position?: Vector3;
  55477. normal?: Vector3;
  55478. size?: Vector3;
  55479. angle?: number;
  55480. }): Mesh;
  55481. }
  55482. }
  55483. declare module "babylonjs/Meshes/meshBuilder" {
  55484. import { Vector4, Color4, Vector3, Vector2, Plane, Color3 } from "babylonjs/Maths/math";
  55485. import { Nullable } from "babylonjs/types";
  55486. import { Scene } from "babylonjs/scene";
  55487. import { Mesh } from "babylonjs/Meshes/mesh";
  55488. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  55489. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  55490. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55491. /**
  55492. * Class containing static functions to help procedurally build meshes
  55493. */
  55494. export class MeshBuilder {
  55495. /**
  55496. * Creates a box mesh
  55497. * * The parameter `size` sets the size (float) of each box side (default 1)
  55498. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  55499. * * 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)
  55500. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55501. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55502. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55503. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55504. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  55505. * @param name defines the name of the mesh
  55506. * @param options defines the options used to create the mesh
  55507. * @param scene defines the hosting scene
  55508. * @returns the box mesh
  55509. */
  55510. static CreateBox(name: string, options: {
  55511. size?: number;
  55512. width?: number;
  55513. height?: number;
  55514. depth?: number;
  55515. faceUV?: Vector4[];
  55516. faceColors?: Color4[];
  55517. sideOrientation?: number;
  55518. frontUVs?: Vector4;
  55519. backUVs?: Vector4;
  55520. updatable?: boolean;
  55521. }, scene?: Nullable<Scene>): Mesh;
  55522. /**
  55523. * Creates a tiled box mesh
  55524. * * faceTiles sets the pattern, tile size and number of tiles for a face
  55525. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55526. * @param name defines the name of the mesh
  55527. * @param options defines the options used to create the mesh
  55528. * @param scene defines the hosting scene
  55529. * @returns the tiled box mesh
  55530. */
  55531. static CreateTiledBox(name: string, options: {
  55532. pattern?: number;
  55533. size?: number;
  55534. width?: number;
  55535. height?: number;
  55536. depth: number;
  55537. tileSize?: number;
  55538. tileWidth?: number;
  55539. tileHeight?: number;
  55540. faceUV?: Vector4[];
  55541. faceColors?: Color4[];
  55542. alignHorizontal?: number;
  55543. alignVertical?: number;
  55544. sideOrientation?: number;
  55545. updatable?: boolean;
  55546. }, scene?: Nullable<Scene>): Mesh;
  55547. /**
  55548. * Creates a sphere mesh
  55549. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  55550. * * 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`)
  55551. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  55552. * * 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
  55553. * * 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)
  55554. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55555. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55556. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55557. * @param name defines the name of the mesh
  55558. * @param options defines the options used to create the mesh
  55559. * @param scene defines the hosting scene
  55560. * @returns the sphere mesh
  55561. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  55562. */
  55563. static CreateSphere(name: string, options: {
  55564. segments?: number;
  55565. diameter?: number;
  55566. diameterX?: number;
  55567. diameterY?: number;
  55568. diameterZ?: number;
  55569. arc?: number;
  55570. slice?: number;
  55571. sideOrientation?: number;
  55572. frontUVs?: Vector4;
  55573. backUVs?: Vector4;
  55574. updatable?: boolean;
  55575. }, scene?: Nullable<Scene>): Mesh;
  55576. /**
  55577. * Creates a plane polygonal mesh. By default, this is a disc
  55578. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  55579. * * 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
  55580. * * 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
  55581. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55582. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55583. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55584. * @param name defines the name of the mesh
  55585. * @param options defines the options used to create the mesh
  55586. * @param scene defines the hosting scene
  55587. * @returns the plane polygonal mesh
  55588. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  55589. */
  55590. static CreateDisc(name: string, options: {
  55591. radius?: number;
  55592. tessellation?: number;
  55593. arc?: number;
  55594. updatable?: boolean;
  55595. sideOrientation?: number;
  55596. frontUVs?: Vector4;
  55597. backUVs?: Vector4;
  55598. }, scene?: Nullable<Scene>): Mesh;
  55599. /**
  55600. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  55601. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  55602. * * 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`)
  55603. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  55604. * * 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
  55605. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55606. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55607. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55608. * @param name defines the name of the mesh
  55609. * @param options defines the options used to create the mesh
  55610. * @param scene defines the hosting scene
  55611. * @returns the icosahedron mesh
  55612. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  55613. */
  55614. static CreateIcoSphere(name: string, options: {
  55615. radius?: number;
  55616. radiusX?: number;
  55617. radiusY?: number;
  55618. radiusZ?: number;
  55619. flat?: boolean;
  55620. subdivisions?: number;
  55621. sideOrientation?: number;
  55622. frontUVs?: Vector4;
  55623. backUVs?: Vector4;
  55624. updatable?: boolean;
  55625. }, scene?: Nullable<Scene>): Mesh;
  55626. /**
  55627. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55628. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  55629. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  55630. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  55631. * * 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
  55632. * * 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
  55633. * * 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
  55634. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55635. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55636. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55637. * * 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
  55638. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55639. * * 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
  55640. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55641. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55642. * @param name defines the name of the mesh
  55643. * @param options defines the options used to create the mesh
  55644. * @param scene defines the hosting scene
  55645. * @returns the ribbon mesh
  55646. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55647. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55648. */
  55649. static CreateRibbon(name: string, options: {
  55650. pathArray: Vector3[][];
  55651. closeArray?: boolean;
  55652. closePath?: boolean;
  55653. offset?: number;
  55654. updatable?: boolean;
  55655. sideOrientation?: number;
  55656. frontUVs?: Vector4;
  55657. backUVs?: Vector4;
  55658. instance?: Mesh;
  55659. invertUV?: boolean;
  55660. uvs?: Vector2[];
  55661. colors?: Color4[];
  55662. }, scene?: Nullable<Scene>): Mesh;
  55663. /**
  55664. * Creates a cylinder or a cone mesh
  55665. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  55666. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  55667. * * 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.
  55668. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  55669. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  55670. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  55671. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  55672. * * 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).
  55673. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  55674. * * 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).
  55675. * * 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
  55676. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  55677. * * 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
  55678. * * 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.
  55679. * * If `enclose` is false, a ring surface is one element.
  55680. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  55681. * * 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
  55682. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55683. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55684. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55685. * @param name defines the name of the mesh
  55686. * @param options defines the options used to create the mesh
  55687. * @param scene defines the hosting scene
  55688. * @returns the cylinder mesh
  55689. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  55690. */
  55691. static CreateCylinder(name: string, options: {
  55692. height?: number;
  55693. diameterTop?: number;
  55694. diameterBottom?: number;
  55695. diameter?: number;
  55696. tessellation?: number;
  55697. subdivisions?: number;
  55698. arc?: number;
  55699. faceColors?: Color4[];
  55700. faceUV?: Vector4[];
  55701. updatable?: boolean;
  55702. hasRings?: boolean;
  55703. enclose?: boolean;
  55704. cap?: number;
  55705. sideOrientation?: number;
  55706. frontUVs?: Vector4;
  55707. backUVs?: Vector4;
  55708. }, scene?: Nullable<Scene>): Mesh;
  55709. /**
  55710. * Creates a torus mesh
  55711. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  55712. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  55713. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  55714. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55715. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55716. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55717. * @param name defines the name of the mesh
  55718. * @param options defines the options used to create the mesh
  55719. * @param scene defines the hosting scene
  55720. * @returns the torus mesh
  55721. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  55722. */
  55723. static CreateTorus(name: string, options: {
  55724. diameter?: number;
  55725. thickness?: number;
  55726. tessellation?: number;
  55727. updatable?: boolean;
  55728. sideOrientation?: number;
  55729. frontUVs?: Vector4;
  55730. backUVs?: Vector4;
  55731. }, scene?: Nullable<Scene>): Mesh;
  55732. /**
  55733. * Creates a torus knot mesh
  55734. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  55735. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  55736. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  55737. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  55738. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55739. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55740. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55741. * @param name defines the name of the mesh
  55742. * @param options defines the options used to create the mesh
  55743. * @param scene defines the hosting scene
  55744. * @returns the torus knot mesh
  55745. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  55746. */
  55747. static CreateTorusKnot(name: string, options: {
  55748. radius?: number;
  55749. tube?: number;
  55750. radialSegments?: number;
  55751. tubularSegments?: number;
  55752. p?: number;
  55753. q?: number;
  55754. updatable?: boolean;
  55755. sideOrientation?: number;
  55756. frontUVs?: Vector4;
  55757. backUVs?: Vector4;
  55758. }, scene?: Nullable<Scene>): Mesh;
  55759. /**
  55760. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  55761. * * 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
  55762. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  55763. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  55764. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  55765. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  55766. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  55767. * * 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
  55768. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  55769. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55770. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  55771. * @param name defines the name of the new line system
  55772. * @param options defines the options used to create the line system
  55773. * @param scene defines the hosting scene
  55774. * @returns a new line system mesh
  55775. */
  55776. static CreateLineSystem(name: string, options: {
  55777. lines: Vector3[][];
  55778. updatable?: boolean;
  55779. instance?: Nullable<LinesMesh>;
  55780. colors?: Nullable<Color4[][]>;
  55781. useVertexAlpha?: boolean;
  55782. }, scene: Nullable<Scene>): LinesMesh;
  55783. /**
  55784. * Creates a line mesh
  55785. * 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
  55786. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  55787. * * The parameter `points` is an array successive Vector3
  55788. * * 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
  55789. * * The optional parameter `colors` is an array of successive Color4, one per line point
  55790. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  55791. * * When updating an instance, remember that only point positions can change, not the number of points
  55792. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55793. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  55794. * @param name defines the name of the new line system
  55795. * @param options defines the options used to create the line system
  55796. * @param scene defines the hosting scene
  55797. * @returns a new line mesh
  55798. */
  55799. static CreateLines(name: string, options: {
  55800. points: Vector3[];
  55801. updatable?: boolean;
  55802. instance?: Nullable<LinesMesh>;
  55803. colors?: Color4[];
  55804. useVertexAlpha?: boolean;
  55805. }, scene?: Nullable<Scene>): LinesMesh;
  55806. /**
  55807. * Creates a dashed line mesh
  55808. * * 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
  55809. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  55810. * * The parameter `points` is an array successive Vector3
  55811. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  55812. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  55813. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  55814. * * 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
  55815. * * When updating an instance, remember that only point positions can change, not the number of points
  55816. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55817. * @param name defines the name of the mesh
  55818. * @param options defines the options used to create the mesh
  55819. * @param scene defines the hosting scene
  55820. * @returns the dashed line mesh
  55821. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  55822. */
  55823. static CreateDashedLines(name: string, options: {
  55824. points: Vector3[];
  55825. dashSize?: number;
  55826. gapSize?: number;
  55827. dashNb?: number;
  55828. updatable?: boolean;
  55829. instance?: LinesMesh;
  55830. }, scene?: Nullable<Scene>): LinesMesh;
  55831. /**
  55832. * 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.
  55833. * * 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.
  55834. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55835. * * 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.
  55836. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  55837. * * 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
  55838. * * 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
  55839. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  55840. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55841. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55842. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  55843. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55844. * @param name defines the name of the mesh
  55845. * @param options defines the options used to create the mesh
  55846. * @param scene defines the hosting scene
  55847. * @returns the extruded shape mesh
  55848. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55849. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55850. */
  55851. static ExtrudeShape(name: string, options: {
  55852. shape: Vector3[];
  55853. path: Vector3[];
  55854. scale?: number;
  55855. rotation?: number;
  55856. cap?: number;
  55857. updatable?: boolean;
  55858. sideOrientation?: number;
  55859. frontUVs?: Vector4;
  55860. backUVs?: Vector4;
  55861. instance?: Mesh;
  55862. invertUV?: boolean;
  55863. }, scene?: Nullable<Scene>): Mesh;
  55864. /**
  55865. * Creates an custom extruded shape mesh.
  55866. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55867. * * 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.
  55868. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55869. * * 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
  55870. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55871. * * 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
  55872. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55873. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55874. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55875. * * 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
  55876. * * 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
  55877. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55878. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55879. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55880. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55881. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55882. * @param name defines the name of the mesh
  55883. * @param options defines the options used to create the mesh
  55884. * @param scene defines the hosting scene
  55885. * @returns the custom extruded shape mesh
  55886. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55887. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55888. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55889. */
  55890. static ExtrudeShapeCustom(name: string, options: {
  55891. shape: Vector3[];
  55892. path: Vector3[];
  55893. scaleFunction?: any;
  55894. rotationFunction?: any;
  55895. ribbonCloseArray?: boolean;
  55896. ribbonClosePath?: boolean;
  55897. cap?: number;
  55898. updatable?: boolean;
  55899. sideOrientation?: number;
  55900. frontUVs?: Vector4;
  55901. backUVs?: Vector4;
  55902. instance?: Mesh;
  55903. invertUV?: boolean;
  55904. }, scene?: Nullable<Scene>): Mesh;
  55905. /**
  55906. * Creates lathe mesh.
  55907. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  55908. * * 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
  55909. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  55910. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  55911. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  55912. * * 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
  55913. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  55914. * * 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
  55915. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55916. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55917. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55918. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55919. * @param name defines the name of the mesh
  55920. * @param options defines the options used to create the mesh
  55921. * @param scene defines the hosting scene
  55922. * @returns the lathe mesh
  55923. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  55924. */
  55925. static CreateLathe(name: string, options: {
  55926. shape: Vector3[];
  55927. radius?: number;
  55928. tessellation?: number;
  55929. clip?: number;
  55930. arc?: number;
  55931. closed?: boolean;
  55932. updatable?: boolean;
  55933. sideOrientation?: number;
  55934. frontUVs?: Vector4;
  55935. backUVs?: Vector4;
  55936. cap?: number;
  55937. invertUV?: boolean;
  55938. }, scene?: Nullable<Scene>): Mesh;
  55939. /**
  55940. * Creates a tiled plane mesh
  55941. * * You can set a limited pattern arrangement with the tiles
  55942. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55943. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55944. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55945. * @param name defines the name of the mesh
  55946. * @param options defines the options used to create the mesh
  55947. * @param scene defines the hosting scene
  55948. * @returns the plane mesh
  55949. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  55950. */
  55951. static CreateTiledPlane(name: string, options: {
  55952. pattern?: number;
  55953. tileSize?: number;
  55954. tileWidth?: number;
  55955. tileHeight?: number;
  55956. size?: number;
  55957. width?: number;
  55958. height?: number;
  55959. alignHorizontal?: number;
  55960. alignVertical?: number;
  55961. sideOrientation?: number;
  55962. frontUVs?: Vector4;
  55963. backUVs?: Vector4;
  55964. updatable?: boolean;
  55965. }, scene?: Nullable<Scene>): Mesh;
  55966. /**
  55967. * Creates a plane mesh
  55968. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  55969. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  55970. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  55971. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55972. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55973. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55974. * @param name defines the name of the mesh
  55975. * @param options defines the options used to create the mesh
  55976. * @param scene defines the hosting scene
  55977. * @returns the plane mesh
  55978. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  55979. */
  55980. static CreatePlane(name: string, options: {
  55981. size?: number;
  55982. width?: number;
  55983. height?: number;
  55984. sideOrientation?: number;
  55985. frontUVs?: Vector4;
  55986. backUVs?: Vector4;
  55987. updatable?: boolean;
  55988. sourcePlane?: Plane;
  55989. }, scene?: Nullable<Scene>): Mesh;
  55990. /**
  55991. * Creates a ground mesh
  55992. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  55993. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  55994. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55995. * @param name defines the name of the mesh
  55996. * @param options defines the options used to create the mesh
  55997. * @param scene defines the hosting scene
  55998. * @returns the ground mesh
  55999. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  56000. */
  56001. static CreateGround(name: string, options: {
  56002. width?: number;
  56003. height?: number;
  56004. subdivisions?: number;
  56005. subdivisionsX?: number;
  56006. subdivisionsY?: number;
  56007. updatable?: boolean;
  56008. }, scene?: Nullable<Scene>): Mesh;
  56009. /**
  56010. * Creates a tiled ground mesh
  56011. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  56012. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  56013. * * 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
  56014. * * 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
  56015. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56016. * @param name defines the name of the mesh
  56017. * @param options defines the options used to create the mesh
  56018. * @param scene defines the hosting scene
  56019. * @returns the tiled ground mesh
  56020. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  56021. */
  56022. static CreateTiledGround(name: string, options: {
  56023. xmin: number;
  56024. zmin: number;
  56025. xmax: number;
  56026. zmax: number;
  56027. subdivisions?: {
  56028. w: number;
  56029. h: number;
  56030. };
  56031. precision?: {
  56032. w: number;
  56033. h: number;
  56034. };
  56035. updatable?: boolean;
  56036. }, scene?: Nullable<Scene>): Mesh;
  56037. /**
  56038. * Creates a ground mesh from a height map
  56039. * * The parameter `url` sets the URL of the height map image resource.
  56040. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  56041. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  56042. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  56043. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  56044. * * 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.
  56045. * * 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).
  56046. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  56047. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56048. * @param name defines the name of the mesh
  56049. * @param url defines the url to the height map
  56050. * @param options defines the options used to create the mesh
  56051. * @param scene defines the hosting scene
  56052. * @returns the ground mesh
  56053. * @see https://doc.babylonjs.com/babylon101/height_map
  56054. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  56055. */
  56056. static CreateGroundFromHeightMap(name: string, url: string, options: {
  56057. width?: number;
  56058. height?: number;
  56059. subdivisions?: number;
  56060. minHeight?: number;
  56061. maxHeight?: number;
  56062. colorFilter?: Color3;
  56063. alphaFilter?: number;
  56064. updatable?: boolean;
  56065. onReady?: (mesh: GroundMesh) => void;
  56066. }, scene?: Nullable<Scene>): GroundMesh;
  56067. /**
  56068. * Creates a polygon mesh
  56069. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  56070. * * 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
  56071. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  56072. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56073. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  56074. * * Remember you can only change the shape positions, not their number when updating a polygon
  56075. * @param name defines the name of the mesh
  56076. * @param options defines the options used to create the mesh
  56077. * @param scene defines the hosting scene
  56078. * @param earcutInjection can be used to inject your own earcut reference
  56079. * @returns the polygon mesh
  56080. */
  56081. static CreatePolygon(name: string, options: {
  56082. shape: Vector3[];
  56083. holes?: Vector3[][];
  56084. depth?: number;
  56085. faceUV?: Vector4[];
  56086. faceColors?: Color4[];
  56087. updatable?: boolean;
  56088. sideOrientation?: number;
  56089. frontUVs?: Vector4;
  56090. backUVs?: Vector4;
  56091. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56092. /**
  56093. * Creates an extruded polygon mesh, with depth in the Y direction.
  56094. * * 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)
  56095. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56096. * @param name defines the name of the mesh
  56097. * @param options defines the options used to create the mesh
  56098. * @param scene defines the hosting scene
  56099. * @param earcutInjection can be used to inject your own earcut reference
  56100. * @returns the polygon mesh
  56101. */
  56102. static ExtrudePolygon(name: string, options: {
  56103. shape: Vector3[];
  56104. holes?: Vector3[][];
  56105. depth?: number;
  56106. faceUV?: Vector4[];
  56107. faceColors?: Color4[];
  56108. updatable?: boolean;
  56109. sideOrientation?: number;
  56110. frontUVs?: Vector4;
  56111. backUVs?: Vector4;
  56112. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56113. /**
  56114. * Creates a tube mesh.
  56115. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56116. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  56117. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  56118. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  56119. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  56120. * * 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)
  56121. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  56122. * * 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
  56123. * * 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
  56124. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56125. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56126. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56127. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56128. * @param name defines the name of the mesh
  56129. * @param options defines the options used to create the mesh
  56130. * @param scene defines the hosting scene
  56131. * @returns the tube mesh
  56132. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56133. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  56134. */
  56135. static CreateTube(name: string, options: {
  56136. path: Vector3[];
  56137. radius?: number;
  56138. tessellation?: number;
  56139. radiusFunction?: {
  56140. (i: number, distance: number): number;
  56141. };
  56142. cap?: number;
  56143. arc?: number;
  56144. updatable?: boolean;
  56145. sideOrientation?: number;
  56146. frontUVs?: Vector4;
  56147. backUVs?: Vector4;
  56148. instance?: Mesh;
  56149. invertUV?: boolean;
  56150. }, scene?: Nullable<Scene>): Mesh;
  56151. /**
  56152. * Creates a polyhedron mesh
  56153. * * 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
  56154. * * The parameter `size` (positive float, default 1) sets the polygon size
  56155. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  56156. * * 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`
  56157. * * 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
  56158. * * 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)`)
  56159. * * 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
  56160. * * 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
  56161. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56162. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56163. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56164. * @param name defines the name of the mesh
  56165. * @param options defines the options used to create the mesh
  56166. * @param scene defines the hosting scene
  56167. * @returns the polyhedron mesh
  56168. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  56169. */
  56170. static CreatePolyhedron(name: string, options: {
  56171. type?: number;
  56172. size?: number;
  56173. sizeX?: number;
  56174. sizeY?: number;
  56175. sizeZ?: number;
  56176. custom?: any;
  56177. faceUV?: Vector4[];
  56178. faceColors?: Color4[];
  56179. flat?: boolean;
  56180. updatable?: boolean;
  56181. sideOrientation?: number;
  56182. frontUVs?: Vector4;
  56183. backUVs?: Vector4;
  56184. }, scene?: Nullable<Scene>): Mesh;
  56185. /**
  56186. * Creates a decal mesh.
  56187. * 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
  56188. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  56189. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  56190. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  56191. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  56192. * @param name defines the name of the mesh
  56193. * @param sourceMesh defines the mesh where the decal must be applied
  56194. * @param options defines the options used to create the mesh
  56195. * @param scene defines the hosting scene
  56196. * @returns the decal mesh
  56197. * @see https://doc.babylonjs.com/how_to/decals
  56198. */
  56199. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  56200. position?: Vector3;
  56201. normal?: Vector3;
  56202. size?: Vector3;
  56203. angle?: number;
  56204. }): Mesh;
  56205. }
  56206. }
  56207. declare module "babylonjs/Meshes/meshSimplification" {
  56208. import { Mesh } from "babylonjs/Meshes/mesh";
  56209. /**
  56210. * A simplifier interface for future simplification implementations
  56211. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56212. */
  56213. export interface ISimplifier {
  56214. /**
  56215. * Simplification of a given mesh according to the given settings.
  56216. * Since this requires computation, it is assumed that the function runs async.
  56217. * @param settings The settings of the simplification, including quality and distance
  56218. * @param successCallback A callback that will be called after the mesh was simplified.
  56219. * @param errorCallback in case of an error, this callback will be called. optional.
  56220. */
  56221. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  56222. }
  56223. /**
  56224. * Expected simplification settings.
  56225. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  56226. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56227. */
  56228. export interface ISimplificationSettings {
  56229. /**
  56230. * Gets or sets the expected quality
  56231. */
  56232. quality: number;
  56233. /**
  56234. * Gets or sets the distance when this optimized version should be used
  56235. */
  56236. distance: number;
  56237. /**
  56238. * Gets an already optimized mesh
  56239. */
  56240. optimizeMesh?: boolean;
  56241. }
  56242. /**
  56243. * Class used to specify simplification options
  56244. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56245. */
  56246. export class SimplificationSettings implements ISimplificationSettings {
  56247. /** expected quality */
  56248. quality: number;
  56249. /** distance when this optimized version should be used */
  56250. distance: number;
  56251. /** already optimized mesh */
  56252. optimizeMesh?: boolean | undefined;
  56253. /**
  56254. * Creates a SimplificationSettings
  56255. * @param quality expected quality
  56256. * @param distance distance when this optimized version should be used
  56257. * @param optimizeMesh already optimized mesh
  56258. */
  56259. constructor(
  56260. /** expected quality */
  56261. quality: number,
  56262. /** distance when this optimized version should be used */
  56263. distance: number,
  56264. /** already optimized mesh */
  56265. optimizeMesh?: boolean | undefined);
  56266. }
  56267. /**
  56268. * Interface used to define a simplification task
  56269. */
  56270. export interface ISimplificationTask {
  56271. /**
  56272. * Array of settings
  56273. */
  56274. settings: Array<ISimplificationSettings>;
  56275. /**
  56276. * Simplification type
  56277. */
  56278. simplificationType: SimplificationType;
  56279. /**
  56280. * Mesh to simplify
  56281. */
  56282. mesh: Mesh;
  56283. /**
  56284. * Callback called on success
  56285. */
  56286. successCallback?: () => void;
  56287. /**
  56288. * Defines if parallel processing can be used
  56289. */
  56290. parallelProcessing: boolean;
  56291. }
  56292. /**
  56293. * Queue used to order the simplification tasks
  56294. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56295. */
  56296. export class SimplificationQueue {
  56297. private _simplificationArray;
  56298. /**
  56299. * Gets a boolean indicating that the process is still running
  56300. */
  56301. running: boolean;
  56302. /**
  56303. * Creates a new queue
  56304. */
  56305. constructor();
  56306. /**
  56307. * Adds a new simplification task
  56308. * @param task defines a task to add
  56309. */
  56310. addTask(task: ISimplificationTask): void;
  56311. /**
  56312. * Execute next task
  56313. */
  56314. executeNext(): void;
  56315. /**
  56316. * Execute a simplification task
  56317. * @param task defines the task to run
  56318. */
  56319. runSimplification(task: ISimplificationTask): void;
  56320. private getSimplifier;
  56321. }
  56322. /**
  56323. * The implemented types of simplification
  56324. * At the moment only Quadratic Error Decimation is implemented
  56325. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56326. */
  56327. export enum SimplificationType {
  56328. /** Quadratic error decimation */
  56329. QUADRATIC = 0
  56330. }
  56331. }
  56332. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  56333. import { Scene } from "babylonjs/scene";
  56334. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  56335. import { ISceneComponent } from "babylonjs/sceneComponent";
  56336. module "babylonjs/scene" {
  56337. interface Scene {
  56338. /** @hidden (Backing field) */
  56339. _simplificationQueue: SimplificationQueue;
  56340. /**
  56341. * Gets or sets the simplification queue attached to the scene
  56342. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56343. */
  56344. simplificationQueue: SimplificationQueue;
  56345. }
  56346. }
  56347. module "babylonjs/Meshes/mesh" {
  56348. interface Mesh {
  56349. /**
  56350. * Simplify the mesh according to the given array of settings.
  56351. * Function will return immediately and will simplify async
  56352. * @param settings a collection of simplification settings
  56353. * @param parallelProcessing should all levels calculate parallel or one after the other
  56354. * @param simplificationType the type of simplification to run
  56355. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  56356. * @returns the current mesh
  56357. */
  56358. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  56359. }
  56360. }
  56361. /**
  56362. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  56363. * created in a scene
  56364. */
  56365. export class SimplicationQueueSceneComponent implements ISceneComponent {
  56366. /**
  56367. * The component name helpfull to identify the component in the list of scene components.
  56368. */
  56369. readonly name: string;
  56370. /**
  56371. * The scene the component belongs to.
  56372. */
  56373. scene: Scene;
  56374. /**
  56375. * Creates a new instance of the component for the given scene
  56376. * @param scene Defines the scene to register the component in
  56377. */
  56378. constructor(scene: Scene);
  56379. /**
  56380. * Registers the component in a given scene
  56381. */
  56382. register(): void;
  56383. /**
  56384. * Rebuilds the elements related to this component in case of
  56385. * context lost for instance.
  56386. */
  56387. rebuild(): void;
  56388. /**
  56389. * Disposes the component and the associated ressources
  56390. */
  56391. dispose(): void;
  56392. private _beforeCameraUpdate;
  56393. }
  56394. }
  56395. declare module "babylonjs/Meshes/Builders/index" {
  56396. export * from "babylonjs/Meshes/Builders/boxBuilder";
  56397. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  56398. export * from "babylonjs/Meshes/Builders/discBuilder";
  56399. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  56400. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  56401. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  56402. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  56403. export * from "babylonjs/Meshes/Builders/torusBuilder";
  56404. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  56405. export * from "babylonjs/Meshes/Builders/linesBuilder";
  56406. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  56407. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  56408. export * from "babylonjs/Meshes/Builders/latheBuilder";
  56409. export * from "babylonjs/Meshes/Builders/planeBuilder";
  56410. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  56411. export * from "babylonjs/Meshes/Builders/groundBuilder";
  56412. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  56413. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  56414. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  56415. export * from "babylonjs/Meshes/Builders/decalBuilder";
  56416. }
  56417. declare module "babylonjs/Meshes/index" {
  56418. export * from "babylonjs/Meshes/abstractMesh";
  56419. export * from "babylonjs/Meshes/buffer";
  56420. export * from "babylonjs/Meshes/Compression/index";
  56421. export * from "babylonjs/Meshes/csg";
  56422. export * from "babylonjs/Meshes/geometry";
  56423. export * from "babylonjs/Meshes/groundMesh";
  56424. export * from "babylonjs/Meshes/trailMesh";
  56425. export * from "babylonjs/Meshes/instancedMesh";
  56426. export * from "babylonjs/Meshes/linesMesh";
  56427. export * from "babylonjs/Meshes/mesh";
  56428. export * from "babylonjs/Meshes/mesh.vertexData";
  56429. export * from "babylonjs/Meshes/meshBuilder";
  56430. export * from "babylonjs/Meshes/meshSimplification";
  56431. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  56432. export * from "babylonjs/Meshes/polygonMesh";
  56433. export * from "babylonjs/Meshes/subMesh";
  56434. export * from "babylonjs/Meshes/meshLODLevel";
  56435. export * from "babylonjs/Meshes/transformNode";
  56436. export * from "babylonjs/Meshes/Builders/index";
  56437. export * from "babylonjs/Meshes/dataBuffer";
  56438. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  56439. }
  56440. declare module "babylonjs/Morph/index" {
  56441. export * from "babylonjs/Morph/morphTarget";
  56442. export * from "babylonjs/Morph/morphTargetManager";
  56443. }
  56444. declare module "babylonjs/Offline/database" {
  56445. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  56446. /**
  56447. * Class used to enable access to IndexedDB
  56448. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  56449. */
  56450. export class Database implements IOfflineProvider {
  56451. private _callbackManifestChecked;
  56452. private _currentSceneUrl;
  56453. private _db;
  56454. private _enableSceneOffline;
  56455. private _enableTexturesOffline;
  56456. private _manifestVersionFound;
  56457. private _mustUpdateRessources;
  56458. private _hasReachedQuota;
  56459. private _isSupported;
  56460. private _idbFactory;
  56461. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  56462. private static IsUASupportingBlobStorage;
  56463. /**
  56464. * Gets a boolean indicating if Database storate is enabled (off by default)
  56465. */
  56466. static IDBStorageEnabled: boolean;
  56467. /**
  56468. * Gets a boolean indicating if scene must be saved in the database
  56469. */
  56470. readonly enableSceneOffline: boolean;
  56471. /**
  56472. * Gets a boolean indicating if textures must be saved in the database
  56473. */
  56474. readonly enableTexturesOffline: boolean;
  56475. /**
  56476. * Creates a new Database
  56477. * @param urlToScene defines the url to load the scene
  56478. * @param callbackManifestChecked defines the callback to use when manifest is checked
  56479. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  56480. */
  56481. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  56482. private static _ParseURL;
  56483. private static _ReturnFullUrlLocation;
  56484. private _checkManifestFile;
  56485. /**
  56486. * Open the database and make it available
  56487. * @param successCallback defines the callback to call on success
  56488. * @param errorCallback defines the callback to call on error
  56489. */
  56490. open(successCallback: () => void, errorCallback: () => void): void;
  56491. /**
  56492. * Loads an image from the database
  56493. * @param url defines the url to load from
  56494. * @param image defines the target DOM image
  56495. */
  56496. loadImage(url: string, image: HTMLImageElement): void;
  56497. private _loadImageFromDBAsync;
  56498. private _saveImageIntoDBAsync;
  56499. private _checkVersionFromDB;
  56500. private _loadVersionFromDBAsync;
  56501. private _saveVersionIntoDBAsync;
  56502. /**
  56503. * Loads a file from database
  56504. * @param url defines the URL to load from
  56505. * @param sceneLoaded defines a callback to call on success
  56506. * @param progressCallBack defines a callback to call when progress changed
  56507. * @param errorCallback defines a callback to call on error
  56508. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  56509. */
  56510. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  56511. private _loadFileAsync;
  56512. private _saveFileAsync;
  56513. /**
  56514. * Validates if xhr data is correct
  56515. * @param xhr defines the request to validate
  56516. * @param dataType defines the expected data type
  56517. * @returns true if data is correct
  56518. */
  56519. private static _ValidateXHRData;
  56520. }
  56521. }
  56522. declare module "babylonjs/Offline/index" {
  56523. export * from "babylonjs/Offline/database";
  56524. export * from "babylonjs/Offline/IOfflineProvider";
  56525. }
  56526. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  56527. /** @hidden */
  56528. export var gpuUpdateParticlesPixelShader: {
  56529. name: string;
  56530. shader: string;
  56531. };
  56532. }
  56533. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  56534. /** @hidden */
  56535. export var gpuUpdateParticlesVertexShader: {
  56536. name: string;
  56537. shader: string;
  56538. };
  56539. }
  56540. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  56541. /** @hidden */
  56542. export var clipPlaneFragmentDeclaration2: {
  56543. name: string;
  56544. shader: string;
  56545. };
  56546. }
  56547. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  56548. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  56549. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  56550. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56551. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  56552. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  56553. /** @hidden */
  56554. export var gpuRenderParticlesPixelShader: {
  56555. name: string;
  56556. shader: string;
  56557. };
  56558. }
  56559. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  56560. /** @hidden */
  56561. export var clipPlaneVertexDeclaration2: {
  56562. name: string;
  56563. shader: string;
  56564. };
  56565. }
  56566. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  56567. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  56568. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  56569. /** @hidden */
  56570. export var gpuRenderParticlesVertexShader: {
  56571. name: string;
  56572. shader: string;
  56573. };
  56574. }
  56575. declare module "babylonjs/Particles/gpuParticleSystem" {
  56576. import { Nullable } from "babylonjs/types";
  56577. import { IAnimatable, IValueGradient, Color3Gradient } from "babylonjs/Misc/tools";
  56578. import { Observable } from "babylonjs/Misc/observable";
  56579. import { Color4, Color3 } from "babylonjs/Maths/math";
  56580. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  56581. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  56582. import { Scene, IDisposable } from "babylonjs/scene";
  56583. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  56584. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  56585. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  56586. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  56587. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  56588. /**
  56589. * This represents a GPU particle system in Babylon
  56590. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  56591. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  56592. */
  56593. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  56594. /**
  56595. * The layer mask we are rendering the particles through.
  56596. */
  56597. layerMask: number;
  56598. private _capacity;
  56599. private _activeCount;
  56600. private _currentActiveCount;
  56601. private _accumulatedCount;
  56602. private _renderEffect;
  56603. private _updateEffect;
  56604. private _buffer0;
  56605. private _buffer1;
  56606. private _spriteBuffer;
  56607. private _updateVAO;
  56608. private _renderVAO;
  56609. private _targetIndex;
  56610. private _sourceBuffer;
  56611. private _targetBuffer;
  56612. private _engine;
  56613. private _currentRenderId;
  56614. private _started;
  56615. private _stopped;
  56616. private _timeDelta;
  56617. private _randomTexture;
  56618. private _randomTexture2;
  56619. private _attributesStrideSize;
  56620. private _updateEffectOptions;
  56621. private _randomTextureSize;
  56622. private _actualFrame;
  56623. private readonly _rawTextureWidth;
  56624. /**
  56625. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  56626. */
  56627. static readonly IsSupported: boolean;
  56628. /**
  56629. * An event triggered when the system is disposed.
  56630. */
  56631. onDisposeObservable: Observable<GPUParticleSystem>;
  56632. /**
  56633. * Gets the maximum number of particles active at the same time.
  56634. * @returns The max number of active particles.
  56635. */
  56636. getCapacity(): number;
  56637. /**
  56638. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  56639. * to override the particles.
  56640. */
  56641. forceDepthWrite: boolean;
  56642. /**
  56643. * Gets or set the number of active particles
  56644. */
  56645. activeParticleCount: number;
  56646. private _preWarmDone;
  56647. /**
  56648. * Is this system ready to be used/rendered
  56649. * @return true if the system is ready
  56650. */
  56651. isReady(): boolean;
  56652. /**
  56653. * Gets if the system has been started. (Note: this will still be true after stop is called)
  56654. * @returns True if it has been started, otherwise false.
  56655. */
  56656. isStarted(): boolean;
  56657. /**
  56658. * Starts the particle system and begins to emit
  56659. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  56660. */
  56661. start(delay?: number): void;
  56662. /**
  56663. * Stops the particle system.
  56664. */
  56665. stop(): void;
  56666. /**
  56667. * Remove all active particles
  56668. */
  56669. reset(): void;
  56670. /**
  56671. * Returns the string "GPUParticleSystem"
  56672. * @returns a string containing the class name
  56673. */
  56674. getClassName(): string;
  56675. private _colorGradientsTexture;
  56676. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  56677. /**
  56678. * Adds a new color gradient
  56679. * @param gradient defines the gradient to use (between 0 and 1)
  56680. * @param color1 defines the color to affect to the specified gradient
  56681. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  56682. * @returns the current particle system
  56683. */
  56684. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  56685. /**
  56686. * Remove a specific color gradient
  56687. * @param gradient defines the gradient to remove
  56688. * @returns the current particle system
  56689. */
  56690. removeColorGradient(gradient: number): GPUParticleSystem;
  56691. private _angularSpeedGradientsTexture;
  56692. private _sizeGradientsTexture;
  56693. private _velocityGradientsTexture;
  56694. private _limitVelocityGradientsTexture;
  56695. private _dragGradientsTexture;
  56696. private _addFactorGradient;
  56697. /**
  56698. * Adds a new size gradient
  56699. * @param gradient defines the gradient to use (between 0 and 1)
  56700. * @param factor defines the size factor to affect to the specified gradient
  56701. * @returns the current particle system
  56702. */
  56703. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  56704. /**
  56705. * Remove a specific size gradient
  56706. * @param gradient defines the gradient to remove
  56707. * @returns the current particle system
  56708. */
  56709. removeSizeGradient(gradient: number): GPUParticleSystem;
  56710. /**
  56711. * Adds a new angular speed gradient
  56712. * @param gradient defines the gradient to use (between 0 and 1)
  56713. * @param factor defines the angular speed to affect to the specified gradient
  56714. * @returns the current particle system
  56715. */
  56716. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  56717. /**
  56718. * Remove a specific angular speed gradient
  56719. * @param gradient defines the gradient to remove
  56720. * @returns the current particle system
  56721. */
  56722. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  56723. /**
  56724. * Adds a new velocity gradient
  56725. * @param gradient defines the gradient to use (between 0 and 1)
  56726. * @param factor defines the velocity to affect to the specified gradient
  56727. * @returns the current particle system
  56728. */
  56729. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  56730. /**
  56731. * Remove a specific velocity gradient
  56732. * @param gradient defines the gradient to remove
  56733. * @returns the current particle system
  56734. */
  56735. removeVelocityGradient(gradient: number): GPUParticleSystem;
  56736. /**
  56737. * Adds a new limit velocity gradient
  56738. * @param gradient defines the gradient to use (between 0 and 1)
  56739. * @param factor defines the limit velocity value to affect to the specified gradient
  56740. * @returns the current particle system
  56741. */
  56742. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  56743. /**
  56744. * Remove a specific limit velocity gradient
  56745. * @param gradient defines the gradient to remove
  56746. * @returns the current particle system
  56747. */
  56748. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  56749. /**
  56750. * Adds a new drag gradient
  56751. * @param gradient defines the gradient to use (between 0 and 1)
  56752. * @param factor defines the drag value to affect to the specified gradient
  56753. * @returns the current particle system
  56754. */
  56755. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  56756. /**
  56757. * Remove a specific drag gradient
  56758. * @param gradient defines the gradient to remove
  56759. * @returns the current particle system
  56760. */
  56761. removeDragGradient(gradient: number): GPUParticleSystem;
  56762. /**
  56763. * Not supported by GPUParticleSystem
  56764. * @param gradient defines the gradient to use (between 0 and 1)
  56765. * @param factor defines the emit rate value to affect to the specified gradient
  56766. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  56767. * @returns the current particle system
  56768. */
  56769. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  56770. /**
  56771. * Not supported by GPUParticleSystem
  56772. * @param gradient defines the gradient to remove
  56773. * @returns the current particle system
  56774. */
  56775. removeEmitRateGradient(gradient: number): IParticleSystem;
  56776. /**
  56777. * Not supported by GPUParticleSystem
  56778. * @param gradient defines the gradient to use (between 0 and 1)
  56779. * @param factor defines the start size value to affect to the specified gradient
  56780. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  56781. * @returns the current particle system
  56782. */
  56783. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  56784. /**
  56785. * Not supported by GPUParticleSystem
  56786. * @param gradient defines the gradient to remove
  56787. * @returns the current particle system
  56788. */
  56789. removeStartSizeGradient(gradient: number): IParticleSystem;
  56790. /**
  56791. * Not supported by GPUParticleSystem
  56792. * @param gradient defines the gradient to use (between 0 and 1)
  56793. * @param min defines the color remap minimal range
  56794. * @param max defines the color remap maximal range
  56795. * @returns the current particle system
  56796. */
  56797. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  56798. /**
  56799. * Not supported by GPUParticleSystem
  56800. * @param gradient defines the gradient to remove
  56801. * @returns the current particle system
  56802. */
  56803. removeColorRemapGradient(): IParticleSystem;
  56804. /**
  56805. * Not supported by GPUParticleSystem
  56806. * @param gradient defines the gradient to use (between 0 and 1)
  56807. * @param min defines the alpha remap minimal range
  56808. * @param max defines the alpha remap maximal range
  56809. * @returns the current particle system
  56810. */
  56811. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  56812. /**
  56813. * Not supported by GPUParticleSystem
  56814. * @param gradient defines the gradient to remove
  56815. * @returns the current particle system
  56816. */
  56817. removeAlphaRemapGradient(): IParticleSystem;
  56818. /**
  56819. * Not supported by GPUParticleSystem
  56820. * @param gradient defines the gradient to use (between 0 and 1)
  56821. * @param color defines the color to affect to the specified gradient
  56822. * @returns the current particle system
  56823. */
  56824. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  56825. /**
  56826. * Not supported by GPUParticleSystem
  56827. * @param gradient defines the gradient to remove
  56828. * @returns the current particle system
  56829. */
  56830. removeRampGradient(): IParticleSystem;
  56831. /**
  56832. * Not supported by GPUParticleSystem
  56833. * @returns the list of ramp gradients
  56834. */
  56835. getRampGradients(): Nullable<Array<Color3Gradient>>;
  56836. /**
  56837. * Not supported by GPUParticleSystem
  56838. * Gets or sets a boolean indicating that ramp gradients must be used
  56839. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  56840. */
  56841. useRampGradients: boolean;
  56842. /**
  56843. * Not supported by GPUParticleSystem
  56844. * @param gradient defines the gradient to use (between 0 and 1)
  56845. * @param factor defines the life time factor to affect to the specified gradient
  56846. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  56847. * @returns the current particle system
  56848. */
  56849. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  56850. /**
  56851. * Not supported by GPUParticleSystem
  56852. * @param gradient defines the gradient to remove
  56853. * @returns the current particle system
  56854. */
  56855. removeLifeTimeGradient(gradient: number): IParticleSystem;
  56856. /**
  56857. * Instantiates a GPU particle system.
  56858. * 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.
  56859. * @param name The name of the particle system
  56860. * @param options The options used to create the system
  56861. * @param scene The scene the particle system belongs to
  56862. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  56863. */
  56864. constructor(name: string, options: Partial<{
  56865. capacity: number;
  56866. randomTextureSize: number;
  56867. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  56868. protected _reset(): void;
  56869. private _createUpdateVAO;
  56870. private _createRenderVAO;
  56871. private _initialize;
  56872. /** @hidden */
  56873. _recreateUpdateEffect(): void;
  56874. /** @hidden */
  56875. _recreateRenderEffect(): void;
  56876. /**
  56877. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  56878. * @param preWarm defines if we are in the pre-warmimg phase
  56879. */
  56880. animate(preWarm?: boolean): void;
  56881. private _createFactorGradientTexture;
  56882. private _createSizeGradientTexture;
  56883. private _createAngularSpeedGradientTexture;
  56884. private _createVelocityGradientTexture;
  56885. private _createLimitVelocityGradientTexture;
  56886. private _createDragGradientTexture;
  56887. private _createColorGradientTexture;
  56888. /**
  56889. * Renders the particle system in its current state
  56890. * @param preWarm defines if the system should only update the particles but not render them
  56891. * @returns the current number of particles
  56892. */
  56893. render(preWarm?: boolean): number;
  56894. /**
  56895. * Rebuilds the particle system
  56896. */
  56897. rebuild(): void;
  56898. private _releaseBuffers;
  56899. private _releaseVAOs;
  56900. /**
  56901. * Disposes the particle system and free the associated resources
  56902. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  56903. */
  56904. dispose(disposeTexture?: boolean): void;
  56905. /**
  56906. * Clones the particle system.
  56907. * @param name The name of the cloned object
  56908. * @param newEmitter The new emitter to use
  56909. * @returns the cloned particle system
  56910. */
  56911. clone(name: string, newEmitter: any): GPUParticleSystem;
  56912. /**
  56913. * Serializes the particle system to a JSON object.
  56914. * @returns the JSON object
  56915. */
  56916. serialize(): any;
  56917. /**
  56918. * Parses a JSON object to create a GPU particle system.
  56919. * @param parsedParticleSystem The JSON object to parse
  56920. * @param scene The scene to create the particle system in
  56921. * @param rootUrl The root url to use to load external dependencies like texture
  56922. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  56923. * @returns the parsed GPU particle system
  56924. */
  56925. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  56926. }
  56927. }
  56928. declare module "babylonjs/Particles/particleSystemSet" {
  56929. import { Nullable } from "babylonjs/types";
  56930. import { Color3 } from "babylonjs/Maths/math";
  56931. import { TransformNode } from "babylonjs/Meshes/transformNode";
  56932. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56933. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  56934. import { Scene, IDisposable } from "babylonjs/scene";
  56935. /**
  56936. * Represents a set of particle systems working together to create a specific effect
  56937. */
  56938. export class ParticleSystemSet implements IDisposable {
  56939. private _emitterCreationOptions;
  56940. private _emitterNode;
  56941. /**
  56942. * Gets the particle system list
  56943. */
  56944. systems: IParticleSystem[];
  56945. /**
  56946. * Gets the emitter node used with this set
  56947. */
  56948. readonly emitterNode: Nullable<TransformNode>;
  56949. /**
  56950. * Creates a new emitter mesh as a sphere
  56951. * @param options defines the options used to create the sphere
  56952. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  56953. * @param scene defines the hosting scene
  56954. */
  56955. setEmitterAsSphere(options: {
  56956. diameter: number;
  56957. segments: number;
  56958. color: Color3;
  56959. }, renderingGroupId: number, scene: Scene): void;
  56960. /**
  56961. * Starts all particle systems of the set
  56962. * @param emitter defines an optional mesh to use as emitter for the particle systems
  56963. */
  56964. start(emitter?: AbstractMesh): void;
  56965. /**
  56966. * Release all associated resources
  56967. */
  56968. dispose(): void;
  56969. /**
  56970. * Serialize the set into a JSON compatible object
  56971. * @returns a JSON compatible representation of the set
  56972. */
  56973. serialize(): any;
  56974. /**
  56975. * Parse a new ParticleSystemSet from a serialized source
  56976. * @param data defines a JSON compatible representation of the set
  56977. * @param scene defines the hosting scene
  56978. * @param gpu defines if we want GPU particles or CPU particles
  56979. * @returns a new ParticleSystemSet
  56980. */
  56981. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  56982. }
  56983. }
  56984. declare module "babylonjs/Particles/particleHelper" {
  56985. import { Nullable } from "babylonjs/types";
  56986. import { Scene } from "babylonjs/scene";
  56987. import { Vector3 } from "babylonjs/Maths/math";
  56988. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56989. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  56990. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  56991. /**
  56992. * This class is made for on one-liner static method to help creating particle system set.
  56993. */
  56994. export class ParticleHelper {
  56995. /**
  56996. * Gets or sets base Assets URL
  56997. */
  56998. static BaseAssetsUrl: string;
  56999. /**
  57000. * Create a default particle system that you can tweak
  57001. * @param emitter defines the emitter to use
  57002. * @param capacity defines the system capacity (default is 500 particles)
  57003. * @param scene defines the hosting scene
  57004. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  57005. * @returns the new Particle system
  57006. */
  57007. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  57008. /**
  57009. * This is the main static method (one-liner) of this helper to create different particle systems
  57010. * @param type This string represents the type to the particle system to create
  57011. * @param scene The scene where the particle system should live
  57012. * @param gpu If the system will use gpu
  57013. * @returns the ParticleSystemSet created
  57014. */
  57015. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  57016. /**
  57017. * Static function used to export a particle system to a ParticleSystemSet variable.
  57018. * Please note that the emitter shape is not exported
  57019. * @param systems defines the particle systems to export
  57020. * @returns the created particle system set
  57021. */
  57022. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  57023. }
  57024. }
  57025. declare module "babylonjs/Particles/particleSystemComponent" {
  57026. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  57027. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  57028. import "babylonjs/Shaders/particles.vertex";
  57029. module "babylonjs/Engines/engine" {
  57030. interface Engine {
  57031. /**
  57032. * Create an effect to use with particle systems.
  57033. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  57034. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  57035. * @param uniformsNames defines a list of attribute names
  57036. * @param samplers defines an array of string used to represent textures
  57037. * @param defines defines the string containing the defines to use to compile the shaders
  57038. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  57039. * @param onCompiled defines a function to call when the effect creation is successful
  57040. * @param onError defines a function to call when the effect creation has failed
  57041. * @returns the new Effect
  57042. */
  57043. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  57044. }
  57045. }
  57046. module "babylonjs/Meshes/mesh" {
  57047. interface Mesh {
  57048. /**
  57049. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  57050. * @returns an array of IParticleSystem
  57051. */
  57052. getEmittedParticleSystems(): IParticleSystem[];
  57053. /**
  57054. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  57055. * @returns an array of IParticleSystem
  57056. */
  57057. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  57058. }
  57059. }
  57060. /**
  57061. * @hidden
  57062. */
  57063. export var _IDoNeedToBeInTheBuild: number;
  57064. }
  57065. declare module "babylonjs/Particles/index" {
  57066. export * from "babylonjs/Particles/baseParticleSystem";
  57067. export * from "babylonjs/Particles/EmitterTypes/index";
  57068. export * from "babylonjs/Particles/gpuParticleSystem";
  57069. export * from "babylonjs/Particles/IParticleSystem";
  57070. export * from "babylonjs/Particles/particle";
  57071. export * from "babylonjs/Particles/particleHelper";
  57072. export * from "babylonjs/Particles/particleSystem";
  57073. export * from "babylonjs/Particles/particleSystemComponent";
  57074. export * from "babylonjs/Particles/particleSystemSet";
  57075. export * from "babylonjs/Particles/solidParticle";
  57076. export * from "babylonjs/Particles/solidParticleSystem";
  57077. export * from "babylonjs/Particles/subEmitter";
  57078. }
  57079. declare module "babylonjs/Physics/physicsEngineComponent" {
  57080. import { Nullable } from "babylonjs/types";
  57081. import { Observable, Observer } from "babylonjs/Misc/observable";
  57082. import { Vector3 } from "babylonjs/Maths/math";
  57083. import { Mesh } from "babylonjs/Meshes/mesh";
  57084. import { ISceneComponent } from "babylonjs/sceneComponent";
  57085. import { Scene } from "babylonjs/scene";
  57086. import { Node } from "babylonjs/node";
  57087. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  57088. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57089. module "babylonjs/scene" {
  57090. interface Scene {
  57091. /** @hidden (Backing field) */
  57092. _physicsEngine: Nullable<IPhysicsEngine>;
  57093. /**
  57094. * Gets the current physics engine
  57095. * @returns a IPhysicsEngine or null if none attached
  57096. */
  57097. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  57098. /**
  57099. * Enables physics to the current scene
  57100. * @param gravity defines the scene's gravity for the physics engine
  57101. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  57102. * @return a boolean indicating if the physics engine was initialized
  57103. */
  57104. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  57105. /**
  57106. * Disables and disposes the physics engine associated with the scene
  57107. */
  57108. disablePhysicsEngine(): void;
  57109. /**
  57110. * Gets a boolean indicating if there is an active physics engine
  57111. * @returns a boolean indicating if there is an active physics engine
  57112. */
  57113. isPhysicsEnabled(): boolean;
  57114. /**
  57115. * Deletes a physics compound impostor
  57116. * @param compound defines the compound to delete
  57117. */
  57118. deleteCompoundImpostor(compound: any): void;
  57119. /**
  57120. * An event triggered when physic simulation is about to be run
  57121. */
  57122. onBeforePhysicsObservable: Observable<Scene>;
  57123. /**
  57124. * An event triggered when physic simulation has been done
  57125. */
  57126. onAfterPhysicsObservable: Observable<Scene>;
  57127. }
  57128. }
  57129. module "babylonjs/Meshes/abstractMesh" {
  57130. interface AbstractMesh {
  57131. /** @hidden */
  57132. _physicsImpostor: Nullable<PhysicsImpostor>;
  57133. /**
  57134. * Gets or sets impostor used for physic simulation
  57135. * @see http://doc.babylonjs.com/features/physics_engine
  57136. */
  57137. physicsImpostor: Nullable<PhysicsImpostor>;
  57138. /**
  57139. * Gets the current physics impostor
  57140. * @see http://doc.babylonjs.com/features/physics_engine
  57141. * @returns a physics impostor or null
  57142. */
  57143. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  57144. /** Apply a physic impulse to the mesh
  57145. * @param force defines the force to apply
  57146. * @param contactPoint defines where to apply the force
  57147. * @returns the current mesh
  57148. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  57149. */
  57150. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  57151. /**
  57152. * Creates a physic joint between two meshes
  57153. * @param otherMesh defines the other mesh to use
  57154. * @param pivot1 defines the pivot to use on this mesh
  57155. * @param pivot2 defines the pivot to use on the other mesh
  57156. * @param options defines additional options (can be plugin dependent)
  57157. * @returns the current mesh
  57158. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  57159. */
  57160. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  57161. /** @hidden */
  57162. _disposePhysicsObserver: Nullable<Observer<Node>>;
  57163. }
  57164. }
  57165. /**
  57166. * Defines the physics engine scene component responsible to manage a physics engine
  57167. */
  57168. export class PhysicsEngineSceneComponent implements ISceneComponent {
  57169. /**
  57170. * The component name helpful to identify the component in the list of scene components.
  57171. */
  57172. readonly name: string;
  57173. /**
  57174. * The scene the component belongs to.
  57175. */
  57176. scene: Scene;
  57177. /**
  57178. * Creates a new instance of the component for the given scene
  57179. * @param scene Defines the scene to register the component in
  57180. */
  57181. constructor(scene: Scene);
  57182. /**
  57183. * Registers the component in a given scene
  57184. */
  57185. register(): void;
  57186. /**
  57187. * Rebuilds the elements related to this component in case of
  57188. * context lost for instance.
  57189. */
  57190. rebuild(): void;
  57191. /**
  57192. * Disposes the component and the associated ressources
  57193. */
  57194. dispose(): void;
  57195. }
  57196. }
  57197. declare module "babylonjs/Physics/physicsHelper" {
  57198. import { Nullable } from "babylonjs/types";
  57199. import { Vector3 } from "babylonjs/Maths/math";
  57200. import { Mesh } from "babylonjs/Meshes/mesh";
  57201. import { Scene } from "babylonjs/scene";
  57202. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57203. /**
  57204. * A helper for physics simulations
  57205. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57206. */
  57207. export class PhysicsHelper {
  57208. private _scene;
  57209. private _physicsEngine;
  57210. /**
  57211. * Initializes the Physics helper
  57212. * @param scene Babylon.js scene
  57213. */
  57214. constructor(scene: Scene);
  57215. /**
  57216. * Applies a radial explosion impulse
  57217. * @param origin the origin of the explosion
  57218. * @param radiusOrEventOptions the radius or the options of radial explosion
  57219. * @param strength the explosion strength
  57220. * @param falloff possible options: Constant & Linear. Defaults to Constant
  57221. * @returns A physics radial explosion event, or null
  57222. */
  57223. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  57224. /**
  57225. * Applies a radial explosion force
  57226. * @param origin the origin of the explosion
  57227. * @param radiusOrEventOptions the radius or the options of radial explosion
  57228. * @param strength the explosion strength
  57229. * @param falloff possible options: Constant & Linear. Defaults to Constant
  57230. * @returns A physics radial explosion event, or null
  57231. */
  57232. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  57233. /**
  57234. * Creates a gravitational field
  57235. * @param origin the origin of the explosion
  57236. * @param radiusOrEventOptions the radius or the options of radial explosion
  57237. * @param strength the explosion strength
  57238. * @param falloff possible options: Constant & Linear. Defaults to Constant
  57239. * @returns A physics gravitational field event, or null
  57240. */
  57241. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  57242. /**
  57243. * Creates a physics updraft event
  57244. * @param origin the origin of the updraft
  57245. * @param radiusOrEventOptions the radius or the options of the updraft
  57246. * @param strength the strength of the updraft
  57247. * @param height the height of the updraft
  57248. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  57249. * @returns A physics updraft event, or null
  57250. */
  57251. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  57252. /**
  57253. * Creates a physics vortex event
  57254. * @param origin the of the vortex
  57255. * @param radiusOrEventOptions the radius or the options of the vortex
  57256. * @param strength the strength of the vortex
  57257. * @param height the height of the vortex
  57258. * @returns a Physics vortex event, or null
  57259. * A physics vortex event or null
  57260. */
  57261. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  57262. }
  57263. /**
  57264. * Represents a physics radial explosion event
  57265. */
  57266. class PhysicsRadialExplosionEvent {
  57267. private _scene;
  57268. private _options;
  57269. private _sphere;
  57270. private _dataFetched;
  57271. /**
  57272. * Initializes a radial explosioin event
  57273. * @param _scene BabylonJS scene
  57274. * @param _options The options for the vortex event
  57275. */
  57276. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  57277. /**
  57278. * Returns the data related to the radial explosion event (sphere).
  57279. * @returns The radial explosion event data
  57280. */
  57281. getData(): PhysicsRadialExplosionEventData;
  57282. /**
  57283. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  57284. * @param impostor A physics imposter
  57285. * @param origin the origin of the explosion
  57286. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  57287. */
  57288. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  57289. /**
  57290. * Triggers affecterd impostors callbacks
  57291. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  57292. */
  57293. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  57294. /**
  57295. * Disposes the sphere.
  57296. * @param force Specifies if the sphere should be disposed by force
  57297. */
  57298. dispose(force?: boolean): void;
  57299. /*** Helpers ***/
  57300. private _prepareSphere;
  57301. private _intersectsWithSphere;
  57302. }
  57303. /**
  57304. * Represents a gravitational field event
  57305. */
  57306. class PhysicsGravitationalFieldEvent {
  57307. private _physicsHelper;
  57308. private _scene;
  57309. private _origin;
  57310. private _options;
  57311. private _tickCallback;
  57312. private _sphere;
  57313. private _dataFetched;
  57314. /**
  57315. * Initializes the physics gravitational field event
  57316. * @param _physicsHelper A physics helper
  57317. * @param _scene BabylonJS scene
  57318. * @param _origin The origin position of the gravitational field event
  57319. * @param _options The options for the vortex event
  57320. */
  57321. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  57322. /**
  57323. * Returns the data related to the gravitational field event (sphere).
  57324. * @returns A gravitational field event
  57325. */
  57326. getData(): PhysicsGravitationalFieldEventData;
  57327. /**
  57328. * Enables the gravitational field.
  57329. */
  57330. enable(): void;
  57331. /**
  57332. * Disables the gravitational field.
  57333. */
  57334. disable(): void;
  57335. /**
  57336. * Disposes the sphere.
  57337. * @param force The force to dispose from the gravitational field event
  57338. */
  57339. dispose(force?: boolean): void;
  57340. private _tick;
  57341. }
  57342. /**
  57343. * Represents a physics updraft event
  57344. */
  57345. class PhysicsUpdraftEvent {
  57346. private _scene;
  57347. private _origin;
  57348. private _options;
  57349. private _physicsEngine;
  57350. private _originTop;
  57351. private _originDirection;
  57352. private _tickCallback;
  57353. private _cylinder;
  57354. private _cylinderPosition;
  57355. private _dataFetched;
  57356. /**
  57357. * Initializes the physics updraft event
  57358. * @param _scene BabylonJS scene
  57359. * @param _origin The origin position of the updraft
  57360. * @param _options The options for the updraft event
  57361. */
  57362. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  57363. /**
  57364. * Returns the data related to the updraft event (cylinder).
  57365. * @returns A physics updraft event
  57366. */
  57367. getData(): PhysicsUpdraftEventData;
  57368. /**
  57369. * Enables the updraft.
  57370. */
  57371. enable(): void;
  57372. /**
  57373. * Disables the updraft.
  57374. */
  57375. disable(): void;
  57376. /**
  57377. * Disposes the cylinder.
  57378. * @param force Specifies if the updraft should be disposed by force
  57379. */
  57380. dispose(force?: boolean): void;
  57381. private getImpostorHitData;
  57382. private _tick;
  57383. /*** Helpers ***/
  57384. private _prepareCylinder;
  57385. private _intersectsWithCylinder;
  57386. }
  57387. /**
  57388. * Represents a physics vortex event
  57389. */
  57390. class PhysicsVortexEvent {
  57391. private _scene;
  57392. private _origin;
  57393. private _options;
  57394. private _physicsEngine;
  57395. private _originTop;
  57396. private _tickCallback;
  57397. private _cylinder;
  57398. private _cylinderPosition;
  57399. private _dataFetched;
  57400. /**
  57401. * Initializes the physics vortex event
  57402. * @param _scene The BabylonJS scene
  57403. * @param _origin The origin position of the vortex
  57404. * @param _options The options for the vortex event
  57405. */
  57406. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  57407. /**
  57408. * Returns the data related to the vortex event (cylinder).
  57409. * @returns The physics vortex event data
  57410. */
  57411. getData(): PhysicsVortexEventData;
  57412. /**
  57413. * Enables the vortex.
  57414. */
  57415. enable(): void;
  57416. /**
  57417. * Disables the cortex.
  57418. */
  57419. disable(): void;
  57420. /**
  57421. * Disposes the sphere.
  57422. * @param force
  57423. */
  57424. dispose(force?: boolean): void;
  57425. private getImpostorHitData;
  57426. private _tick;
  57427. /*** Helpers ***/
  57428. private _prepareCylinder;
  57429. private _intersectsWithCylinder;
  57430. }
  57431. /**
  57432. * Options fot the radial explosion event
  57433. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57434. */
  57435. export class PhysicsRadialExplosionEventOptions {
  57436. /**
  57437. * The radius of the sphere for the radial explosion.
  57438. */
  57439. radius: number;
  57440. /**
  57441. * The strenth of the explosion.
  57442. */
  57443. strength: number;
  57444. /**
  57445. * The strenght of the force in correspondence to the distance of the affected object
  57446. */
  57447. falloff: PhysicsRadialImpulseFalloff;
  57448. /**
  57449. * Sphere options for the radial explosion.
  57450. */
  57451. sphere: {
  57452. segments: number;
  57453. diameter: number;
  57454. };
  57455. /**
  57456. * Sphere options for the radial explosion.
  57457. */
  57458. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  57459. }
  57460. /**
  57461. * Options fot the updraft event
  57462. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57463. */
  57464. export class PhysicsUpdraftEventOptions {
  57465. /**
  57466. * The radius of the cylinder for the vortex
  57467. */
  57468. radius: number;
  57469. /**
  57470. * The strenth of the updraft.
  57471. */
  57472. strength: number;
  57473. /**
  57474. * The height of the cylinder for the updraft.
  57475. */
  57476. height: number;
  57477. /**
  57478. * The mode for the the updraft.
  57479. */
  57480. updraftMode: PhysicsUpdraftMode;
  57481. }
  57482. /**
  57483. * Options fot the vortex event
  57484. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57485. */
  57486. export class PhysicsVortexEventOptions {
  57487. /**
  57488. * The radius of the cylinder for the vortex
  57489. */
  57490. radius: number;
  57491. /**
  57492. * The strenth of the vortex.
  57493. */
  57494. strength: number;
  57495. /**
  57496. * The height of the cylinder for the vortex.
  57497. */
  57498. height: number;
  57499. /**
  57500. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  57501. */
  57502. centripetalForceThreshold: number;
  57503. /**
  57504. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  57505. */
  57506. centripetalForceMultiplier: number;
  57507. /**
  57508. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  57509. */
  57510. centrifugalForceMultiplier: number;
  57511. /**
  57512. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  57513. */
  57514. updraftForceMultiplier: number;
  57515. }
  57516. /**
  57517. * The strenght of the force in correspondence to the distance of the affected object
  57518. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57519. */
  57520. export enum PhysicsRadialImpulseFalloff {
  57521. /** Defines that impulse is constant in strength across it's whole radius */
  57522. Constant = 0,
  57523. /** Defines that impulse gets weaker if it's further from the origin */
  57524. Linear = 1
  57525. }
  57526. /**
  57527. * The strength of the force in correspondence to the distance of the affected object
  57528. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57529. */
  57530. export enum PhysicsUpdraftMode {
  57531. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  57532. Center = 0,
  57533. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  57534. Perpendicular = 1
  57535. }
  57536. /**
  57537. * Interface for a physics hit data
  57538. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57539. */
  57540. export interface PhysicsHitData {
  57541. /**
  57542. * The force applied at the contact point
  57543. */
  57544. force: Vector3;
  57545. /**
  57546. * The contact point
  57547. */
  57548. contactPoint: Vector3;
  57549. /**
  57550. * The distance from the origin to the contact point
  57551. */
  57552. distanceFromOrigin: number;
  57553. }
  57554. /**
  57555. * Interface for radial explosion event data
  57556. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57557. */
  57558. export interface PhysicsRadialExplosionEventData {
  57559. /**
  57560. * A sphere used for the radial explosion event
  57561. */
  57562. sphere: Mesh;
  57563. }
  57564. /**
  57565. * Interface for gravitational field event data
  57566. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57567. */
  57568. export interface PhysicsGravitationalFieldEventData {
  57569. /**
  57570. * A sphere mesh used for the gravitational field event
  57571. */
  57572. sphere: Mesh;
  57573. }
  57574. /**
  57575. * Interface for updraft event data
  57576. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57577. */
  57578. export interface PhysicsUpdraftEventData {
  57579. /**
  57580. * A cylinder used for the updraft event
  57581. */
  57582. cylinder: Mesh;
  57583. }
  57584. /**
  57585. * Interface for vortex event data
  57586. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57587. */
  57588. export interface PhysicsVortexEventData {
  57589. /**
  57590. * A cylinder used for the vortex event
  57591. */
  57592. cylinder: Mesh;
  57593. }
  57594. /**
  57595. * Interface for an affected physics impostor
  57596. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57597. */
  57598. export interface PhysicsAffectedImpostorWithData {
  57599. /**
  57600. * The impostor affected by the effect
  57601. */
  57602. impostor: PhysicsImpostor;
  57603. /**
  57604. * The data about the hit/horce from the explosion
  57605. */
  57606. hitData: PhysicsHitData;
  57607. }
  57608. }
  57609. declare module "babylonjs/Physics/Plugins/index" {
  57610. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  57611. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  57612. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  57613. }
  57614. declare module "babylonjs/Physics/index" {
  57615. export * from "babylonjs/Physics/IPhysicsEngine";
  57616. export * from "babylonjs/Physics/physicsEngine";
  57617. export * from "babylonjs/Physics/physicsEngineComponent";
  57618. export * from "babylonjs/Physics/physicsHelper";
  57619. export * from "babylonjs/Physics/physicsImpostor";
  57620. export * from "babylonjs/Physics/physicsJoint";
  57621. export * from "babylonjs/Physics/Plugins/index";
  57622. }
  57623. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  57624. /** @hidden */
  57625. export var blackAndWhitePixelShader: {
  57626. name: string;
  57627. shader: string;
  57628. };
  57629. }
  57630. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  57631. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57632. import { Camera } from "babylonjs/Cameras/camera";
  57633. import { Engine } from "babylonjs/Engines/engine";
  57634. import "babylonjs/Shaders/blackAndWhite.fragment";
  57635. /**
  57636. * Post process used to render in black and white
  57637. */
  57638. export class BlackAndWhitePostProcess extends PostProcess {
  57639. /**
  57640. * Linear about to convert he result to black and white (default: 1)
  57641. */
  57642. degree: number;
  57643. /**
  57644. * Creates a black and white post process
  57645. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  57646. * @param name The name of the effect.
  57647. * @param options The required width/height ratio to downsize to before computing the render pass.
  57648. * @param camera The camera to apply the render pass to.
  57649. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57650. * @param engine The engine which the post process will be applied. (default: current engine)
  57651. * @param reusable If the post process can be reused on the same frame. (default: false)
  57652. */
  57653. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57654. }
  57655. }
  57656. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  57657. import { Nullable } from "babylonjs/types";
  57658. import { Camera } from "babylonjs/Cameras/camera";
  57659. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  57660. import { Engine } from "babylonjs/Engines/engine";
  57661. /**
  57662. * This represents a set of one or more post processes in Babylon.
  57663. * A post process can be used to apply a shader to a texture after it is rendered.
  57664. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  57665. */
  57666. export class PostProcessRenderEffect {
  57667. private _postProcesses;
  57668. private _getPostProcesses;
  57669. private _singleInstance;
  57670. private _cameras;
  57671. private _indicesForCamera;
  57672. /**
  57673. * Name of the effect
  57674. * @hidden
  57675. */
  57676. _name: string;
  57677. /**
  57678. * Instantiates a post process render effect.
  57679. * A post process can be used to apply a shader to a texture after it is rendered.
  57680. * @param engine The engine the effect is tied to
  57681. * @param name The name of the effect
  57682. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  57683. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  57684. */
  57685. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  57686. /**
  57687. * Checks if all the post processes in the effect are supported.
  57688. */
  57689. readonly isSupported: boolean;
  57690. /**
  57691. * Updates the current state of the effect
  57692. * @hidden
  57693. */
  57694. _update(): void;
  57695. /**
  57696. * Attaches the effect on cameras
  57697. * @param cameras The camera to attach to.
  57698. * @hidden
  57699. */
  57700. _attachCameras(cameras: Camera): void;
  57701. /**
  57702. * Attaches the effect on cameras
  57703. * @param cameras The camera to attach to.
  57704. * @hidden
  57705. */
  57706. _attachCameras(cameras: Camera[]): void;
  57707. /**
  57708. * Detaches the effect on cameras
  57709. * @param cameras The camera to detatch from.
  57710. * @hidden
  57711. */
  57712. _detachCameras(cameras: Camera): void;
  57713. /**
  57714. * Detatches the effect on cameras
  57715. * @param cameras The camera to detatch from.
  57716. * @hidden
  57717. */
  57718. _detachCameras(cameras: Camera[]): void;
  57719. /**
  57720. * Enables the effect on given cameras
  57721. * @param cameras The camera to enable.
  57722. * @hidden
  57723. */
  57724. _enable(cameras: Camera): void;
  57725. /**
  57726. * Enables the effect on given cameras
  57727. * @param cameras The camera to enable.
  57728. * @hidden
  57729. */
  57730. _enable(cameras: Nullable<Camera[]>): void;
  57731. /**
  57732. * Disables the effect on the given cameras
  57733. * @param cameras The camera to disable.
  57734. * @hidden
  57735. */
  57736. _disable(cameras: Camera): void;
  57737. /**
  57738. * Disables the effect on the given cameras
  57739. * @param cameras The camera to disable.
  57740. * @hidden
  57741. */
  57742. _disable(cameras: Nullable<Camera[]>): void;
  57743. /**
  57744. * Gets a list of the post processes contained in the effect.
  57745. * @param camera The camera to get the post processes on.
  57746. * @returns The list of the post processes in the effect.
  57747. */
  57748. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  57749. }
  57750. }
  57751. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  57752. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57753. /** @hidden */
  57754. export var extractHighlightsPixelShader: {
  57755. name: string;
  57756. shader: string;
  57757. };
  57758. }
  57759. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  57760. import { Nullable } from "babylonjs/types";
  57761. import { Camera } from "babylonjs/Cameras/camera";
  57762. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57763. import { Engine } from "babylonjs/Engines/engine";
  57764. import "babylonjs/Shaders/extractHighlights.fragment";
  57765. /**
  57766. * 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.
  57767. */
  57768. export class ExtractHighlightsPostProcess extends PostProcess {
  57769. /**
  57770. * The luminance threshold, pixels below this value will be set to black.
  57771. */
  57772. threshold: number;
  57773. /** @hidden */
  57774. _exposure: number;
  57775. /**
  57776. * Post process which has the input texture to be used when performing highlight extraction
  57777. * @hidden
  57778. */
  57779. _inputPostProcess: Nullable<PostProcess>;
  57780. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57781. }
  57782. }
  57783. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  57784. /** @hidden */
  57785. export var bloomMergePixelShader: {
  57786. name: string;
  57787. shader: string;
  57788. };
  57789. }
  57790. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  57791. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57792. import { Nullable } from "babylonjs/types";
  57793. import { Engine } from "babylonjs/Engines/engine";
  57794. import { Camera } from "babylonjs/Cameras/camera";
  57795. import "babylonjs/Shaders/bloomMerge.fragment";
  57796. /**
  57797. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  57798. */
  57799. export class BloomMergePostProcess extends PostProcess {
  57800. /** Weight of the bloom to be added to the original input. */
  57801. weight: number;
  57802. /**
  57803. * Creates a new instance of @see BloomMergePostProcess
  57804. * @param name The name of the effect.
  57805. * @param originalFromInput Post process which's input will be used for the merge.
  57806. * @param blurred Blurred highlights post process which's output will be used.
  57807. * @param weight Weight of the bloom to be added to the original input.
  57808. * @param options The required width/height ratio to downsize to before computing the render pass.
  57809. * @param camera The camera to apply the render pass to.
  57810. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57811. * @param engine The engine which the post process will be applied. (default: current engine)
  57812. * @param reusable If the post process can be reused on the same frame. (default: false)
  57813. * @param textureType Type of textures used when performing the post process. (default: 0)
  57814. * @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)
  57815. */
  57816. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  57817. /** Weight of the bloom to be added to the original input. */
  57818. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57819. }
  57820. }
  57821. declare module "babylonjs/PostProcesses/bloomEffect" {
  57822. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  57823. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  57824. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  57825. import { Camera } from "babylonjs/Cameras/camera";
  57826. import { Scene } from "babylonjs/scene";
  57827. /**
  57828. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  57829. */
  57830. export class BloomEffect extends PostProcessRenderEffect {
  57831. private bloomScale;
  57832. /**
  57833. * @hidden Internal
  57834. */
  57835. _effects: Array<PostProcess>;
  57836. /**
  57837. * @hidden Internal
  57838. */
  57839. _downscale: ExtractHighlightsPostProcess;
  57840. private _blurX;
  57841. private _blurY;
  57842. private _merge;
  57843. /**
  57844. * The luminance threshold to find bright areas of the image to bloom.
  57845. */
  57846. threshold: number;
  57847. /**
  57848. * The strength of the bloom.
  57849. */
  57850. weight: number;
  57851. /**
  57852. * Specifies the size of the bloom blur kernel, relative to the final output size
  57853. */
  57854. kernel: number;
  57855. /**
  57856. * Creates a new instance of @see BloomEffect
  57857. * @param scene The scene the effect belongs to.
  57858. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  57859. * @param bloomKernel The size of the kernel to be used when applying the blur.
  57860. * @param bloomWeight The the strength of bloom.
  57861. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  57862. * @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)
  57863. */
  57864. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  57865. /**
  57866. * Disposes each of the internal effects for a given camera.
  57867. * @param camera The camera to dispose the effect on.
  57868. */
  57869. disposeEffects(camera: Camera): void;
  57870. /**
  57871. * @hidden Internal
  57872. */
  57873. _updateEffects(): void;
  57874. /**
  57875. * Internal
  57876. * @returns if all the contained post processes are ready.
  57877. * @hidden
  57878. */
  57879. _isReady(): boolean;
  57880. }
  57881. }
  57882. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  57883. /** @hidden */
  57884. export var chromaticAberrationPixelShader: {
  57885. name: string;
  57886. shader: string;
  57887. };
  57888. }
  57889. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  57890. import { Vector2 } from "babylonjs/Maths/math";
  57891. import { Nullable } from "babylonjs/types";
  57892. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57893. import { Camera } from "babylonjs/Cameras/camera";
  57894. import { Engine } from "babylonjs/Engines/engine";
  57895. import "babylonjs/Shaders/chromaticAberration.fragment";
  57896. /**
  57897. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  57898. */
  57899. export class ChromaticAberrationPostProcess extends PostProcess {
  57900. /**
  57901. * The amount of seperation of rgb channels (default: 30)
  57902. */
  57903. aberrationAmount: number;
  57904. /**
  57905. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  57906. */
  57907. radialIntensity: number;
  57908. /**
  57909. * 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))
  57910. */
  57911. direction: Vector2;
  57912. /**
  57913. * 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))
  57914. */
  57915. centerPosition: Vector2;
  57916. /**
  57917. * Creates a new instance ChromaticAberrationPostProcess
  57918. * @param name The name of the effect.
  57919. * @param screenWidth The width of the screen to apply the effect on.
  57920. * @param screenHeight The height of the screen to apply the effect on.
  57921. * @param options The required width/height ratio to downsize to before computing the render pass.
  57922. * @param camera The camera to apply the render pass to.
  57923. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57924. * @param engine The engine which the post process will be applied. (default: current engine)
  57925. * @param reusable If the post process can be reused on the same frame. (default: false)
  57926. * @param textureType Type of textures used when performing the post process. (default: 0)
  57927. * @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)
  57928. */
  57929. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57930. }
  57931. }
  57932. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  57933. /** @hidden */
  57934. export var circleOfConfusionPixelShader: {
  57935. name: string;
  57936. shader: string;
  57937. };
  57938. }
  57939. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  57940. import { Nullable } from "babylonjs/types";
  57941. import { Engine } from "babylonjs/Engines/engine";
  57942. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57943. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57944. import { Camera } from "babylonjs/Cameras/camera";
  57945. import "babylonjs/Shaders/circleOfConfusion.fragment";
  57946. /**
  57947. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  57948. */
  57949. export class CircleOfConfusionPostProcess extends PostProcess {
  57950. /**
  57951. * 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.
  57952. */
  57953. lensSize: number;
  57954. /**
  57955. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  57956. */
  57957. fStop: number;
  57958. /**
  57959. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  57960. */
  57961. focusDistance: number;
  57962. /**
  57963. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  57964. */
  57965. focalLength: number;
  57966. private _depthTexture;
  57967. /**
  57968. * Creates a new instance CircleOfConfusionPostProcess
  57969. * @param name The name of the effect.
  57970. * @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.
  57971. * @param options The required width/height ratio to downsize to before computing the render pass.
  57972. * @param camera The camera to apply the render pass to.
  57973. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57974. * @param engine The engine which the post process will be applied. (default: current engine)
  57975. * @param reusable If the post process can be reused on the same frame. (default: false)
  57976. * @param textureType Type of textures used when performing the post process. (default: 0)
  57977. * @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)
  57978. */
  57979. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57980. /**
  57981. * 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.
  57982. */
  57983. depthTexture: RenderTargetTexture;
  57984. }
  57985. }
  57986. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  57987. /** @hidden */
  57988. export var colorCorrectionPixelShader: {
  57989. name: string;
  57990. shader: string;
  57991. };
  57992. }
  57993. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  57994. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57995. import { Engine } from "babylonjs/Engines/engine";
  57996. import { Camera } from "babylonjs/Cameras/camera";
  57997. import "babylonjs/Shaders/colorCorrection.fragment";
  57998. /**
  57999. *
  58000. * This post-process allows the modification of rendered colors by using
  58001. * a 'look-up table' (LUT). This effect is also called Color Grading.
  58002. *
  58003. * The object needs to be provided an url to a texture containing the color
  58004. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  58005. * Use an image editing software to tweak the LUT to match your needs.
  58006. *
  58007. * For an example of a color LUT, see here:
  58008. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  58009. * For explanations on color grading, see here:
  58010. * @see http://udn.epicgames.com/Three/ColorGrading.html
  58011. *
  58012. */
  58013. export class ColorCorrectionPostProcess extends PostProcess {
  58014. private _colorTableTexture;
  58015. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58016. }
  58017. }
  58018. declare module "babylonjs/Shaders/convolution.fragment" {
  58019. /** @hidden */
  58020. export var convolutionPixelShader: {
  58021. name: string;
  58022. shader: string;
  58023. };
  58024. }
  58025. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  58026. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58027. import { Nullable } from "babylonjs/types";
  58028. import { Camera } from "babylonjs/Cameras/camera";
  58029. import { Engine } from "babylonjs/Engines/engine";
  58030. import "babylonjs/Shaders/convolution.fragment";
  58031. /**
  58032. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  58033. * input texture to perform effects such as edge detection or sharpening
  58034. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  58035. */
  58036. export class ConvolutionPostProcess extends PostProcess {
  58037. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  58038. kernel: number[];
  58039. /**
  58040. * Creates a new instance ConvolutionPostProcess
  58041. * @param name The name of the effect.
  58042. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  58043. * @param options The required width/height ratio to downsize to before computing the render pass.
  58044. * @param camera The camera to apply the render pass to.
  58045. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58046. * @param engine The engine which the post process will be applied. (default: current engine)
  58047. * @param reusable If the post process can be reused on the same frame. (default: false)
  58048. * @param textureType Type of textures used when performing the post process. (default: 0)
  58049. */
  58050. constructor(name: string,
  58051. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  58052. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  58053. /**
  58054. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58055. */
  58056. static EdgeDetect0Kernel: number[];
  58057. /**
  58058. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58059. */
  58060. static EdgeDetect1Kernel: number[];
  58061. /**
  58062. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58063. */
  58064. static EdgeDetect2Kernel: number[];
  58065. /**
  58066. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58067. */
  58068. static SharpenKernel: number[];
  58069. /**
  58070. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58071. */
  58072. static EmbossKernel: number[];
  58073. /**
  58074. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58075. */
  58076. static GaussianKernel: number[];
  58077. }
  58078. }
  58079. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  58080. import { Nullable } from "babylonjs/types";
  58081. import { Vector2 } from "babylonjs/Maths/math";
  58082. import { Camera } from "babylonjs/Cameras/camera";
  58083. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58084. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  58085. import { Engine } from "babylonjs/Engines/engine";
  58086. import { Scene } from "babylonjs/scene";
  58087. /**
  58088. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  58089. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  58090. * based on samples that have a large difference in distance than the center pixel.
  58091. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  58092. */
  58093. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  58094. direction: Vector2;
  58095. /**
  58096. * Creates a new instance CircleOfConfusionPostProcess
  58097. * @param name The name of the effect.
  58098. * @param scene The scene the effect belongs to.
  58099. * @param direction The direction the blur should be applied.
  58100. * @param kernel The size of the kernel used to blur.
  58101. * @param options The required width/height ratio to downsize to before computing the render pass.
  58102. * @param camera The camera to apply the render pass to.
  58103. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  58104. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  58105. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58106. * @param engine The engine which the post process will be applied. (default: current engine)
  58107. * @param reusable If the post process can be reused on the same frame. (default: false)
  58108. * @param textureType Type of textures used when performing the post process. (default: 0)
  58109. * @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)
  58110. */
  58111. 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);
  58112. }
  58113. }
  58114. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  58115. /** @hidden */
  58116. export var depthOfFieldMergePixelShader: {
  58117. name: string;
  58118. shader: string;
  58119. };
  58120. }
  58121. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  58122. import { Nullable } from "babylonjs/types";
  58123. import { Camera } from "babylonjs/Cameras/camera";
  58124. import { Effect } from "babylonjs/Materials/effect";
  58125. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58126. import { Engine } from "babylonjs/Engines/engine";
  58127. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  58128. /**
  58129. * Options to be set when merging outputs from the default pipeline.
  58130. */
  58131. export class DepthOfFieldMergePostProcessOptions {
  58132. /**
  58133. * The original image to merge on top of
  58134. */
  58135. originalFromInput: PostProcess;
  58136. /**
  58137. * Parameters to perform the merge of the depth of field effect
  58138. */
  58139. depthOfField?: {
  58140. circleOfConfusion: PostProcess;
  58141. blurSteps: Array<PostProcess>;
  58142. };
  58143. /**
  58144. * Parameters to perform the merge of bloom effect
  58145. */
  58146. bloom?: {
  58147. blurred: PostProcess;
  58148. weight: number;
  58149. };
  58150. }
  58151. /**
  58152. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  58153. */
  58154. export class DepthOfFieldMergePostProcess extends PostProcess {
  58155. private blurSteps;
  58156. /**
  58157. * Creates a new instance of DepthOfFieldMergePostProcess
  58158. * @param name The name of the effect.
  58159. * @param originalFromInput Post process which's input will be used for the merge.
  58160. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  58161. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  58162. * @param options The required width/height ratio to downsize to before computing the render pass.
  58163. * @param camera The camera to apply the render pass to.
  58164. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58165. * @param engine The engine which the post process will be applied. (default: current engine)
  58166. * @param reusable If the post process can be reused on the same frame. (default: false)
  58167. * @param textureType Type of textures used when performing the post process. (default: 0)
  58168. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  58169. */
  58170. constructor(name: string, originalFromInput: PostProcess, circleOfConfusion: PostProcess, blurSteps: Array<PostProcess>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58171. /**
  58172. * Updates the effect with the current post process compile time values and recompiles the shader.
  58173. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  58174. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  58175. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  58176. * @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
  58177. * @param onCompiled Called when the shader has been compiled.
  58178. * @param onError Called if there is an error when compiling a shader.
  58179. */
  58180. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  58181. }
  58182. }
  58183. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  58184. import { Nullable } from "babylonjs/types";
  58185. import { Camera } from "babylonjs/Cameras/camera";
  58186. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  58187. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  58188. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  58189. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  58190. import { Scene } from "babylonjs/scene";
  58191. /**
  58192. * Specifies the level of max blur that should be applied when using the depth of field effect
  58193. */
  58194. export enum DepthOfFieldEffectBlurLevel {
  58195. /**
  58196. * Subtle blur
  58197. */
  58198. Low = 0,
  58199. /**
  58200. * Medium blur
  58201. */
  58202. Medium = 1,
  58203. /**
  58204. * Large blur
  58205. */
  58206. High = 2
  58207. }
  58208. /**
  58209. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  58210. */
  58211. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  58212. private _circleOfConfusion;
  58213. /**
  58214. * @hidden Internal, blurs from high to low
  58215. */
  58216. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  58217. private _depthOfFieldBlurY;
  58218. private _dofMerge;
  58219. /**
  58220. * @hidden Internal post processes in depth of field effect
  58221. */
  58222. _effects: Array<PostProcess>;
  58223. /**
  58224. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  58225. */
  58226. focalLength: number;
  58227. /**
  58228. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  58229. */
  58230. fStop: number;
  58231. /**
  58232. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  58233. */
  58234. focusDistance: number;
  58235. /**
  58236. * 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.
  58237. */
  58238. lensSize: number;
  58239. /**
  58240. * Creates a new instance DepthOfFieldEffect
  58241. * @param scene The scene the effect belongs to.
  58242. * @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.
  58243. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  58244. * @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)
  58245. */
  58246. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  58247. /**
  58248. * Get the current class name of the current effet
  58249. * @returns "DepthOfFieldEffect"
  58250. */
  58251. getClassName(): string;
  58252. /**
  58253. * 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.
  58254. */
  58255. depthTexture: RenderTargetTexture;
  58256. /**
  58257. * Disposes each of the internal effects for a given camera.
  58258. * @param camera The camera to dispose the effect on.
  58259. */
  58260. disposeEffects(camera: Camera): void;
  58261. /**
  58262. * @hidden Internal
  58263. */
  58264. _updateEffects(): void;
  58265. /**
  58266. * Internal
  58267. * @returns if all the contained post processes are ready.
  58268. * @hidden
  58269. */
  58270. _isReady(): boolean;
  58271. }
  58272. }
  58273. declare module "babylonjs/Shaders/displayPass.fragment" {
  58274. /** @hidden */
  58275. export var displayPassPixelShader: {
  58276. name: string;
  58277. shader: string;
  58278. };
  58279. }
  58280. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  58281. import { Nullable } from "babylonjs/types";
  58282. import { Camera } from "babylonjs/Cameras/camera";
  58283. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58284. import { Engine } from "babylonjs/Engines/engine";
  58285. import "babylonjs/Shaders/displayPass.fragment";
  58286. /**
  58287. * DisplayPassPostProcess which produces an output the same as it's input
  58288. */
  58289. export class DisplayPassPostProcess extends PostProcess {
  58290. /**
  58291. * Creates the DisplayPassPostProcess
  58292. * @param name The name of the effect.
  58293. * @param options The required width/height ratio to downsize to before computing the render pass.
  58294. * @param camera The camera to apply the render pass to.
  58295. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58296. * @param engine The engine which the post process will be applied. (default: current engine)
  58297. * @param reusable If the post process can be reused on the same frame. (default: false)
  58298. */
  58299. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58300. }
  58301. }
  58302. declare module "babylonjs/Shaders/filter.fragment" {
  58303. /** @hidden */
  58304. export var filterPixelShader: {
  58305. name: string;
  58306. shader: string;
  58307. };
  58308. }
  58309. declare module "babylonjs/PostProcesses/filterPostProcess" {
  58310. import { Nullable } from "babylonjs/types";
  58311. import { Matrix } from "babylonjs/Maths/math";
  58312. import { Camera } from "babylonjs/Cameras/camera";
  58313. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58314. import { Engine } from "babylonjs/Engines/engine";
  58315. import "babylonjs/Shaders/filter.fragment";
  58316. /**
  58317. * Applies a kernel filter to the image
  58318. */
  58319. export class FilterPostProcess extends PostProcess {
  58320. /** The matrix to be applied to the image */
  58321. kernelMatrix: Matrix;
  58322. /**
  58323. *
  58324. * @param name The name of the effect.
  58325. * @param kernelMatrix The matrix to be applied to the image
  58326. * @param options The required width/height ratio to downsize to before computing the render pass.
  58327. * @param camera The camera to apply the render pass to.
  58328. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58329. * @param engine The engine which the post process will be applied. (default: current engine)
  58330. * @param reusable If the post process can be reused on the same frame. (default: false)
  58331. */
  58332. constructor(name: string,
  58333. /** The matrix to be applied to the image */
  58334. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58335. }
  58336. }
  58337. declare module "babylonjs/Shaders/fxaa.fragment" {
  58338. /** @hidden */
  58339. export var fxaaPixelShader: {
  58340. name: string;
  58341. shader: string;
  58342. };
  58343. }
  58344. declare module "babylonjs/Shaders/fxaa.vertex" {
  58345. /** @hidden */
  58346. export var fxaaVertexShader: {
  58347. name: string;
  58348. shader: string;
  58349. };
  58350. }
  58351. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  58352. import { Nullable } from "babylonjs/types";
  58353. import { Camera } from "babylonjs/Cameras/camera";
  58354. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58355. import { Engine } from "babylonjs/Engines/engine";
  58356. import "babylonjs/Shaders/fxaa.fragment";
  58357. import "babylonjs/Shaders/fxaa.vertex";
  58358. /**
  58359. * Fxaa post process
  58360. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  58361. */
  58362. export class FxaaPostProcess extends PostProcess {
  58363. /** @hidden */
  58364. texelWidth: number;
  58365. /** @hidden */
  58366. texelHeight: number;
  58367. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  58368. private _getDefines;
  58369. }
  58370. }
  58371. declare module "babylonjs/Shaders/grain.fragment" {
  58372. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58373. /** @hidden */
  58374. export var grainPixelShader: {
  58375. name: string;
  58376. shader: string;
  58377. };
  58378. }
  58379. declare module "babylonjs/PostProcesses/grainPostProcess" {
  58380. import { Nullable } from "babylonjs/types";
  58381. import { Camera } from "babylonjs/Cameras/camera";
  58382. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58383. import { Engine } from "babylonjs/Engines/engine";
  58384. import "babylonjs/Shaders/grain.fragment";
  58385. /**
  58386. * The GrainPostProcess adds noise to the image at mid luminance levels
  58387. */
  58388. export class GrainPostProcess extends PostProcess {
  58389. /**
  58390. * The intensity of the grain added (default: 30)
  58391. */
  58392. intensity: number;
  58393. /**
  58394. * If the grain should be randomized on every frame
  58395. */
  58396. animated: boolean;
  58397. /**
  58398. * Creates a new instance of @see GrainPostProcess
  58399. * @param name The name of the effect.
  58400. * @param options The required width/height ratio to downsize to before computing the render pass.
  58401. * @param camera The camera to apply the render pass to.
  58402. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58403. * @param engine The engine which the post process will be applied. (default: current engine)
  58404. * @param reusable If the post process can be reused on the same frame. (default: false)
  58405. * @param textureType Type of textures used when performing the post process. (default: 0)
  58406. * @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)
  58407. */
  58408. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58409. }
  58410. }
  58411. declare module "babylonjs/Shaders/highlights.fragment" {
  58412. /** @hidden */
  58413. export var highlightsPixelShader: {
  58414. name: string;
  58415. shader: string;
  58416. };
  58417. }
  58418. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  58419. import { Nullable } from "babylonjs/types";
  58420. import { Camera } from "babylonjs/Cameras/camera";
  58421. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58422. import { Engine } from "babylonjs/Engines/engine";
  58423. import "babylonjs/Shaders/highlights.fragment";
  58424. /**
  58425. * Extracts highlights from the image
  58426. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  58427. */
  58428. export class HighlightsPostProcess extends PostProcess {
  58429. /**
  58430. * Extracts highlights from the image
  58431. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  58432. * @param name The name of the effect.
  58433. * @param options The required width/height ratio to downsize to before computing the render pass.
  58434. * @param camera The camera to apply the render pass to.
  58435. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58436. * @param engine The engine which the post process will be applied. (default: current engine)
  58437. * @param reusable If the post process can be reused on the same frame. (default: false)
  58438. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  58439. */
  58440. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  58441. }
  58442. }
  58443. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  58444. /** @hidden */
  58445. export var mrtFragmentDeclaration: {
  58446. name: string;
  58447. shader: string;
  58448. };
  58449. }
  58450. declare module "babylonjs/Shaders/geometry.fragment" {
  58451. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  58452. /** @hidden */
  58453. export var geometryPixelShader: {
  58454. name: string;
  58455. shader: string;
  58456. };
  58457. }
  58458. declare module "babylonjs/Shaders/geometry.vertex" {
  58459. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  58460. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  58461. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  58462. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  58463. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  58464. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  58465. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  58466. /** @hidden */
  58467. export var geometryVertexShader: {
  58468. name: string;
  58469. shader: string;
  58470. };
  58471. }
  58472. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  58473. import { Matrix } from "babylonjs/Maths/math";
  58474. import { SubMesh } from "babylonjs/Meshes/subMesh";
  58475. import { Mesh } from "babylonjs/Meshes/mesh";
  58476. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  58477. import { Effect } from "babylonjs/Materials/effect";
  58478. import { Scene } from "babylonjs/scene";
  58479. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58480. import "babylonjs/Shaders/geometry.fragment";
  58481. import "babylonjs/Shaders/geometry.vertex";
  58482. /** @hidden */
  58483. interface ISavedTransformationMatrix {
  58484. world: Matrix;
  58485. viewProjection: Matrix;
  58486. }
  58487. /**
  58488. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  58489. */
  58490. export class GeometryBufferRenderer {
  58491. /**
  58492. * Constant used to retrieve the position texture index in the G-Buffer textures array
  58493. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  58494. */
  58495. static readonly POSITION_TEXTURE_TYPE: number;
  58496. /**
  58497. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  58498. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  58499. */
  58500. static readonly VELOCITY_TEXTURE_TYPE: number;
  58501. /**
  58502. * Dictionary used to store the previous transformation matrices of each rendered mesh
  58503. * in order to compute objects velocities when enableVelocity is set to "true"
  58504. * @hidden
  58505. */
  58506. _previousTransformationMatrices: {
  58507. [index: number]: ISavedTransformationMatrix;
  58508. };
  58509. /**
  58510. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  58511. * in order to compute objects velocities when enableVelocity is set to "true"
  58512. * @hidden
  58513. */
  58514. _previousBonesTransformationMatrices: {
  58515. [index: number]: Float32Array;
  58516. };
  58517. /**
  58518. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  58519. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  58520. */
  58521. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  58522. private _scene;
  58523. private _multiRenderTarget;
  58524. private _ratio;
  58525. private _enablePosition;
  58526. private _enableVelocity;
  58527. private _positionIndex;
  58528. private _velocityIndex;
  58529. protected _effect: Effect;
  58530. protected _cachedDefines: string;
  58531. /**
  58532. * Set the render list (meshes to be rendered) used in the G buffer.
  58533. */
  58534. renderList: Mesh[];
  58535. /**
  58536. * Gets wether or not G buffer are supported by the running hardware.
  58537. * This requires draw buffer supports
  58538. */
  58539. readonly isSupported: boolean;
  58540. /**
  58541. * Returns the index of the given texture type in the G-Buffer textures array
  58542. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  58543. * @returns the index of the given texture type in the G-Buffer textures array
  58544. */
  58545. getTextureIndex(textureType: number): number;
  58546. /**
  58547. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  58548. */
  58549. /**
  58550. * Sets whether or not objects positions are enabled for the G buffer.
  58551. */
  58552. enablePosition: boolean;
  58553. /**
  58554. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  58555. */
  58556. /**
  58557. * Sets wether or not objects velocities are enabled for the G buffer.
  58558. */
  58559. enableVelocity: boolean;
  58560. /**
  58561. * Gets the scene associated with the buffer.
  58562. */
  58563. readonly scene: Scene;
  58564. /**
  58565. * Gets the ratio used by the buffer during its creation.
  58566. * How big is the buffer related to the main canvas.
  58567. */
  58568. readonly ratio: number;
  58569. /** @hidden */
  58570. static _SceneComponentInitialization: (scene: Scene) => void;
  58571. /**
  58572. * Creates a new G Buffer for the scene
  58573. * @param scene The scene the buffer belongs to
  58574. * @param ratio How big is the buffer related to the main canvas.
  58575. */
  58576. constructor(scene: Scene, ratio?: number);
  58577. /**
  58578. * Checks wether everything is ready to render a submesh to the G buffer.
  58579. * @param subMesh the submesh to check readiness for
  58580. * @param useInstances is the mesh drawn using instance or not
  58581. * @returns true if ready otherwise false
  58582. */
  58583. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58584. /**
  58585. * Gets the current underlying G Buffer.
  58586. * @returns the buffer
  58587. */
  58588. getGBuffer(): MultiRenderTarget;
  58589. /**
  58590. * Gets the number of samples used to render the buffer (anti aliasing).
  58591. */
  58592. /**
  58593. * Sets the number of samples used to render the buffer (anti aliasing).
  58594. */
  58595. samples: number;
  58596. /**
  58597. * Disposes the renderer and frees up associated resources.
  58598. */
  58599. dispose(): void;
  58600. protected _createRenderTargets(): void;
  58601. private _copyBonesTransformationMatrices;
  58602. }
  58603. }
  58604. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  58605. import { Nullable } from "babylonjs/types";
  58606. import { Scene } from "babylonjs/scene";
  58607. import { ISceneComponent } from "babylonjs/sceneComponent";
  58608. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  58609. module "babylonjs/scene" {
  58610. interface Scene {
  58611. /** @hidden (Backing field) */
  58612. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  58613. /**
  58614. * Gets or Sets the current geometry buffer associated to the scene.
  58615. */
  58616. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  58617. /**
  58618. * Enables a GeometryBufferRender and associates it with the scene
  58619. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  58620. * @returns the GeometryBufferRenderer
  58621. */
  58622. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  58623. /**
  58624. * Disables the GeometryBufferRender associated with the scene
  58625. */
  58626. disableGeometryBufferRenderer(): void;
  58627. }
  58628. }
  58629. /**
  58630. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  58631. * in several rendering techniques.
  58632. */
  58633. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  58634. /**
  58635. * The component name helpful to identify the component in the list of scene components.
  58636. */
  58637. readonly name: string;
  58638. /**
  58639. * The scene the component belongs to.
  58640. */
  58641. scene: Scene;
  58642. /**
  58643. * Creates a new instance of the component for the given scene
  58644. * @param scene Defines the scene to register the component in
  58645. */
  58646. constructor(scene: Scene);
  58647. /**
  58648. * Registers the component in a given scene
  58649. */
  58650. register(): void;
  58651. /**
  58652. * Rebuilds the elements related to this component in case of
  58653. * context lost for instance.
  58654. */
  58655. rebuild(): void;
  58656. /**
  58657. * Disposes the component and the associated ressources
  58658. */
  58659. dispose(): void;
  58660. private _gatherRenderTargets;
  58661. }
  58662. }
  58663. declare module "babylonjs/Shaders/motionBlur.fragment" {
  58664. /** @hidden */
  58665. export var motionBlurPixelShader: {
  58666. name: string;
  58667. shader: string;
  58668. };
  58669. }
  58670. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  58671. import { Nullable } from "babylonjs/types";
  58672. import { Camera } from "babylonjs/Cameras/camera";
  58673. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58674. import { Scene } from "babylonjs/scene";
  58675. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58676. import "babylonjs/Animations/animatable";
  58677. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  58678. import "babylonjs/Shaders/motionBlur.fragment";
  58679. import { Engine } from "babylonjs/Engines/engine";
  58680. /**
  58681. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  58682. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  58683. * As an example, all you have to do is to create the post-process:
  58684. * var mb = new BABYLON.MotionBlurPostProcess(
  58685. * 'mb', // The name of the effect.
  58686. * scene, // The scene containing the objects to blur according to their velocity.
  58687. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  58688. * camera // The camera to apply the render pass to.
  58689. * );
  58690. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  58691. */
  58692. export class MotionBlurPostProcess extends PostProcess {
  58693. /**
  58694. * Defines how much the image is blurred by the movement. Default value is equal to 1
  58695. */
  58696. motionStrength: number;
  58697. /**
  58698. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  58699. */
  58700. /**
  58701. * Sets the number of iterations to be used for motion blur quality
  58702. */
  58703. motionBlurSamples: number;
  58704. private _motionBlurSamples;
  58705. private _geometryBufferRenderer;
  58706. /**
  58707. * Creates a new instance MotionBlurPostProcess
  58708. * @param name The name of the effect.
  58709. * @param scene The scene containing the objects to blur according to their velocity.
  58710. * @param options The required width/height ratio to downsize to before computing the render pass.
  58711. * @param camera The camera to apply the render pass to.
  58712. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58713. * @param engine The engine which the post process will be applied. (default: current engine)
  58714. * @param reusable If the post process can be reused on the same frame. (default: false)
  58715. * @param textureType Type of textures used when performing the post process. (default: 0)
  58716. * @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)
  58717. */
  58718. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58719. /**
  58720. * Excludes the given skinned mesh from computing bones velocities.
  58721. * 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.
  58722. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  58723. */
  58724. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  58725. /**
  58726. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  58727. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  58728. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  58729. */
  58730. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  58731. /**
  58732. * Disposes the post process.
  58733. * @param camera The camera to dispose the post process on.
  58734. */
  58735. dispose(camera?: Camera): void;
  58736. }
  58737. }
  58738. declare module "babylonjs/Shaders/refraction.fragment" {
  58739. /** @hidden */
  58740. export var refractionPixelShader: {
  58741. name: string;
  58742. shader: string;
  58743. };
  58744. }
  58745. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  58746. import { Color3 } from "babylonjs/Maths/math";
  58747. import { Camera } from "babylonjs/Cameras/camera";
  58748. import { Texture } from "babylonjs/Materials/Textures/texture";
  58749. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58750. import { Engine } from "babylonjs/Engines/engine";
  58751. import "babylonjs/Shaders/refraction.fragment";
  58752. /**
  58753. * Post process which applies a refractin texture
  58754. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  58755. */
  58756. export class RefractionPostProcess extends PostProcess {
  58757. /** the base color of the refraction (used to taint the rendering) */
  58758. color: Color3;
  58759. /** simulated refraction depth */
  58760. depth: number;
  58761. /** the coefficient of the base color (0 to remove base color tainting) */
  58762. colorLevel: number;
  58763. private _refTexture;
  58764. private _ownRefractionTexture;
  58765. /**
  58766. * Gets or sets the refraction texture
  58767. * Please note that you are responsible for disposing the texture if you set it manually
  58768. */
  58769. refractionTexture: Texture;
  58770. /**
  58771. * Initializes the RefractionPostProcess
  58772. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  58773. * @param name The name of the effect.
  58774. * @param refractionTextureUrl Url of the refraction texture to use
  58775. * @param color the base color of the refraction (used to taint the rendering)
  58776. * @param depth simulated refraction depth
  58777. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  58778. * @param camera The camera to apply the render pass to.
  58779. * @param options The required width/height ratio to downsize to before computing the render pass.
  58780. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58781. * @param engine The engine which the post process will be applied. (default: current engine)
  58782. * @param reusable If the post process can be reused on the same frame. (default: false)
  58783. */
  58784. constructor(name: string, refractionTextureUrl: string,
  58785. /** the base color of the refraction (used to taint the rendering) */
  58786. color: Color3,
  58787. /** simulated refraction depth */
  58788. depth: number,
  58789. /** the coefficient of the base color (0 to remove base color tainting) */
  58790. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58791. /**
  58792. * Disposes of the post process
  58793. * @param camera Camera to dispose post process on
  58794. */
  58795. dispose(camera: Camera): void;
  58796. }
  58797. }
  58798. declare module "babylonjs/Shaders/sharpen.fragment" {
  58799. /** @hidden */
  58800. export var sharpenPixelShader: {
  58801. name: string;
  58802. shader: string;
  58803. };
  58804. }
  58805. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  58806. import { Nullable } from "babylonjs/types";
  58807. import { Camera } from "babylonjs/Cameras/camera";
  58808. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58809. import "babylonjs/Shaders/sharpen.fragment";
  58810. import { Engine } from "babylonjs/Engines/engine";
  58811. /**
  58812. * The SharpenPostProcess applies a sharpen kernel to every pixel
  58813. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  58814. */
  58815. export class SharpenPostProcess extends PostProcess {
  58816. /**
  58817. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  58818. */
  58819. colorAmount: number;
  58820. /**
  58821. * How much sharpness should be applied (default: 0.3)
  58822. */
  58823. edgeAmount: number;
  58824. /**
  58825. * Creates a new instance ConvolutionPostProcess
  58826. * @param name The name of the effect.
  58827. * @param options The required width/height ratio to downsize to before computing the render pass.
  58828. * @param camera The camera to apply the render pass to.
  58829. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58830. * @param engine The engine which the post process will be applied. (default: current engine)
  58831. * @param reusable If the post process can be reused on the same frame. (default: false)
  58832. * @param textureType Type of textures used when performing the post process. (default: 0)
  58833. * @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)
  58834. */
  58835. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58836. }
  58837. }
  58838. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  58839. import { Nullable } from "babylonjs/types";
  58840. import { Camera } from "babylonjs/Cameras/camera";
  58841. import { Engine } from "babylonjs/Engines/engine";
  58842. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  58843. import { IInspectable } from "babylonjs/Misc/iInspectable";
  58844. /**
  58845. * PostProcessRenderPipeline
  58846. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58847. */
  58848. export class PostProcessRenderPipeline {
  58849. private engine;
  58850. private _renderEffects;
  58851. private _renderEffectsForIsolatedPass;
  58852. /**
  58853. * List of inspectable custom properties (used by the Inspector)
  58854. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  58855. */
  58856. inspectableCustomProperties: IInspectable[];
  58857. /**
  58858. * @hidden
  58859. */
  58860. protected _cameras: Camera[];
  58861. /** @hidden */
  58862. _name: string;
  58863. /**
  58864. * Gets pipeline name
  58865. */
  58866. readonly name: string;
  58867. /**
  58868. * Initializes a PostProcessRenderPipeline
  58869. * @param engine engine to add the pipeline to
  58870. * @param name name of the pipeline
  58871. */
  58872. constructor(engine: Engine, name: string);
  58873. /**
  58874. * Gets the class name
  58875. * @returns "PostProcessRenderPipeline"
  58876. */
  58877. getClassName(): string;
  58878. /**
  58879. * If all the render effects in the pipeline are supported
  58880. */
  58881. readonly isSupported: boolean;
  58882. /**
  58883. * Adds an effect to the pipeline
  58884. * @param renderEffect the effect to add
  58885. */
  58886. addEffect(renderEffect: PostProcessRenderEffect): void;
  58887. /** @hidden */
  58888. _rebuild(): void;
  58889. /** @hidden */
  58890. _enableEffect(renderEffectName: string, cameras: Camera): void;
  58891. /** @hidden */
  58892. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  58893. /** @hidden */
  58894. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  58895. /** @hidden */
  58896. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  58897. /** @hidden */
  58898. _attachCameras(cameras: Camera, unique: boolean): void;
  58899. /** @hidden */
  58900. _attachCameras(cameras: Camera[], unique: boolean): void;
  58901. /** @hidden */
  58902. _detachCameras(cameras: Camera): void;
  58903. /** @hidden */
  58904. _detachCameras(cameras: Nullable<Camera[]>): void;
  58905. /** @hidden */
  58906. _update(): void;
  58907. /** @hidden */
  58908. _reset(): void;
  58909. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  58910. /**
  58911. * Disposes of the pipeline
  58912. */
  58913. dispose(): void;
  58914. }
  58915. }
  58916. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  58917. import { Camera } from "babylonjs/Cameras/camera";
  58918. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  58919. /**
  58920. * PostProcessRenderPipelineManager class
  58921. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58922. */
  58923. export class PostProcessRenderPipelineManager {
  58924. private _renderPipelines;
  58925. /**
  58926. * Initializes a PostProcessRenderPipelineManager
  58927. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58928. */
  58929. constructor();
  58930. /**
  58931. * Gets the list of supported render pipelines
  58932. */
  58933. readonly supportedPipelines: PostProcessRenderPipeline[];
  58934. /**
  58935. * Adds a pipeline to the manager
  58936. * @param renderPipeline The pipeline to add
  58937. */
  58938. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  58939. /**
  58940. * Attaches a camera to the pipeline
  58941. * @param renderPipelineName The name of the pipeline to attach to
  58942. * @param cameras the camera to attach
  58943. * @param unique if the camera can be attached multiple times to the pipeline
  58944. */
  58945. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  58946. /**
  58947. * Detaches a camera from the pipeline
  58948. * @param renderPipelineName The name of the pipeline to detach from
  58949. * @param cameras the camera to detach
  58950. */
  58951. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  58952. /**
  58953. * Enables an effect by name on a pipeline
  58954. * @param renderPipelineName the name of the pipeline to enable the effect in
  58955. * @param renderEffectName the name of the effect to enable
  58956. * @param cameras the cameras that the effect should be enabled on
  58957. */
  58958. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  58959. /**
  58960. * Disables an effect by name on a pipeline
  58961. * @param renderPipelineName the name of the pipeline to disable the effect in
  58962. * @param renderEffectName the name of the effect to disable
  58963. * @param cameras the cameras that the effect should be disabled on
  58964. */
  58965. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  58966. /**
  58967. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  58968. */
  58969. update(): void;
  58970. /** @hidden */
  58971. _rebuild(): void;
  58972. /**
  58973. * Disposes of the manager and pipelines
  58974. */
  58975. dispose(): void;
  58976. }
  58977. }
  58978. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  58979. import { ISceneComponent } from "babylonjs/sceneComponent";
  58980. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  58981. import { Scene } from "babylonjs/scene";
  58982. module "babylonjs/scene" {
  58983. interface Scene {
  58984. /** @hidden (Backing field) */
  58985. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  58986. /**
  58987. * Gets the postprocess render pipeline manager
  58988. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58989. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  58990. */
  58991. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  58992. }
  58993. }
  58994. /**
  58995. * Defines the Render Pipeline scene component responsible to rendering pipelines
  58996. */
  58997. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  58998. /**
  58999. * The component name helpfull to identify the component in the list of scene components.
  59000. */
  59001. readonly name: string;
  59002. /**
  59003. * The scene the component belongs to.
  59004. */
  59005. scene: Scene;
  59006. /**
  59007. * Creates a new instance of the component for the given scene
  59008. * @param scene Defines the scene to register the component in
  59009. */
  59010. constructor(scene: Scene);
  59011. /**
  59012. * Registers the component in a given scene
  59013. */
  59014. register(): void;
  59015. /**
  59016. * Rebuilds the elements related to this component in case of
  59017. * context lost for instance.
  59018. */
  59019. rebuild(): void;
  59020. /**
  59021. * Disposes the component and the associated ressources
  59022. */
  59023. dispose(): void;
  59024. private _gatherRenderTargets;
  59025. }
  59026. }
  59027. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  59028. import { Nullable } from "babylonjs/types";
  59029. import { IAnimatable } from "babylonjs/Misc/tools";
  59030. import { Camera } from "babylonjs/Cameras/camera";
  59031. import { IDisposable } from "babylonjs/scene";
  59032. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  59033. import { Scene } from "babylonjs/scene";
  59034. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  59035. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  59036. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  59037. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  59038. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  59039. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  59040. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  59041. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  59042. import { Animation } from "babylonjs/Animations/animation";
  59043. /**
  59044. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  59045. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  59046. */
  59047. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  59048. private _scene;
  59049. private _camerasToBeAttached;
  59050. /**
  59051. * ID of the sharpen post process,
  59052. */
  59053. private readonly SharpenPostProcessId;
  59054. /**
  59055. * @ignore
  59056. * ID of the image processing post process;
  59057. */
  59058. readonly ImageProcessingPostProcessId: string;
  59059. /**
  59060. * @ignore
  59061. * ID of the Fast Approximate Anti-Aliasing post process;
  59062. */
  59063. readonly FxaaPostProcessId: string;
  59064. /**
  59065. * ID of the chromatic aberration post process,
  59066. */
  59067. private readonly ChromaticAberrationPostProcessId;
  59068. /**
  59069. * ID of the grain post process
  59070. */
  59071. private readonly GrainPostProcessId;
  59072. /**
  59073. * Sharpen post process which will apply a sharpen convolution to enhance edges
  59074. */
  59075. sharpen: SharpenPostProcess;
  59076. private _sharpenEffect;
  59077. private bloom;
  59078. /**
  59079. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  59080. */
  59081. depthOfField: DepthOfFieldEffect;
  59082. /**
  59083. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  59084. */
  59085. fxaa: FxaaPostProcess;
  59086. /**
  59087. * Image post processing pass used to perform operations such as tone mapping or color grading.
  59088. */
  59089. imageProcessing: ImageProcessingPostProcess;
  59090. /**
  59091. * Chromatic aberration post process which will shift rgb colors in the image
  59092. */
  59093. chromaticAberration: ChromaticAberrationPostProcess;
  59094. private _chromaticAberrationEffect;
  59095. /**
  59096. * Grain post process which add noise to the image
  59097. */
  59098. grain: GrainPostProcess;
  59099. private _grainEffect;
  59100. /**
  59101. * Glow post process which adds a glow to emissive areas of the image
  59102. */
  59103. private _glowLayer;
  59104. /**
  59105. * Animations which can be used to tweak settings over a period of time
  59106. */
  59107. animations: Animation[];
  59108. private _imageProcessingConfigurationObserver;
  59109. private _sharpenEnabled;
  59110. private _bloomEnabled;
  59111. private _depthOfFieldEnabled;
  59112. private _depthOfFieldBlurLevel;
  59113. private _fxaaEnabled;
  59114. private _imageProcessingEnabled;
  59115. private _defaultPipelineTextureType;
  59116. private _bloomScale;
  59117. private _chromaticAberrationEnabled;
  59118. private _grainEnabled;
  59119. private _buildAllowed;
  59120. /**
  59121. * Gets active scene
  59122. */
  59123. readonly scene: Scene;
  59124. /**
  59125. * Enable or disable the sharpen process from the pipeline
  59126. */
  59127. sharpenEnabled: boolean;
  59128. private _resizeObserver;
  59129. private _hardwareScaleLevel;
  59130. private _bloomKernel;
  59131. /**
  59132. * Specifies the size of the bloom blur kernel, relative to the final output size
  59133. */
  59134. bloomKernel: number;
  59135. /**
  59136. * Specifies the weight of the bloom in the final rendering
  59137. */
  59138. private _bloomWeight;
  59139. /**
  59140. * Specifies the luma threshold for the area that will be blurred by the bloom
  59141. */
  59142. private _bloomThreshold;
  59143. private _hdr;
  59144. /**
  59145. * The strength of the bloom.
  59146. */
  59147. bloomWeight: number;
  59148. /**
  59149. * The strength of the bloom.
  59150. */
  59151. bloomThreshold: number;
  59152. /**
  59153. * The scale of the bloom, lower value will provide better performance.
  59154. */
  59155. bloomScale: number;
  59156. /**
  59157. * Enable or disable the bloom from the pipeline
  59158. */
  59159. bloomEnabled: boolean;
  59160. private _rebuildBloom;
  59161. /**
  59162. * If the depth of field is enabled.
  59163. */
  59164. depthOfFieldEnabled: boolean;
  59165. /**
  59166. * Blur level of the depth of field effect. (Higher blur will effect performance)
  59167. */
  59168. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  59169. /**
  59170. * If the anti aliasing is enabled.
  59171. */
  59172. fxaaEnabled: boolean;
  59173. private _samples;
  59174. /**
  59175. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  59176. */
  59177. samples: number;
  59178. /**
  59179. * If image processing is enabled.
  59180. */
  59181. imageProcessingEnabled: boolean;
  59182. /**
  59183. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  59184. */
  59185. glowLayerEnabled: boolean;
  59186. /**
  59187. * Gets the glow layer (or null if not defined)
  59188. */
  59189. readonly glowLayer: Nullable<GlowLayer>;
  59190. /**
  59191. * Enable or disable the chromaticAberration process from the pipeline
  59192. */
  59193. chromaticAberrationEnabled: boolean;
  59194. /**
  59195. * Enable or disable the grain process from the pipeline
  59196. */
  59197. grainEnabled: boolean;
  59198. /**
  59199. * @constructor
  59200. * @param name - The rendering pipeline name (default: "")
  59201. * @param hdr - If high dynamic range textures should be used (default: true)
  59202. * @param scene - The scene linked to this pipeline (default: the last created scene)
  59203. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  59204. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  59205. */
  59206. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  59207. /**
  59208. * Get the class name
  59209. * @returns "DefaultRenderingPipeline"
  59210. */
  59211. getClassName(): string;
  59212. /**
  59213. * Force the compilation of the entire pipeline.
  59214. */
  59215. prepare(): void;
  59216. private _hasCleared;
  59217. private _prevPostProcess;
  59218. private _prevPrevPostProcess;
  59219. private _setAutoClearAndTextureSharing;
  59220. private _depthOfFieldSceneObserver;
  59221. private _buildPipeline;
  59222. private _disposePostProcesses;
  59223. /**
  59224. * Adds a camera to the pipeline
  59225. * @param camera the camera to be added
  59226. */
  59227. addCamera(camera: Camera): void;
  59228. /**
  59229. * Removes a camera from the pipeline
  59230. * @param camera the camera to remove
  59231. */
  59232. removeCamera(camera: Camera): void;
  59233. /**
  59234. * Dispose of the pipeline and stop all post processes
  59235. */
  59236. dispose(): void;
  59237. /**
  59238. * Serialize the rendering pipeline (Used when exporting)
  59239. * @returns the serialized object
  59240. */
  59241. serialize(): any;
  59242. /**
  59243. * Parse the serialized pipeline
  59244. * @param source Source pipeline.
  59245. * @param scene The scene to load the pipeline to.
  59246. * @param rootUrl The URL of the serialized pipeline.
  59247. * @returns An instantiated pipeline from the serialized object.
  59248. */
  59249. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  59250. }
  59251. }
  59252. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  59253. /** @hidden */
  59254. export var lensHighlightsPixelShader: {
  59255. name: string;
  59256. shader: string;
  59257. };
  59258. }
  59259. declare module "babylonjs/Shaders/depthOfField.fragment" {
  59260. /** @hidden */
  59261. export var depthOfFieldPixelShader: {
  59262. name: string;
  59263. shader: string;
  59264. };
  59265. }
  59266. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  59267. import { Camera } from "babylonjs/Cameras/camera";
  59268. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  59269. import { Scene } from "babylonjs/scene";
  59270. import "babylonjs/Shaders/chromaticAberration.fragment";
  59271. import "babylonjs/Shaders/lensHighlights.fragment";
  59272. import "babylonjs/Shaders/depthOfField.fragment";
  59273. /**
  59274. * BABYLON.JS Chromatic Aberration GLSL Shader
  59275. * Author: Olivier Guyot
  59276. * Separates very slightly R, G and B colors on the edges of the screen
  59277. * Inspired by Francois Tarlier & Martins Upitis
  59278. */
  59279. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  59280. /**
  59281. * @ignore
  59282. * The chromatic aberration PostProcess id in the pipeline
  59283. */
  59284. LensChromaticAberrationEffect: string;
  59285. /**
  59286. * @ignore
  59287. * The highlights enhancing PostProcess id in the pipeline
  59288. */
  59289. HighlightsEnhancingEffect: string;
  59290. /**
  59291. * @ignore
  59292. * The depth-of-field PostProcess id in the pipeline
  59293. */
  59294. LensDepthOfFieldEffect: string;
  59295. private _scene;
  59296. private _depthTexture;
  59297. private _grainTexture;
  59298. private _chromaticAberrationPostProcess;
  59299. private _highlightsPostProcess;
  59300. private _depthOfFieldPostProcess;
  59301. private _edgeBlur;
  59302. private _grainAmount;
  59303. private _chromaticAberration;
  59304. private _distortion;
  59305. private _highlightsGain;
  59306. private _highlightsThreshold;
  59307. private _dofDistance;
  59308. private _dofAperture;
  59309. private _dofDarken;
  59310. private _dofPentagon;
  59311. private _blurNoise;
  59312. /**
  59313. * @constructor
  59314. *
  59315. * Effect parameters are as follow:
  59316. * {
  59317. * chromatic_aberration: number; // from 0 to x (1 for realism)
  59318. * edge_blur: number; // from 0 to x (1 for realism)
  59319. * distortion: number; // from 0 to x (1 for realism)
  59320. * grain_amount: number; // from 0 to 1
  59321. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  59322. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  59323. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  59324. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  59325. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  59326. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  59327. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  59328. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  59329. * }
  59330. * Note: if an effect parameter is unset, effect is disabled
  59331. *
  59332. * @param name The rendering pipeline name
  59333. * @param parameters - An object containing all parameters (see above)
  59334. * @param scene The scene linked to this pipeline
  59335. * @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)
  59336. * @param cameras The array of cameras that the rendering pipeline will be attached to
  59337. */
  59338. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  59339. /**
  59340. * Get the class name
  59341. * @returns "LensRenderingPipeline"
  59342. */
  59343. getClassName(): string;
  59344. /**
  59345. * Gets associated scene
  59346. */
  59347. readonly scene: Scene;
  59348. /**
  59349. * Gets or sets the edge blur
  59350. */
  59351. edgeBlur: number;
  59352. /**
  59353. * Gets or sets the grain amount
  59354. */
  59355. grainAmount: number;
  59356. /**
  59357. * Gets or sets the chromatic aberration amount
  59358. */
  59359. chromaticAberration: number;
  59360. /**
  59361. * Gets or sets the depth of field aperture
  59362. */
  59363. dofAperture: number;
  59364. /**
  59365. * Gets or sets the edge distortion
  59366. */
  59367. edgeDistortion: number;
  59368. /**
  59369. * Gets or sets the depth of field distortion
  59370. */
  59371. dofDistortion: number;
  59372. /**
  59373. * Gets or sets the darken out of focus amount
  59374. */
  59375. darkenOutOfFocus: number;
  59376. /**
  59377. * Gets or sets a boolean indicating if blur noise is enabled
  59378. */
  59379. blurNoise: boolean;
  59380. /**
  59381. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  59382. */
  59383. pentagonBokeh: boolean;
  59384. /**
  59385. * Gets or sets the highlight grain amount
  59386. */
  59387. highlightsGain: number;
  59388. /**
  59389. * Gets or sets the highlight threshold
  59390. */
  59391. highlightsThreshold: number;
  59392. /**
  59393. * Sets the amount of blur at the edges
  59394. * @param amount blur amount
  59395. */
  59396. setEdgeBlur(amount: number): void;
  59397. /**
  59398. * Sets edge blur to 0
  59399. */
  59400. disableEdgeBlur(): void;
  59401. /**
  59402. * Sets the amout of grain
  59403. * @param amount Amount of grain
  59404. */
  59405. setGrainAmount(amount: number): void;
  59406. /**
  59407. * Set grain amount to 0
  59408. */
  59409. disableGrain(): void;
  59410. /**
  59411. * Sets the chromatic aberration amount
  59412. * @param amount amount of chromatic aberration
  59413. */
  59414. setChromaticAberration(amount: number): void;
  59415. /**
  59416. * Sets chromatic aberration amount to 0
  59417. */
  59418. disableChromaticAberration(): void;
  59419. /**
  59420. * Sets the EdgeDistortion amount
  59421. * @param amount amount of EdgeDistortion
  59422. */
  59423. setEdgeDistortion(amount: number): void;
  59424. /**
  59425. * Sets edge distortion to 0
  59426. */
  59427. disableEdgeDistortion(): void;
  59428. /**
  59429. * Sets the FocusDistance amount
  59430. * @param amount amount of FocusDistance
  59431. */
  59432. setFocusDistance(amount: number): void;
  59433. /**
  59434. * Disables depth of field
  59435. */
  59436. disableDepthOfField(): void;
  59437. /**
  59438. * Sets the Aperture amount
  59439. * @param amount amount of Aperture
  59440. */
  59441. setAperture(amount: number): void;
  59442. /**
  59443. * Sets the DarkenOutOfFocus amount
  59444. * @param amount amount of DarkenOutOfFocus
  59445. */
  59446. setDarkenOutOfFocus(amount: number): void;
  59447. private _pentagonBokehIsEnabled;
  59448. /**
  59449. * Creates a pentagon bokeh effect
  59450. */
  59451. enablePentagonBokeh(): void;
  59452. /**
  59453. * Disables the pentagon bokeh effect
  59454. */
  59455. disablePentagonBokeh(): void;
  59456. /**
  59457. * Enables noise blur
  59458. */
  59459. enableNoiseBlur(): void;
  59460. /**
  59461. * Disables noise blur
  59462. */
  59463. disableNoiseBlur(): void;
  59464. /**
  59465. * Sets the HighlightsGain amount
  59466. * @param amount amount of HighlightsGain
  59467. */
  59468. setHighlightsGain(amount: number): void;
  59469. /**
  59470. * Sets the HighlightsThreshold amount
  59471. * @param amount amount of HighlightsThreshold
  59472. */
  59473. setHighlightsThreshold(amount: number): void;
  59474. /**
  59475. * Disables highlights
  59476. */
  59477. disableHighlights(): void;
  59478. /**
  59479. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  59480. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  59481. */
  59482. dispose(disableDepthRender?: boolean): void;
  59483. private _createChromaticAberrationPostProcess;
  59484. private _createHighlightsPostProcess;
  59485. private _createDepthOfFieldPostProcess;
  59486. private _createGrainTexture;
  59487. }
  59488. }
  59489. declare module "babylonjs/Shaders/ssao2.fragment" {
  59490. /** @hidden */
  59491. export var ssao2PixelShader: {
  59492. name: string;
  59493. shader: string;
  59494. };
  59495. }
  59496. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  59497. /** @hidden */
  59498. export var ssaoCombinePixelShader: {
  59499. name: string;
  59500. shader: string;
  59501. };
  59502. }
  59503. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  59504. import { Camera } from "babylonjs/Cameras/camera";
  59505. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  59506. import { Scene } from "babylonjs/scene";
  59507. import "babylonjs/Shaders/ssao2.fragment";
  59508. import "babylonjs/Shaders/ssaoCombine.fragment";
  59509. /**
  59510. * Render pipeline to produce ssao effect
  59511. */
  59512. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  59513. /**
  59514. * @ignore
  59515. * The PassPostProcess id in the pipeline that contains the original scene color
  59516. */
  59517. SSAOOriginalSceneColorEffect: string;
  59518. /**
  59519. * @ignore
  59520. * The SSAO PostProcess id in the pipeline
  59521. */
  59522. SSAORenderEffect: string;
  59523. /**
  59524. * @ignore
  59525. * The horizontal blur PostProcess id in the pipeline
  59526. */
  59527. SSAOBlurHRenderEffect: string;
  59528. /**
  59529. * @ignore
  59530. * The vertical blur PostProcess id in the pipeline
  59531. */
  59532. SSAOBlurVRenderEffect: string;
  59533. /**
  59534. * @ignore
  59535. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  59536. */
  59537. SSAOCombineRenderEffect: string;
  59538. /**
  59539. * The output strength of the SSAO post-process. Default value is 1.0.
  59540. */
  59541. totalStrength: number;
  59542. /**
  59543. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  59544. */
  59545. maxZ: number;
  59546. /**
  59547. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  59548. */
  59549. minZAspect: number;
  59550. private _samples;
  59551. /**
  59552. * Number of samples used for the SSAO calculations. Default value is 8
  59553. */
  59554. samples: number;
  59555. private _textureSamples;
  59556. /**
  59557. * Number of samples to use for antialiasing
  59558. */
  59559. textureSamples: number;
  59560. /**
  59561. * Ratio object used for SSAO ratio and blur ratio
  59562. */
  59563. private _ratio;
  59564. /**
  59565. * Dynamically generated sphere sampler.
  59566. */
  59567. private _sampleSphere;
  59568. /**
  59569. * Blur filter offsets
  59570. */
  59571. private _samplerOffsets;
  59572. private _expensiveBlur;
  59573. /**
  59574. * If bilateral blur should be used
  59575. */
  59576. expensiveBlur: boolean;
  59577. /**
  59578. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  59579. */
  59580. radius: number;
  59581. /**
  59582. * The base color of the SSAO post-process
  59583. * The final result is "base + ssao" between [0, 1]
  59584. */
  59585. base: number;
  59586. /**
  59587. * Support test.
  59588. */
  59589. static readonly IsSupported: boolean;
  59590. private _scene;
  59591. private _depthTexture;
  59592. private _normalTexture;
  59593. private _randomTexture;
  59594. private _originalColorPostProcess;
  59595. private _ssaoPostProcess;
  59596. private _blurHPostProcess;
  59597. private _blurVPostProcess;
  59598. private _ssaoCombinePostProcess;
  59599. private _firstUpdate;
  59600. /**
  59601. * Gets active scene
  59602. */
  59603. readonly scene: Scene;
  59604. /**
  59605. * @constructor
  59606. * @param name The rendering pipeline name
  59607. * @param scene The scene linked to this pipeline
  59608. * @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 }
  59609. * @param cameras The array of cameras that the rendering pipeline will be attached to
  59610. */
  59611. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  59612. /**
  59613. * Get the class name
  59614. * @returns "SSAO2RenderingPipeline"
  59615. */
  59616. getClassName(): string;
  59617. /**
  59618. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  59619. */
  59620. dispose(disableGeometryBufferRenderer?: boolean): void;
  59621. private _createBlurPostProcess;
  59622. /** @hidden */
  59623. _rebuild(): void;
  59624. private _bits;
  59625. private _radicalInverse_VdC;
  59626. private _hammersley;
  59627. private _hemisphereSample_uniform;
  59628. private _generateHemisphere;
  59629. private _createSSAOPostProcess;
  59630. private _createSSAOCombinePostProcess;
  59631. private _createRandomTexture;
  59632. /**
  59633. * Serialize the rendering pipeline (Used when exporting)
  59634. * @returns the serialized object
  59635. */
  59636. serialize(): any;
  59637. /**
  59638. * Parse the serialized pipeline
  59639. * @param source Source pipeline.
  59640. * @param scene The scene to load the pipeline to.
  59641. * @param rootUrl The URL of the serialized pipeline.
  59642. * @returns An instantiated pipeline from the serialized object.
  59643. */
  59644. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  59645. }
  59646. }
  59647. declare module "babylonjs/Shaders/ssao.fragment" {
  59648. /** @hidden */
  59649. export var ssaoPixelShader: {
  59650. name: string;
  59651. shader: string;
  59652. };
  59653. }
  59654. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  59655. import { Camera } from "babylonjs/Cameras/camera";
  59656. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  59657. import { Scene } from "babylonjs/scene";
  59658. import "babylonjs/Shaders/ssao.fragment";
  59659. import "babylonjs/Shaders/ssaoCombine.fragment";
  59660. /**
  59661. * Render pipeline to produce ssao effect
  59662. */
  59663. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  59664. /**
  59665. * @ignore
  59666. * The PassPostProcess id in the pipeline that contains the original scene color
  59667. */
  59668. SSAOOriginalSceneColorEffect: string;
  59669. /**
  59670. * @ignore
  59671. * The SSAO PostProcess id in the pipeline
  59672. */
  59673. SSAORenderEffect: string;
  59674. /**
  59675. * @ignore
  59676. * The horizontal blur PostProcess id in the pipeline
  59677. */
  59678. SSAOBlurHRenderEffect: string;
  59679. /**
  59680. * @ignore
  59681. * The vertical blur PostProcess id in the pipeline
  59682. */
  59683. SSAOBlurVRenderEffect: string;
  59684. /**
  59685. * @ignore
  59686. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  59687. */
  59688. SSAOCombineRenderEffect: string;
  59689. /**
  59690. * The output strength of the SSAO post-process. Default value is 1.0.
  59691. */
  59692. totalStrength: number;
  59693. /**
  59694. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  59695. */
  59696. radius: number;
  59697. /**
  59698. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  59699. * Must not be equal to fallOff and superior to fallOff.
  59700. * Default value is 0.0075
  59701. */
  59702. area: number;
  59703. /**
  59704. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  59705. * Must not be equal to area and inferior to area.
  59706. * Default value is 0.000001
  59707. */
  59708. fallOff: number;
  59709. /**
  59710. * The base color of the SSAO post-process
  59711. * The final result is "base + ssao" between [0, 1]
  59712. */
  59713. base: number;
  59714. private _scene;
  59715. private _depthTexture;
  59716. private _randomTexture;
  59717. private _originalColorPostProcess;
  59718. private _ssaoPostProcess;
  59719. private _blurHPostProcess;
  59720. private _blurVPostProcess;
  59721. private _ssaoCombinePostProcess;
  59722. private _firstUpdate;
  59723. /**
  59724. * Gets active scene
  59725. */
  59726. readonly scene: Scene;
  59727. /**
  59728. * @constructor
  59729. * @param name - The rendering pipeline name
  59730. * @param scene - The scene linked to this pipeline
  59731. * @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 }
  59732. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  59733. */
  59734. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  59735. /**
  59736. * Get the class name
  59737. * @returns "SSAORenderingPipeline"
  59738. */
  59739. getClassName(): string;
  59740. /**
  59741. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  59742. */
  59743. dispose(disableDepthRender?: boolean): void;
  59744. private _createBlurPostProcess;
  59745. /** @hidden */
  59746. _rebuild(): void;
  59747. private _createSSAOPostProcess;
  59748. private _createSSAOCombinePostProcess;
  59749. private _createRandomTexture;
  59750. }
  59751. }
  59752. declare module "babylonjs/Shaders/standard.fragment" {
  59753. /** @hidden */
  59754. export var standardPixelShader: {
  59755. name: string;
  59756. shader: string;
  59757. };
  59758. }
  59759. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  59760. import { Nullable } from "babylonjs/types";
  59761. import { IAnimatable } from "babylonjs/Misc/tools";
  59762. import { Camera } from "babylonjs/Cameras/camera";
  59763. import { Texture } from "babylonjs/Materials/Textures/texture";
  59764. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  59765. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  59766. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  59767. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  59768. import { IDisposable } from "babylonjs/scene";
  59769. import { SpotLight } from "babylonjs/Lights/spotLight";
  59770. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  59771. import { Scene } from "babylonjs/scene";
  59772. import { Animation } from "babylonjs/Animations/animation";
  59773. import "babylonjs/Shaders/standard.fragment";
  59774. /**
  59775. * Standard rendering pipeline
  59776. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  59777. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  59778. */
  59779. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  59780. /**
  59781. * Public members
  59782. */
  59783. /**
  59784. * Post-process which contains the original scene color before the pipeline applies all the effects
  59785. */
  59786. originalPostProcess: Nullable<PostProcess>;
  59787. /**
  59788. * Post-process used to down scale an image x4
  59789. */
  59790. downSampleX4PostProcess: Nullable<PostProcess>;
  59791. /**
  59792. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  59793. */
  59794. brightPassPostProcess: Nullable<PostProcess>;
  59795. /**
  59796. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  59797. */
  59798. blurHPostProcesses: PostProcess[];
  59799. /**
  59800. * Post-process array storing all the vertical blur post-processes used by the pipeline
  59801. */
  59802. blurVPostProcesses: PostProcess[];
  59803. /**
  59804. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  59805. */
  59806. textureAdderPostProcess: Nullable<PostProcess>;
  59807. /**
  59808. * Post-process used to create volumetric lighting effect
  59809. */
  59810. volumetricLightPostProcess: Nullable<PostProcess>;
  59811. /**
  59812. * Post-process used to smooth the previous volumetric light post-process on the X axis
  59813. */
  59814. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  59815. /**
  59816. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  59817. */
  59818. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  59819. /**
  59820. * Post-process used to merge the volumetric light effect and the real scene color
  59821. */
  59822. volumetricLightMergePostProces: Nullable<PostProcess>;
  59823. /**
  59824. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  59825. */
  59826. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  59827. /**
  59828. * Base post-process used to calculate the average luminance of the final image for HDR
  59829. */
  59830. luminancePostProcess: Nullable<PostProcess>;
  59831. /**
  59832. * Post-processes used to create down sample post-processes in order to get
  59833. * the average luminance of the final image for HDR
  59834. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  59835. */
  59836. luminanceDownSamplePostProcesses: PostProcess[];
  59837. /**
  59838. * Post-process used to create a HDR effect (light adaptation)
  59839. */
  59840. hdrPostProcess: Nullable<PostProcess>;
  59841. /**
  59842. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  59843. */
  59844. textureAdderFinalPostProcess: Nullable<PostProcess>;
  59845. /**
  59846. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  59847. */
  59848. lensFlareFinalPostProcess: Nullable<PostProcess>;
  59849. /**
  59850. * Post-process used to merge the final HDR post-process and the real scene color
  59851. */
  59852. hdrFinalPostProcess: Nullable<PostProcess>;
  59853. /**
  59854. * Post-process used to create a lens flare effect
  59855. */
  59856. lensFlarePostProcess: Nullable<PostProcess>;
  59857. /**
  59858. * Post-process that merges the result of the lens flare post-process and the real scene color
  59859. */
  59860. lensFlareComposePostProcess: Nullable<PostProcess>;
  59861. /**
  59862. * Post-process used to create a motion blur effect
  59863. */
  59864. motionBlurPostProcess: Nullable<PostProcess>;
  59865. /**
  59866. * Post-process used to create a depth of field effect
  59867. */
  59868. depthOfFieldPostProcess: Nullable<PostProcess>;
  59869. /**
  59870. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  59871. */
  59872. fxaaPostProcess: Nullable<FxaaPostProcess>;
  59873. /**
  59874. * Represents the brightness threshold in order to configure the illuminated surfaces
  59875. */
  59876. brightThreshold: number;
  59877. /**
  59878. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  59879. */
  59880. blurWidth: number;
  59881. /**
  59882. * Sets if the blur for highlighted surfaces must be only horizontal
  59883. */
  59884. horizontalBlur: boolean;
  59885. /**
  59886. * Gets the overall exposure used by the pipeline
  59887. */
  59888. /**
  59889. * Sets the overall exposure used by the pipeline
  59890. */
  59891. exposure: number;
  59892. /**
  59893. * Texture used typically to simulate "dirty" on camera lens
  59894. */
  59895. lensTexture: Nullable<Texture>;
  59896. /**
  59897. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  59898. */
  59899. volumetricLightCoefficient: number;
  59900. /**
  59901. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  59902. */
  59903. volumetricLightPower: number;
  59904. /**
  59905. * Used the set the blur intensity to smooth the volumetric lights
  59906. */
  59907. volumetricLightBlurScale: number;
  59908. /**
  59909. * Light (spot or directional) used to generate the volumetric lights rays
  59910. * The source light must have a shadow generate so the pipeline can get its
  59911. * depth map
  59912. */
  59913. sourceLight: Nullable<SpotLight | DirectionalLight>;
  59914. /**
  59915. * For eye adaptation, represents the minimum luminance the eye can see
  59916. */
  59917. hdrMinimumLuminance: number;
  59918. /**
  59919. * For eye adaptation, represents the decrease luminance speed
  59920. */
  59921. hdrDecreaseRate: number;
  59922. /**
  59923. * For eye adaptation, represents the increase luminance speed
  59924. */
  59925. hdrIncreaseRate: number;
  59926. /**
  59927. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  59928. */
  59929. /**
  59930. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  59931. */
  59932. hdrAutoExposure: boolean;
  59933. /**
  59934. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  59935. */
  59936. lensColorTexture: Nullable<Texture>;
  59937. /**
  59938. * The overall strengh for the lens flare effect
  59939. */
  59940. lensFlareStrength: number;
  59941. /**
  59942. * Dispersion coefficient for lens flare ghosts
  59943. */
  59944. lensFlareGhostDispersal: number;
  59945. /**
  59946. * Main lens flare halo width
  59947. */
  59948. lensFlareHaloWidth: number;
  59949. /**
  59950. * Based on the lens distortion effect, defines how much the lens flare result
  59951. * is distorted
  59952. */
  59953. lensFlareDistortionStrength: number;
  59954. /**
  59955. * Lens star texture must be used to simulate rays on the flares and is available
  59956. * in the documentation
  59957. */
  59958. lensStarTexture: Nullable<Texture>;
  59959. /**
  59960. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  59961. * flare effect by taking account of the dirt texture
  59962. */
  59963. lensFlareDirtTexture: Nullable<Texture>;
  59964. /**
  59965. * Represents the focal length for the depth of field effect
  59966. */
  59967. depthOfFieldDistance: number;
  59968. /**
  59969. * Represents the blur intensity for the blurred part of the depth of field effect
  59970. */
  59971. depthOfFieldBlurWidth: number;
  59972. /**
  59973. * Gets how much the image is blurred by the movement while using the motion blur post-process
  59974. */
  59975. /**
  59976. * Sets how much the image is blurred by the movement while using the motion blur post-process
  59977. */
  59978. motionStrength: number;
  59979. /**
  59980. * Gets wether or not the motion blur post-process is object based or screen based.
  59981. */
  59982. /**
  59983. * Sets wether or not the motion blur post-process should be object based or screen based
  59984. */
  59985. objectBasedMotionBlur: boolean;
  59986. /**
  59987. * List of animations for the pipeline (IAnimatable implementation)
  59988. */
  59989. animations: Animation[];
  59990. /**
  59991. * Private members
  59992. */
  59993. private _scene;
  59994. private _currentDepthOfFieldSource;
  59995. private _basePostProcess;
  59996. private _fixedExposure;
  59997. private _currentExposure;
  59998. private _hdrAutoExposure;
  59999. private _hdrCurrentLuminance;
  60000. private _motionStrength;
  60001. private _isObjectBasedMotionBlur;
  60002. private _floatTextureType;
  60003. private _ratio;
  60004. private _bloomEnabled;
  60005. private _depthOfFieldEnabled;
  60006. private _vlsEnabled;
  60007. private _lensFlareEnabled;
  60008. private _hdrEnabled;
  60009. private _motionBlurEnabled;
  60010. private _fxaaEnabled;
  60011. private _motionBlurSamples;
  60012. private _volumetricLightStepsCount;
  60013. private _samples;
  60014. /**
  60015. * @ignore
  60016. * Specifies if the bloom pipeline is enabled
  60017. */
  60018. BloomEnabled: boolean;
  60019. /**
  60020. * @ignore
  60021. * Specifies if the depth of field pipeline is enabed
  60022. */
  60023. DepthOfFieldEnabled: boolean;
  60024. /**
  60025. * @ignore
  60026. * Specifies if the lens flare pipeline is enabed
  60027. */
  60028. LensFlareEnabled: boolean;
  60029. /**
  60030. * @ignore
  60031. * Specifies if the HDR pipeline is enabled
  60032. */
  60033. HDREnabled: boolean;
  60034. /**
  60035. * @ignore
  60036. * Specifies if the volumetric lights scattering effect is enabled
  60037. */
  60038. VLSEnabled: boolean;
  60039. /**
  60040. * @ignore
  60041. * Specifies if the motion blur effect is enabled
  60042. */
  60043. MotionBlurEnabled: boolean;
  60044. /**
  60045. * Specifies if anti-aliasing is enabled
  60046. */
  60047. fxaaEnabled: boolean;
  60048. /**
  60049. * Specifies the number of steps used to calculate the volumetric lights
  60050. * Typically in interval [50, 200]
  60051. */
  60052. volumetricLightStepsCount: number;
  60053. /**
  60054. * Specifies the number of samples used for the motion blur effect
  60055. * Typically in interval [16, 64]
  60056. */
  60057. motionBlurSamples: number;
  60058. /**
  60059. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  60060. */
  60061. samples: number;
  60062. /**
  60063. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  60064. * @constructor
  60065. * @param name The rendering pipeline name
  60066. * @param scene The scene linked to this pipeline
  60067. * @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)
  60068. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  60069. * @param cameras The array of cameras that the rendering pipeline will be attached to
  60070. */
  60071. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  60072. private _buildPipeline;
  60073. private _createDownSampleX4PostProcess;
  60074. private _createBrightPassPostProcess;
  60075. private _createBlurPostProcesses;
  60076. private _createTextureAdderPostProcess;
  60077. private _createVolumetricLightPostProcess;
  60078. private _createLuminancePostProcesses;
  60079. private _createHdrPostProcess;
  60080. private _createLensFlarePostProcess;
  60081. private _createDepthOfFieldPostProcess;
  60082. private _createMotionBlurPostProcess;
  60083. private _getDepthTexture;
  60084. private _disposePostProcesses;
  60085. /**
  60086. * Dispose of the pipeline and stop all post processes
  60087. */
  60088. dispose(): void;
  60089. /**
  60090. * Serialize the rendering pipeline (Used when exporting)
  60091. * @returns the serialized object
  60092. */
  60093. serialize(): any;
  60094. /**
  60095. * Parse the serialized pipeline
  60096. * @param source Source pipeline.
  60097. * @param scene The scene to load the pipeline to.
  60098. * @param rootUrl The URL of the serialized pipeline.
  60099. * @returns An instantiated pipeline from the serialized object.
  60100. */
  60101. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  60102. /**
  60103. * Luminance steps
  60104. */
  60105. static LuminanceSteps: number;
  60106. }
  60107. }
  60108. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  60109. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  60110. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  60111. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  60112. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  60113. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  60114. }
  60115. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  60116. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  60117. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  60118. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  60119. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  60120. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  60121. }
  60122. declare module "babylonjs/Shaders/tonemap.fragment" {
  60123. /** @hidden */
  60124. export var tonemapPixelShader: {
  60125. name: string;
  60126. shader: string;
  60127. };
  60128. }
  60129. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  60130. import { Camera } from "babylonjs/Cameras/camera";
  60131. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  60132. import "babylonjs/Shaders/tonemap.fragment";
  60133. import { Engine } from "babylonjs/Engines/engine";
  60134. /** Defines operator used for tonemapping */
  60135. export enum TonemappingOperator {
  60136. /** Hable */
  60137. Hable = 0,
  60138. /** Reinhard */
  60139. Reinhard = 1,
  60140. /** HejiDawson */
  60141. HejiDawson = 2,
  60142. /** Photographic */
  60143. Photographic = 3
  60144. }
  60145. /**
  60146. * Defines a post process to apply tone mapping
  60147. */
  60148. export class TonemapPostProcess extends PostProcess {
  60149. private _operator;
  60150. /** Defines the required exposure adjustement */
  60151. exposureAdjustment: number;
  60152. /**
  60153. * Creates a new TonemapPostProcess
  60154. * @param name defines the name of the postprocess
  60155. * @param _operator defines the operator to use
  60156. * @param exposureAdjustment defines the required exposure adjustement
  60157. * @param camera defines the camera to use (can be null)
  60158. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  60159. * @param engine defines the hosting engine (can be ignore if camera is set)
  60160. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  60161. */
  60162. constructor(name: string, _operator: TonemappingOperator,
  60163. /** Defines the required exposure adjustement */
  60164. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  60165. }
  60166. }
  60167. declare module "babylonjs/Shaders/depth.vertex" {
  60168. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60169. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60170. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60171. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  60172. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  60173. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  60174. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60175. /** @hidden */
  60176. export var depthVertexShader: {
  60177. name: string;
  60178. shader: string;
  60179. };
  60180. }
  60181. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  60182. /** @hidden */
  60183. export var volumetricLightScatteringPixelShader: {
  60184. name: string;
  60185. shader: string;
  60186. };
  60187. }
  60188. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  60189. /** @hidden */
  60190. export var volumetricLightScatteringPassPixelShader: {
  60191. name: string;
  60192. shader: string;
  60193. };
  60194. }
  60195. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  60196. import { Vector3 } from "babylonjs/Maths/math";
  60197. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60198. import { Mesh } from "babylonjs/Meshes/mesh";
  60199. import { Camera } from "babylonjs/Cameras/camera";
  60200. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60201. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  60202. import { Scene } from "babylonjs/scene";
  60203. import "babylonjs/Meshes/Builders/planeBuilder";
  60204. import "babylonjs/Shaders/depth.vertex";
  60205. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  60206. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  60207. import { Engine } from "babylonjs/Engines/engine";
  60208. /**
  60209. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  60210. */
  60211. export class VolumetricLightScatteringPostProcess extends PostProcess {
  60212. private _volumetricLightScatteringPass;
  60213. private _volumetricLightScatteringRTT;
  60214. private _viewPort;
  60215. private _screenCoordinates;
  60216. private _cachedDefines;
  60217. /**
  60218. * If not undefined, the mesh position is computed from the attached node position
  60219. */
  60220. attachedNode: {
  60221. position: Vector3;
  60222. };
  60223. /**
  60224. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  60225. */
  60226. customMeshPosition: Vector3;
  60227. /**
  60228. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  60229. */
  60230. useCustomMeshPosition: boolean;
  60231. /**
  60232. * If the post-process should inverse the light scattering direction
  60233. */
  60234. invert: boolean;
  60235. /**
  60236. * The internal mesh used by the post-process
  60237. */
  60238. mesh: Mesh;
  60239. /**
  60240. * @hidden
  60241. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  60242. */
  60243. useDiffuseColor: boolean;
  60244. /**
  60245. * Array containing the excluded meshes not rendered in the internal pass
  60246. */
  60247. excludedMeshes: AbstractMesh[];
  60248. /**
  60249. * Controls the overall intensity of the post-process
  60250. */
  60251. exposure: number;
  60252. /**
  60253. * Dissipates each sample's contribution in range [0, 1]
  60254. */
  60255. decay: number;
  60256. /**
  60257. * Controls the overall intensity of each sample
  60258. */
  60259. weight: number;
  60260. /**
  60261. * Controls the density of each sample
  60262. */
  60263. density: number;
  60264. /**
  60265. * @constructor
  60266. * @param name The post-process name
  60267. * @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)
  60268. * @param camera The camera that the post-process will be attached to
  60269. * @param mesh The mesh used to create the light scattering
  60270. * @param samples The post-process quality, default 100
  60271. * @param samplingModeThe post-process filtering mode
  60272. * @param engine The babylon engine
  60273. * @param reusable If the post-process is reusable
  60274. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  60275. */
  60276. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  60277. /**
  60278. * Returns the string "VolumetricLightScatteringPostProcess"
  60279. * @returns "VolumetricLightScatteringPostProcess"
  60280. */
  60281. getClassName(): string;
  60282. private _isReady;
  60283. /**
  60284. * Sets the new light position for light scattering effect
  60285. * @param position The new custom light position
  60286. */
  60287. setCustomMeshPosition(position: Vector3): void;
  60288. /**
  60289. * Returns the light position for light scattering effect
  60290. * @return Vector3 The custom light position
  60291. */
  60292. getCustomMeshPosition(): Vector3;
  60293. /**
  60294. * Disposes the internal assets and detaches the post-process from the camera
  60295. */
  60296. dispose(camera: Camera): void;
  60297. /**
  60298. * Returns the render target texture used by the post-process
  60299. * @return the render target texture used by the post-process
  60300. */
  60301. getPass(): RenderTargetTexture;
  60302. private _meshExcluded;
  60303. private _createPass;
  60304. private _updateMeshScreenCoordinates;
  60305. /**
  60306. * Creates a default mesh for the Volumeric Light Scattering post-process
  60307. * @param name The mesh name
  60308. * @param scene The scene where to create the mesh
  60309. * @return the default mesh
  60310. */
  60311. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  60312. }
  60313. }
  60314. declare module "babylonjs/PostProcesses/index" {
  60315. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  60316. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  60317. export * from "babylonjs/PostProcesses/bloomEffect";
  60318. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  60319. export * from "babylonjs/PostProcesses/blurPostProcess";
  60320. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  60321. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  60322. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  60323. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  60324. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  60325. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  60326. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  60327. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  60328. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  60329. export * from "babylonjs/PostProcesses/filterPostProcess";
  60330. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  60331. export * from "babylonjs/PostProcesses/grainPostProcess";
  60332. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  60333. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  60334. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  60335. export * from "babylonjs/PostProcesses/passPostProcess";
  60336. export * from "babylonjs/PostProcesses/postProcess";
  60337. export * from "babylonjs/PostProcesses/postProcessManager";
  60338. export * from "babylonjs/PostProcesses/refractionPostProcess";
  60339. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  60340. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  60341. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  60342. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  60343. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  60344. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  60345. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  60346. }
  60347. declare module "babylonjs/Probes/index" {
  60348. export * from "babylonjs/Probes/reflectionProbe";
  60349. }
  60350. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  60351. import { Scene } from "babylonjs/scene";
  60352. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60353. import { Color3 } from "babylonjs/Maths/math";
  60354. import { SmartArray } from "babylonjs/Misc/smartArray";
  60355. import { ISceneComponent } from "babylonjs/sceneComponent";
  60356. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  60357. import "babylonjs/Meshes/Builders/boxBuilder";
  60358. import "babylonjs/Shaders/color.fragment";
  60359. import "babylonjs/Shaders/color.vertex";
  60360. module "babylonjs/scene" {
  60361. interface Scene {
  60362. /** @hidden (Backing field) */
  60363. _boundingBoxRenderer: BoundingBoxRenderer;
  60364. /** @hidden (Backing field) */
  60365. _forceShowBoundingBoxes: boolean;
  60366. /**
  60367. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  60368. */
  60369. forceShowBoundingBoxes: boolean;
  60370. /**
  60371. * Gets the bounding box renderer associated with the scene
  60372. * @returns a BoundingBoxRenderer
  60373. */
  60374. getBoundingBoxRenderer(): BoundingBoxRenderer;
  60375. }
  60376. }
  60377. module "babylonjs/Meshes/abstractMesh" {
  60378. interface AbstractMesh {
  60379. /** @hidden (Backing field) */
  60380. _showBoundingBox: boolean;
  60381. /**
  60382. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  60383. */
  60384. showBoundingBox: boolean;
  60385. }
  60386. }
  60387. /**
  60388. * Component responsible of rendering the bounding box of the meshes in a scene.
  60389. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  60390. */
  60391. export class BoundingBoxRenderer implements ISceneComponent {
  60392. /**
  60393. * The component name helpfull to identify the component in the list of scene components.
  60394. */
  60395. readonly name: string;
  60396. /**
  60397. * The scene the component belongs to.
  60398. */
  60399. scene: Scene;
  60400. /**
  60401. * Color of the bounding box lines placed in front of an object
  60402. */
  60403. frontColor: Color3;
  60404. /**
  60405. * Color of the bounding box lines placed behind an object
  60406. */
  60407. backColor: Color3;
  60408. /**
  60409. * Defines if the renderer should show the back lines or not
  60410. */
  60411. showBackLines: boolean;
  60412. /**
  60413. * @hidden
  60414. */
  60415. renderList: SmartArray<BoundingBox>;
  60416. private _colorShader;
  60417. private _vertexBuffers;
  60418. private _indexBuffer;
  60419. private _fillIndexBuffer;
  60420. private _fillIndexData;
  60421. /**
  60422. * Instantiates a new bounding box renderer in a scene.
  60423. * @param scene the scene the renderer renders in
  60424. */
  60425. constructor(scene: Scene);
  60426. /**
  60427. * Registers the component in a given scene
  60428. */
  60429. register(): void;
  60430. private _evaluateSubMesh;
  60431. private _activeMesh;
  60432. private _prepareRessources;
  60433. private _createIndexBuffer;
  60434. /**
  60435. * Rebuilds the elements related to this component in case of
  60436. * context lost for instance.
  60437. */
  60438. rebuild(): void;
  60439. /**
  60440. * @hidden
  60441. */
  60442. reset(): void;
  60443. /**
  60444. * Render the bounding boxes of a specific rendering group
  60445. * @param renderingGroupId defines the rendering group to render
  60446. */
  60447. render(renderingGroupId: number): void;
  60448. /**
  60449. * In case of occlusion queries, we can render the occlusion bounding box through this method
  60450. * @param mesh Define the mesh to render the occlusion bounding box for
  60451. */
  60452. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  60453. /**
  60454. * Dispose and release the resources attached to this renderer.
  60455. */
  60456. dispose(): void;
  60457. }
  60458. }
  60459. declare module "babylonjs/Shaders/depth.fragment" {
  60460. /** @hidden */
  60461. export var depthPixelShader: {
  60462. name: string;
  60463. shader: string;
  60464. };
  60465. }
  60466. declare module "babylonjs/Rendering/depthRenderer" {
  60467. import { Nullable } from "babylonjs/types";
  60468. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60469. import { Scene } from "babylonjs/scene";
  60470. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60471. import { Camera } from "babylonjs/Cameras/camera";
  60472. import "babylonjs/Shaders/depth.fragment";
  60473. import "babylonjs/Shaders/depth.vertex";
  60474. /**
  60475. * This represents a depth renderer in Babylon.
  60476. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  60477. */
  60478. export class DepthRenderer {
  60479. private _scene;
  60480. private _depthMap;
  60481. private _effect;
  60482. private _cachedDefines;
  60483. private _camera;
  60484. /**
  60485. * Specifiess that the depth renderer will only be used within
  60486. * the camera it is created for.
  60487. * This can help forcing its rendering during the camera processing.
  60488. */
  60489. useOnlyInActiveCamera: boolean;
  60490. /** @hidden */
  60491. static _SceneComponentInitialization: (scene: Scene) => void;
  60492. /**
  60493. * Instantiates a depth renderer
  60494. * @param scene The scene the renderer belongs to
  60495. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  60496. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  60497. */
  60498. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  60499. /**
  60500. * Creates the depth rendering effect and checks if the effect is ready.
  60501. * @param subMesh The submesh to be used to render the depth map of
  60502. * @param useInstances If multiple world instances should be used
  60503. * @returns if the depth renderer is ready to render the depth map
  60504. */
  60505. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60506. /**
  60507. * Gets the texture which the depth map will be written to.
  60508. * @returns The depth map texture
  60509. */
  60510. getDepthMap(): RenderTargetTexture;
  60511. /**
  60512. * Disposes of the depth renderer.
  60513. */
  60514. dispose(): void;
  60515. }
  60516. }
  60517. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  60518. import { Nullable } from "babylonjs/types";
  60519. import { Scene } from "babylonjs/scene";
  60520. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  60521. import { Camera } from "babylonjs/Cameras/camera";
  60522. import { ISceneComponent } from "babylonjs/sceneComponent";
  60523. module "babylonjs/scene" {
  60524. interface Scene {
  60525. /** @hidden (Backing field) */
  60526. _depthRenderer: {
  60527. [id: string]: DepthRenderer;
  60528. };
  60529. /**
  60530. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  60531. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  60532. * @returns the created depth renderer
  60533. */
  60534. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  60535. /**
  60536. * Disables a depth renderer for a given camera
  60537. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  60538. */
  60539. disableDepthRenderer(camera?: Nullable<Camera>): void;
  60540. }
  60541. }
  60542. /**
  60543. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  60544. * in several rendering techniques.
  60545. */
  60546. export class DepthRendererSceneComponent implements ISceneComponent {
  60547. /**
  60548. * The component name helpfull to identify the component in the list of scene components.
  60549. */
  60550. readonly name: string;
  60551. /**
  60552. * The scene the component belongs to.
  60553. */
  60554. scene: Scene;
  60555. /**
  60556. * Creates a new instance of the component for the given scene
  60557. * @param scene Defines the scene to register the component in
  60558. */
  60559. constructor(scene: Scene);
  60560. /**
  60561. * Registers the component in a given scene
  60562. */
  60563. register(): void;
  60564. /**
  60565. * Rebuilds the elements related to this component in case of
  60566. * context lost for instance.
  60567. */
  60568. rebuild(): void;
  60569. /**
  60570. * Disposes the component and the associated ressources
  60571. */
  60572. dispose(): void;
  60573. private _gatherRenderTargets;
  60574. private _gatherActiveCameraRenderTargets;
  60575. }
  60576. }
  60577. declare module "babylonjs/Shaders/outline.fragment" {
  60578. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  60579. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  60580. /** @hidden */
  60581. export var outlinePixelShader: {
  60582. name: string;
  60583. shader: string;
  60584. };
  60585. }
  60586. declare module "babylonjs/Shaders/outline.vertex" {
  60587. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60588. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60589. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60590. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  60591. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  60592. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  60593. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  60594. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60595. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  60596. /** @hidden */
  60597. export var outlineVertexShader: {
  60598. name: string;
  60599. shader: string;
  60600. };
  60601. }
  60602. declare module "babylonjs/Rendering/outlineRenderer" {
  60603. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60604. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  60605. import { Scene } from "babylonjs/scene";
  60606. import { ISceneComponent } from "babylonjs/sceneComponent";
  60607. import "babylonjs/Shaders/outline.fragment";
  60608. import "babylonjs/Shaders/outline.vertex";
  60609. module "babylonjs/scene" {
  60610. interface Scene {
  60611. /** @hidden */
  60612. _outlineRenderer: OutlineRenderer;
  60613. /**
  60614. * Gets the outline renderer associated with the scene
  60615. * @returns a OutlineRenderer
  60616. */
  60617. getOutlineRenderer(): OutlineRenderer;
  60618. }
  60619. }
  60620. module "babylonjs/Meshes/abstractMesh" {
  60621. interface AbstractMesh {
  60622. /** @hidden (Backing field) */
  60623. _renderOutline: boolean;
  60624. /**
  60625. * Gets or sets a boolean indicating if the outline must be rendered as well
  60626. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  60627. */
  60628. renderOutline: boolean;
  60629. /** @hidden (Backing field) */
  60630. _renderOverlay: boolean;
  60631. /**
  60632. * Gets or sets a boolean indicating if the overlay must be rendered as well
  60633. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  60634. */
  60635. renderOverlay: boolean;
  60636. }
  60637. }
  60638. /**
  60639. * This class is responsible to draw bothe outline/overlay of meshes.
  60640. * It should not be used directly but through the available method on mesh.
  60641. */
  60642. export class OutlineRenderer implements ISceneComponent {
  60643. /**
  60644. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  60645. */
  60646. private static _StencilReference;
  60647. /**
  60648. * The name of the component. Each component must have a unique name.
  60649. */
  60650. name: string;
  60651. /**
  60652. * The scene the component belongs to.
  60653. */
  60654. scene: Scene;
  60655. /**
  60656. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  60657. */
  60658. zOffset: number;
  60659. private _engine;
  60660. private _effect;
  60661. private _cachedDefines;
  60662. private _savedDepthWrite;
  60663. /**
  60664. * Instantiates a new outline renderer. (There could be only one per scene).
  60665. * @param scene Defines the scene it belongs to
  60666. */
  60667. constructor(scene: Scene);
  60668. /**
  60669. * Register the component to one instance of a scene.
  60670. */
  60671. register(): void;
  60672. /**
  60673. * Rebuilds the elements related to this component in case of
  60674. * context lost for instance.
  60675. */
  60676. rebuild(): void;
  60677. /**
  60678. * Disposes the component and the associated ressources.
  60679. */
  60680. dispose(): void;
  60681. /**
  60682. * Renders the outline in the canvas.
  60683. * @param subMesh Defines the sumesh to render
  60684. * @param batch Defines the batch of meshes in case of instances
  60685. * @param useOverlay Defines if the rendering is for the overlay or the outline
  60686. */
  60687. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  60688. /**
  60689. * Returns whether or not the outline renderer is ready for a given submesh.
  60690. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  60691. * @param subMesh Defines the submesh to check readyness for
  60692. * @param useInstances Defines wheter wee are trying to render instances or not
  60693. * @returns true if ready otherwise false
  60694. */
  60695. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60696. private _beforeRenderingMesh;
  60697. private _afterRenderingMesh;
  60698. }
  60699. }
  60700. declare module "babylonjs/Rendering/index" {
  60701. export * from "babylonjs/Rendering/boundingBoxRenderer";
  60702. export * from "babylonjs/Rendering/depthRenderer";
  60703. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  60704. export * from "babylonjs/Rendering/edgesRenderer";
  60705. export * from "babylonjs/Rendering/geometryBufferRenderer";
  60706. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  60707. export * from "babylonjs/Rendering/outlineRenderer";
  60708. export * from "babylonjs/Rendering/renderingGroup";
  60709. export * from "babylonjs/Rendering/renderingManager";
  60710. export * from "babylonjs/Rendering/utilityLayerRenderer";
  60711. }
  60712. declare module "babylonjs/Sprites/index" {
  60713. export * from "babylonjs/Sprites/sprite";
  60714. export * from "babylonjs/Sprites/spriteManager";
  60715. export * from "babylonjs/Sprites/spriteSceneComponent";
  60716. }
  60717. declare module "babylonjs/Misc/assetsManager" {
  60718. import { Scene } from "babylonjs/scene";
  60719. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60720. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  60721. import { Skeleton } from "babylonjs/Bones/skeleton";
  60722. import { Observable } from "babylonjs/Misc/observable";
  60723. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60724. import { Texture } from "babylonjs/Materials/Textures/texture";
  60725. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  60726. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  60727. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  60728. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  60729. /**
  60730. * Defines the list of states available for a task inside a AssetsManager
  60731. */
  60732. export enum AssetTaskState {
  60733. /**
  60734. * Initialization
  60735. */
  60736. INIT = 0,
  60737. /**
  60738. * Running
  60739. */
  60740. RUNNING = 1,
  60741. /**
  60742. * Done
  60743. */
  60744. DONE = 2,
  60745. /**
  60746. * Error
  60747. */
  60748. ERROR = 3
  60749. }
  60750. /**
  60751. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  60752. */
  60753. export abstract class AbstractAssetTask {
  60754. /**
  60755. * Task name
  60756. */ name: string;
  60757. /**
  60758. * Callback called when the task is successful
  60759. */
  60760. onSuccess: (task: any) => void;
  60761. /**
  60762. * Callback called when the task is not successful
  60763. */
  60764. onError: (task: any, message?: string, exception?: any) => void;
  60765. /**
  60766. * Creates a new AssetsManager
  60767. * @param name defines the name of the task
  60768. */
  60769. constructor(
  60770. /**
  60771. * Task name
  60772. */ name: string);
  60773. private _isCompleted;
  60774. private _taskState;
  60775. private _errorObject;
  60776. /**
  60777. * Get if the task is completed
  60778. */
  60779. readonly isCompleted: boolean;
  60780. /**
  60781. * Gets the current state of the task
  60782. */
  60783. readonly taskState: AssetTaskState;
  60784. /**
  60785. * Gets the current error object (if task is in error)
  60786. */
  60787. readonly errorObject: {
  60788. message?: string;
  60789. exception?: any;
  60790. };
  60791. /**
  60792. * Internal only
  60793. * @hidden
  60794. */
  60795. _setErrorObject(message?: string, exception?: any): void;
  60796. /**
  60797. * Execute the current task
  60798. * @param scene defines the scene where you want your assets to be loaded
  60799. * @param onSuccess is a callback called when the task is successfully executed
  60800. * @param onError is a callback called if an error occurs
  60801. */
  60802. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60803. /**
  60804. * Execute the current task
  60805. * @param scene defines the scene where you want your assets to be loaded
  60806. * @param onSuccess is a callback called when the task is successfully executed
  60807. * @param onError is a callback called if an error occurs
  60808. */
  60809. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60810. /**
  60811. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  60812. * This can be used with failed tasks that have the reason for failure fixed.
  60813. */
  60814. reset(): void;
  60815. private onErrorCallback;
  60816. private onDoneCallback;
  60817. }
  60818. /**
  60819. * Define the interface used by progress events raised during assets loading
  60820. */
  60821. export interface IAssetsProgressEvent {
  60822. /**
  60823. * Defines the number of remaining tasks to process
  60824. */
  60825. remainingCount: number;
  60826. /**
  60827. * Defines the total number of tasks
  60828. */
  60829. totalCount: number;
  60830. /**
  60831. * Defines the task that was just processed
  60832. */
  60833. task: AbstractAssetTask;
  60834. }
  60835. /**
  60836. * Class used to share progress information about assets loading
  60837. */
  60838. export class AssetsProgressEvent implements IAssetsProgressEvent {
  60839. /**
  60840. * Defines the number of remaining tasks to process
  60841. */
  60842. remainingCount: number;
  60843. /**
  60844. * Defines the total number of tasks
  60845. */
  60846. totalCount: number;
  60847. /**
  60848. * Defines the task that was just processed
  60849. */
  60850. task: AbstractAssetTask;
  60851. /**
  60852. * Creates a AssetsProgressEvent
  60853. * @param remainingCount defines the number of remaining tasks to process
  60854. * @param totalCount defines the total number of tasks
  60855. * @param task defines the task that was just processed
  60856. */
  60857. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  60858. }
  60859. /**
  60860. * Define a task used by AssetsManager to load meshes
  60861. */
  60862. export class MeshAssetTask extends AbstractAssetTask {
  60863. /**
  60864. * Defines the name of the task
  60865. */
  60866. name: string;
  60867. /**
  60868. * Defines the list of mesh's names you want to load
  60869. */
  60870. meshesNames: any;
  60871. /**
  60872. * Defines the root url to use as a base to load your meshes and associated resources
  60873. */
  60874. rootUrl: string;
  60875. /**
  60876. * Defines the filename of the scene to load from
  60877. */
  60878. sceneFilename: string;
  60879. /**
  60880. * Gets the list of loaded meshes
  60881. */
  60882. loadedMeshes: Array<AbstractMesh>;
  60883. /**
  60884. * Gets the list of loaded particle systems
  60885. */
  60886. loadedParticleSystems: Array<IParticleSystem>;
  60887. /**
  60888. * Gets the list of loaded skeletons
  60889. */
  60890. loadedSkeletons: Array<Skeleton>;
  60891. /**
  60892. * Gets the list of loaded animation groups
  60893. */
  60894. loadedAnimationGroups: Array<AnimationGroup>;
  60895. /**
  60896. * Callback called when the task is successful
  60897. */
  60898. onSuccess: (task: MeshAssetTask) => void;
  60899. /**
  60900. * Callback called when the task is successful
  60901. */
  60902. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  60903. /**
  60904. * Creates a new MeshAssetTask
  60905. * @param name defines the name of the task
  60906. * @param meshesNames defines the list of mesh's names you want to load
  60907. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  60908. * @param sceneFilename defines the filename of the scene to load from
  60909. */
  60910. constructor(
  60911. /**
  60912. * Defines the name of the task
  60913. */
  60914. name: string,
  60915. /**
  60916. * Defines the list of mesh's names you want to load
  60917. */
  60918. meshesNames: any,
  60919. /**
  60920. * Defines the root url to use as a base to load your meshes and associated resources
  60921. */
  60922. rootUrl: string,
  60923. /**
  60924. * Defines the filename of the scene to load from
  60925. */
  60926. sceneFilename: string);
  60927. /**
  60928. * Execute the current task
  60929. * @param scene defines the scene where you want your assets to be loaded
  60930. * @param onSuccess is a callback called when the task is successfully executed
  60931. * @param onError is a callback called if an error occurs
  60932. */
  60933. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60934. }
  60935. /**
  60936. * Define a task used by AssetsManager to load text content
  60937. */
  60938. export class TextFileAssetTask extends AbstractAssetTask {
  60939. /**
  60940. * Defines the name of the task
  60941. */
  60942. name: string;
  60943. /**
  60944. * Defines the location of the file to load
  60945. */
  60946. url: string;
  60947. /**
  60948. * Gets the loaded text string
  60949. */
  60950. text: string;
  60951. /**
  60952. * Callback called when the task is successful
  60953. */
  60954. onSuccess: (task: TextFileAssetTask) => void;
  60955. /**
  60956. * Callback called when the task is successful
  60957. */
  60958. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  60959. /**
  60960. * Creates a new TextFileAssetTask object
  60961. * @param name defines the name of the task
  60962. * @param url defines the location of the file to load
  60963. */
  60964. constructor(
  60965. /**
  60966. * Defines the name of the task
  60967. */
  60968. name: string,
  60969. /**
  60970. * Defines the location of the file to load
  60971. */
  60972. url: string);
  60973. /**
  60974. * Execute the current task
  60975. * @param scene defines the scene where you want your assets to be loaded
  60976. * @param onSuccess is a callback called when the task is successfully executed
  60977. * @param onError is a callback called if an error occurs
  60978. */
  60979. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60980. }
  60981. /**
  60982. * Define a task used by AssetsManager to load binary data
  60983. */
  60984. export class BinaryFileAssetTask extends AbstractAssetTask {
  60985. /**
  60986. * Defines the name of the task
  60987. */
  60988. name: string;
  60989. /**
  60990. * Defines the location of the file to load
  60991. */
  60992. url: string;
  60993. /**
  60994. * Gets the lodaded data (as an array buffer)
  60995. */
  60996. data: ArrayBuffer;
  60997. /**
  60998. * Callback called when the task is successful
  60999. */
  61000. onSuccess: (task: BinaryFileAssetTask) => void;
  61001. /**
  61002. * Callback called when the task is successful
  61003. */
  61004. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  61005. /**
  61006. * Creates a new BinaryFileAssetTask object
  61007. * @param name defines the name of the new task
  61008. * @param url defines the location of the file to load
  61009. */
  61010. constructor(
  61011. /**
  61012. * Defines the name of the task
  61013. */
  61014. name: string,
  61015. /**
  61016. * Defines the location of the file to load
  61017. */
  61018. url: string);
  61019. /**
  61020. * Execute the current task
  61021. * @param scene defines the scene where you want your assets to be loaded
  61022. * @param onSuccess is a callback called when the task is successfully executed
  61023. * @param onError is a callback called if an error occurs
  61024. */
  61025. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61026. }
  61027. /**
  61028. * Define a task used by AssetsManager to load images
  61029. */
  61030. export class ImageAssetTask extends AbstractAssetTask {
  61031. /**
  61032. * Defines the name of the task
  61033. */
  61034. name: string;
  61035. /**
  61036. * Defines the location of the image to load
  61037. */
  61038. url: string;
  61039. /**
  61040. * Gets the loaded images
  61041. */
  61042. image: HTMLImageElement;
  61043. /**
  61044. * Callback called when the task is successful
  61045. */
  61046. onSuccess: (task: ImageAssetTask) => void;
  61047. /**
  61048. * Callback called when the task is successful
  61049. */
  61050. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  61051. /**
  61052. * Creates a new ImageAssetTask
  61053. * @param name defines the name of the task
  61054. * @param url defines the location of the image to load
  61055. */
  61056. constructor(
  61057. /**
  61058. * Defines the name of the task
  61059. */
  61060. name: string,
  61061. /**
  61062. * Defines the location of the image to load
  61063. */
  61064. url: string);
  61065. /**
  61066. * Execute the current task
  61067. * @param scene defines the scene where you want your assets to be loaded
  61068. * @param onSuccess is a callback called when the task is successfully executed
  61069. * @param onError is a callback called if an error occurs
  61070. */
  61071. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61072. }
  61073. /**
  61074. * Defines the interface used by texture loading tasks
  61075. */
  61076. export interface ITextureAssetTask<TEX extends BaseTexture> {
  61077. /**
  61078. * Gets the loaded texture
  61079. */
  61080. texture: TEX;
  61081. }
  61082. /**
  61083. * Define a task used by AssetsManager to load 2D textures
  61084. */
  61085. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  61086. /**
  61087. * Defines the name of the task
  61088. */
  61089. name: string;
  61090. /**
  61091. * Defines the location of the file to load
  61092. */
  61093. url: string;
  61094. /**
  61095. * Defines if mipmap should not be generated (default is false)
  61096. */
  61097. noMipmap?: boolean | undefined;
  61098. /**
  61099. * Defines if texture must be inverted on Y axis (default is false)
  61100. */
  61101. invertY?: boolean | undefined;
  61102. /**
  61103. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  61104. */
  61105. samplingMode: number;
  61106. /**
  61107. * Gets the loaded texture
  61108. */
  61109. texture: Texture;
  61110. /**
  61111. * Callback called when the task is successful
  61112. */
  61113. onSuccess: (task: TextureAssetTask) => void;
  61114. /**
  61115. * Callback called when the task is successful
  61116. */
  61117. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  61118. /**
  61119. * Creates a new TextureAssetTask object
  61120. * @param name defines the name of the task
  61121. * @param url defines the location of the file to load
  61122. * @param noMipmap defines if mipmap should not be generated (default is false)
  61123. * @param invertY defines if texture must be inverted on Y axis (default is false)
  61124. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  61125. */
  61126. constructor(
  61127. /**
  61128. * Defines the name of the task
  61129. */
  61130. name: string,
  61131. /**
  61132. * Defines the location of the file to load
  61133. */
  61134. url: string,
  61135. /**
  61136. * Defines if mipmap should not be generated (default is false)
  61137. */
  61138. noMipmap?: boolean | undefined,
  61139. /**
  61140. * Defines if texture must be inverted on Y axis (default is false)
  61141. */
  61142. invertY?: boolean | undefined,
  61143. /**
  61144. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  61145. */
  61146. samplingMode?: number);
  61147. /**
  61148. * Execute the current task
  61149. * @param scene defines the scene where you want your assets to be loaded
  61150. * @param onSuccess is a callback called when the task is successfully executed
  61151. * @param onError is a callback called if an error occurs
  61152. */
  61153. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61154. }
  61155. /**
  61156. * Define a task used by AssetsManager to load cube textures
  61157. */
  61158. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  61159. /**
  61160. * Defines the name of the task
  61161. */
  61162. name: string;
  61163. /**
  61164. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  61165. */
  61166. url: string;
  61167. /**
  61168. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  61169. */
  61170. extensions?: string[] | undefined;
  61171. /**
  61172. * Defines if mipmaps should not be generated (default is false)
  61173. */
  61174. noMipmap?: boolean | undefined;
  61175. /**
  61176. * Defines the explicit list of files (undefined by default)
  61177. */
  61178. files?: string[] | undefined;
  61179. /**
  61180. * Gets the loaded texture
  61181. */
  61182. texture: CubeTexture;
  61183. /**
  61184. * Callback called when the task is successful
  61185. */
  61186. onSuccess: (task: CubeTextureAssetTask) => void;
  61187. /**
  61188. * Callback called when the task is successful
  61189. */
  61190. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  61191. /**
  61192. * Creates a new CubeTextureAssetTask
  61193. * @param name defines the name of the task
  61194. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  61195. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  61196. * @param noMipmap defines if mipmaps should not be generated (default is false)
  61197. * @param files defines the explicit list of files (undefined by default)
  61198. */
  61199. constructor(
  61200. /**
  61201. * Defines the name of the task
  61202. */
  61203. name: string,
  61204. /**
  61205. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  61206. */
  61207. url: string,
  61208. /**
  61209. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  61210. */
  61211. extensions?: string[] | undefined,
  61212. /**
  61213. * Defines if mipmaps should not be generated (default is false)
  61214. */
  61215. noMipmap?: boolean | undefined,
  61216. /**
  61217. * Defines the explicit list of files (undefined by default)
  61218. */
  61219. files?: string[] | undefined);
  61220. /**
  61221. * Execute the current task
  61222. * @param scene defines the scene where you want your assets to be loaded
  61223. * @param onSuccess is a callback called when the task is successfully executed
  61224. * @param onError is a callback called if an error occurs
  61225. */
  61226. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61227. }
  61228. /**
  61229. * Define a task used by AssetsManager to load HDR cube textures
  61230. */
  61231. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  61232. /**
  61233. * Defines the name of the task
  61234. */
  61235. name: string;
  61236. /**
  61237. * Defines the location of the file to load
  61238. */
  61239. url: string;
  61240. /**
  61241. * Defines the desired size (the more it increases the longer the generation will be)
  61242. */
  61243. size: number;
  61244. /**
  61245. * Defines if mipmaps should not be generated (default is false)
  61246. */
  61247. noMipmap: boolean;
  61248. /**
  61249. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  61250. */
  61251. generateHarmonics: boolean;
  61252. /**
  61253. * 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)
  61254. */
  61255. gammaSpace: boolean;
  61256. /**
  61257. * Internal Use Only
  61258. */
  61259. reserved: boolean;
  61260. /**
  61261. * Gets the loaded texture
  61262. */
  61263. texture: HDRCubeTexture;
  61264. /**
  61265. * Callback called when the task is successful
  61266. */
  61267. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  61268. /**
  61269. * Callback called when the task is successful
  61270. */
  61271. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  61272. /**
  61273. * Creates a new HDRCubeTextureAssetTask object
  61274. * @param name defines the name of the task
  61275. * @param url defines the location of the file to load
  61276. * @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.
  61277. * @param noMipmap defines if mipmaps should not be generated (default is false)
  61278. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  61279. * @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)
  61280. * @param reserved Internal use only
  61281. */
  61282. constructor(
  61283. /**
  61284. * Defines the name of the task
  61285. */
  61286. name: string,
  61287. /**
  61288. * Defines the location of the file to load
  61289. */
  61290. url: string,
  61291. /**
  61292. * Defines the desired size (the more it increases the longer the generation will be)
  61293. */
  61294. size: number,
  61295. /**
  61296. * Defines if mipmaps should not be generated (default is false)
  61297. */
  61298. noMipmap?: boolean,
  61299. /**
  61300. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  61301. */
  61302. generateHarmonics?: boolean,
  61303. /**
  61304. * 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)
  61305. */
  61306. gammaSpace?: boolean,
  61307. /**
  61308. * Internal Use Only
  61309. */
  61310. reserved?: boolean);
  61311. /**
  61312. * Execute the current task
  61313. * @param scene defines the scene where you want your assets to be loaded
  61314. * @param onSuccess is a callback called when the task is successfully executed
  61315. * @param onError is a callback called if an error occurs
  61316. */
  61317. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61318. }
  61319. /**
  61320. * Define a task used by AssetsManager to load Equirectangular cube textures
  61321. */
  61322. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  61323. /**
  61324. * Defines the name of the task
  61325. */
  61326. name: string;
  61327. /**
  61328. * Defines the location of the file to load
  61329. */
  61330. url: string;
  61331. /**
  61332. * Defines the desired size (the more it increases the longer the generation will be)
  61333. */
  61334. size: number;
  61335. /**
  61336. * Defines if mipmaps should not be generated (default is false)
  61337. */
  61338. noMipmap: boolean;
  61339. /**
  61340. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  61341. * but the standard material would require them in Gamma space) (default is true)
  61342. */
  61343. gammaSpace: boolean;
  61344. /**
  61345. * Gets the loaded texture
  61346. */
  61347. texture: EquiRectangularCubeTexture;
  61348. /**
  61349. * Callback called when the task is successful
  61350. */
  61351. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  61352. /**
  61353. * Callback called when the task is successful
  61354. */
  61355. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  61356. /**
  61357. * Creates a new EquiRectangularCubeTextureAssetTask object
  61358. * @param name defines the name of the task
  61359. * @param url defines the location of the file to load
  61360. * @param size defines the desired size (the more it increases the longer the generation will be)
  61361. * If the size is omitted this implies you are using a preprocessed cubemap.
  61362. * @param noMipmap defines if mipmaps should not be generated (default is false)
  61363. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  61364. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  61365. * (default is true)
  61366. */
  61367. constructor(
  61368. /**
  61369. * Defines the name of the task
  61370. */
  61371. name: string,
  61372. /**
  61373. * Defines the location of the file to load
  61374. */
  61375. url: string,
  61376. /**
  61377. * Defines the desired size (the more it increases the longer the generation will be)
  61378. */
  61379. size: number,
  61380. /**
  61381. * Defines if mipmaps should not be generated (default is false)
  61382. */
  61383. noMipmap?: boolean,
  61384. /**
  61385. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  61386. * but the standard material would require them in Gamma space) (default is true)
  61387. */
  61388. gammaSpace?: boolean);
  61389. /**
  61390. * Execute the current task
  61391. * @param scene defines the scene where you want your assets to be loaded
  61392. * @param onSuccess is a callback called when the task is successfully executed
  61393. * @param onError is a callback called if an error occurs
  61394. */
  61395. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61396. }
  61397. /**
  61398. * This class can be used to easily import assets into a scene
  61399. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  61400. */
  61401. export class AssetsManager {
  61402. private _scene;
  61403. private _isLoading;
  61404. protected _tasks: AbstractAssetTask[];
  61405. protected _waitingTasksCount: number;
  61406. protected _totalTasksCount: number;
  61407. /**
  61408. * Callback called when all tasks are processed
  61409. */
  61410. onFinish: (tasks: AbstractAssetTask[]) => void;
  61411. /**
  61412. * Callback called when a task is successful
  61413. */
  61414. onTaskSuccess: (task: AbstractAssetTask) => void;
  61415. /**
  61416. * Callback called when a task had an error
  61417. */
  61418. onTaskError: (task: AbstractAssetTask) => void;
  61419. /**
  61420. * Callback called when a task is done (whatever the result is)
  61421. */
  61422. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  61423. /**
  61424. * Observable called when all tasks are processed
  61425. */
  61426. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  61427. /**
  61428. * Observable called when a task had an error
  61429. */
  61430. onTaskErrorObservable: Observable<AbstractAssetTask>;
  61431. /**
  61432. * Observable called when all tasks were executed
  61433. */
  61434. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  61435. /**
  61436. * Observable called when a task is done (whatever the result is)
  61437. */
  61438. onProgressObservable: Observable<IAssetsProgressEvent>;
  61439. /**
  61440. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  61441. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  61442. */
  61443. useDefaultLoadingScreen: boolean;
  61444. /**
  61445. * Creates a new AssetsManager
  61446. * @param scene defines the scene to work on
  61447. */
  61448. constructor(scene: Scene);
  61449. /**
  61450. * Add a MeshAssetTask to the list of active tasks
  61451. * @param taskName defines the name of the new task
  61452. * @param meshesNames defines the name of meshes to load
  61453. * @param rootUrl defines the root url to use to locate files
  61454. * @param sceneFilename defines the filename of the scene file
  61455. * @returns a new MeshAssetTask object
  61456. */
  61457. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  61458. /**
  61459. * Add a TextFileAssetTask to the list of active tasks
  61460. * @param taskName defines the name of the new task
  61461. * @param url defines the url of the file to load
  61462. * @returns a new TextFileAssetTask object
  61463. */
  61464. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  61465. /**
  61466. * Add a BinaryFileAssetTask to the list of active tasks
  61467. * @param taskName defines the name of the new task
  61468. * @param url defines the url of the file to load
  61469. * @returns a new BinaryFileAssetTask object
  61470. */
  61471. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  61472. /**
  61473. * Add a ImageAssetTask to the list of active tasks
  61474. * @param taskName defines the name of the new task
  61475. * @param url defines the url of the file to load
  61476. * @returns a new ImageAssetTask object
  61477. */
  61478. addImageTask(taskName: string, url: string): ImageAssetTask;
  61479. /**
  61480. * Add a TextureAssetTask to the list of active tasks
  61481. * @param taskName defines the name of the new task
  61482. * @param url defines the url of the file to load
  61483. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61484. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  61485. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  61486. * @returns a new TextureAssetTask object
  61487. */
  61488. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  61489. /**
  61490. * Add a CubeTextureAssetTask to the list of active tasks
  61491. * @param taskName defines the name of the new task
  61492. * @param url defines the url of the file to load
  61493. * @param extensions defines the extension to use to load the cube map (can be null)
  61494. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61495. * @param files defines the list of files to load (can be null)
  61496. * @returns a new CubeTextureAssetTask object
  61497. */
  61498. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  61499. /**
  61500. *
  61501. * Add a HDRCubeTextureAssetTask to the list of active tasks
  61502. * @param taskName defines the name of the new task
  61503. * @param url defines the url of the file to load
  61504. * @param size defines the size you want for the cubemap (can be null)
  61505. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61506. * @param generateHarmonics defines if you want to automatically generate (true by default)
  61507. * @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)
  61508. * @param reserved Internal use only
  61509. * @returns a new HDRCubeTextureAssetTask object
  61510. */
  61511. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  61512. /**
  61513. *
  61514. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  61515. * @param taskName defines the name of the new task
  61516. * @param url defines the url of the file to load
  61517. * @param size defines the size you want for the cubemap (can be null)
  61518. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61519. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  61520. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  61521. * @returns a new EquiRectangularCubeTextureAssetTask object
  61522. */
  61523. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  61524. /**
  61525. * Remove a task from the assets manager.
  61526. * @param task the task to remove
  61527. */
  61528. removeTask(task: AbstractAssetTask): void;
  61529. private _decreaseWaitingTasksCount;
  61530. private _runTask;
  61531. /**
  61532. * Reset the AssetsManager and remove all tasks
  61533. * @return the current instance of the AssetsManager
  61534. */
  61535. reset(): AssetsManager;
  61536. /**
  61537. * Start the loading process
  61538. * @return the current instance of the AssetsManager
  61539. */
  61540. load(): AssetsManager;
  61541. /**
  61542. * Start the loading process as an async operation
  61543. * @return a promise returning the list of failed tasks
  61544. */
  61545. loadAsync(): Promise<void>;
  61546. }
  61547. }
  61548. declare module "babylonjs/Misc/deferred" {
  61549. /**
  61550. * Wrapper class for promise with external resolve and reject.
  61551. */
  61552. export class Deferred<T> {
  61553. /**
  61554. * The promise associated with this deferred object.
  61555. */
  61556. readonly promise: Promise<T>;
  61557. private _resolve;
  61558. private _reject;
  61559. /**
  61560. * The resolve method of the promise associated with this deferred object.
  61561. */
  61562. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  61563. /**
  61564. * The reject method of the promise associated with this deferred object.
  61565. */
  61566. readonly reject: (reason?: any) => void;
  61567. /**
  61568. * Constructor for this deferred object.
  61569. */
  61570. constructor();
  61571. }
  61572. }
  61573. declare module "babylonjs/Misc/meshExploder" {
  61574. import { Mesh } from "babylonjs/Meshes/mesh";
  61575. /**
  61576. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  61577. */
  61578. export class MeshExploder {
  61579. private _centerMesh;
  61580. private _meshes;
  61581. private _meshesOrigins;
  61582. private _toCenterVectors;
  61583. private _scaledDirection;
  61584. private _newPosition;
  61585. private _centerPosition;
  61586. /**
  61587. * Explodes meshes from a center mesh.
  61588. * @param meshes The meshes to explode.
  61589. * @param centerMesh The mesh to be center of explosion.
  61590. */
  61591. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  61592. private _setCenterMesh;
  61593. /**
  61594. * Get class name
  61595. * @returns "MeshExploder"
  61596. */
  61597. getClassName(): string;
  61598. /**
  61599. * "Exploded meshes"
  61600. * @returns Array of meshes with the centerMesh at index 0.
  61601. */
  61602. getMeshes(): Array<Mesh>;
  61603. /**
  61604. * Explodes meshes giving a specific direction
  61605. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  61606. */
  61607. explode(direction?: number): void;
  61608. }
  61609. }
  61610. declare module "babylonjs/Misc/filesInput" {
  61611. import { Engine } from "babylonjs/Engines/engine";
  61612. import { Scene } from "babylonjs/scene";
  61613. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  61614. /**
  61615. * Class used to help managing file picking and drag'n'drop
  61616. */
  61617. export class FilesInput {
  61618. /**
  61619. * List of files ready to be loaded
  61620. */
  61621. static readonly FilesToLoad: {
  61622. [key: string]: File;
  61623. };
  61624. /**
  61625. * Callback called when a file is processed
  61626. */
  61627. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  61628. private _engine;
  61629. private _currentScene;
  61630. private _sceneLoadedCallback;
  61631. private _progressCallback;
  61632. private _additionalRenderLoopLogicCallback;
  61633. private _textureLoadingCallback;
  61634. private _startingProcessingFilesCallback;
  61635. private _onReloadCallback;
  61636. private _errorCallback;
  61637. private _elementToMonitor;
  61638. private _sceneFileToLoad;
  61639. private _filesToLoad;
  61640. /**
  61641. * Creates a new FilesInput
  61642. * @param engine defines the rendering engine
  61643. * @param scene defines the hosting scene
  61644. * @param sceneLoadedCallback callback called when scene is loaded
  61645. * @param progressCallback callback called to track progress
  61646. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  61647. * @param textureLoadingCallback callback called when a texture is loading
  61648. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  61649. * @param onReloadCallback callback called when a reload is requested
  61650. * @param errorCallback callback call if an error occurs
  61651. */
  61652. 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);
  61653. private _dragEnterHandler;
  61654. private _dragOverHandler;
  61655. private _dropHandler;
  61656. /**
  61657. * Calls this function to listen to drag'n'drop events on a specific DOM element
  61658. * @param elementToMonitor defines the DOM element to track
  61659. */
  61660. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  61661. /**
  61662. * Release all associated resources
  61663. */
  61664. dispose(): void;
  61665. private renderFunction;
  61666. private drag;
  61667. private drop;
  61668. private _traverseFolder;
  61669. private _processFiles;
  61670. /**
  61671. * Load files from a drop event
  61672. * @param event defines the drop event to use as source
  61673. */
  61674. loadFiles(event: any): void;
  61675. private _processReload;
  61676. /**
  61677. * Reload the current scene from the loaded files
  61678. */
  61679. reload(): void;
  61680. }
  61681. }
  61682. declare module "babylonjs/Misc/HighDynamicRange/index" {
  61683. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  61684. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  61685. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  61686. }
  61687. declare module "babylonjs/Misc/sceneOptimizer" {
  61688. import { Scene, IDisposable } from "babylonjs/scene";
  61689. import { Observable } from "babylonjs/Misc/observable";
  61690. /**
  61691. * Defines the root class used to create scene optimization to use with SceneOptimizer
  61692. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61693. */
  61694. export class SceneOptimization {
  61695. /**
  61696. * Defines the priority of this optimization (0 by default which means first in the list)
  61697. */
  61698. priority: number;
  61699. /**
  61700. * Gets a string describing the action executed by the current optimization
  61701. * @returns description string
  61702. */
  61703. getDescription(): string;
  61704. /**
  61705. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61706. * @param scene defines the current scene where to apply this optimization
  61707. * @param optimizer defines the current optimizer
  61708. * @returns true if everything that can be done was applied
  61709. */
  61710. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61711. /**
  61712. * Creates the SceneOptimization object
  61713. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61714. * @param desc defines the description associated with the optimization
  61715. */
  61716. constructor(
  61717. /**
  61718. * Defines the priority of this optimization (0 by default which means first in the list)
  61719. */
  61720. priority?: number);
  61721. }
  61722. /**
  61723. * Defines an optimization used to reduce the size of render target textures
  61724. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61725. */
  61726. export class TextureOptimization extends SceneOptimization {
  61727. /**
  61728. * Defines the priority of this optimization (0 by default which means first in the list)
  61729. */
  61730. priority: number;
  61731. /**
  61732. * 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
  61733. */
  61734. maximumSize: number;
  61735. /**
  61736. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61737. */
  61738. step: number;
  61739. /**
  61740. * Gets a string describing the action executed by the current optimization
  61741. * @returns description string
  61742. */
  61743. getDescription(): string;
  61744. /**
  61745. * Creates the TextureOptimization object
  61746. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61747. * @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
  61748. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61749. */
  61750. constructor(
  61751. /**
  61752. * Defines the priority of this optimization (0 by default which means first in the list)
  61753. */
  61754. priority?: number,
  61755. /**
  61756. * 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
  61757. */
  61758. maximumSize?: number,
  61759. /**
  61760. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61761. */
  61762. step?: number);
  61763. /**
  61764. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61765. * @param scene defines the current scene where to apply this optimization
  61766. * @param optimizer defines the current optimizer
  61767. * @returns true if everything that can be done was applied
  61768. */
  61769. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61770. }
  61771. /**
  61772. * Defines an optimization used to increase or decrease the rendering resolution
  61773. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61774. */
  61775. export class HardwareScalingOptimization extends SceneOptimization {
  61776. /**
  61777. * Defines the priority of this optimization (0 by default which means first in the list)
  61778. */
  61779. priority: number;
  61780. /**
  61781. * Defines the maximum scale to use (2 by default)
  61782. */
  61783. maximumScale: number;
  61784. /**
  61785. * Defines the step to use between two passes (0.5 by default)
  61786. */
  61787. step: number;
  61788. private _currentScale;
  61789. private _directionOffset;
  61790. /**
  61791. * Gets a string describing the action executed by the current optimization
  61792. * @return description string
  61793. */
  61794. getDescription(): string;
  61795. /**
  61796. * Creates the HardwareScalingOptimization object
  61797. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61798. * @param maximumScale defines the maximum scale to use (2 by default)
  61799. * @param step defines the step to use between two passes (0.5 by default)
  61800. */
  61801. constructor(
  61802. /**
  61803. * Defines the priority of this optimization (0 by default which means first in the list)
  61804. */
  61805. priority?: number,
  61806. /**
  61807. * Defines the maximum scale to use (2 by default)
  61808. */
  61809. maximumScale?: number,
  61810. /**
  61811. * Defines the step to use between two passes (0.5 by default)
  61812. */
  61813. step?: number);
  61814. /**
  61815. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61816. * @param scene defines the current scene where to apply this optimization
  61817. * @param optimizer defines the current optimizer
  61818. * @returns true if everything that can be done was applied
  61819. */
  61820. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61821. }
  61822. /**
  61823. * Defines an optimization used to remove shadows
  61824. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61825. */
  61826. export class ShadowsOptimization extends SceneOptimization {
  61827. /**
  61828. * Gets a string describing the action executed by the current optimization
  61829. * @return description string
  61830. */
  61831. getDescription(): string;
  61832. /**
  61833. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61834. * @param scene defines the current scene where to apply this optimization
  61835. * @param optimizer defines the current optimizer
  61836. * @returns true if everything that can be done was applied
  61837. */
  61838. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61839. }
  61840. /**
  61841. * Defines an optimization used to turn post-processes off
  61842. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61843. */
  61844. export class PostProcessesOptimization extends SceneOptimization {
  61845. /**
  61846. * Gets a string describing the action executed by the current optimization
  61847. * @return description string
  61848. */
  61849. getDescription(): string;
  61850. /**
  61851. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61852. * @param scene defines the current scene where to apply this optimization
  61853. * @param optimizer defines the current optimizer
  61854. * @returns true if everything that can be done was applied
  61855. */
  61856. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61857. }
  61858. /**
  61859. * Defines an optimization used to turn lens flares off
  61860. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61861. */
  61862. export class LensFlaresOptimization extends SceneOptimization {
  61863. /**
  61864. * Gets a string describing the action executed by the current optimization
  61865. * @return description string
  61866. */
  61867. getDescription(): string;
  61868. /**
  61869. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61870. * @param scene defines the current scene where to apply this optimization
  61871. * @param optimizer defines the current optimizer
  61872. * @returns true if everything that can be done was applied
  61873. */
  61874. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61875. }
  61876. /**
  61877. * Defines an optimization based on user defined callback.
  61878. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61879. */
  61880. export class CustomOptimization extends SceneOptimization {
  61881. /**
  61882. * Callback called to apply the custom optimization.
  61883. */
  61884. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  61885. /**
  61886. * Callback called to get custom description
  61887. */
  61888. onGetDescription: () => string;
  61889. /**
  61890. * Gets a string describing the action executed by the current optimization
  61891. * @returns description string
  61892. */
  61893. getDescription(): string;
  61894. /**
  61895. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61896. * @param scene defines the current scene where to apply this optimization
  61897. * @param optimizer defines the current optimizer
  61898. * @returns true if everything that can be done was applied
  61899. */
  61900. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61901. }
  61902. /**
  61903. * Defines an optimization used to turn particles off
  61904. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61905. */
  61906. export class ParticlesOptimization extends SceneOptimization {
  61907. /**
  61908. * Gets a string describing the action executed by the current optimization
  61909. * @return description string
  61910. */
  61911. getDescription(): string;
  61912. /**
  61913. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61914. * @param scene defines the current scene where to apply this optimization
  61915. * @param optimizer defines the current optimizer
  61916. * @returns true if everything that can be done was applied
  61917. */
  61918. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61919. }
  61920. /**
  61921. * Defines an optimization used to turn render targets off
  61922. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61923. */
  61924. export class RenderTargetsOptimization extends SceneOptimization {
  61925. /**
  61926. * Gets a string describing the action executed by the current optimization
  61927. * @return description string
  61928. */
  61929. getDescription(): string;
  61930. /**
  61931. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61932. * @param scene defines the current scene where to apply this optimization
  61933. * @param optimizer defines the current optimizer
  61934. * @returns true if everything that can be done was applied
  61935. */
  61936. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61937. }
  61938. /**
  61939. * Defines an optimization used to merge meshes with compatible materials
  61940. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61941. */
  61942. export class MergeMeshesOptimization extends SceneOptimization {
  61943. private static _UpdateSelectionTree;
  61944. /**
  61945. * Gets or sets a boolean which defines if optimization octree has to be updated
  61946. */
  61947. /**
  61948. * Gets or sets a boolean which defines if optimization octree has to be updated
  61949. */
  61950. static UpdateSelectionTree: boolean;
  61951. /**
  61952. * Gets a string describing the action executed by the current optimization
  61953. * @return description string
  61954. */
  61955. getDescription(): string;
  61956. private _canBeMerged;
  61957. /**
  61958. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61959. * @param scene defines the current scene where to apply this optimization
  61960. * @param optimizer defines the current optimizer
  61961. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  61962. * @returns true if everything that can be done was applied
  61963. */
  61964. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  61965. }
  61966. /**
  61967. * Defines a list of options used by SceneOptimizer
  61968. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61969. */
  61970. export class SceneOptimizerOptions {
  61971. /**
  61972. * Defines the target frame rate to reach (60 by default)
  61973. */
  61974. targetFrameRate: number;
  61975. /**
  61976. * Defines the interval between two checkes (2000ms by default)
  61977. */
  61978. trackerDuration: number;
  61979. /**
  61980. * Gets the list of optimizations to apply
  61981. */
  61982. optimizations: SceneOptimization[];
  61983. /**
  61984. * Creates a new list of options used by SceneOptimizer
  61985. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  61986. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  61987. */
  61988. constructor(
  61989. /**
  61990. * Defines the target frame rate to reach (60 by default)
  61991. */
  61992. targetFrameRate?: number,
  61993. /**
  61994. * Defines the interval between two checkes (2000ms by default)
  61995. */
  61996. trackerDuration?: number);
  61997. /**
  61998. * Add a new optimization
  61999. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  62000. * @returns the current SceneOptimizerOptions
  62001. */
  62002. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  62003. /**
  62004. * Add a new custom optimization
  62005. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  62006. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  62007. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  62008. * @returns the current SceneOptimizerOptions
  62009. */
  62010. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  62011. /**
  62012. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  62013. * @param targetFrameRate defines the target frame rate (60 by default)
  62014. * @returns a SceneOptimizerOptions object
  62015. */
  62016. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  62017. /**
  62018. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  62019. * @param targetFrameRate defines the target frame rate (60 by default)
  62020. * @returns a SceneOptimizerOptions object
  62021. */
  62022. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  62023. /**
  62024. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  62025. * @param targetFrameRate defines the target frame rate (60 by default)
  62026. * @returns a SceneOptimizerOptions object
  62027. */
  62028. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  62029. }
  62030. /**
  62031. * Class used to run optimizations in order to reach a target frame rate
  62032. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62033. */
  62034. export class SceneOptimizer implements IDisposable {
  62035. private _isRunning;
  62036. private _options;
  62037. private _scene;
  62038. private _currentPriorityLevel;
  62039. private _targetFrameRate;
  62040. private _trackerDuration;
  62041. private _currentFrameRate;
  62042. private _sceneDisposeObserver;
  62043. private _improvementMode;
  62044. /**
  62045. * Defines an observable called when the optimizer reaches the target frame rate
  62046. */
  62047. onSuccessObservable: Observable<SceneOptimizer>;
  62048. /**
  62049. * Defines an observable called when the optimizer enables an optimization
  62050. */
  62051. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  62052. /**
  62053. * Defines an observable called when the optimizer is not able to reach the target frame rate
  62054. */
  62055. onFailureObservable: Observable<SceneOptimizer>;
  62056. /**
  62057. * Gets a boolean indicating if the optimizer is in improvement mode
  62058. */
  62059. readonly isInImprovementMode: boolean;
  62060. /**
  62061. * Gets the current priority level (0 at start)
  62062. */
  62063. readonly currentPriorityLevel: number;
  62064. /**
  62065. * Gets the current frame rate checked by the SceneOptimizer
  62066. */
  62067. readonly currentFrameRate: number;
  62068. /**
  62069. * Gets or sets the current target frame rate (60 by default)
  62070. */
  62071. /**
  62072. * Gets or sets the current target frame rate (60 by default)
  62073. */
  62074. targetFrameRate: number;
  62075. /**
  62076. * Gets or sets the current interval between two checks (every 2000ms by default)
  62077. */
  62078. /**
  62079. * Gets or sets the current interval between two checks (every 2000ms by default)
  62080. */
  62081. trackerDuration: number;
  62082. /**
  62083. * Gets the list of active optimizations
  62084. */
  62085. readonly optimizations: SceneOptimization[];
  62086. /**
  62087. * Creates a new SceneOptimizer
  62088. * @param scene defines the scene to work on
  62089. * @param options defines the options to use with the SceneOptimizer
  62090. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  62091. * @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)
  62092. */
  62093. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  62094. /**
  62095. * Stops the current optimizer
  62096. */
  62097. stop(): void;
  62098. /**
  62099. * Reset the optimizer to initial step (current priority level = 0)
  62100. */
  62101. reset(): void;
  62102. /**
  62103. * Start the optimizer. By default it will try to reach a specific framerate
  62104. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  62105. */
  62106. start(): void;
  62107. private _checkCurrentState;
  62108. /**
  62109. * Release all resources
  62110. */
  62111. dispose(): void;
  62112. /**
  62113. * Helper function to create a SceneOptimizer with one single line of code
  62114. * @param scene defines the scene to work on
  62115. * @param options defines the options to use with the SceneOptimizer
  62116. * @param onSuccess defines a callback to call on success
  62117. * @param onFailure defines a callback to call on failure
  62118. * @returns the new SceneOptimizer object
  62119. */
  62120. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  62121. }
  62122. }
  62123. declare module "babylonjs/Misc/sceneSerializer" {
  62124. import { Scene } from "babylonjs/scene";
  62125. /**
  62126. * Class used to serialize a scene into a string
  62127. */
  62128. export class SceneSerializer {
  62129. /**
  62130. * Clear cache used by a previous serialization
  62131. */
  62132. static ClearCache(): void;
  62133. /**
  62134. * Serialize a scene into a JSON compatible object
  62135. * @param scene defines the scene to serialize
  62136. * @returns a JSON compatible object
  62137. */
  62138. static Serialize(scene: Scene): any;
  62139. /**
  62140. * Serialize a mesh into a JSON compatible object
  62141. * @param toSerialize defines the mesh to serialize
  62142. * @param withParents defines if parents must be serialized as well
  62143. * @param withChildren defines if children must be serialized as well
  62144. * @returns a JSON compatible object
  62145. */
  62146. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  62147. }
  62148. }
  62149. declare module "babylonjs/Misc/textureTools" {
  62150. import { Texture } from "babylonjs/Materials/Textures/texture";
  62151. /**
  62152. * Class used to host texture specific utilities
  62153. */
  62154. export class TextureTools {
  62155. /**
  62156. * Uses the GPU to create a copy texture rescaled at a given size
  62157. * @param texture Texture to copy from
  62158. * @param width defines the desired width
  62159. * @param height defines the desired height
  62160. * @param useBilinearMode defines if bilinear mode has to be used
  62161. * @return the generated texture
  62162. */
  62163. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  62164. }
  62165. }
  62166. declare module "babylonjs/Misc/videoRecorder" {
  62167. import { Nullable } from "babylonjs/types";
  62168. import { Engine } from "babylonjs/Engines/engine";
  62169. /**
  62170. * This represents the different options available for the video capture.
  62171. */
  62172. export interface VideoRecorderOptions {
  62173. /** Defines the mime type of the video. */
  62174. mimeType: string;
  62175. /** Defines the FPS the video should be recorded at. */
  62176. fps: number;
  62177. /** Defines the chunk size for the recording data. */
  62178. recordChunckSize: number;
  62179. /** The audio tracks to attach to the recording. */
  62180. audioTracks?: MediaStreamTrack[];
  62181. }
  62182. /**
  62183. * This can help with recording videos from BabylonJS.
  62184. * This is based on the available WebRTC functionalities of the browser.
  62185. *
  62186. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  62187. */
  62188. export class VideoRecorder {
  62189. private static readonly _defaultOptions;
  62190. /**
  62191. * Returns whether or not the VideoRecorder is available in your browser.
  62192. * @param engine Defines the Babylon Engine.
  62193. * @returns true if supported otherwise false.
  62194. */
  62195. static IsSupported(engine: Engine): boolean;
  62196. private readonly _options;
  62197. private _canvas;
  62198. private _mediaRecorder;
  62199. private _recordedChunks;
  62200. private _fileName;
  62201. private _resolve;
  62202. private _reject;
  62203. /**
  62204. * True when a recording is already in progress.
  62205. */
  62206. readonly isRecording: boolean;
  62207. /**
  62208. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  62209. * @param engine Defines the BabylonJS Engine you wish to record.
  62210. * @param options Defines options that can be used to customize the capture.
  62211. */
  62212. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  62213. /**
  62214. * Stops the current recording before the default capture timeout passed in the startRecording function.
  62215. */
  62216. stopRecording(): void;
  62217. /**
  62218. * Starts recording the canvas for a max duration specified in parameters.
  62219. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  62220. * If null no automatic download will start and you can rely on the promise to get the data back.
  62221. * @param maxDuration Defines the maximum recording time in seconds.
  62222. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  62223. * @return A promise callback at the end of the recording with the video data in Blob.
  62224. */
  62225. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  62226. /**
  62227. * Releases internal resources used during the recording.
  62228. */
  62229. dispose(): void;
  62230. private _handleDataAvailable;
  62231. private _handleError;
  62232. private _handleStop;
  62233. }
  62234. }
  62235. declare module "babylonjs/Misc/screenshotTools" {
  62236. import { Camera } from "babylonjs/Cameras/camera";
  62237. import { Engine } from "babylonjs/Engines/engine";
  62238. /**
  62239. * Class containing a set of static utilities functions for screenshots
  62240. */
  62241. export class ScreenshotTools {
  62242. /**
  62243. * Captures a screenshot of the current rendering
  62244. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  62245. * @param engine defines the rendering engine
  62246. * @param camera defines the source camera
  62247. * @param size This parameter can be set to a single number or to an object with the
  62248. * following (optional) properties: precision, width, height. If a single number is passed,
  62249. * it will be used for both width and height. If an object is passed, the screenshot size
  62250. * will be derived from the parameters. The precision property is a multiplier allowing
  62251. * rendering at a higher or lower resolution
  62252. * @param successCallback defines the callback receives a single parameter which contains the
  62253. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  62254. * src parameter of an <img> to display it
  62255. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  62256. * Check your browser for supported MIME types
  62257. */
  62258. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  62259. /**
  62260. * Generates an image screenshot from the specified camera.
  62261. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  62262. * @param engine The engine to use for rendering
  62263. * @param camera The camera to use for rendering
  62264. * @param size This parameter can be set to a single number or to an object with the
  62265. * following (optional) properties: precision, width, height. If a single number is passed,
  62266. * it will be used for both width and height. If an object is passed, the screenshot size
  62267. * will be derived from the parameters. The precision property is a multiplier allowing
  62268. * rendering at a higher or lower resolution
  62269. * @param successCallback The callback receives a single parameter which contains the
  62270. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  62271. * src parameter of an <img> to display it
  62272. * @param mimeType The MIME type of the screenshot image (default: image/png).
  62273. * Check your browser for supported MIME types
  62274. * @param samples Texture samples (default: 1)
  62275. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  62276. * @param fileName A name for for the downloaded file.
  62277. */
  62278. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  62279. }
  62280. }
  62281. declare module "babylonjs/Misc/index" {
  62282. export * from "babylonjs/Misc/andOrNotEvaluator";
  62283. export * from "babylonjs/Misc/assetsManager";
  62284. export * from "babylonjs/Misc/dds";
  62285. export * from "babylonjs/Misc/decorators";
  62286. export * from "babylonjs/Misc/deferred";
  62287. export * from "babylonjs/Misc/environmentTextureTools";
  62288. export * from "babylonjs/Misc/meshExploder";
  62289. export * from "babylonjs/Misc/filesInput";
  62290. export * from "babylonjs/Misc/HighDynamicRange/index";
  62291. export * from "babylonjs/Misc/khronosTextureContainer";
  62292. export * from "babylonjs/Misc/observable";
  62293. export * from "babylonjs/Misc/performanceMonitor";
  62294. export * from "babylonjs/Misc/promise";
  62295. export * from "babylonjs/Misc/sceneOptimizer";
  62296. export * from "babylonjs/Misc/sceneSerializer";
  62297. export * from "babylonjs/Misc/smartArray";
  62298. export * from "babylonjs/Misc/stringDictionary";
  62299. export * from "babylonjs/Misc/tags";
  62300. export * from "babylonjs/Misc/textureTools";
  62301. export * from "babylonjs/Misc/tga";
  62302. export * from "babylonjs/Misc/tools";
  62303. export * from "babylonjs/Misc/videoRecorder";
  62304. export * from "babylonjs/Misc/virtualJoystick";
  62305. export * from "babylonjs/Misc/workerPool";
  62306. export * from "babylonjs/Misc/logger";
  62307. export * from "babylonjs/Misc/typeStore";
  62308. export * from "babylonjs/Misc/filesInputStore";
  62309. export * from "babylonjs/Misc/deepCopier";
  62310. export * from "babylonjs/Misc/pivotTools";
  62311. export * from "babylonjs/Misc/precisionDate";
  62312. export * from "babylonjs/Misc/screenshotTools";
  62313. export * from "babylonjs/Misc/typeStore";
  62314. export * from "babylonjs/Misc/webRequest";
  62315. export * from "babylonjs/Misc/iInspectable";
  62316. export * from "babylonjs/Misc/brdfTextureTools";
  62317. }
  62318. declare module "babylonjs/index" {
  62319. export * from "babylonjs/abstractScene";
  62320. export * from "babylonjs/Actions/index";
  62321. export * from "babylonjs/Animations/index";
  62322. export * from "babylonjs/assetContainer";
  62323. export * from "babylonjs/Audio/index";
  62324. export * from "babylonjs/Behaviors/index";
  62325. export * from "babylonjs/Bones/index";
  62326. export * from "babylonjs/Cameras/index";
  62327. export * from "babylonjs/Collisions/index";
  62328. export * from "babylonjs/Culling/index";
  62329. export * from "babylonjs/Debug/index";
  62330. export * from "babylonjs/Engines/index";
  62331. export * from "babylonjs/Events/index";
  62332. export * from "babylonjs/Gamepads/index";
  62333. export * from "babylonjs/Gizmos/index";
  62334. export * from "babylonjs/Helpers/index";
  62335. export * from "babylonjs/Instrumentation/index";
  62336. export * from "babylonjs/Layers/index";
  62337. export * from "babylonjs/LensFlares/index";
  62338. export * from "babylonjs/Lights/index";
  62339. export * from "babylonjs/Loading/index";
  62340. export * from "babylonjs/Materials/index";
  62341. export * from "babylonjs/Maths/index";
  62342. export * from "babylonjs/Meshes/index";
  62343. export * from "babylonjs/Morph/index";
  62344. export * from "babylonjs/node";
  62345. export * from "babylonjs/Offline/index";
  62346. export * from "babylonjs/Particles/index";
  62347. export * from "babylonjs/Physics/index";
  62348. export * from "babylonjs/PostProcesses/index";
  62349. export * from "babylonjs/Probes/index";
  62350. export * from "babylonjs/Rendering/index";
  62351. export * from "babylonjs/scene";
  62352. export * from "babylonjs/sceneComponent";
  62353. export * from "babylonjs/Sprites/index";
  62354. export * from "babylonjs/States/index";
  62355. export * from "babylonjs/Misc/index";
  62356. export * from "babylonjs/types";
  62357. }
  62358. declare module "babylonjs/Animations/pathCursor" {
  62359. import { Path2, Vector3 } from "babylonjs/Maths/math";
  62360. /**
  62361. * A cursor which tracks a point on a path
  62362. */
  62363. export class PathCursor {
  62364. private path;
  62365. /**
  62366. * Stores path cursor callbacks for when an onchange event is triggered
  62367. */
  62368. private _onchange;
  62369. /**
  62370. * The value of the path cursor
  62371. */
  62372. value: number;
  62373. /**
  62374. * The animation array of the path cursor
  62375. */
  62376. animations: Animation[];
  62377. /**
  62378. * Initializes the path cursor
  62379. * @param path The path to track
  62380. */
  62381. constructor(path: Path2);
  62382. /**
  62383. * Gets the cursor point on the path
  62384. * @returns A point on the path cursor at the cursor location
  62385. */
  62386. getPoint(): Vector3;
  62387. /**
  62388. * Moves the cursor ahead by the step amount
  62389. * @param step The amount to move the cursor forward
  62390. * @returns This path cursor
  62391. */
  62392. moveAhead(step?: number): PathCursor;
  62393. /**
  62394. * Moves the cursor behind by the step amount
  62395. * @param step The amount to move the cursor back
  62396. * @returns This path cursor
  62397. */
  62398. moveBack(step?: number): PathCursor;
  62399. /**
  62400. * Moves the cursor by the step amount
  62401. * If the step amount is greater than one, an exception is thrown
  62402. * @param step The amount to move the cursor
  62403. * @returns This path cursor
  62404. */
  62405. move(step: number): PathCursor;
  62406. /**
  62407. * Ensures that the value is limited between zero and one
  62408. * @returns This path cursor
  62409. */
  62410. private ensureLimits;
  62411. /**
  62412. * Runs onchange callbacks on change (used by the animation engine)
  62413. * @returns This path cursor
  62414. */
  62415. private raiseOnChange;
  62416. /**
  62417. * Executes a function on change
  62418. * @param f A path cursor onchange callback
  62419. * @returns This path cursor
  62420. */
  62421. onchange(f: (cursor: PathCursor) => void): PathCursor;
  62422. }
  62423. }
  62424. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  62425. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  62426. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  62427. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  62428. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  62429. }
  62430. declare module "babylonjs/Engines/Processors/Expressions/index" {
  62431. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  62432. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  62433. }
  62434. declare module "babylonjs/Engines/Processors/index" {
  62435. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  62436. export * from "babylonjs/Engines/Processors/Expressions/index";
  62437. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  62438. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  62439. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  62440. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  62441. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  62442. export * from "babylonjs/Engines/Processors/shaderProcessor";
  62443. }
  62444. declare module "babylonjs/Legacy/legacy" {
  62445. import * as Babylon from "babylonjs/index";
  62446. export * from "babylonjs/index";
  62447. }
  62448. declare module "babylonjs/Shaders/blur.fragment" {
  62449. /** @hidden */
  62450. export var blurPixelShader: {
  62451. name: string;
  62452. shader: string;
  62453. };
  62454. }
  62455. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  62456. /** @hidden */
  62457. export var pointCloudVertexDeclaration: {
  62458. name: string;
  62459. shader: string;
  62460. };
  62461. }
  62462. // Mixins
  62463. interface Window {
  62464. mozIndexedDB: IDBFactory;
  62465. webkitIndexedDB: IDBFactory;
  62466. msIndexedDB: IDBFactory;
  62467. webkitURL: typeof URL;
  62468. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  62469. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  62470. WebGLRenderingContext: WebGLRenderingContext;
  62471. MSGesture: MSGesture;
  62472. CANNON: any;
  62473. AudioContext: AudioContext;
  62474. webkitAudioContext: AudioContext;
  62475. PointerEvent: any;
  62476. Math: Math;
  62477. Uint8Array: Uint8ArrayConstructor;
  62478. Float32Array: Float32ArrayConstructor;
  62479. mozURL: typeof URL;
  62480. msURL: typeof URL;
  62481. VRFrameData: any; // WebVR, from specs 1.1
  62482. DracoDecoderModule: any;
  62483. setImmediate(handler: (...args: any[]) => void): number;
  62484. }
  62485. interface HTMLCanvasElement {
  62486. requestPointerLock(): void;
  62487. msRequestPointerLock?(): void;
  62488. mozRequestPointerLock?(): void;
  62489. webkitRequestPointerLock?(): void;
  62490. /** Track wether a record is in progress */
  62491. isRecording: boolean;
  62492. /** Capture Stream method defined by some browsers */
  62493. captureStream(fps?: number): MediaStream;
  62494. }
  62495. interface CanvasRenderingContext2D {
  62496. msImageSmoothingEnabled: boolean;
  62497. }
  62498. interface MouseEvent {
  62499. mozMovementX: number;
  62500. mozMovementY: number;
  62501. webkitMovementX: number;
  62502. webkitMovementY: number;
  62503. msMovementX: number;
  62504. msMovementY: number;
  62505. }
  62506. interface Navigator {
  62507. mozGetVRDevices: (any: any) => any;
  62508. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  62509. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  62510. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  62511. webkitGetGamepads(): Gamepad[];
  62512. msGetGamepads(): Gamepad[];
  62513. webkitGamepads(): Gamepad[];
  62514. }
  62515. interface HTMLVideoElement {
  62516. mozSrcObject: any;
  62517. }
  62518. interface Math {
  62519. fround(x: number): number;
  62520. imul(a: number, b: number): number;
  62521. }
  62522. interface WebGLRenderingContext {
  62523. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  62524. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  62525. vertexAttribDivisor(index: number, divisor: number): void;
  62526. createVertexArray(): any;
  62527. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  62528. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  62529. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  62530. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  62531. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  62532. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  62533. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  62534. // Queries
  62535. createQuery(): WebGLQuery;
  62536. deleteQuery(query: WebGLQuery): void;
  62537. beginQuery(target: number, query: WebGLQuery): void;
  62538. endQuery(target: number): void;
  62539. getQueryParameter(query: WebGLQuery, pname: number): any;
  62540. getQuery(target: number, pname: number): any;
  62541. MAX_SAMPLES: number;
  62542. RGBA8: number;
  62543. READ_FRAMEBUFFER: number;
  62544. DRAW_FRAMEBUFFER: number;
  62545. UNIFORM_BUFFER: number;
  62546. HALF_FLOAT_OES: number;
  62547. RGBA16F: number;
  62548. RGBA32F: number;
  62549. R32F: number;
  62550. RG32F: number;
  62551. RGB32F: number;
  62552. R16F: number;
  62553. RG16F: number;
  62554. RGB16F: number;
  62555. RED: number;
  62556. RG: number;
  62557. R8: number;
  62558. RG8: number;
  62559. UNSIGNED_INT_24_8: number;
  62560. DEPTH24_STENCIL8: number;
  62561. /* Multiple Render Targets */
  62562. drawBuffers(buffers: number[]): void;
  62563. readBuffer(src: number): void;
  62564. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  62565. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  62566. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  62567. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  62568. // Occlusion Query
  62569. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  62570. ANY_SAMPLES_PASSED: number;
  62571. QUERY_RESULT_AVAILABLE: number;
  62572. QUERY_RESULT: number;
  62573. }
  62574. interface WebGLProgram {
  62575. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  62576. }
  62577. interface EXT_disjoint_timer_query {
  62578. QUERY_COUNTER_BITS_EXT: number;
  62579. TIME_ELAPSED_EXT: number;
  62580. TIMESTAMP_EXT: number;
  62581. GPU_DISJOINT_EXT: number;
  62582. QUERY_RESULT_EXT: number;
  62583. QUERY_RESULT_AVAILABLE_EXT: number;
  62584. queryCounterEXT(query: WebGLQuery, target: number): void;
  62585. createQueryEXT(): WebGLQuery;
  62586. beginQueryEXT(target: number, query: WebGLQuery): void;
  62587. endQueryEXT(target: number): void;
  62588. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  62589. deleteQueryEXT(query: WebGLQuery): void;
  62590. }
  62591. interface WebGLUniformLocation {
  62592. _currentState: any;
  62593. }
  62594. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  62595. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  62596. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  62597. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  62598. interface WebGLRenderingContext {
  62599. readonly RASTERIZER_DISCARD: number;
  62600. readonly DEPTH_COMPONENT24: number;
  62601. readonly TEXTURE_3D: number;
  62602. readonly TEXTURE_2D_ARRAY: number;
  62603. readonly TEXTURE_COMPARE_FUNC: number;
  62604. readonly TEXTURE_COMPARE_MODE: number;
  62605. readonly COMPARE_REF_TO_TEXTURE: number;
  62606. readonly TEXTURE_WRAP_R: number;
  62607. readonly HALF_FLOAT: number;
  62608. readonly RGB8: number;
  62609. readonly RED_INTEGER: number;
  62610. readonly RG_INTEGER: number;
  62611. readonly RGB_INTEGER: number;
  62612. readonly RGBA_INTEGER: number;
  62613. readonly R8_SNORM: number;
  62614. readonly RG8_SNORM: number;
  62615. readonly RGB8_SNORM: number;
  62616. readonly RGBA8_SNORM: number;
  62617. readonly R8I: number;
  62618. readonly RG8I: number;
  62619. readonly RGB8I: number;
  62620. readonly RGBA8I: number;
  62621. readonly R8UI: number;
  62622. readonly RG8UI: number;
  62623. readonly RGB8UI: number;
  62624. readonly RGBA8UI: number;
  62625. readonly R16I: number;
  62626. readonly RG16I: number;
  62627. readonly RGB16I: number;
  62628. readonly RGBA16I: number;
  62629. readonly R16UI: number;
  62630. readonly RG16UI: number;
  62631. readonly RGB16UI: number;
  62632. readonly RGBA16UI: number;
  62633. readonly R32I: number;
  62634. readonly RG32I: number;
  62635. readonly RGB32I: number;
  62636. readonly RGBA32I: number;
  62637. readonly R32UI: number;
  62638. readonly RG32UI: number;
  62639. readonly RGB32UI: number;
  62640. readonly RGBA32UI: number;
  62641. readonly RGB10_A2UI: number;
  62642. readonly R11F_G11F_B10F: number;
  62643. readonly RGB9_E5: number;
  62644. readonly RGB10_A2: number;
  62645. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  62646. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  62647. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  62648. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  62649. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  62650. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  62651. 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;
  62652. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  62653. readonly TRANSFORM_FEEDBACK: number;
  62654. readonly INTERLEAVED_ATTRIBS: number;
  62655. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  62656. createTransformFeedback(): WebGLTransformFeedback;
  62657. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  62658. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  62659. beginTransformFeedback(primitiveMode: number): void;
  62660. endTransformFeedback(): void;
  62661. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  62662. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  62663. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  62664. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  62665. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  62666. }
  62667. interface ImageBitmap {
  62668. readonly width: number;
  62669. readonly height: number;
  62670. close(): void;
  62671. }
  62672. interface WebGLQuery extends WebGLObject {
  62673. }
  62674. declare var WebGLQuery: {
  62675. prototype: WebGLQuery;
  62676. new(): WebGLQuery;
  62677. };
  62678. interface WebGLSampler extends WebGLObject {
  62679. }
  62680. declare var WebGLSampler: {
  62681. prototype: WebGLSampler;
  62682. new(): WebGLSampler;
  62683. };
  62684. interface WebGLSync extends WebGLObject {
  62685. }
  62686. declare var WebGLSync: {
  62687. prototype: WebGLSync;
  62688. new(): WebGLSync;
  62689. };
  62690. interface WebGLTransformFeedback extends WebGLObject {
  62691. }
  62692. declare var WebGLTransformFeedback: {
  62693. prototype: WebGLTransformFeedback;
  62694. new(): WebGLTransformFeedback;
  62695. };
  62696. interface WebGLVertexArrayObject extends WebGLObject {
  62697. }
  62698. declare var WebGLVertexArrayObject: {
  62699. prototype: WebGLVertexArrayObject;
  62700. new(): WebGLVertexArrayObject;
  62701. };
  62702. // Type definitions for WebVR API
  62703. // Project: https://w3c.github.io/webvr/
  62704. // Definitions by: six a <https://github.com/lostfictions>
  62705. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  62706. interface VRDisplay extends EventTarget {
  62707. /**
  62708. * Dictionary of capabilities describing the VRDisplay.
  62709. */
  62710. readonly capabilities: VRDisplayCapabilities;
  62711. /**
  62712. * z-depth defining the far plane of the eye view frustum
  62713. * enables mapping of values in the render target depth
  62714. * attachment to scene coordinates. Initially set to 10000.0.
  62715. */
  62716. depthFar: number;
  62717. /**
  62718. * z-depth defining the near plane of the eye view frustum
  62719. * enables mapping of values in the render target depth
  62720. * attachment to scene coordinates. Initially set to 0.01.
  62721. */
  62722. depthNear: number;
  62723. /**
  62724. * An identifier for this distinct VRDisplay. Used as an
  62725. * association point in the Gamepad API.
  62726. */
  62727. readonly displayId: number;
  62728. /**
  62729. * A display name, a user-readable name identifying it.
  62730. */
  62731. readonly displayName: string;
  62732. readonly isConnected: boolean;
  62733. readonly isPresenting: boolean;
  62734. /**
  62735. * If this VRDisplay supports room-scale experiences, the optional
  62736. * stage attribute contains details on the room-scale parameters.
  62737. */
  62738. readonly stageParameters: VRStageParameters | null;
  62739. /**
  62740. * Passing the value returned by `requestAnimationFrame` to
  62741. * `cancelAnimationFrame` will unregister the callback.
  62742. * @param handle Define the hanle of the request to cancel
  62743. */
  62744. cancelAnimationFrame(handle: number): void;
  62745. /**
  62746. * Stops presenting to the VRDisplay.
  62747. * @returns a promise to know when it stopped
  62748. */
  62749. exitPresent(): Promise<void>;
  62750. /**
  62751. * Return the current VREyeParameters for the given eye.
  62752. * @param whichEye Define the eye we want the parameter for
  62753. * @returns the eye parameters
  62754. */
  62755. getEyeParameters(whichEye: string): VREyeParameters;
  62756. /**
  62757. * Populates the passed VRFrameData with the information required to render
  62758. * the current frame.
  62759. * @param frameData Define the data structure to populate
  62760. * @returns true if ok otherwise false
  62761. */
  62762. getFrameData(frameData: VRFrameData): boolean;
  62763. /**
  62764. * Get the layers currently being presented.
  62765. * @returns the list of VR layers
  62766. */
  62767. getLayers(): VRLayer[];
  62768. /**
  62769. * Return a VRPose containing the future predicted pose of the VRDisplay
  62770. * when the current frame will be presented. The value returned will not
  62771. * change until JavaScript has returned control to the browser.
  62772. *
  62773. * The VRPose will contain the position, orientation, velocity,
  62774. * and acceleration of each of these properties.
  62775. * @returns the pose object
  62776. */
  62777. getPose(): VRPose;
  62778. /**
  62779. * Return the current instantaneous pose of the VRDisplay, with no
  62780. * prediction applied.
  62781. * @returns the current instantaneous pose
  62782. */
  62783. getImmediatePose(): VRPose;
  62784. /**
  62785. * The callback passed to `requestAnimationFrame` will be called
  62786. * any time a new frame should be rendered. When the VRDisplay is
  62787. * presenting the callback will be called at the native refresh
  62788. * rate of the HMD. When not presenting this function acts
  62789. * identically to how window.requestAnimationFrame acts. Content should
  62790. * make no assumptions of frame rate or vsync behavior as the HMD runs
  62791. * asynchronously from other displays and at differing refresh rates.
  62792. * @param callback Define the eaction to run next frame
  62793. * @returns the request handle it
  62794. */
  62795. requestAnimationFrame(callback: FrameRequestCallback): number;
  62796. /**
  62797. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  62798. * Repeat calls while already presenting will update the VRLayers being displayed.
  62799. * @param layers Define the list of layer to present
  62800. * @returns a promise to know when the request has been fulfilled
  62801. */
  62802. requestPresent(layers: VRLayer[]): Promise<void>;
  62803. /**
  62804. * Reset the pose for this display, treating its current position and
  62805. * orientation as the "origin/zero" values. VRPose.position,
  62806. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  62807. * updated when calling resetPose(). This should be called in only
  62808. * sitting-space experiences.
  62809. */
  62810. resetPose(): void;
  62811. /**
  62812. * The VRLayer provided to the VRDisplay will be captured and presented
  62813. * in the HMD. Calling this function has the same effect on the source
  62814. * canvas as any other operation that uses its source image, and canvases
  62815. * created without preserveDrawingBuffer set to true will be cleared.
  62816. * @param pose Define the pose to submit
  62817. */
  62818. submitFrame(pose?: VRPose): void;
  62819. }
  62820. declare var VRDisplay: {
  62821. prototype: VRDisplay;
  62822. new(): VRDisplay;
  62823. };
  62824. interface VRLayer {
  62825. leftBounds?: number[] | Float32Array | null;
  62826. rightBounds?: number[] | Float32Array | null;
  62827. source?: HTMLCanvasElement | null;
  62828. }
  62829. interface VRDisplayCapabilities {
  62830. readonly canPresent: boolean;
  62831. readonly hasExternalDisplay: boolean;
  62832. readonly hasOrientation: boolean;
  62833. readonly hasPosition: boolean;
  62834. readonly maxLayers: number;
  62835. }
  62836. interface VREyeParameters {
  62837. /** @deprecated */
  62838. readonly fieldOfView: VRFieldOfView;
  62839. readonly offset: Float32Array;
  62840. readonly renderHeight: number;
  62841. readonly renderWidth: number;
  62842. }
  62843. interface VRFieldOfView {
  62844. readonly downDegrees: number;
  62845. readonly leftDegrees: number;
  62846. readonly rightDegrees: number;
  62847. readonly upDegrees: number;
  62848. }
  62849. interface VRFrameData {
  62850. readonly leftProjectionMatrix: Float32Array;
  62851. readonly leftViewMatrix: Float32Array;
  62852. readonly pose: VRPose;
  62853. readonly rightProjectionMatrix: Float32Array;
  62854. readonly rightViewMatrix: Float32Array;
  62855. readonly timestamp: number;
  62856. }
  62857. interface VRPose {
  62858. readonly angularAcceleration: Float32Array | null;
  62859. readonly angularVelocity: Float32Array | null;
  62860. readonly linearAcceleration: Float32Array | null;
  62861. readonly linearVelocity: Float32Array | null;
  62862. readonly orientation: Float32Array | null;
  62863. readonly position: Float32Array | null;
  62864. readonly timestamp: number;
  62865. }
  62866. interface VRStageParameters {
  62867. sittingToStandingTransform?: Float32Array;
  62868. sizeX?: number;
  62869. sizeY?: number;
  62870. }
  62871. interface Navigator {
  62872. getVRDisplays(): Promise<VRDisplay[]>;
  62873. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  62874. }
  62875. interface Window {
  62876. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  62877. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  62878. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  62879. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  62880. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  62881. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  62882. }
  62883. interface Gamepad {
  62884. readonly displayId: number;
  62885. }
  62886. interface XRDevice {
  62887. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  62888. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  62889. }
  62890. interface XRSession {
  62891. getInputSources(): Array<any>;
  62892. baseLayer: XRWebGLLayer;
  62893. requestFrameOfReference(type: string): Promise<void>;
  62894. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  62895. end(): Promise<void>;
  62896. requestAnimationFrame: Function;
  62897. addEventListener: Function;
  62898. }
  62899. interface XRSessionCreationOptions {
  62900. outputContext?: WebGLRenderingContext | null;
  62901. immersive?: boolean;
  62902. environmentIntegration?: boolean;
  62903. }
  62904. interface XRLayer {
  62905. getViewport: Function;
  62906. framebufferWidth: number;
  62907. framebufferHeight: number;
  62908. }
  62909. interface XRView {
  62910. projectionMatrix: Float32Array;
  62911. }
  62912. interface XRFrame {
  62913. getDevicePose: Function;
  62914. getInputPose: Function;
  62915. views: Array<XRView>;
  62916. baseLayer: XRLayer;
  62917. }
  62918. interface XRFrameOfReference {
  62919. }
  62920. interface XRWebGLLayer extends XRLayer {
  62921. framebuffer: WebGLFramebuffer;
  62922. }
  62923. declare var XRWebGLLayer: {
  62924. prototype: XRWebGLLayer;
  62925. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  62926. };
  62927. declare module "babylonjs" {
  62928. export * from "babylonjs/Legacy/legacy";
  62929. }
  62930. declare module BABYLON {
  62931. /** Alias type for value that can be null */
  62932. export type Nullable<T> = T | null;
  62933. /**
  62934. * Alias type for number that are floats
  62935. * @ignorenaming
  62936. */
  62937. export type float = number;
  62938. /**
  62939. * Alias type for number that are doubles.
  62940. * @ignorenaming
  62941. */
  62942. export type double = number;
  62943. /**
  62944. * Alias type for number that are integer
  62945. * @ignorenaming
  62946. */
  62947. export type int = number;
  62948. /** Alias type for number array or Float32Array */
  62949. export type FloatArray = number[] | Float32Array;
  62950. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  62951. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  62952. /**
  62953. * Alias for types that can be used by a Buffer or VertexBuffer.
  62954. */
  62955. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  62956. /**
  62957. * Alias type for primitive types
  62958. * @ignorenaming
  62959. */
  62960. type Primitive = undefined | null | boolean | string | number | Function;
  62961. /**
  62962. * Type modifier to make all the properties of an object Readonly
  62963. */
  62964. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  62965. /**
  62966. * Type modifier to make all the properties of an object Readonly recursively
  62967. */
  62968. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  62969. /** @hidden */
  62970. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  62971. }
  62972. /** @hidden */
  62973. /** @hidden */
  62974. type DeepImmutableObject<T> = {
  62975. readonly [K in keyof T]: DeepImmutable<T[K]>;
  62976. };
  62977. }
  62978. declare module BABYLON {
  62979. /**
  62980. * Class containing a set of static utilities functions for arrays.
  62981. */
  62982. export class ArrayTools {
  62983. /**
  62984. * Returns an array of the given size filled with element built from the given constructor and the paramters
  62985. * @param size the number of element to construct and put in the array
  62986. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  62987. * @returns a new array filled with new objects
  62988. */
  62989. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  62990. }
  62991. }
  62992. declare module BABYLON {
  62993. /**
  62994. * Scalar computation library
  62995. */
  62996. export class Scalar {
  62997. /**
  62998. * Two pi constants convenient for computation.
  62999. */
  63000. static TwoPi: number;
  63001. /**
  63002. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  63003. * @param a number
  63004. * @param b number
  63005. * @param epsilon (default = 1.401298E-45)
  63006. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  63007. */
  63008. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  63009. /**
  63010. * Returns a string : the upper case translation of the number i to hexadecimal.
  63011. * @param i number
  63012. * @returns the upper case translation of the number i to hexadecimal.
  63013. */
  63014. static ToHex(i: number): string;
  63015. /**
  63016. * Returns -1 if value is negative and +1 is value is positive.
  63017. * @param value the value
  63018. * @returns the value itself if it's equal to zero.
  63019. */
  63020. static Sign(value: number): number;
  63021. /**
  63022. * Returns the value itself if it's between min and max.
  63023. * Returns min if the value is lower than min.
  63024. * Returns max if the value is greater than max.
  63025. * @param value the value to clmap
  63026. * @param min the min value to clamp to (default: 0)
  63027. * @param max the max value to clamp to (default: 1)
  63028. * @returns the clamped value
  63029. */
  63030. static Clamp(value: number, min?: number, max?: number): number;
  63031. /**
  63032. * the log2 of value.
  63033. * @param value the value to compute log2 of
  63034. * @returns the log2 of value.
  63035. */
  63036. static Log2(value: number): number;
  63037. /**
  63038. * Loops the value, so that it is never larger than length and never smaller than 0.
  63039. *
  63040. * This is similar to the modulo operator but it works with floating point numbers.
  63041. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  63042. * With t = 5 and length = 2.5, the result would be 0.0.
  63043. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  63044. * @param value the value
  63045. * @param length the length
  63046. * @returns the looped value
  63047. */
  63048. static Repeat(value: number, length: number): number;
  63049. /**
  63050. * Normalize the value between 0.0 and 1.0 using min and max values
  63051. * @param value value to normalize
  63052. * @param min max to normalize between
  63053. * @param max min to normalize between
  63054. * @returns the normalized value
  63055. */
  63056. static Normalize(value: number, min: number, max: number): number;
  63057. /**
  63058. * Denormalize the value from 0.0 and 1.0 using min and max values
  63059. * @param normalized value to denormalize
  63060. * @param min max to denormalize between
  63061. * @param max min to denormalize between
  63062. * @returns the denormalized value
  63063. */
  63064. static Denormalize(normalized: number, min: number, max: number): number;
  63065. /**
  63066. * Calculates the shortest difference between two given angles given in degrees.
  63067. * @param current current angle in degrees
  63068. * @param target target angle in degrees
  63069. * @returns the delta
  63070. */
  63071. static DeltaAngle(current: number, target: number): number;
  63072. /**
  63073. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  63074. * @param tx value
  63075. * @param length length
  63076. * @returns The returned value will move back and forth between 0 and length
  63077. */
  63078. static PingPong(tx: number, length: number): number;
  63079. /**
  63080. * Interpolates between min and max with smoothing at the limits.
  63081. *
  63082. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  63083. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  63084. * @param from from
  63085. * @param to to
  63086. * @param tx value
  63087. * @returns the smooth stepped value
  63088. */
  63089. static SmoothStep(from: number, to: number, tx: number): number;
  63090. /**
  63091. * Moves a value current towards target.
  63092. *
  63093. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  63094. * Negative values of maxDelta pushes the value away from target.
  63095. * @param current current value
  63096. * @param target target value
  63097. * @param maxDelta max distance to move
  63098. * @returns resulting value
  63099. */
  63100. static MoveTowards(current: number, target: number, maxDelta: number): number;
  63101. /**
  63102. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  63103. *
  63104. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  63105. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  63106. * @param current current value
  63107. * @param target target value
  63108. * @param maxDelta max distance to move
  63109. * @returns resulting angle
  63110. */
  63111. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  63112. /**
  63113. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  63114. * @param start start value
  63115. * @param end target value
  63116. * @param amount amount to lerp between
  63117. * @returns the lerped value
  63118. */
  63119. static Lerp(start: number, end: number, amount: number): number;
  63120. /**
  63121. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  63122. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  63123. * @param start start value
  63124. * @param end target value
  63125. * @param amount amount to lerp between
  63126. * @returns the lerped value
  63127. */
  63128. static LerpAngle(start: number, end: number, amount: number): number;
  63129. /**
  63130. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  63131. * @param a start value
  63132. * @param b target value
  63133. * @param value value between a and b
  63134. * @returns the inverseLerp value
  63135. */
  63136. static InverseLerp(a: number, b: number, value: number): number;
  63137. /**
  63138. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  63139. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  63140. * @param value1 spline value
  63141. * @param tangent1 spline value
  63142. * @param value2 spline value
  63143. * @param tangent2 spline value
  63144. * @param amount input value
  63145. * @returns hermite result
  63146. */
  63147. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  63148. /**
  63149. * Returns a random float number between and min and max values
  63150. * @param min min value of random
  63151. * @param max max value of random
  63152. * @returns random value
  63153. */
  63154. static RandomRange(min: number, max: number): number;
  63155. /**
  63156. * This function returns percentage of a number in a given range.
  63157. *
  63158. * RangeToPercent(40,20,60) will return 0.5 (50%)
  63159. * RangeToPercent(34,0,100) will return 0.34 (34%)
  63160. * @param number to convert to percentage
  63161. * @param min min range
  63162. * @param max max range
  63163. * @returns the percentage
  63164. */
  63165. static RangeToPercent(number: number, min: number, max: number): number;
  63166. /**
  63167. * This function returns number that corresponds to the percentage in a given range.
  63168. *
  63169. * PercentToRange(0.34,0,100) will return 34.
  63170. * @param percent to convert to number
  63171. * @param min min range
  63172. * @param max max range
  63173. * @returns the number
  63174. */
  63175. static PercentToRange(percent: number, min: number, max: number): number;
  63176. /**
  63177. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  63178. * @param angle The angle to normalize in radian.
  63179. * @return The converted angle.
  63180. */
  63181. static NormalizeRadians(angle: number): number;
  63182. }
  63183. }
  63184. declare module BABYLON {
  63185. /**
  63186. * Constant used to convert a value to gamma space
  63187. * @ignorenaming
  63188. */
  63189. export const ToGammaSpace: number;
  63190. /**
  63191. * Constant used to convert a value to linear space
  63192. * @ignorenaming
  63193. */
  63194. export const ToLinearSpace = 2.2;
  63195. /**
  63196. * Constant used to define the minimal number value in Babylon.js
  63197. * @ignorenaming
  63198. */
  63199. let Epsilon: number;
  63200. /**
  63201. * Class used to hold a RBG color
  63202. */
  63203. export class Color3 {
  63204. /**
  63205. * Defines the red component (between 0 and 1, default is 0)
  63206. */
  63207. r: number;
  63208. /**
  63209. * Defines the green component (between 0 and 1, default is 0)
  63210. */
  63211. g: number;
  63212. /**
  63213. * Defines the blue component (between 0 and 1, default is 0)
  63214. */
  63215. b: number;
  63216. /**
  63217. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  63218. * @param r defines the red component (between 0 and 1, default is 0)
  63219. * @param g defines the green component (between 0 and 1, default is 0)
  63220. * @param b defines the blue component (between 0 and 1, default is 0)
  63221. */
  63222. constructor(
  63223. /**
  63224. * Defines the red component (between 0 and 1, default is 0)
  63225. */
  63226. r?: number,
  63227. /**
  63228. * Defines the green component (between 0 and 1, default is 0)
  63229. */
  63230. g?: number,
  63231. /**
  63232. * Defines the blue component (between 0 and 1, default is 0)
  63233. */
  63234. b?: number);
  63235. /**
  63236. * Creates a string with the Color3 current values
  63237. * @returns the string representation of the Color3 object
  63238. */
  63239. toString(): string;
  63240. /**
  63241. * Returns the string "Color3"
  63242. * @returns "Color3"
  63243. */
  63244. getClassName(): string;
  63245. /**
  63246. * Compute the Color3 hash code
  63247. * @returns an unique number that can be used to hash Color3 objects
  63248. */
  63249. getHashCode(): number;
  63250. /**
  63251. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  63252. * @param array defines the array where to store the r,g,b components
  63253. * @param index defines an optional index in the target array to define where to start storing values
  63254. * @returns the current Color3 object
  63255. */
  63256. toArray(array: FloatArray, index?: number): Color3;
  63257. /**
  63258. * Returns a new Color4 object from the current Color3 and the given alpha
  63259. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  63260. * @returns a new Color4 object
  63261. */
  63262. toColor4(alpha?: number): Color4;
  63263. /**
  63264. * Returns a new array populated with 3 numeric elements : red, green and blue values
  63265. * @returns the new array
  63266. */
  63267. asArray(): number[];
  63268. /**
  63269. * Returns the luminance value
  63270. * @returns a float value
  63271. */
  63272. toLuminance(): number;
  63273. /**
  63274. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  63275. * @param otherColor defines the second operand
  63276. * @returns the new Color3 object
  63277. */
  63278. multiply(otherColor: DeepImmutable<Color3>): Color3;
  63279. /**
  63280. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  63281. * @param otherColor defines the second operand
  63282. * @param result defines the Color3 object where to store the result
  63283. * @returns the current Color3
  63284. */
  63285. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  63286. /**
  63287. * Determines equality between Color3 objects
  63288. * @param otherColor defines the second operand
  63289. * @returns true if the rgb values are equal to the given ones
  63290. */
  63291. equals(otherColor: DeepImmutable<Color3>): boolean;
  63292. /**
  63293. * Determines equality between the current Color3 object and a set of r,b,g values
  63294. * @param r defines the red component to check
  63295. * @param g defines the green component to check
  63296. * @param b defines the blue component to check
  63297. * @returns true if the rgb values are equal to the given ones
  63298. */
  63299. equalsFloats(r: number, g: number, b: number): boolean;
  63300. /**
  63301. * Multiplies in place each rgb value by scale
  63302. * @param scale defines the scaling factor
  63303. * @returns the updated Color3
  63304. */
  63305. scale(scale: number): Color3;
  63306. /**
  63307. * Multiplies the rgb values by scale and stores the result into "result"
  63308. * @param scale defines the scaling factor
  63309. * @param result defines the Color3 object where to store the result
  63310. * @returns the unmodified current Color3
  63311. */
  63312. scaleToRef(scale: number, result: Color3): Color3;
  63313. /**
  63314. * Scale the current Color3 values by a factor and add the result to a given Color3
  63315. * @param scale defines the scale factor
  63316. * @param result defines color to store the result into
  63317. * @returns the unmodified current Color3
  63318. */
  63319. scaleAndAddToRef(scale: number, result: Color3): Color3;
  63320. /**
  63321. * Clamps the rgb values by the min and max values and stores the result into "result"
  63322. * @param min defines minimum clamping value (default is 0)
  63323. * @param max defines maximum clamping value (default is 1)
  63324. * @param result defines color to store the result into
  63325. * @returns the original Color3
  63326. */
  63327. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  63328. /**
  63329. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  63330. * @param otherColor defines the second operand
  63331. * @returns the new Color3
  63332. */
  63333. add(otherColor: DeepImmutable<Color3>): Color3;
  63334. /**
  63335. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  63336. * @param otherColor defines the second operand
  63337. * @param result defines Color3 object to store the result into
  63338. * @returns the unmodified current Color3
  63339. */
  63340. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  63341. /**
  63342. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  63343. * @param otherColor defines the second operand
  63344. * @returns the new Color3
  63345. */
  63346. subtract(otherColor: DeepImmutable<Color3>): Color3;
  63347. /**
  63348. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  63349. * @param otherColor defines the second operand
  63350. * @param result defines Color3 object to store the result into
  63351. * @returns the unmodified current Color3
  63352. */
  63353. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  63354. /**
  63355. * Copy the current object
  63356. * @returns a new Color3 copied the current one
  63357. */
  63358. clone(): Color3;
  63359. /**
  63360. * Copies the rgb values from the source in the current Color3
  63361. * @param source defines the source Color3 object
  63362. * @returns the updated Color3 object
  63363. */
  63364. copyFrom(source: DeepImmutable<Color3>): Color3;
  63365. /**
  63366. * Updates the Color3 rgb values from the given floats
  63367. * @param r defines the red component to read from
  63368. * @param g defines the green component to read from
  63369. * @param b defines the blue component to read from
  63370. * @returns the current Color3 object
  63371. */
  63372. copyFromFloats(r: number, g: number, b: number): Color3;
  63373. /**
  63374. * Updates the Color3 rgb values from the given floats
  63375. * @param r defines the red component to read from
  63376. * @param g defines the green component to read from
  63377. * @param b defines the blue component to read from
  63378. * @returns the current Color3 object
  63379. */
  63380. set(r: number, g: number, b: number): Color3;
  63381. /**
  63382. * Compute the Color3 hexadecimal code as a string
  63383. * @returns a string containing the hexadecimal representation of the Color3 object
  63384. */
  63385. toHexString(): string;
  63386. /**
  63387. * Computes a new Color3 converted from the current one to linear space
  63388. * @returns a new Color3 object
  63389. */
  63390. toLinearSpace(): Color3;
  63391. /**
  63392. * Converts current color in rgb space to HSV values
  63393. * @returns a new color3 representing the HSV values
  63394. */
  63395. toHSV(): Color3;
  63396. /**
  63397. * Converts current color in rgb space to HSV values
  63398. * @param result defines the Color3 where to store the HSV values
  63399. */
  63400. toHSVToRef(result: Color3): void;
  63401. /**
  63402. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  63403. * @param convertedColor defines the Color3 object where to store the linear space version
  63404. * @returns the unmodified Color3
  63405. */
  63406. toLinearSpaceToRef(convertedColor: Color3): Color3;
  63407. /**
  63408. * Computes a new Color3 converted from the current one to gamma space
  63409. * @returns a new Color3 object
  63410. */
  63411. toGammaSpace(): Color3;
  63412. /**
  63413. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  63414. * @param convertedColor defines the Color3 object where to store the gamma space version
  63415. * @returns the unmodified Color3
  63416. */
  63417. toGammaSpaceToRef(convertedColor: Color3): Color3;
  63418. private static _BlackReadOnly;
  63419. /**
  63420. * Convert Hue, saturation and value to a Color3 (RGB)
  63421. * @param hue defines the hue
  63422. * @param saturation defines the saturation
  63423. * @param value defines the value
  63424. * @param result defines the Color3 where to store the RGB values
  63425. */
  63426. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  63427. /**
  63428. * Creates a new Color3 from the string containing valid hexadecimal values
  63429. * @param hex defines a string containing valid hexadecimal values
  63430. * @returns a new Color3 object
  63431. */
  63432. static FromHexString(hex: string): Color3;
  63433. /**
  63434. * Creates a new Color3 from the starting index of the given array
  63435. * @param array defines the source array
  63436. * @param offset defines an offset in the source array
  63437. * @returns a new Color3 object
  63438. */
  63439. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  63440. /**
  63441. * Creates a new Color3 from integer values (< 256)
  63442. * @param r defines the red component to read from (value between 0 and 255)
  63443. * @param g defines the green component to read from (value between 0 and 255)
  63444. * @param b defines the blue component to read from (value between 0 and 255)
  63445. * @returns a new Color3 object
  63446. */
  63447. static FromInts(r: number, g: number, b: number): Color3;
  63448. /**
  63449. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  63450. * @param start defines the start Color3 value
  63451. * @param end defines the end Color3 value
  63452. * @param amount defines the gradient value between start and end
  63453. * @returns a new Color3 object
  63454. */
  63455. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  63456. /**
  63457. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  63458. * @param left defines the start value
  63459. * @param right defines the end value
  63460. * @param amount defines the gradient factor
  63461. * @param result defines the Color3 object where to store the result
  63462. */
  63463. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  63464. /**
  63465. * Returns a Color3 value containing a red color
  63466. * @returns a new Color3 object
  63467. */
  63468. static Red(): Color3;
  63469. /**
  63470. * Returns a Color3 value containing a green color
  63471. * @returns a new Color3 object
  63472. */
  63473. static Green(): Color3;
  63474. /**
  63475. * Returns a Color3 value containing a blue color
  63476. * @returns a new Color3 object
  63477. */
  63478. static Blue(): Color3;
  63479. /**
  63480. * Returns a Color3 value containing a black color
  63481. * @returns a new Color3 object
  63482. */
  63483. static Black(): Color3;
  63484. /**
  63485. * Gets a Color3 value containing a black color that must not be updated
  63486. */
  63487. static readonly BlackReadOnly: DeepImmutable<Color3>;
  63488. /**
  63489. * Returns a Color3 value containing a white color
  63490. * @returns a new Color3 object
  63491. */
  63492. static White(): Color3;
  63493. /**
  63494. * Returns a Color3 value containing a purple color
  63495. * @returns a new Color3 object
  63496. */
  63497. static Purple(): Color3;
  63498. /**
  63499. * Returns a Color3 value containing a magenta color
  63500. * @returns a new Color3 object
  63501. */
  63502. static Magenta(): Color3;
  63503. /**
  63504. * Returns a Color3 value containing a yellow color
  63505. * @returns a new Color3 object
  63506. */
  63507. static Yellow(): Color3;
  63508. /**
  63509. * Returns a Color3 value containing a gray color
  63510. * @returns a new Color3 object
  63511. */
  63512. static Gray(): Color3;
  63513. /**
  63514. * Returns a Color3 value containing a teal color
  63515. * @returns a new Color3 object
  63516. */
  63517. static Teal(): Color3;
  63518. /**
  63519. * Returns a Color3 value containing a random color
  63520. * @returns a new Color3 object
  63521. */
  63522. static Random(): Color3;
  63523. }
  63524. /**
  63525. * Class used to hold a RBGA color
  63526. */
  63527. export class Color4 {
  63528. /**
  63529. * Defines the red component (between 0 and 1, default is 0)
  63530. */
  63531. r: number;
  63532. /**
  63533. * Defines the green component (between 0 and 1, default is 0)
  63534. */
  63535. g: number;
  63536. /**
  63537. * Defines the blue component (between 0 and 1, default is 0)
  63538. */
  63539. b: number;
  63540. /**
  63541. * Defines the alpha component (between 0 and 1, default is 1)
  63542. */
  63543. a: number;
  63544. /**
  63545. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  63546. * @param r defines the red component (between 0 and 1, default is 0)
  63547. * @param g defines the green component (between 0 and 1, default is 0)
  63548. * @param b defines the blue component (between 0 and 1, default is 0)
  63549. * @param a defines the alpha component (between 0 and 1, default is 1)
  63550. */
  63551. constructor(
  63552. /**
  63553. * Defines the red component (between 0 and 1, default is 0)
  63554. */
  63555. r?: number,
  63556. /**
  63557. * Defines the green component (between 0 and 1, default is 0)
  63558. */
  63559. g?: number,
  63560. /**
  63561. * Defines the blue component (between 0 and 1, default is 0)
  63562. */
  63563. b?: number,
  63564. /**
  63565. * Defines the alpha component (between 0 and 1, default is 1)
  63566. */
  63567. a?: number);
  63568. /**
  63569. * Adds in place the given Color4 values to the current Color4 object
  63570. * @param right defines the second operand
  63571. * @returns the current updated Color4 object
  63572. */
  63573. addInPlace(right: DeepImmutable<Color4>): Color4;
  63574. /**
  63575. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  63576. * @returns the new array
  63577. */
  63578. asArray(): number[];
  63579. /**
  63580. * Stores from the starting index in the given array the Color4 successive values
  63581. * @param array defines the array where to store the r,g,b components
  63582. * @param index defines an optional index in the target array to define where to start storing values
  63583. * @returns the current Color4 object
  63584. */
  63585. toArray(array: number[], index?: number): Color4;
  63586. /**
  63587. * Determines equality between Color4 objects
  63588. * @param otherColor defines the second operand
  63589. * @returns true if the rgba values are equal to the given ones
  63590. */
  63591. equals(otherColor: DeepImmutable<Color4>): boolean;
  63592. /**
  63593. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  63594. * @param right defines the second operand
  63595. * @returns a new Color4 object
  63596. */
  63597. add(right: DeepImmutable<Color4>): Color4;
  63598. /**
  63599. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  63600. * @param right defines the second operand
  63601. * @returns a new Color4 object
  63602. */
  63603. subtract(right: DeepImmutable<Color4>): Color4;
  63604. /**
  63605. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  63606. * @param right defines the second operand
  63607. * @param result defines the Color4 object where to store the result
  63608. * @returns the current Color4 object
  63609. */
  63610. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  63611. /**
  63612. * Creates a new Color4 with the current Color4 values multiplied by scale
  63613. * @param scale defines the scaling factor to apply
  63614. * @returns a new Color4 object
  63615. */
  63616. scale(scale: number): Color4;
  63617. /**
  63618. * Multiplies the current Color4 values by scale and stores the result in "result"
  63619. * @param scale defines the scaling factor to apply
  63620. * @param result defines the Color4 object where to store the result
  63621. * @returns the current unmodified Color4
  63622. */
  63623. scaleToRef(scale: number, result: Color4): Color4;
  63624. /**
  63625. * Scale the current Color4 values by a factor and add the result to a given Color4
  63626. * @param scale defines the scale factor
  63627. * @param result defines the Color4 object where to store the result
  63628. * @returns the unmodified current Color4
  63629. */
  63630. scaleAndAddToRef(scale: number, result: Color4): Color4;
  63631. /**
  63632. * Clamps the rgb values by the min and max values and stores the result into "result"
  63633. * @param min defines minimum clamping value (default is 0)
  63634. * @param max defines maximum clamping value (default is 1)
  63635. * @param result defines color to store the result into.
  63636. * @returns the cuurent Color4
  63637. */
  63638. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  63639. /**
  63640. * Multipy an Color4 value by another and return a new Color4 object
  63641. * @param color defines the Color4 value to multiply by
  63642. * @returns a new Color4 object
  63643. */
  63644. multiply(color: Color4): Color4;
  63645. /**
  63646. * Multipy a Color4 value by another and push the result in a reference value
  63647. * @param color defines the Color4 value to multiply by
  63648. * @param result defines the Color4 to fill the result in
  63649. * @returns the result Color4
  63650. */
  63651. multiplyToRef(color: Color4, result: Color4): Color4;
  63652. /**
  63653. * Creates a string with the Color4 current values
  63654. * @returns the string representation of the Color4 object
  63655. */
  63656. toString(): string;
  63657. /**
  63658. * Returns the string "Color4"
  63659. * @returns "Color4"
  63660. */
  63661. getClassName(): string;
  63662. /**
  63663. * Compute the Color4 hash code
  63664. * @returns an unique number that can be used to hash Color4 objects
  63665. */
  63666. getHashCode(): number;
  63667. /**
  63668. * Creates a new Color4 copied from the current one
  63669. * @returns a new Color4 object
  63670. */
  63671. clone(): Color4;
  63672. /**
  63673. * Copies the given Color4 values into the current one
  63674. * @param source defines the source Color4 object
  63675. * @returns the current updated Color4 object
  63676. */
  63677. copyFrom(source: Color4): Color4;
  63678. /**
  63679. * Copies the given float values into the current one
  63680. * @param r defines the red component to read from
  63681. * @param g defines the green component to read from
  63682. * @param b defines the blue component to read from
  63683. * @param a defines the alpha component to read from
  63684. * @returns the current updated Color4 object
  63685. */
  63686. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  63687. /**
  63688. * Copies the given float values into the current one
  63689. * @param r defines the red component to read from
  63690. * @param g defines the green component to read from
  63691. * @param b defines the blue component to read from
  63692. * @param a defines the alpha component to read from
  63693. * @returns the current updated Color4 object
  63694. */
  63695. set(r: number, g: number, b: number, a: number): Color4;
  63696. /**
  63697. * Compute the Color4 hexadecimal code as a string
  63698. * @returns a string containing the hexadecimal representation of the Color4 object
  63699. */
  63700. toHexString(): string;
  63701. /**
  63702. * Computes a new Color4 converted from the current one to linear space
  63703. * @returns a new Color4 object
  63704. */
  63705. toLinearSpace(): Color4;
  63706. /**
  63707. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  63708. * @param convertedColor defines the Color4 object where to store the linear space version
  63709. * @returns the unmodified Color4
  63710. */
  63711. toLinearSpaceToRef(convertedColor: Color4): Color4;
  63712. /**
  63713. * Computes a new Color4 converted from the current one to gamma space
  63714. * @returns a new Color4 object
  63715. */
  63716. toGammaSpace(): Color4;
  63717. /**
  63718. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  63719. * @param convertedColor defines the Color4 object where to store the gamma space version
  63720. * @returns the unmodified Color4
  63721. */
  63722. toGammaSpaceToRef(convertedColor: Color4): Color4;
  63723. /**
  63724. * Creates a new Color4 from the string containing valid hexadecimal values
  63725. * @param hex defines a string containing valid hexadecimal values
  63726. * @returns a new Color4 object
  63727. */
  63728. static FromHexString(hex: string): Color4;
  63729. /**
  63730. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  63731. * @param left defines the start value
  63732. * @param right defines the end value
  63733. * @param amount defines the gradient factor
  63734. * @returns a new Color4 object
  63735. */
  63736. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  63737. /**
  63738. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  63739. * @param left defines the start value
  63740. * @param right defines the end value
  63741. * @param amount defines the gradient factor
  63742. * @param result defines the Color4 object where to store data
  63743. */
  63744. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  63745. /**
  63746. * Creates a new Color4 from a Color3 and an alpha value
  63747. * @param color3 defines the source Color3 to read from
  63748. * @param alpha defines the alpha component (1.0 by default)
  63749. * @returns a new Color4 object
  63750. */
  63751. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  63752. /**
  63753. * Creates a new Color4 from the starting index element of the given array
  63754. * @param array defines the source array to read from
  63755. * @param offset defines the offset in the source array
  63756. * @returns a new Color4 object
  63757. */
  63758. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  63759. /**
  63760. * Creates a new Color3 from integer values (< 256)
  63761. * @param r defines the red component to read from (value between 0 and 255)
  63762. * @param g defines the green component to read from (value between 0 and 255)
  63763. * @param b defines the blue component to read from (value between 0 and 255)
  63764. * @param a defines the alpha component to read from (value between 0 and 255)
  63765. * @returns a new Color3 object
  63766. */
  63767. static FromInts(r: number, g: number, b: number, a: number): Color4;
  63768. /**
  63769. * Check the content of a given array and convert it to an array containing RGBA data
  63770. * If the original array was already containing count * 4 values then it is returned directly
  63771. * @param colors defines the array to check
  63772. * @param count defines the number of RGBA data to expect
  63773. * @returns an array containing count * 4 values (RGBA)
  63774. */
  63775. static CheckColors4(colors: number[], count: number): number[];
  63776. }
  63777. /**
  63778. * Class representing a vector containing 2 coordinates
  63779. */
  63780. export class Vector2 {
  63781. /** defines the first coordinate */
  63782. x: number;
  63783. /** defines the second coordinate */
  63784. y: number;
  63785. /**
  63786. * Creates a new Vector2 from the given x and y coordinates
  63787. * @param x defines the first coordinate
  63788. * @param y defines the second coordinate
  63789. */
  63790. constructor(
  63791. /** defines the first coordinate */
  63792. x?: number,
  63793. /** defines the second coordinate */
  63794. y?: number);
  63795. /**
  63796. * Gets a string with the Vector2 coordinates
  63797. * @returns a string with the Vector2 coordinates
  63798. */
  63799. toString(): string;
  63800. /**
  63801. * Gets class name
  63802. * @returns the string "Vector2"
  63803. */
  63804. getClassName(): string;
  63805. /**
  63806. * Gets current vector hash code
  63807. * @returns the Vector2 hash code as a number
  63808. */
  63809. getHashCode(): number;
  63810. /**
  63811. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  63812. * @param array defines the source array
  63813. * @param index defines the offset in source array
  63814. * @returns the current Vector2
  63815. */
  63816. toArray(array: FloatArray, index?: number): Vector2;
  63817. /**
  63818. * Copy the current vector to an array
  63819. * @returns a new array with 2 elements: the Vector2 coordinates.
  63820. */
  63821. asArray(): number[];
  63822. /**
  63823. * Sets the Vector2 coordinates with the given Vector2 coordinates
  63824. * @param source defines the source Vector2
  63825. * @returns the current updated Vector2
  63826. */
  63827. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  63828. /**
  63829. * Sets the Vector2 coordinates with the given floats
  63830. * @param x defines the first coordinate
  63831. * @param y defines the second coordinate
  63832. * @returns the current updated Vector2
  63833. */
  63834. copyFromFloats(x: number, y: number): Vector2;
  63835. /**
  63836. * Sets the Vector2 coordinates with the given floats
  63837. * @param x defines the first coordinate
  63838. * @param y defines the second coordinate
  63839. * @returns the current updated Vector2
  63840. */
  63841. set(x: number, y: number): Vector2;
  63842. /**
  63843. * Add another vector with the current one
  63844. * @param otherVector defines the other vector
  63845. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  63846. */
  63847. add(otherVector: DeepImmutable<Vector2>): Vector2;
  63848. /**
  63849. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  63850. * @param otherVector defines the other vector
  63851. * @param result defines the target vector
  63852. * @returns the unmodified current Vector2
  63853. */
  63854. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  63855. /**
  63856. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  63857. * @param otherVector defines the other vector
  63858. * @returns the current updated Vector2
  63859. */
  63860. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  63861. /**
  63862. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  63863. * @param otherVector defines the other vector
  63864. * @returns a new Vector2
  63865. */
  63866. addVector3(otherVector: Vector3): Vector2;
  63867. /**
  63868. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  63869. * @param otherVector defines the other vector
  63870. * @returns a new Vector2
  63871. */
  63872. subtract(otherVector: Vector2): Vector2;
  63873. /**
  63874. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  63875. * @param otherVector defines the other vector
  63876. * @param result defines the target vector
  63877. * @returns the unmodified current Vector2
  63878. */
  63879. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  63880. /**
  63881. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  63882. * @param otherVector defines the other vector
  63883. * @returns the current updated Vector2
  63884. */
  63885. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  63886. /**
  63887. * Multiplies in place the current Vector2 coordinates by the given ones
  63888. * @param otherVector defines the other vector
  63889. * @returns the current updated Vector2
  63890. */
  63891. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  63892. /**
  63893. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  63894. * @param otherVector defines the other vector
  63895. * @returns a new Vector2
  63896. */
  63897. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  63898. /**
  63899. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  63900. * @param otherVector defines the other vector
  63901. * @param result defines the target vector
  63902. * @returns the unmodified current Vector2
  63903. */
  63904. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  63905. /**
  63906. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  63907. * @param x defines the first coordinate
  63908. * @param y defines the second coordinate
  63909. * @returns a new Vector2
  63910. */
  63911. multiplyByFloats(x: number, y: number): Vector2;
  63912. /**
  63913. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  63914. * @param otherVector defines the other vector
  63915. * @returns a new Vector2
  63916. */
  63917. divide(otherVector: Vector2): Vector2;
  63918. /**
  63919. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  63920. * @param otherVector defines the other vector
  63921. * @param result defines the target vector
  63922. * @returns the unmodified current Vector2
  63923. */
  63924. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  63925. /**
  63926. * Divides the current Vector2 coordinates by the given ones
  63927. * @param otherVector defines the other vector
  63928. * @returns the current updated Vector2
  63929. */
  63930. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  63931. /**
  63932. * Gets a new Vector2 with current Vector2 negated coordinates
  63933. * @returns a new Vector2
  63934. */
  63935. negate(): Vector2;
  63936. /**
  63937. * Multiply the Vector2 coordinates by scale
  63938. * @param scale defines the scaling factor
  63939. * @returns the current updated Vector2
  63940. */
  63941. scaleInPlace(scale: number): Vector2;
  63942. /**
  63943. * Returns a new Vector2 scaled by "scale" from the current Vector2
  63944. * @param scale defines the scaling factor
  63945. * @returns a new Vector2
  63946. */
  63947. scale(scale: number): Vector2;
  63948. /**
  63949. * Scale the current Vector2 values by a factor to a given Vector2
  63950. * @param scale defines the scale factor
  63951. * @param result defines the Vector2 object where to store the result
  63952. * @returns the unmodified current Vector2
  63953. */
  63954. scaleToRef(scale: number, result: Vector2): Vector2;
  63955. /**
  63956. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  63957. * @param scale defines the scale factor
  63958. * @param result defines the Vector2 object where to store the result
  63959. * @returns the unmodified current Vector2
  63960. */
  63961. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  63962. /**
  63963. * Gets a boolean if two vectors are equals
  63964. * @param otherVector defines the other vector
  63965. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  63966. */
  63967. equals(otherVector: DeepImmutable<Vector2>): boolean;
  63968. /**
  63969. * Gets a boolean if two vectors are equals (using an epsilon value)
  63970. * @param otherVector defines the other vector
  63971. * @param epsilon defines the minimal distance to consider equality
  63972. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  63973. */
  63974. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  63975. /**
  63976. * Gets a new Vector2 from current Vector2 floored values
  63977. * @returns a new Vector2
  63978. */
  63979. floor(): Vector2;
  63980. /**
  63981. * Gets a new Vector2 from current Vector2 floored values
  63982. * @returns a new Vector2
  63983. */
  63984. fract(): Vector2;
  63985. /**
  63986. * Gets the length of the vector
  63987. * @returns the vector length (float)
  63988. */
  63989. length(): number;
  63990. /**
  63991. * Gets the vector squared length
  63992. * @returns the vector squared length (float)
  63993. */
  63994. lengthSquared(): number;
  63995. /**
  63996. * Normalize the vector
  63997. * @returns the current updated Vector2
  63998. */
  63999. normalize(): Vector2;
  64000. /**
  64001. * Gets a new Vector2 copied from the Vector2
  64002. * @returns a new Vector2
  64003. */
  64004. clone(): Vector2;
  64005. /**
  64006. * Gets a new Vector2(0, 0)
  64007. * @returns a new Vector2
  64008. */
  64009. static Zero(): Vector2;
  64010. /**
  64011. * Gets a new Vector2(1, 1)
  64012. * @returns a new Vector2
  64013. */
  64014. static One(): Vector2;
  64015. /**
  64016. * Gets a new Vector2 set from the given index element of the given array
  64017. * @param array defines the data source
  64018. * @param offset defines the offset in the data source
  64019. * @returns a new Vector2
  64020. */
  64021. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  64022. /**
  64023. * Sets "result" from the given index element of the given array
  64024. * @param array defines the data source
  64025. * @param offset defines the offset in the data source
  64026. * @param result defines the target vector
  64027. */
  64028. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  64029. /**
  64030. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  64031. * @param value1 defines 1st point of control
  64032. * @param value2 defines 2nd point of control
  64033. * @param value3 defines 3rd point of control
  64034. * @param value4 defines 4th point of control
  64035. * @param amount defines the interpolation factor
  64036. * @returns a new Vector2
  64037. */
  64038. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  64039. /**
  64040. * 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".
  64041. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  64042. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  64043. * @param value defines the value to clamp
  64044. * @param min defines the lower limit
  64045. * @param max defines the upper limit
  64046. * @returns a new Vector2
  64047. */
  64048. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  64049. /**
  64050. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  64051. * @param value1 defines the 1st control point
  64052. * @param tangent1 defines the outgoing tangent
  64053. * @param value2 defines the 2nd control point
  64054. * @param tangent2 defines the incoming tangent
  64055. * @param amount defines the interpolation factor
  64056. * @returns a new Vector2
  64057. */
  64058. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  64059. /**
  64060. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  64061. * @param start defines the start vector
  64062. * @param end defines the end vector
  64063. * @param amount defines the interpolation factor
  64064. * @returns a new Vector2
  64065. */
  64066. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  64067. /**
  64068. * Gets the dot product of the vector "left" and the vector "right"
  64069. * @param left defines first vector
  64070. * @param right defines second vector
  64071. * @returns the dot product (float)
  64072. */
  64073. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  64074. /**
  64075. * Returns a new Vector2 equal to the normalized given vector
  64076. * @param vector defines the vector to normalize
  64077. * @returns a new Vector2
  64078. */
  64079. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  64080. /**
  64081. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  64082. * @param left defines 1st vector
  64083. * @param right defines 2nd vector
  64084. * @returns a new Vector2
  64085. */
  64086. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  64087. /**
  64088. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  64089. * @param left defines 1st vector
  64090. * @param right defines 2nd vector
  64091. * @returns a new Vector2
  64092. */
  64093. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  64094. /**
  64095. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  64096. * @param vector defines the vector to transform
  64097. * @param transformation defines the matrix to apply
  64098. * @returns a new Vector2
  64099. */
  64100. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  64101. /**
  64102. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  64103. * @param vector defines the vector to transform
  64104. * @param transformation defines the matrix to apply
  64105. * @param result defines the target vector
  64106. */
  64107. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  64108. /**
  64109. * Determines if a given vector is included in a triangle
  64110. * @param p defines the vector to test
  64111. * @param p0 defines 1st triangle point
  64112. * @param p1 defines 2nd triangle point
  64113. * @param p2 defines 3rd triangle point
  64114. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  64115. */
  64116. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  64117. /**
  64118. * Gets the distance between the vectors "value1" and "value2"
  64119. * @param value1 defines first vector
  64120. * @param value2 defines second vector
  64121. * @returns the distance between vectors
  64122. */
  64123. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  64124. /**
  64125. * Returns the squared distance between the vectors "value1" and "value2"
  64126. * @param value1 defines first vector
  64127. * @param value2 defines second vector
  64128. * @returns the squared distance between vectors
  64129. */
  64130. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  64131. /**
  64132. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  64133. * @param value1 defines first vector
  64134. * @param value2 defines second vector
  64135. * @returns a new Vector2
  64136. */
  64137. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  64138. /**
  64139. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  64140. * @param p defines the middle point
  64141. * @param segA defines one point of the segment
  64142. * @param segB defines the other point of the segment
  64143. * @returns the shortest distance
  64144. */
  64145. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  64146. }
  64147. /**
  64148. * Classed used to store (x,y,z) vector representation
  64149. * A Vector3 is the main object used in 3D geometry
  64150. * It can represent etiher the coordinates of a point the space, either a direction
  64151. * Reminder: js uses a left handed forward facing system
  64152. */
  64153. export class Vector3 {
  64154. /**
  64155. * Defines the first coordinates (on X axis)
  64156. */
  64157. x: number;
  64158. /**
  64159. * Defines the second coordinates (on Y axis)
  64160. */
  64161. y: number;
  64162. /**
  64163. * Defines the third coordinates (on Z axis)
  64164. */
  64165. z: number;
  64166. private static _UpReadOnly;
  64167. private static _ZeroReadOnly;
  64168. /**
  64169. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  64170. * @param x defines the first coordinates (on X axis)
  64171. * @param y defines the second coordinates (on Y axis)
  64172. * @param z defines the third coordinates (on Z axis)
  64173. */
  64174. constructor(
  64175. /**
  64176. * Defines the first coordinates (on X axis)
  64177. */
  64178. x?: number,
  64179. /**
  64180. * Defines the second coordinates (on Y axis)
  64181. */
  64182. y?: number,
  64183. /**
  64184. * Defines the third coordinates (on Z axis)
  64185. */
  64186. z?: number);
  64187. /**
  64188. * Creates a string representation of the Vector3
  64189. * @returns a string with the Vector3 coordinates.
  64190. */
  64191. toString(): string;
  64192. /**
  64193. * Gets the class name
  64194. * @returns the string "Vector3"
  64195. */
  64196. getClassName(): string;
  64197. /**
  64198. * Creates the Vector3 hash code
  64199. * @returns a number which tends to be unique between Vector3 instances
  64200. */
  64201. getHashCode(): number;
  64202. /**
  64203. * Creates an array containing three elements : the coordinates of the Vector3
  64204. * @returns a new array of numbers
  64205. */
  64206. asArray(): number[];
  64207. /**
  64208. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  64209. * @param array defines the destination array
  64210. * @param index defines the offset in the destination array
  64211. * @returns the current Vector3
  64212. */
  64213. toArray(array: FloatArray, index?: number): Vector3;
  64214. /**
  64215. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  64216. * @returns a new Quaternion object, computed from the Vector3 coordinates
  64217. */
  64218. toQuaternion(): Quaternion;
  64219. /**
  64220. * Adds the given vector to the current Vector3
  64221. * @param otherVector defines the second operand
  64222. * @returns the current updated Vector3
  64223. */
  64224. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  64225. /**
  64226. * Adds the given coordinates to the current Vector3
  64227. * @param x defines the x coordinate of the operand
  64228. * @param y defines the y coordinate of the operand
  64229. * @param z defines the z coordinate of the operand
  64230. * @returns the current updated Vector3
  64231. */
  64232. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  64233. /**
  64234. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  64235. * @param otherVector defines the second operand
  64236. * @returns the resulting Vector3
  64237. */
  64238. add(otherVector: DeepImmutable<Vector3>): Vector3;
  64239. /**
  64240. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  64241. * @param otherVector defines the second operand
  64242. * @param result defines the Vector3 object where to store the result
  64243. * @returns the current Vector3
  64244. */
  64245. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  64246. /**
  64247. * Subtract the given vector from the current Vector3
  64248. * @param otherVector defines the second operand
  64249. * @returns the current updated Vector3
  64250. */
  64251. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  64252. /**
  64253. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  64254. * @param otherVector defines the second operand
  64255. * @returns the resulting Vector3
  64256. */
  64257. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  64258. /**
  64259. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  64260. * @param otherVector defines the second operand
  64261. * @param result defines the Vector3 object where to store the result
  64262. * @returns the current Vector3
  64263. */
  64264. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  64265. /**
  64266. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  64267. * @param x defines the x coordinate of the operand
  64268. * @param y defines the y coordinate of the operand
  64269. * @param z defines the z coordinate of the operand
  64270. * @returns the resulting Vector3
  64271. */
  64272. subtractFromFloats(x: number, y: number, z: number): Vector3;
  64273. /**
  64274. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  64275. * @param x defines the x coordinate of the operand
  64276. * @param y defines the y coordinate of the operand
  64277. * @param z defines the z coordinate of the operand
  64278. * @param result defines the Vector3 object where to store the result
  64279. * @returns the current Vector3
  64280. */
  64281. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  64282. /**
  64283. * Gets a new Vector3 set with the current Vector3 negated coordinates
  64284. * @returns a new Vector3
  64285. */
  64286. negate(): Vector3;
  64287. /**
  64288. * Multiplies the Vector3 coordinates by the float "scale"
  64289. * @param scale defines the multiplier factor
  64290. * @returns the current updated Vector3
  64291. */
  64292. scaleInPlace(scale: number): Vector3;
  64293. /**
  64294. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  64295. * @param scale defines the multiplier factor
  64296. * @returns a new Vector3
  64297. */
  64298. scale(scale: number): Vector3;
  64299. /**
  64300. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  64301. * @param scale defines the multiplier factor
  64302. * @param result defines the Vector3 object where to store the result
  64303. * @returns the current Vector3
  64304. */
  64305. scaleToRef(scale: number, result: Vector3): Vector3;
  64306. /**
  64307. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  64308. * @param scale defines the scale factor
  64309. * @param result defines the Vector3 object where to store the result
  64310. * @returns the unmodified current Vector3
  64311. */
  64312. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  64313. /**
  64314. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  64315. * @param otherVector defines the second operand
  64316. * @returns true if both vectors are equals
  64317. */
  64318. equals(otherVector: DeepImmutable<Vector3>): boolean;
  64319. /**
  64320. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  64321. * @param otherVector defines the second operand
  64322. * @param epsilon defines the minimal distance to define values as equals
  64323. * @returns true if both vectors are distant less than epsilon
  64324. */
  64325. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  64326. /**
  64327. * Returns true if the current Vector3 coordinates equals the given floats
  64328. * @param x defines the x coordinate of the operand
  64329. * @param y defines the y coordinate of the operand
  64330. * @param z defines the z coordinate of the operand
  64331. * @returns true if both vectors are equals
  64332. */
  64333. equalsToFloats(x: number, y: number, z: number): boolean;
  64334. /**
  64335. * Multiplies the current Vector3 coordinates by the given ones
  64336. * @param otherVector defines the second operand
  64337. * @returns the current updated Vector3
  64338. */
  64339. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  64340. /**
  64341. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  64342. * @param otherVector defines the second operand
  64343. * @returns the new Vector3
  64344. */
  64345. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  64346. /**
  64347. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  64348. * @param otherVector defines the second operand
  64349. * @param result defines the Vector3 object where to store the result
  64350. * @returns the current Vector3
  64351. */
  64352. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  64353. /**
  64354. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  64355. * @param x defines the x coordinate of the operand
  64356. * @param y defines the y coordinate of the operand
  64357. * @param z defines the z coordinate of the operand
  64358. * @returns the new Vector3
  64359. */
  64360. multiplyByFloats(x: number, y: number, z: number): Vector3;
  64361. /**
  64362. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  64363. * @param otherVector defines the second operand
  64364. * @returns the new Vector3
  64365. */
  64366. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  64367. /**
  64368. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  64369. * @param otherVector defines the second operand
  64370. * @param result defines the Vector3 object where to store the result
  64371. * @returns the current Vector3
  64372. */
  64373. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  64374. /**
  64375. * Divides the current Vector3 coordinates by the given ones.
  64376. * @param otherVector defines the second operand
  64377. * @returns the current updated Vector3
  64378. */
  64379. divideInPlace(otherVector: Vector3): Vector3;
  64380. /**
  64381. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  64382. * @param other defines the second operand
  64383. * @returns the current updated Vector3
  64384. */
  64385. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  64386. /**
  64387. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  64388. * @param other defines the second operand
  64389. * @returns the current updated Vector3
  64390. */
  64391. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  64392. /**
  64393. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  64394. * @param x defines the x coordinate of the operand
  64395. * @param y defines the y coordinate of the operand
  64396. * @param z defines the z coordinate of the operand
  64397. * @returns the current updated Vector3
  64398. */
  64399. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  64400. /**
  64401. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  64402. * @param x defines the x coordinate of the operand
  64403. * @param y defines the y coordinate of the operand
  64404. * @param z defines the z coordinate of the operand
  64405. * @returns the current updated Vector3
  64406. */
  64407. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  64408. /**
  64409. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  64410. * Check if is non uniform within a certain amount of decimal places to account for this
  64411. * @param epsilon the amount the values can differ
  64412. * @returns if the the vector is non uniform to a certain number of decimal places
  64413. */
  64414. isNonUniformWithinEpsilon(epsilon: number): boolean;
  64415. /**
  64416. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  64417. */
  64418. readonly isNonUniform: boolean;
  64419. /**
  64420. * Gets a new Vector3 from current Vector3 floored values
  64421. * @returns a new Vector3
  64422. */
  64423. floor(): Vector3;
  64424. /**
  64425. * Gets a new Vector3 from current Vector3 floored values
  64426. * @returns a new Vector3
  64427. */
  64428. fract(): Vector3;
  64429. /**
  64430. * Gets the length of the Vector3
  64431. * @returns the length of the Vector3
  64432. */
  64433. length(): number;
  64434. /**
  64435. * Gets the squared length of the Vector3
  64436. * @returns squared length of the Vector3
  64437. */
  64438. lengthSquared(): number;
  64439. /**
  64440. * Normalize the current Vector3.
  64441. * Please note that this is an in place operation.
  64442. * @returns the current updated Vector3
  64443. */
  64444. normalize(): Vector3;
  64445. /**
  64446. * Reorders the x y z properties of the vector in place
  64447. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  64448. * @returns the current updated vector
  64449. */
  64450. reorderInPlace(order: string): this;
  64451. /**
  64452. * Rotates the vector around 0,0,0 by a quaternion
  64453. * @param quaternion the rotation quaternion
  64454. * @param result vector to store the result
  64455. * @returns the resulting vector
  64456. */
  64457. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  64458. /**
  64459. * Rotates a vector around a given point
  64460. * @param quaternion the rotation quaternion
  64461. * @param point the point to rotate around
  64462. * @param result vector to store the result
  64463. * @returns the resulting vector
  64464. */
  64465. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  64466. /**
  64467. * Normalize the current Vector3 with the given input length.
  64468. * Please note that this is an in place operation.
  64469. * @param len the length of the vector
  64470. * @returns the current updated Vector3
  64471. */
  64472. normalizeFromLength(len: number): Vector3;
  64473. /**
  64474. * Normalize the current Vector3 to a new vector
  64475. * @returns the new Vector3
  64476. */
  64477. normalizeToNew(): Vector3;
  64478. /**
  64479. * Normalize the current Vector3 to the reference
  64480. * @param reference define the Vector3 to update
  64481. * @returns the updated Vector3
  64482. */
  64483. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  64484. /**
  64485. * Creates a new Vector3 copied from the current Vector3
  64486. * @returns the new Vector3
  64487. */
  64488. clone(): Vector3;
  64489. /**
  64490. * Copies the given vector coordinates to the current Vector3 ones
  64491. * @param source defines the source Vector3
  64492. * @returns the current updated Vector3
  64493. */
  64494. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  64495. /**
  64496. * Copies the given floats to the current Vector3 coordinates
  64497. * @param x defines the x coordinate of the operand
  64498. * @param y defines the y coordinate of the operand
  64499. * @param z defines the z coordinate of the operand
  64500. * @returns the current updated Vector3
  64501. */
  64502. copyFromFloats(x: number, y: number, z: number): Vector3;
  64503. /**
  64504. * Copies the given floats to the current Vector3 coordinates
  64505. * @param x defines the x coordinate of the operand
  64506. * @param y defines the y coordinate of the operand
  64507. * @param z defines the z coordinate of the operand
  64508. * @returns the current updated Vector3
  64509. */
  64510. set(x: number, y: number, z: number): Vector3;
  64511. /**
  64512. * Copies the given float to the current Vector3 coordinates
  64513. * @param v defines the x, y and z coordinates of the operand
  64514. * @returns the current updated Vector3
  64515. */
  64516. setAll(v: number): Vector3;
  64517. /**
  64518. * Get the clip factor between two vectors
  64519. * @param vector0 defines the first operand
  64520. * @param vector1 defines the second operand
  64521. * @param axis defines the axis to use
  64522. * @param size defines the size along the axis
  64523. * @returns the clip factor
  64524. */
  64525. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  64526. /**
  64527. * Get angle between two vectors
  64528. * @param vector0 angle between vector0 and vector1
  64529. * @param vector1 angle between vector0 and vector1
  64530. * @param normal direction of the normal
  64531. * @return the angle between vector0 and vector1
  64532. */
  64533. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  64534. /**
  64535. * Returns a new Vector3 set from the index "offset" of the given array
  64536. * @param array defines the source array
  64537. * @param offset defines the offset in the source array
  64538. * @returns the new Vector3
  64539. */
  64540. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  64541. /**
  64542. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  64543. * This function is deprecated. Use FromArray instead
  64544. * @param array defines the source array
  64545. * @param offset defines the offset in the source array
  64546. * @returns the new Vector3
  64547. */
  64548. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  64549. /**
  64550. * Sets the given vector "result" with the element values from the index "offset" of the given array
  64551. * @param array defines the source array
  64552. * @param offset defines the offset in the source array
  64553. * @param result defines the Vector3 where to store the result
  64554. */
  64555. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  64556. /**
  64557. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  64558. * This function is deprecated. Use FromArrayToRef instead.
  64559. * @param array defines the source array
  64560. * @param offset defines the offset in the source array
  64561. * @param result defines the Vector3 where to store the result
  64562. */
  64563. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  64564. /**
  64565. * Sets the given vector "result" with the given floats.
  64566. * @param x defines the x coordinate of the source
  64567. * @param y defines the y coordinate of the source
  64568. * @param z defines the z coordinate of the source
  64569. * @param result defines the Vector3 where to store the result
  64570. */
  64571. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  64572. /**
  64573. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  64574. * @returns a new empty Vector3
  64575. */
  64576. static Zero(): Vector3;
  64577. /**
  64578. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  64579. * @returns a new unit Vector3
  64580. */
  64581. static One(): Vector3;
  64582. /**
  64583. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  64584. * @returns a new up Vector3
  64585. */
  64586. static Up(): Vector3;
  64587. /**
  64588. * Gets a up Vector3 that must not be updated
  64589. */
  64590. static readonly UpReadOnly: DeepImmutable<Vector3>;
  64591. /**
  64592. * Gets a zero Vector3 that must not be updated
  64593. */
  64594. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  64595. /**
  64596. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  64597. * @returns a new down Vector3
  64598. */
  64599. static Down(): Vector3;
  64600. /**
  64601. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  64602. * @returns a new forward Vector3
  64603. */
  64604. static Forward(): Vector3;
  64605. /**
  64606. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  64607. * @returns a new forward Vector3
  64608. */
  64609. static Backward(): Vector3;
  64610. /**
  64611. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  64612. * @returns a new right Vector3
  64613. */
  64614. static Right(): Vector3;
  64615. /**
  64616. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  64617. * @returns a new left Vector3
  64618. */
  64619. static Left(): Vector3;
  64620. /**
  64621. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  64622. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  64623. * @param vector defines the Vector3 to transform
  64624. * @param transformation defines the transformation matrix
  64625. * @returns the transformed Vector3
  64626. */
  64627. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  64628. /**
  64629. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  64630. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  64631. * @param vector defines the Vector3 to transform
  64632. * @param transformation defines the transformation matrix
  64633. * @param result defines the Vector3 where to store the result
  64634. */
  64635. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  64636. /**
  64637. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  64638. * This method computes tranformed coordinates only, not transformed direction vectors
  64639. * @param x define the x coordinate of the source vector
  64640. * @param y define the y coordinate of the source vector
  64641. * @param z define the z coordinate of the source vector
  64642. * @param transformation defines the transformation matrix
  64643. * @param result defines the Vector3 where to store the result
  64644. */
  64645. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  64646. /**
  64647. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  64648. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  64649. * @param vector defines the Vector3 to transform
  64650. * @param transformation defines the transformation matrix
  64651. * @returns the new Vector3
  64652. */
  64653. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  64654. /**
  64655. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  64656. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  64657. * @param vector defines the Vector3 to transform
  64658. * @param transformation defines the transformation matrix
  64659. * @param result defines the Vector3 where to store the result
  64660. */
  64661. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  64662. /**
  64663. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  64664. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  64665. * @param x define the x coordinate of the source vector
  64666. * @param y define the y coordinate of the source vector
  64667. * @param z define the z coordinate of the source vector
  64668. * @param transformation defines the transformation matrix
  64669. * @param result defines the Vector3 where to store the result
  64670. */
  64671. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  64672. /**
  64673. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  64674. * @param value1 defines the first control point
  64675. * @param value2 defines the second control point
  64676. * @param value3 defines the third control point
  64677. * @param value4 defines the fourth control point
  64678. * @param amount defines the amount on the spline to use
  64679. * @returns the new Vector3
  64680. */
  64681. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  64682. /**
  64683. * 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"
  64684. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  64685. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  64686. * @param value defines the current value
  64687. * @param min defines the lower range value
  64688. * @param max defines the upper range value
  64689. * @returns the new Vector3
  64690. */
  64691. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  64692. /**
  64693. * 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"
  64694. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  64695. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  64696. * @param value defines the current value
  64697. * @param min defines the lower range value
  64698. * @param max defines the upper range value
  64699. * @param result defines the Vector3 where to store the result
  64700. */
  64701. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  64702. /**
  64703. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  64704. * @param value1 defines the first control point
  64705. * @param tangent1 defines the first tangent vector
  64706. * @param value2 defines the second control point
  64707. * @param tangent2 defines the second tangent vector
  64708. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  64709. * @returns the new Vector3
  64710. */
  64711. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  64712. /**
  64713. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  64714. * @param start defines the start value
  64715. * @param end defines the end value
  64716. * @param amount max defines amount between both (between 0 and 1)
  64717. * @returns the new Vector3
  64718. */
  64719. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  64720. /**
  64721. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  64722. * @param start defines the start value
  64723. * @param end defines the end value
  64724. * @param amount max defines amount between both (between 0 and 1)
  64725. * @param result defines the Vector3 where to store the result
  64726. */
  64727. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  64728. /**
  64729. * Returns the dot product (float) between the vectors "left" and "right"
  64730. * @param left defines the left operand
  64731. * @param right defines the right operand
  64732. * @returns the dot product
  64733. */
  64734. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  64735. /**
  64736. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  64737. * The cross product is then orthogonal to both "left" and "right"
  64738. * @param left defines the left operand
  64739. * @param right defines the right operand
  64740. * @returns the cross product
  64741. */
  64742. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  64743. /**
  64744. * Sets the given vector "result" with the cross product of "left" and "right"
  64745. * The cross product is then orthogonal to both "left" and "right"
  64746. * @param left defines the left operand
  64747. * @param right defines the right operand
  64748. * @param result defines the Vector3 where to store the result
  64749. */
  64750. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  64751. /**
  64752. * Returns a new Vector3 as the normalization of the given vector
  64753. * @param vector defines the Vector3 to normalize
  64754. * @returns the new Vector3
  64755. */
  64756. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  64757. /**
  64758. * Sets the given vector "result" with the normalization of the given first vector
  64759. * @param vector defines the Vector3 to normalize
  64760. * @param result defines the Vector3 where to store the result
  64761. */
  64762. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  64763. /**
  64764. * Project a Vector3 onto screen space
  64765. * @param vector defines the Vector3 to project
  64766. * @param world defines the world matrix to use
  64767. * @param transform defines the transform (view x projection) matrix to use
  64768. * @param viewport defines the screen viewport to use
  64769. * @returns the new Vector3
  64770. */
  64771. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  64772. /** @hidden */
  64773. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  64774. /**
  64775. * Unproject from screen space to object space
  64776. * @param source defines the screen space Vector3 to use
  64777. * @param viewportWidth defines the current width of the viewport
  64778. * @param viewportHeight defines the current height of the viewport
  64779. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  64780. * @param transform defines the transform (view x projection) matrix to use
  64781. * @returns the new Vector3
  64782. */
  64783. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  64784. /**
  64785. * Unproject from screen space to object space
  64786. * @param source defines the screen space Vector3 to use
  64787. * @param viewportWidth defines the current width of the viewport
  64788. * @param viewportHeight defines the current height of the viewport
  64789. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  64790. * @param view defines the view matrix to use
  64791. * @param projection defines the projection matrix to use
  64792. * @returns the new Vector3
  64793. */
  64794. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  64795. /**
  64796. * Unproject from screen space to object space
  64797. * @param source defines the screen space Vector3 to use
  64798. * @param viewportWidth defines the current width of the viewport
  64799. * @param viewportHeight defines the current height of the viewport
  64800. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  64801. * @param view defines the view matrix to use
  64802. * @param projection defines the projection matrix to use
  64803. * @param result defines the Vector3 where to store the result
  64804. */
  64805. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  64806. /**
  64807. * Unproject from screen space to object space
  64808. * @param sourceX defines the screen space x coordinate to use
  64809. * @param sourceY defines the screen space y coordinate to use
  64810. * @param sourceZ defines the screen space z coordinate to use
  64811. * @param viewportWidth defines the current width of the viewport
  64812. * @param viewportHeight defines the current height of the viewport
  64813. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  64814. * @param view defines the view matrix to use
  64815. * @param projection defines the projection matrix to use
  64816. * @param result defines the Vector3 where to store the result
  64817. */
  64818. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  64819. /**
  64820. * Gets the minimal coordinate values between two Vector3
  64821. * @param left defines the first operand
  64822. * @param right defines the second operand
  64823. * @returns the new Vector3
  64824. */
  64825. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  64826. /**
  64827. * Gets the maximal coordinate values between two Vector3
  64828. * @param left defines the first operand
  64829. * @param right defines the second operand
  64830. * @returns the new Vector3
  64831. */
  64832. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  64833. /**
  64834. * Returns the distance between the vectors "value1" and "value2"
  64835. * @param value1 defines the first operand
  64836. * @param value2 defines the second operand
  64837. * @returns the distance
  64838. */
  64839. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  64840. /**
  64841. * Returns the squared distance between the vectors "value1" and "value2"
  64842. * @param value1 defines the first operand
  64843. * @param value2 defines the second operand
  64844. * @returns the squared distance
  64845. */
  64846. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  64847. /**
  64848. * Returns a new Vector3 located at the center between "value1" and "value2"
  64849. * @param value1 defines the first operand
  64850. * @param value2 defines the second operand
  64851. * @returns the new Vector3
  64852. */
  64853. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  64854. /**
  64855. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  64856. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  64857. * to something in order to rotate it from its local system to the given target system
  64858. * Note: axis1, axis2 and axis3 are normalized during this operation
  64859. * @param axis1 defines the first axis
  64860. * @param axis2 defines the second axis
  64861. * @param axis3 defines the third axis
  64862. * @returns a new Vector3
  64863. */
  64864. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  64865. /**
  64866. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  64867. * @param axis1 defines the first axis
  64868. * @param axis2 defines the second axis
  64869. * @param axis3 defines the third axis
  64870. * @param ref defines the Vector3 where to store the result
  64871. */
  64872. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  64873. }
  64874. /**
  64875. * Vector4 class created for EulerAngle class conversion to Quaternion
  64876. */
  64877. export class Vector4 {
  64878. /** x value of the vector */
  64879. x: number;
  64880. /** y value of the vector */
  64881. y: number;
  64882. /** z value of the vector */
  64883. z: number;
  64884. /** w value of the vector */
  64885. w: number;
  64886. /**
  64887. * Creates a Vector4 object from the given floats.
  64888. * @param x x value of the vector
  64889. * @param y y value of the vector
  64890. * @param z z value of the vector
  64891. * @param w w value of the vector
  64892. */
  64893. constructor(
  64894. /** x value of the vector */
  64895. x: number,
  64896. /** y value of the vector */
  64897. y: number,
  64898. /** z value of the vector */
  64899. z: number,
  64900. /** w value of the vector */
  64901. w: number);
  64902. /**
  64903. * Returns the string with the Vector4 coordinates.
  64904. * @returns a string containing all the vector values
  64905. */
  64906. toString(): string;
  64907. /**
  64908. * Returns the string "Vector4".
  64909. * @returns "Vector4"
  64910. */
  64911. getClassName(): string;
  64912. /**
  64913. * Returns the Vector4 hash code.
  64914. * @returns a unique hash code
  64915. */
  64916. getHashCode(): number;
  64917. /**
  64918. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  64919. * @returns the resulting array
  64920. */
  64921. asArray(): number[];
  64922. /**
  64923. * Populates the given array from the given index with the Vector4 coordinates.
  64924. * @param array array to populate
  64925. * @param index index of the array to start at (default: 0)
  64926. * @returns the Vector4.
  64927. */
  64928. toArray(array: FloatArray, index?: number): Vector4;
  64929. /**
  64930. * Adds the given vector to the current Vector4.
  64931. * @param otherVector the vector to add
  64932. * @returns the updated Vector4.
  64933. */
  64934. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  64935. /**
  64936. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  64937. * @param otherVector the vector to add
  64938. * @returns the resulting vector
  64939. */
  64940. add(otherVector: DeepImmutable<Vector4>): Vector4;
  64941. /**
  64942. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  64943. * @param otherVector the vector to add
  64944. * @param result the vector to store the result
  64945. * @returns the current Vector4.
  64946. */
  64947. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  64948. /**
  64949. * Subtract in place the given vector from the current Vector4.
  64950. * @param otherVector the vector to subtract
  64951. * @returns the updated Vector4.
  64952. */
  64953. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  64954. /**
  64955. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  64956. * @param otherVector the vector to add
  64957. * @returns the new vector with the result
  64958. */
  64959. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  64960. /**
  64961. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  64962. * @param otherVector the vector to subtract
  64963. * @param result the vector to store the result
  64964. * @returns the current Vector4.
  64965. */
  64966. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  64967. /**
  64968. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  64969. */
  64970. /**
  64971. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  64972. * @param x value to subtract
  64973. * @param y value to subtract
  64974. * @param z value to subtract
  64975. * @param w value to subtract
  64976. * @returns new vector containing the result
  64977. */
  64978. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  64979. /**
  64980. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  64981. * @param x value to subtract
  64982. * @param y value to subtract
  64983. * @param z value to subtract
  64984. * @param w value to subtract
  64985. * @param result the vector to store the result in
  64986. * @returns the current Vector4.
  64987. */
  64988. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  64989. /**
  64990. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  64991. * @returns a new vector with the negated values
  64992. */
  64993. negate(): Vector4;
  64994. /**
  64995. * Multiplies the current Vector4 coordinates by scale (float).
  64996. * @param scale the number to scale with
  64997. * @returns the updated Vector4.
  64998. */
  64999. scaleInPlace(scale: number): Vector4;
  65000. /**
  65001. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  65002. * @param scale the number to scale with
  65003. * @returns a new vector with the result
  65004. */
  65005. scale(scale: number): Vector4;
  65006. /**
  65007. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  65008. * @param scale the number to scale with
  65009. * @param result a vector to store the result in
  65010. * @returns the current Vector4.
  65011. */
  65012. scaleToRef(scale: number, result: Vector4): Vector4;
  65013. /**
  65014. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  65015. * @param scale defines the scale factor
  65016. * @param result defines the Vector4 object where to store the result
  65017. * @returns the unmodified current Vector4
  65018. */
  65019. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  65020. /**
  65021. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  65022. * @param otherVector the vector to compare against
  65023. * @returns true if they are equal
  65024. */
  65025. equals(otherVector: DeepImmutable<Vector4>): boolean;
  65026. /**
  65027. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  65028. * @param otherVector vector to compare against
  65029. * @param epsilon (Default: very small number)
  65030. * @returns true if they are equal
  65031. */
  65032. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  65033. /**
  65034. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  65035. * @param x x value to compare against
  65036. * @param y y value to compare against
  65037. * @param z z value to compare against
  65038. * @param w w value to compare against
  65039. * @returns true if equal
  65040. */
  65041. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  65042. /**
  65043. * Multiplies in place the current Vector4 by the given one.
  65044. * @param otherVector vector to multiple with
  65045. * @returns the updated Vector4.
  65046. */
  65047. multiplyInPlace(otherVector: Vector4): Vector4;
  65048. /**
  65049. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  65050. * @param otherVector vector to multiple with
  65051. * @returns resulting new vector
  65052. */
  65053. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  65054. /**
  65055. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  65056. * @param otherVector vector to multiple with
  65057. * @param result vector to store the result
  65058. * @returns the current Vector4.
  65059. */
  65060. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  65061. /**
  65062. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  65063. * @param x x value multiply with
  65064. * @param y y value multiply with
  65065. * @param z z value multiply with
  65066. * @param w w value multiply with
  65067. * @returns resulting new vector
  65068. */
  65069. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  65070. /**
  65071. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  65072. * @param otherVector vector to devide with
  65073. * @returns resulting new vector
  65074. */
  65075. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  65076. /**
  65077. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  65078. * @param otherVector vector to devide with
  65079. * @param result vector to store the result
  65080. * @returns the current Vector4.
  65081. */
  65082. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  65083. /**
  65084. * Divides the current Vector3 coordinates by the given ones.
  65085. * @param otherVector vector to devide with
  65086. * @returns the updated Vector3.
  65087. */
  65088. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  65089. /**
  65090. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  65091. * @param other defines the second operand
  65092. * @returns the current updated Vector4
  65093. */
  65094. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  65095. /**
  65096. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  65097. * @param other defines the second operand
  65098. * @returns the current updated Vector4
  65099. */
  65100. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  65101. /**
  65102. * Gets a new Vector4 from current Vector4 floored values
  65103. * @returns a new Vector4
  65104. */
  65105. floor(): Vector4;
  65106. /**
  65107. * Gets a new Vector4 from current Vector3 floored values
  65108. * @returns a new Vector4
  65109. */
  65110. fract(): Vector4;
  65111. /**
  65112. * Returns the Vector4 length (float).
  65113. * @returns the length
  65114. */
  65115. length(): number;
  65116. /**
  65117. * Returns the Vector4 squared length (float).
  65118. * @returns the length squared
  65119. */
  65120. lengthSquared(): number;
  65121. /**
  65122. * Normalizes in place the Vector4.
  65123. * @returns the updated Vector4.
  65124. */
  65125. normalize(): Vector4;
  65126. /**
  65127. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  65128. * @returns this converted to a new vector3
  65129. */
  65130. toVector3(): Vector3;
  65131. /**
  65132. * Returns a new Vector4 copied from the current one.
  65133. * @returns the new cloned vector
  65134. */
  65135. clone(): Vector4;
  65136. /**
  65137. * Updates the current Vector4 with the given one coordinates.
  65138. * @param source the source vector to copy from
  65139. * @returns the updated Vector4.
  65140. */
  65141. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  65142. /**
  65143. * Updates the current Vector4 coordinates with the given floats.
  65144. * @param x float to copy from
  65145. * @param y float to copy from
  65146. * @param z float to copy from
  65147. * @param w float to copy from
  65148. * @returns the updated Vector4.
  65149. */
  65150. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  65151. /**
  65152. * Updates the current Vector4 coordinates with the given floats.
  65153. * @param x float to set from
  65154. * @param y float to set from
  65155. * @param z float to set from
  65156. * @param w float to set from
  65157. * @returns the updated Vector4.
  65158. */
  65159. set(x: number, y: number, z: number, w: number): Vector4;
  65160. /**
  65161. * Copies the given float to the current Vector3 coordinates
  65162. * @param v defines the x, y, z and w coordinates of the operand
  65163. * @returns the current updated Vector3
  65164. */
  65165. setAll(v: number): Vector4;
  65166. /**
  65167. * Returns a new Vector4 set from the starting index of the given array.
  65168. * @param array the array to pull values from
  65169. * @param offset the offset into the array to start at
  65170. * @returns the new vector
  65171. */
  65172. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  65173. /**
  65174. * Updates the given vector "result" from the starting index of the given array.
  65175. * @param array the array to pull values from
  65176. * @param offset the offset into the array to start at
  65177. * @param result the vector to store the result in
  65178. */
  65179. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  65180. /**
  65181. * Updates the given vector "result" from the starting index of the given Float32Array.
  65182. * @param array the array to pull values from
  65183. * @param offset the offset into the array to start at
  65184. * @param result the vector to store the result in
  65185. */
  65186. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  65187. /**
  65188. * Updates the given vector "result" coordinates from the given floats.
  65189. * @param x float to set from
  65190. * @param y float to set from
  65191. * @param z float to set from
  65192. * @param w float to set from
  65193. * @param result the vector to the floats in
  65194. */
  65195. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  65196. /**
  65197. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  65198. * @returns the new vector
  65199. */
  65200. static Zero(): Vector4;
  65201. /**
  65202. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  65203. * @returns the new vector
  65204. */
  65205. static One(): Vector4;
  65206. /**
  65207. * Returns a new normalized Vector4 from the given one.
  65208. * @param vector the vector to normalize
  65209. * @returns the vector
  65210. */
  65211. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  65212. /**
  65213. * Updates the given vector "result" from the normalization of the given one.
  65214. * @param vector the vector to normalize
  65215. * @param result the vector to store the result in
  65216. */
  65217. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  65218. /**
  65219. * Returns a vector with the minimum values from the left and right vectors
  65220. * @param left left vector to minimize
  65221. * @param right right vector to minimize
  65222. * @returns a new vector with the minimum of the left and right vector values
  65223. */
  65224. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  65225. /**
  65226. * Returns a vector with the maximum values from the left and right vectors
  65227. * @param left left vector to maximize
  65228. * @param right right vector to maximize
  65229. * @returns a new vector with the maximum of the left and right vector values
  65230. */
  65231. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  65232. /**
  65233. * Returns the distance (float) between the vectors "value1" and "value2".
  65234. * @param value1 value to calulate the distance between
  65235. * @param value2 value to calulate the distance between
  65236. * @return the distance between the two vectors
  65237. */
  65238. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  65239. /**
  65240. * Returns the squared distance (float) between the vectors "value1" and "value2".
  65241. * @param value1 value to calulate the distance between
  65242. * @param value2 value to calulate the distance between
  65243. * @return the distance between the two vectors squared
  65244. */
  65245. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  65246. /**
  65247. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  65248. * @param value1 value to calulate the center between
  65249. * @param value2 value to calulate the center between
  65250. * @return the center between the two vectors
  65251. */
  65252. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  65253. /**
  65254. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  65255. * This methods computes transformed normalized direction vectors only.
  65256. * @param vector the vector to transform
  65257. * @param transformation the transformation matrix to apply
  65258. * @returns the new vector
  65259. */
  65260. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  65261. /**
  65262. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  65263. * This methods computes transformed normalized direction vectors only.
  65264. * @param vector the vector to transform
  65265. * @param transformation the transformation matrix to apply
  65266. * @param result the vector to store the result in
  65267. */
  65268. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  65269. /**
  65270. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  65271. * This methods computes transformed normalized direction vectors only.
  65272. * @param x value to transform
  65273. * @param y value to transform
  65274. * @param z value to transform
  65275. * @param w value to transform
  65276. * @param transformation the transformation matrix to apply
  65277. * @param result the vector to store the results in
  65278. */
  65279. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  65280. /**
  65281. * Creates a new Vector4 from a Vector3
  65282. * @param source defines the source data
  65283. * @param w defines the 4th component (default is 0)
  65284. * @returns a new Vector4
  65285. */
  65286. static FromVector3(source: Vector3, w?: number): Vector4;
  65287. }
  65288. /**
  65289. * Interface for the size containing width and height
  65290. */
  65291. export interface ISize {
  65292. /**
  65293. * Width
  65294. */
  65295. width: number;
  65296. /**
  65297. * Heighht
  65298. */
  65299. height: number;
  65300. }
  65301. /**
  65302. * Size containing widht and height
  65303. */
  65304. export class Size implements ISize {
  65305. /**
  65306. * Width
  65307. */
  65308. width: number;
  65309. /**
  65310. * Height
  65311. */
  65312. height: number;
  65313. /**
  65314. * Creates a Size object from the given width and height (floats).
  65315. * @param width width of the new size
  65316. * @param height height of the new size
  65317. */
  65318. constructor(width: number, height: number);
  65319. /**
  65320. * Returns a string with the Size width and height
  65321. * @returns a string with the Size width and height
  65322. */
  65323. toString(): string;
  65324. /**
  65325. * "Size"
  65326. * @returns the string "Size"
  65327. */
  65328. getClassName(): string;
  65329. /**
  65330. * Returns the Size hash code.
  65331. * @returns a hash code for a unique width and height
  65332. */
  65333. getHashCode(): number;
  65334. /**
  65335. * Updates the current size from the given one.
  65336. * @param src the given size
  65337. */
  65338. copyFrom(src: Size): void;
  65339. /**
  65340. * Updates in place the current Size from the given floats.
  65341. * @param width width of the new size
  65342. * @param height height of the new size
  65343. * @returns the updated Size.
  65344. */
  65345. copyFromFloats(width: number, height: number): Size;
  65346. /**
  65347. * Updates in place the current Size from the given floats.
  65348. * @param width width to set
  65349. * @param height height to set
  65350. * @returns the updated Size.
  65351. */
  65352. set(width: number, height: number): Size;
  65353. /**
  65354. * Multiplies the width and height by numbers
  65355. * @param w factor to multiple the width by
  65356. * @param h factor to multiple the height by
  65357. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  65358. */
  65359. multiplyByFloats(w: number, h: number): Size;
  65360. /**
  65361. * Clones the size
  65362. * @returns a new Size copied from the given one.
  65363. */
  65364. clone(): Size;
  65365. /**
  65366. * True if the current Size and the given one width and height are strictly equal.
  65367. * @param other the other size to compare against
  65368. * @returns True if the current Size and the given one width and height are strictly equal.
  65369. */
  65370. equals(other: Size): boolean;
  65371. /**
  65372. * The surface of the Size : width * height (float).
  65373. */
  65374. readonly surface: number;
  65375. /**
  65376. * Create a new size of zero
  65377. * @returns a new Size set to (0.0, 0.0)
  65378. */
  65379. static Zero(): Size;
  65380. /**
  65381. * Sums the width and height of two sizes
  65382. * @param otherSize size to add to this size
  65383. * @returns a new Size set as the addition result of the current Size and the given one.
  65384. */
  65385. add(otherSize: Size): Size;
  65386. /**
  65387. * Subtracts the width and height of two
  65388. * @param otherSize size to subtract to this size
  65389. * @returns a new Size set as the subtraction result of the given one from the current Size.
  65390. */
  65391. subtract(otherSize: Size): Size;
  65392. /**
  65393. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  65394. * @param start starting size to lerp between
  65395. * @param end end size to lerp between
  65396. * @param amount amount to lerp between the start and end values
  65397. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  65398. */
  65399. static Lerp(start: Size, end: Size, amount: number): Size;
  65400. }
  65401. /**
  65402. * Class used to store quaternion data
  65403. * @see https://en.wikipedia.org/wiki/Quaternion
  65404. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  65405. */
  65406. export class Quaternion {
  65407. /** defines the first component (0 by default) */
  65408. x: number;
  65409. /** defines the second component (0 by default) */
  65410. y: number;
  65411. /** defines the third component (0 by default) */
  65412. z: number;
  65413. /** defines the fourth component (1.0 by default) */
  65414. w: number;
  65415. /**
  65416. * Creates a new Quaternion from the given floats
  65417. * @param x defines the first component (0 by default)
  65418. * @param y defines the second component (0 by default)
  65419. * @param z defines the third component (0 by default)
  65420. * @param w defines the fourth component (1.0 by default)
  65421. */
  65422. constructor(
  65423. /** defines the first component (0 by default) */
  65424. x?: number,
  65425. /** defines the second component (0 by default) */
  65426. y?: number,
  65427. /** defines the third component (0 by default) */
  65428. z?: number,
  65429. /** defines the fourth component (1.0 by default) */
  65430. w?: number);
  65431. /**
  65432. * Gets a string representation for the current quaternion
  65433. * @returns a string with the Quaternion coordinates
  65434. */
  65435. toString(): string;
  65436. /**
  65437. * Gets the class name of the quaternion
  65438. * @returns the string "Quaternion"
  65439. */
  65440. getClassName(): string;
  65441. /**
  65442. * Gets a hash code for this quaternion
  65443. * @returns the quaternion hash code
  65444. */
  65445. getHashCode(): number;
  65446. /**
  65447. * Copy the quaternion to an array
  65448. * @returns a new array populated with 4 elements from the quaternion coordinates
  65449. */
  65450. asArray(): number[];
  65451. /**
  65452. * Check if two quaternions are equals
  65453. * @param otherQuaternion defines the second operand
  65454. * @return true if the current quaternion and the given one coordinates are strictly equals
  65455. */
  65456. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  65457. /**
  65458. * Clone the current quaternion
  65459. * @returns a new quaternion copied from the current one
  65460. */
  65461. clone(): Quaternion;
  65462. /**
  65463. * Copy a quaternion to the current one
  65464. * @param other defines the other quaternion
  65465. * @returns the updated current quaternion
  65466. */
  65467. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  65468. /**
  65469. * Updates the current quaternion with the given float coordinates
  65470. * @param x defines the x coordinate
  65471. * @param y defines the y coordinate
  65472. * @param z defines the z coordinate
  65473. * @param w defines the w coordinate
  65474. * @returns the updated current quaternion
  65475. */
  65476. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  65477. /**
  65478. * Updates the current quaternion from the given float coordinates
  65479. * @param x defines the x coordinate
  65480. * @param y defines the y coordinate
  65481. * @param z defines the z coordinate
  65482. * @param w defines the w coordinate
  65483. * @returns the updated current quaternion
  65484. */
  65485. set(x: number, y: number, z: number, w: number): Quaternion;
  65486. /**
  65487. * Adds two quaternions
  65488. * @param other defines the second operand
  65489. * @returns a new quaternion as the addition result of the given one and the current quaternion
  65490. */
  65491. add(other: DeepImmutable<Quaternion>): Quaternion;
  65492. /**
  65493. * Add a quaternion to the current one
  65494. * @param other defines the quaternion to add
  65495. * @returns the current quaternion
  65496. */
  65497. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  65498. /**
  65499. * Subtract two quaternions
  65500. * @param other defines the second operand
  65501. * @returns a new quaternion as the subtraction result of the given one from the current one
  65502. */
  65503. subtract(other: Quaternion): Quaternion;
  65504. /**
  65505. * Multiplies the current quaternion by a scale factor
  65506. * @param value defines the scale factor
  65507. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  65508. */
  65509. scale(value: number): Quaternion;
  65510. /**
  65511. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  65512. * @param scale defines the scale factor
  65513. * @param result defines the Quaternion object where to store the result
  65514. * @returns the unmodified current quaternion
  65515. */
  65516. scaleToRef(scale: number, result: Quaternion): Quaternion;
  65517. /**
  65518. * Multiplies in place the current quaternion by a scale factor
  65519. * @param value defines the scale factor
  65520. * @returns the current modified quaternion
  65521. */
  65522. scaleInPlace(value: number): Quaternion;
  65523. /**
  65524. * Scale the current quaternion values by a factor and add the result to a given quaternion
  65525. * @param scale defines the scale factor
  65526. * @param result defines the Quaternion object where to store the result
  65527. * @returns the unmodified current quaternion
  65528. */
  65529. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  65530. /**
  65531. * Multiplies two quaternions
  65532. * @param q1 defines the second operand
  65533. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  65534. */
  65535. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  65536. /**
  65537. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  65538. * @param q1 defines the second operand
  65539. * @param result defines the target quaternion
  65540. * @returns the current quaternion
  65541. */
  65542. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  65543. /**
  65544. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  65545. * @param q1 defines the second operand
  65546. * @returns the currentupdated quaternion
  65547. */
  65548. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  65549. /**
  65550. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  65551. * @param ref defines the target quaternion
  65552. * @returns the current quaternion
  65553. */
  65554. conjugateToRef(ref: Quaternion): Quaternion;
  65555. /**
  65556. * Conjugates in place (1-q) the current quaternion
  65557. * @returns the current updated quaternion
  65558. */
  65559. conjugateInPlace(): Quaternion;
  65560. /**
  65561. * Conjugates in place (1-q) the current quaternion
  65562. * @returns a new quaternion
  65563. */
  65564. conjugate(): Quaternion;
  65565. /**
  65566. * Gets length of current quaternion
  65567. * @returns the quaternion length (float)
  65568. */
  65569. length(): number;
  65570. /**
  65571. * Normalize in place the current quaternion
  65572. * @returns the current updated quaternion
  65573. */
  65574. normalize(): Quaternion;
  65575. /**
  65576. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  65577. * @param order is a reserved parameter and is ignore for now
  65578. * @returns a new Vector3 containing the Euler angles
  65579. */
  65580. toEulerAngles(order?: string): Vector3;
  65581. /**
  65582. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  65583. * @param result defines the vector which will be filled with the Euler angles
  65584. * @param order is a reserved parameter and is ignore for now
  65585. * @returns the current unchanged quaternion
  65586. */
  65587. toEulerAnglesToRef(result: Vector3): Quaternion;
  65588. /**
  65589. * Updates the given rotation matrix with the current quaternion values
  65590. * @param result defines the target matrix
  65591. * @returns the current unchanged quaternion
  65592. */
  65593. toRotationMatrix(result: Matrix): Quaternion;
  65594. /**
  65595. * Updates the current quaternion from the given rotation matrix values
  65596. * @param matrix defines the source matrix
  65597. * @returns the current updated quaternion
  65598. */
  65599. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  65600. /**
  65601. * Creates a new quaternion from a rotation matrix
  65602. * @param matrix defines the source matrix
  65603. * @returns a new quaternion created from the given rotation matrix values
  65604. */
  65605. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  65606. /**
  65607. * Updates the given quaternion with the given rotation matrix values
  65608. * @param matrix defines the source matrix
  65609. * @param result defines the target quaternion
  65610. */
  65611. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  65612. /**
  65613. * Returns the dot product (float) between the quaternions "left" and "right"
  65614. * @param left defines the left operand
  65615. * @param right defines the right operand
  65616. * @returns the dot product
  65617. */
  65618. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  65619. /**
  65620. * Checks if the two quaternions are close to each other
  65621. * @param quat0 defines the first quaternion to check
  65622. * @param quat1 defines the second quaternion to check
  65623. * @returns true if the two quaternions are close to each other
  65624. */
  65625. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  65626. /**
  65627. * Creates an empty quaternion
  65628. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  65629. */
  65630. static Zero(): Quaternion;
  65631. /**
  65632. * Inverse a given quaternion
  65633. * @param q defines the source quaternion
  65634. * @returns a new quaternion as the inverted current quaternion
  65635. */
  65636. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  65637. /**
  65638. * Inverse a given quaternion
  65639. * @param q defines the source quaternion
  65640. * @param result the quaternion the result will be stored in
  65641. * @returns the result quaternion
  65642. */
  65643. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  65644. /**
  65645. * Creates an identity quaternion
  65646. * @returns the identity quaternion
  65647. */
  65648. static Identity(): Quaternion;
  65649. /**
  65650. * Gets a boolean indicating if the given quaternion is identity
  65651. * @param quaternion defines the quaternion to check
  65652. * @returns true if the quaternion is identity
  65653. */
  65654. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  65655. /**
  65656. * Creates a quaternion from a rotation around an axis
  65657. * @param axis defines the axis to use
  65658. * @param angle defines the angle to use
  65659. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  65660. */
  65661. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  65662. /**
  65663. * Creates a rotation around an axis and stores it into the given quaternion
  65664. * @param axis defines the axis to use
  65665. * @param angle defines the angle to use
  65666. * @param result defines the target quaternion
  65667. * @returns the target quaternion
  65668. */
  65669. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  65670. /**
  65671. * Creates a new quaternion from data stored into an array
  65672. * @param array defines the data source
  65673. * @param offset defines the offset in the source array where the data starts
  65674. * @returns a new quaternion
  65675. */
  65676. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  65677. /**
  65678. * Create a quaternion from Euler rotation angles
  65679. * @param x Pitch
  65680. * @param y Yaw
  65681. * @param z Roll
  65682. * @returns the new Quaternion
  65683. */
  65684. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  65685. /**
  65686. * Updates a quaternion from Euler rotation angles
  65687. * @param x Pitch
  65688. * @param y Yaw
  65689. * @param z Roll
  65690. * @param result the quaternion to store the result
  65691. * @returns the updated quaternion
  65692. */
  65693. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  65694. /**
  65695. * Create a quaternion from Euler rotation vector
  65696. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  65697. * @returns the new Quaternion
  65698. */
  65699. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  65700. /**
  65701. * Updates a quaternion from Euler rotation vector
  65702. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  65703. * @param result the quaternion to store the result
  65704. * @returns the updated quaternion
  65705. */
  65706. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  65707. /**
  65708. * Creates a new quaternion from the given Euler float angles (y, x, z)
  65709. * @param yaw defines the rotation around Y axis
  65710. * @param pitch defines the rotation around X axis
  65711. * @param roll defines the rotation around Z axis
  65712. * @returns the new quaternion
  65713. */
  65714. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  65715. /**
  65716. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  65717. * @param yaw defines the rotation around Y axis
  65718. * @param pitch defines the rotation around X axis
  65719. * @param roll defines the rotation around Z axis
  65720. * @param result defines the target quaternion
  65721. */
  65722. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  65723. /**
  65724. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  65725. * @param alpha defines the rotation around first axis
  65726. * @param beta defines the rotation around second axis
  65727. * @param gamma defines the rotation around third axis
  65728. * @returns the new quaternion
  65729. */
  65730. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  65731. /**
  65732. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  65733. * @param alpha defines the rotation around first axis
  65734. * @param beta defines the rotation around second axis
  65735. * @param gamma defines the rotation around third axis
  65736. * @param result defines the target quaternion
  65737. */
  65738. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  65739. /**
  65740. * 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)
  65741. * @param axis1 defines the first axis
  65742. * @param axis2 defines the second axis
  65743. * @param axis3 defines the third axis
  65744. * @returns the new quaternion
  65745. */
  65746. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  65747. /**
  65748. * 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
  65749. * @param axis1 defines the first axis
  65750. * @param axis2 defines the second axis
  65751. * @param axis3 defines the third axis
  65752. * @param ref defines the target quaternion
  65753. */
  65754. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  65755. /**
  65756. * Interpolates between two quaternions
  65757. * @param left defines first quaternion
  65758. * @param right defines second quaternion
  65759. * @param amount defines the gradient to use
  65760. * @returns the new interpolated quaternion
  65761. */
  65762. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  65763. /**
  65764. * Interpolates between two quaternions and stores it into a target quaternion
  65765. * @param left defines first quaternion
  65766. * @param right defines second quaternion
  65767. * @param amount defines the gradient to use
  65768. * @param result defines the target quaternion
  65769. */
  65770. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  65771. /**
  65772. * Interpolate between two quaternions using Hermite interpolation
  65773. * @param value1 defines first quaternion
  65774. * @param tangent1 defines the incoming tangent
  65775. * @param value2 defines second quaternion
  65776. * @param tangent2 defines the outgoing tangent
  65777. * @param amount defines the target quaternion
  65778. * @returns the new interpolated quaternion
  65779. */
  65780. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  65781. }
  65782. /**
  65783. * Class used to store matrix data (4x4)
  65784. */
  65785. export class Matrix {
  65786. private static _updateFlagSeed;
  65787. private static _identityReadOnly;
  65788. private _isIdentity;
  65789. private _isIdentityDirty;
  65790. private _isIdentity3x2;
  65791. private _isIdentity3x2Dirty;
  65792. /**
  65793. * Gets the update flag of the matrix which is an unique number for the matrix.
  65794. * It will be incremented every time the matrix data change.
  65795. * You can use it to speed the comparison between two versions of the same matrix.
  65796. */
  65797. updateFlag: number;
  65798. private readonly _m;
  65799. /**
  65800. * Gets the internal data of the matrix
  65801. */
  65802. readonly m: DeepImmutable<Float32Array>;
  65803. /** @hidden */
  65804. _markAsUpdated(): void;
  65805. /** @hidden */
  65806. private _updateIdentityStatus;
  65807. /**
  65808. * Creates an empty matrix (filled with zeros)
  65809. */
  65810. constructor();
  65811. /**
  65812. * Check if the current matrix is identity
  65813. * @returns true is the matrix is the identity matrix
  65814. */
  65815. isIdentity(): boolean;
  65816. /**
  65817. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  65818. * @returns true is the matrix is the identity matrix
  65819. */
  65820. isIdentityAs3x2(): boolean;
  65821. /**
  65822. * Gets the determinant of the matrix
  65823. * @returns the matrix determinant
  65824. */
  65825. determinant(): number;
  65826. /**
  65827. * Returns the matrix as a Float32Array
  65828. * @returns the matrix underlying array
  65829. */
  65830. toArray(): DeepImmutable<Float32Array>;
  65831. /**
  65832. * Returns the matrix as a Float32Array
  65833. * @returns the matrix underlying array.
  65834. */
  65835. asArray(): DeepImmutable<Float32Array>;
  65836. /**
  65837. * Inverts the current matrix in place
  65838. * @returns the current inverted matrix
  65839. */
  65840. invert(): Matrix;
  65841. /**
  65842. * Sets all the matrix elements to zero
  65843. * @returns the current matrix
  65844. */
  65845. reset(): Matrix;
  65846. /**
  65847. * Adds the current matrix with a second one
  65848. * @param other defines the matrix to add
  65849. * @returns a new matrix as the addition of the current matrix and the given one
  65850. */
  65851. add(other: DeepImmutable<Matrix>): Matrix;
  65852. /**
  65853. * Sets the given matrix "result" to the addition of the current matrix and the given one
  65854. * @param other defines the matrix to add
  65855. * @param result defines the target matrix
  65856. * @returns the current matrix
  65857. */
  65858. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  65859. /**
  65860. * Adds in place the given matrix to the current matrix
  65861. * @param other defines the second operand
  65862. * @returns the current updated matrix
  65863. */
  65864. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  65865. /**
  65866. * Sets the given matrix to the current inverted Matrix
  65867. * @param other defines the target matrix
  65868. * @returns the unmodified current matrix
  65869. */
  65870. invertToRef(other: Matrix): Matrix;
  65871. /**
  65872. * add a value at the specified position in the current Matrix
  65873. * @param index the index of the value within the matrix. between 0 and 15.
  65874. * @param value the value to be added
  65875. * @returns the current updated matrix
  65876. */
  65877. addAtIndex(index: number, value: number): Matrix;
  65878. /**
  65879. * mutiply the specified position in the current Matrix by a value
  65880. * @param index the index of the value within the matrix. between 0 and 15.
  65881. * @param value the value to be added
  65882. * @returns the current updated matrix
  65883. */
  65884. multiplyAtIndex(index: number, value: number): Matrix;
  65885. /**
  65886. * Inserts the translation vector (using 3 floats) in the current matrix
  65887. * @param x defines the 1st component of the translation
  65888. * @param y defines the 2nd component of the translation
  65889. * @param z defines the 3rd component of the translation
  65890. * @returns the current updated matrix
  65891. */
  65892. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  65893. /**
  65894. * Adds the translation vector (using 3 floats) in the current matrix
  65895. * @param x defines the 1st component of the translation
  65896. * @param y defines the 2nd component of the translation
  65897. * @param z defines the 3rd component of the translation
  65898. * @returns the current updated matrix
  65899. */
  65900. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  65901. /**
  65902. * Inserts the translation vector in the current matrix
  65903. * @param vector3 defines the translation to insert
  65904. * @returns the current updated matrix
  65905. */
  65906. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  65907. /**
  65908. * Gets the translation value of the current matrix
  65909. * @returns a new Vector3 as the extracted translation from the matrix
  65910. */
  65911. getTranslation(): Vector3;
  65912. /**
  65913. * Fill a Vector3 with the extracted translation from the matrix
  65914. * @param result defines the Vector3 where to store the translation
  65915. * @returns the current matrix
  65916. */
  65917. getTranslationToRef(result: Vector3): Matrix;
  65918. /**
  65919. * Remove rotation and scaling part from the matrix
  65920. * @returns the updated matrix
  65921. */
  65922. removeRotationAndScaling(): Matrix;
  65923. /**
  65924. * Multiply two matrices
  65925. * @param other defines the second operand
  65926. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  65927. */
  65928. multiply(other: DeepImmutable<Matrix>): Matrix;
  65929. /**
  65930. * Copy the current matrix from the given one
  65931. * @param other defines the source matrix
  65932. * @returns the current updated matrix
  65933. */
  65934. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  65935. /**
  65936. * Populates the given array from the starting index with the current matrix values
  65937. * @param array defines the target array
  65938. * @param offset defines the offset in the target array where to start storing values
  65939. * @returns the current matrix
  65940. */
  65941. copyToArray(array: Float32Array, offset?: number): Matrix;
  65942. /**
  65943. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  65944. * @param other defines the second operand
  65945. * @param result defines the matrix where to store the multiplication
  65946. * @returns the current matrix
  65947. */
  65948. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  65949. /**
  65950. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  65951. * @param other defines the second operand
  65952. * @param result defines the array where to store the multiplication
  65953. * @param offset defines the offset in the target array where to start storing values
  65954. * @returns the current matrix
  65955. */
  65956. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  65957. /**
  65958. * Check equality between this matrix and a second one
  65959. * @param value defines the second matrix to compare
  65960. * @returns true is the current matrix and the given one values are strictly equal
  65961. */
  65962. equals(value: DeepImmutable<Matrix>): boolean;
  65963. /**
  65964. * Clone the current matrix
  65965. * @returns a new matrix from the current matrix
  65966. */
  65967. clone(): Matrix;
  65968. /**
  65969. * Returns the name of the current matrix class
  65970. * @returns the string "Matrix"
  65971. */
  65972. getClassName(): string;
  65973. /**
  65974. * Gets the hash code of the current matrix
  65975. * @returns the hash code
  65976. */
  65977. getHashCode(): number;
  65978. /**
  65979. * Decomposes the current Matrix into a translation, rotation and scaling components
  65980. * @param scale defines the scale vector3 given as a reference to update
  65981. * @param rotation defines the rotation quaternion given as a reference to update
  65982. * @param translation defines the translation vector3 given as a reference to update
  65983. * @returns true if operation was successful
  65984. */
  65985. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  65986. /**
  65987. * Gets specific row of the matrix
  65988. * @param index defines the number of the row to get
  65989. * @returns the index-th row of the current matrix as a new Vector4
  65990. */
  65991. getRow(index: number): Nullable<Vector4>;
  65992. /**
  65993. * Sets the index-th row of the current matrix to the vector4 values
  65994. * @param index defines the number of the row to set
  65995. * @param row defines the target vector4
  65996. * @returns the updated current matrix
  65997. */
  65998. setRow(index: number, row: Vector4): Matrix;
  65999. /**
  66000. * Compute the transpose of the matrix
  66001. * @returns the new transposed matrix
  66002. */
  66003. transpose(): Matrix;
  66004. /**
  66005. * Compute the transpose of the matrix and store it in a given matrix
  66006. * @param result defines the target matrix
  66007. * @returns the current matrix
  66008. */
  66009. transposeToRef(result: Matrix): Matrix;
  66010. /**
  66011. * Sets the index-th row of the current matrix with the given 4 x float values
  66012. * @param index defines the row index
  66013. * @param x defines the x component to set
  66014. * @param y defines the y component to set
  66015. * @param z defines the z component to set
  66016. * @param w defines the w component to set
  66017. * @returns the updated current matrix
  66018. */
  66019. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  66020. /**
  66021. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  66022. * @param scale defines the scale factor
  66023. * @returns a new matrix
  66024. */
  66025. scale(scale: number): Matrix;
  66026. /**
  66027. * Scale the current matrix values by a factor to a given result matrix
  66028. * @param scale defines the scale factor
  66029. * @param result defines the matrix to store the result
  66030. * @returns the current matrix
  66031. */
  66032. scaleToRef(scale: number, result: Matrix): Matrix;
  66033. /**
  66034. * Scale the current matrix values by a factor and add the result to a given matrix
  66035. * @param scale defines the scale factor
  66036. * @param result defines the Matrix to store the result
  66037. * @returns the current matrix
  66038. */
  66039. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  66040. /**
  66041. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  66042. * @param ref matrix to store the result
  66043. */
  66044. toNormalMatrix(ref: Matrix): void;
  66045. /**
  66046. * Gets only rotation part of the current matrix
  66047. * @returns a new matrix sets to the extracted rotation matrix from the current one
  66048. */
  66049. getRotationMatrix(): Matrix;
  66050. /**
  66051. * Extracts the rotation matrix from the current one and sets it as the given "result"
  66052. * @param result defines the target matrix to store data to
  66053. * @returns the current matrix
  66054. */
  66055. getRotationMatrixToRef(result: Matrix): Matrix;
  66056. /**
  66057. * Toggles model matrix from being right handed to left handed in place and vice versa
  66058. */
  66059. toggleModelMatrixHandInPlace(): void;
  66060. /**
  66061. * Toggles projection matrix from being right handed to left handed in place and vice versa
  66062. */
  66063. toggleProjectionMatrixHandInPlace(): void;
  66064. /**
  66065. * Creates a matrix from an array
  66066. * @param array defines the source array
  66067. * @param offset defines an offset in the source array
  66068. * @returns a new Matrix set from the starting index of the given array
  66069. */
  66070. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  66071. /**
  66072. * Copy the content of an array into a given matrix
  66073. * @param array defines the source array
  66074. * @param offset defines an offset in the source array
  66075. * @param result defines the target matrix
  66076. */
  66077. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  66078. /**
  66079. * Stores an array into a matrix after having multiplied each component by a given factor
  66080. * @param array defines the source array
  66081. * @param offset defines the offset in the source array
  66082. * @param scale defines the scaling factor
  66083. * @param result defines the target matrix
  66084. */
  66085. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  66086. /**
  66087. * Gets an identity matrix that must not be updated
  66088. */
  66089. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  66090. /**
  66091. * Stores a list of values (16) inside a given matrix
  66092. * @param initialM11 defines 1st value of 1st row
  66093. * @param initialM12 defines 2nd value of 1st row
  66094. * @param initialM13 defines 3rd value of 1st row
  66095. * @param initialM14 defines 4th value of 1st row
  66096. * @param initialM21 defines 1st value of 2nd row
  66097. * @param initialM22 defines 2nd value of 2nd row
  66098. * @param initialM23 defines 3rd value of 2nd row
  66099. * @param initialM24 defines 4th value of 2nd row
  66100. * @param initialM31 defines 1st value of 3rd row
  66101. * @param initialM32 defines 2nd value of 3rd row
  66102. * @param initialM33 defines 3rd value of 3rd row
  66103. * @param initialM34 defines 4th value of 3rd row
  66104. * @param initialM41 defines 1st value of 4th row
  66105. * @param initialM42 defines 2nd value of 4th row
  66106. * @param initialM43 defines 3rd value of 4th row
  66107. * @param initialM44 defines 4th value of 4th row
  66108. * @param result defines the target matrix
  66109. */
  66110. 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;
  66111. /**
  66112. * Creates new matrix from a list of values (16)
  66113. * @param initialM11 defines 1st value of 1st row
  66114. * @param initialM12 defines 2nd value of 1st row
  66115. * @param initialM13 defines 3rd value of 1st row
  66116. * @param initialM14 defines 4th value of 1st row
  66117. * @param initialM21 defines 1st value of 2nd row
  66118. * @param initialM22 defines 2nd value of 2nd row
  66119. * @param initialM23 defines 3rd value of 2nd row
  66120. * @param initialM24 defines 4th value of 2nd row
  66121. * @param initialM31 defines 1st value of 3rd row
  66122. * @param initialM32 defines 2nd value of 3rd row
  66123. * @param initialM33 defines 3rd value of 3rd row
  66124. * @param initialM34 defines 4th value of 3rd row
  66125. * @param initialM41 defines 1st value of 4th row
  66126. * @param initialM42 defines 2nd value of 4th row
  66127. * @param initialM43 defines 3rd value of 4th row
  66128. * @param initialM44 defines 4th value of 4th row
  66129. * @returns the new matrix
  66130. */
  66131. 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;
  66132. /**
  66133. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  66134. * @param scale defines the scale vector3
  66135. * @param rotation defines the rotation quaternion
  66136. * @param translation defines the translation vector3
  66137. * @returns a new matrix
  66138. */
  66139. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  66140. /**
  66141. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  66142. * @param scale defines the scale vector3
  66143. * @param rotation defines the rotation quaternion
  66144. * @param translation defines the translation vector3
  66145. * @param result defines the target matrix
  66146. */
  66147. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  66148. /**
  66149. * Creates a new identity matrix
  66150. * @returns a new identity matrix
  66151. */
  66152. static Identity(): Matrix;
  66153. /**
  66154. * Creates a new identity matrix and stores the result in a given matrix
  66155. * @param result defines the target matrix
  66156. */
  66157. static IdentityToRef(result: Matrix): void;
  66158. /**
  66159. * Creates a new zero matrix
  66160. * @returns a new zero matrix
  66161. */
  66162. static Zero(): Matrix;
  66163. /**
  66164. * Creates a new rotation matrix for "angle" radians around the X axis
  66165. * @param angle defines the angle (in radians) to use
  66166. * @return the new matrix
  66167. */
  66168. static RotationX(angle: number): Matrix;
  66169. /**
  66170. * Creates a new matrix as the invert of a given matrix
  66171. * @param source defines the source matrix
  66172. * @returns the new matrix
  66173. */
  66174. static Invert(source: DeepImmutable<Matrix>): Matrix;
  66175. /**
  66176. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  66177. * @param angle defines the angle (in radians) to use
  66178. * @param result defines the target matrix
  66179. */
  66180. static RotationXToRef(angle: number, result: Matrix): void;
  66181. /**
  66182. * Creates a new rotation matrix for "angle" radians around the Y axis
  66183. * @param angle defines the angle (in radians) to use
  66184. * @return the new matrix
  66185. */
  66186. static RotationY(angle: number): Matrix;
  66187. /**
  66188. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  66189. * @param angle defines the angle (in radians) to use
  66190. * @param result defines the target matrix
  66191. */
  66192. static RotationYToRef(angle: number, result: Matrix): void;
  66193. /**
  66194. * Creates a new rotation matrix for "angle" radians around the Z axis
  66195. * @param angle defines the angle (in radians) to use
  66196. * @return the new matrix
  66197. */
  66198. static RotationZ(angle: number): Matrix;
  66199. /**
  66200. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  66201. * @param angle defines the angle (in radians) to use
  66202. * @param result defines the target matrix
  66203. */
  66204. static RotationZToRef(angle: number, result: Matrix): void;
  66205. /**
  66206. * Creates a new rotation matrix for "angle" radians around the given axis
  66207. * @param axis defines the axis to use
  66208. * @param angle defines the angle (in radians) to use
  66209. * @return the new matrix
  66210. */
  66211. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  66212. /**
  66213. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  66214. * @param axis defines the axis to use
  66215. * @param angle defines the angle (in radians) to use
  66216. * @param result defines the target matrix
  66217. */
  66218. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  66219. /**
  66220. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  66221. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  66222. * @param from defines the vector to align
  66223. * @param to defines the vector to align to
  66224. * @param result defines the target matrix
  66225. */
  66226. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  66227. /**
  66228. * Creates a rotation matrix
  66229. * @param yaw defines the yaw angle in radians (Y axis)
  66230. * @param pitch defines the pitch angle in radians (X axis)
  66231. * @param roll defines the roll angle in radians (X axis)
  66232. * @returns the new rotation matrix
  66233. */
  66234. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  66235. /**
  66236. * Creates a rotation matrix and stores it in a given matrix
  66237. * @param yaw defines the yaw angle in radians (Y axis)
  66238. * @param pitch defines the pitch angle in radians (X axis)
  66239. * @param roll defines the roll angle in radians (X axis)
  66240. * @param result defines the target matrix
  66241. */
  66242. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  66243. /**
  66244. * Creates a scaling matrix
  66245. * @param x defines the scale factor on X axis
  66246. * @param y defines the scale factor on Y axis
  66247. * @param z defines the scale factor on Z axis
  66248. * @returns the new matrix
  66249. */
  66250. static Scaling(x: number, y: number, z: number): Matrix;
  66251. /**
  66252. * Creates a scaling matrix and stores it in a given matrix
  66253. * @param x defines the scale factor on X axis
  66254. * @param y defines the scale factor on Y axis
  66255. * @param z defines the scale factor on Z axis
  66256. * @param result defines the target matrix
  66257. */
  66258. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  66259. /**
  66260. * Creates a translation matrix
  66261. * @param x defines the translation on X axis
  66262. * @param y defines the translation on Y axis
  66263. * @param z defines the translationon Z axis
  66264. * @returns the new matrix
  66265. */
  66266. static Translation(x: number, y: number, z: number): Matrix;
  66267. /**
  66268. * Creates a translation matrix and stores it in a given matrix
  66269. * @param x defines the translation on X axis
  66270. * @param y defines the translation on Y axis
  66271. * @param z defines the translationon Z axis
  66272. * @param result defines the target matrix
  66273. */
  66274. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  66275. /**
  66276. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  66277. * @param startValue defines the start value
  66278. * @param endValue defines the end value
  66279. * @param gradient defines the gradient factor
  66280. * @returns the new matrix
  66281. */
  66282. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  66283. /**
  66284. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  66285. * @param startValue defines the start value
  66286. * @param endValue defines the end value
  66287. * @param gradient defines the gradient factor
  66288. * @param result defines the Matrix object where to store data
  66289. */
  66290. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  66291. /**
  66292. * Builds a new matrix whose values are computed by:
  66293. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  66294. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  66295. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  66296. * @param startValue defines the first matrix
  66297. * @param endValue defines the second matrix
  66298. * @param gradient defines the gradient between the two matrices
  66299. * @returns the new matrix
  66300. */
  66301. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  66302. /**
  66303. * Update a matrix to values which are computed by:
  66304. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  66305. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  66306. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  66307. * @param startValue defines the first matrix
  66308. * @param endValue defines the second matrix
  66309. * @param gradient defines the gradient between the two matrices
  66310. * @param result defines the target matrix
  66311. */
  66312. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  66313. /**
  66314. * 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"
  66315. * This function works in left handed mode
  66316. * @param eye defines the final position of the entity
  66317. * @param target defines where the entity should look at
  66318. * @param up defines the up vector for the entity
  66319. * @returns the new matrix
  66320. */
  66321. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  66322. /**
  66323. * 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".
  66324. * This function works in left handed mode
  66325. * @param eye defines the final position of the entity
  66326. * @param target defines where the entity should look at
  66327. * @param up defines the up vector for the entity
  66328. * @param result defines the target matrix
  66329. */
  66330. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  66331. /**
  66332. * 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"
  66333. * This function works in right handed mode
  66334. * @param eye defines the final position of the entity
  66335. * @param target defines where the entity should look at
  66336. * @param up defines the up vector for the entity
  66337. * @returns the new matrix
  66338. */
  66339. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  66340. /**
  66341. * 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".
  66342. * This function works in right handed mode
  66343. * @param eye defines the final position of the entity
  66344. * @param target defines where the entity should look at
  66345. * @param up defines the up vector for the entity
  66346. * @param result defines the target matrix
  66347. */
  66348. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  66349. /**
  66350. * Create a left-handed orthographic projection matrix
  66351. * @param width defines the viewport width
  66352. * @param height defines the viewport height
  66353. * @param znear defines the near clip plane
  66354. * @param zfar defines the far clip plane
  66355. * @returns a new matrix as a left-handed orthographic projection matrix
  66356. */
  66357. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  66358. /**
  66359. * Store a left-handed orthographic projection to a given matrix
  66360. * @param width defines the viewport width
  66361. * @param height defines the viewport height
  66362. * @param znear defines the near clip plane
  66363. * @param zfar defines the far clip plane
  66364. * @param result defines the target matrix
  66365. */
  66366. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  66367. /**
  66368. * Create a left-handed orthographic projection matrix
  66369. * @param left defines the viewport left coordinate
  66370. * @param right defines the viewport right coordinate
  66371. * @param bottom defines the viewport bottom coordinate
  66372. * @param top defines the viewport top coordinate
  66373. * @param znear defines the near clip plane
  66374. * @param zfar defines the far clip plane
  66375. * @returns a new matrix as a left-handed orthographic projection matrix
  66376. */
  66377. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  66378. /**
  66379. * Stores a left-handed orthographic projection into a given matrix
  66380. * @param left defines the viewport left coordinate
  66381. * @param right defines the viewport right coordinate
  66382. * @param bottom defines the viewport bottom coordinate
  66383. * @param top defines the viewport top coordinate
  66384. * @param znear defines the near clip plane
  66385. * @param zfar defines the far clip plane
  66386. * @param result defines the target matrix
  66387. */
  66388. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  66389. /**
  66390. * Creates a right-handed orthographic projection matrix
  66391. * @param left defines the viewport left coordinate
  66392. * @param right defines the viewport right coordinate
  66393. * @param bottom defines the viewport bottom coordinate
  66394. * @param top defines the viewport top coordinate
  66395. * @param znear defines the near clip plane
  66396. * @param zfar defines the far clip plane
  66397. * @returns a new matrix as a right-handed orthographic projection matrix
  66398. */
  66399. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  66400. /**
  66401. * Stores a right-handed orthographic projection into a given matrix
  66402. * @param left defines the viewport left coordinate
  66403. * @param right defines the viewport right coordinate
  66404. * @param bottom defines the viewport bottom coordinate
  66405. * @param top defines the viewport top coordinate
  66406. * @param znear defines the near clip plane
  66407. * @param zfar defines the far clip plane
  66408. * @param result defines the target matrix
  66409. */
  66410. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  66411. /**
  66412. * Creates a left-handed perspective projection matrix
  66413. * @param width defines the viewport width
  66414. * @param height defines the viewport height
  66415. * @param znear defines the near clip plane
  66416. * @param zfar defines the far clip plane
  66417. * @returns a new matrix as a left-handed perspective projection matrix
  66418. */
  66419. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  66420. /**
  66421. * Creates a left-handed perspective projection matrix
  66422. * @param fov defines the horizontal field of view
  66423. * @param aspect defines the aspect ratio
  66424. * @param znear defines the near clip plane
  66425. * @param zfar defines the far clip plane
  66426. * @returns a new matrix as a left-handed perspective projection matrix
  66427. */
  66428. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  66429. /**
  66430. * Stores a left-handed perspective projection into a given matrix
  66431. * @param fov defines the horizontal field of view
  66432. * @param aspect defines the aspect ratio
  66433. * @param znear defines the near clip plane
  66434. * @param zfar defines the far clip plane
  66435. * @param result defines the target matrix
  66436. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  66437. */
  66438. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  66439. /**
  66440. * Creates a right-handed perspective projection matrix
  66441. * @param fov defines the horizontal field of view
  66442. * @param aspect defines the aspect ratio
  66443. * @param znear defines the near clip plane
  66444. * @param zfar defines the far clip plane
  66445. * @returns a new matrix as a right-handed perspective projection matrix
  66446. */
  66447. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  66448. /**
  66449. * Stores a right-handed perspective projection into a given matrix
  66450. * @param fov defines the horizontal field of view
  66451. * @param aspect defines the aspect ratio
  66452. * @param znear defines the near clip plane
  66453. * @param zfar defines the far clip plane
  66454. * @param result defines the target matrix
  66455. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  66456. */
  66457. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  66458. /**
  66459. * Stores a perspective projection for WebVR info a given matrix
  66460. * @param fov defines the field of view
  66461. * @param znear defines the near clip plane
  66462. * @param zfar defines the far clip plane
  66463. * @param result defines the target matrix
  66464. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  66465. */
  66466. static PerspectiveFovWebVRToRef(fov: {
  66467. upDegrees: number;
  66468. downDegrees: number;
  66469. leftDegrees: number;
  66470. rightDegrees: number;
  66471. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  66472. /**
  66473. * Computes a complete transformation matrix
  66474. * @param viewport defines the viewport to use
  66475. * @param world defines the world matrix
  66476. * @param view defines the view matrix
  66477. * @param projection defines the projection matrix
  66478. * @param zmin defines the near clip plane
  66479. * @param zmax defines the far clip plane
  66480. * @returns the transformation matrix
  66481. */
  66482. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  66483. /**
  66484. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  66485. * @param matrix defines the matrix to use
  66486. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  66487. */
  66488. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  66489. /**
  66490. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  66491. * @param matrix defines the matrix to use
  66492. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  66493. */
  66494. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  66495. /**
  66496. * Compute the transpose of a given matrix
  66497. * @param matrix defines the matrix to transpose
  66498. * @returns the new matrix
  66499. */
  66500. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  66501. /**
  66502. * Compute the transpose of a matrix and store it in a target matrix
  66503. * @param matrix defines the matrix to transpose
  66504. * @param result defines the target matrix
  66505. */
  66506. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  66507. /**
  66508. * Computes a reflection matrix from a plane
  66509. * @param plane defines the reflection plane
  66510. * @returns a new matrix
  66511. */
  66512. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  66513. /**
  66514. * Computes a reflection matrix from a plane
  66515. * @param plane defines the reflection plane
  66516. * @param result defines the target matrix
  66517. */
  66518. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  66519. /**
  66520. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  66521. * @param xaxis defines the value of the 1st axis
  66522. * @param yaxis defines the value of the 2nd axis
  66523. * @param zaxis defines the value of the 3rd axis
  66524. * @param result defines the target matrix
  66525. */
  66526. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  66527. /**
  66528. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  66529. * @param quat defines the quaternion to use
  66530. * @param result defines the target matrix
  66531. */
  66532. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  66533. }
  66534. /**
  66535. * Represens a plane by the equation ax + by + cz + d = 0
  66536. */
  66537. export class Plane {
  66538. /**
  66539. * Normal of the plane (a,b,c)
  66540. */
  66541. normal: Vector3;
  66542. /**
  66543. * d component of the plane
  66544. */
  66545. d: number;
  66546. /**
  66547. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  66548. * @param a a component of the plane
  66549. * @param b b component of the plane
  66550. * @param c c component of the plane
  66551. * @param d d component of the plane
  66552. */
  66553. constructor(a: number, b: number, c: number, d: number);
  66554. /**
  66555. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  66556. */
  66557. asArray(): number[];
  66558. /**
  66559. * @returns a new plane copied from the current Plane.
  66560. */
  66561. clone(): Plane;
  66562. /**
  66563. * @returns the string "Plane".
  66564. */
  66565. getClassName(): string;
  66566. /**
  66567. * @returns the Plane hash code.
  66568. */
  66569. getHashCode(): number;
  66570. /**
  66571. * Normalize the current Plane in place.
  66572. * @returns the updated Plane.
  66573. */
  66574. normalize(): Plane;
  66575. /**
  66576. * Applies a transformation the plane and returns the result
  66577. * @param transformation the transformation matrix to be applied to the plane
  66578. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  66579. */
  66580. transform(transformation: DeepImmutable<Matrix>): Plane;
  66581. /**
  66582. * Calcualtte the dot product between the point and the plane normal
  66583. * @param point point to calculate the dot product with
  66584. * @returns the dot product (float) of the point coordinates and the plane normal.
  66585. */
  66586. dotCoordinate(point: DeepImmutable<Vector3>): number;
  66587. /**
  66588. * Updates the current Plane from the plane defined by the three given points.
  66589. * @param point1 one of the points used to contruct the plane
  66590. * @param point2 one of the points used to contruct the plane
  66591. * @param point3 one of the points used to contruct the plane
  66592. * @returns the updated Plane.
  66593. */
  66594. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  66595. /**
  66596. * Checks if the plane is facing a given direction
  66597. * @param direction the direction to check if the plane is facing
  66598. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  66599. * @returns True is the vector "direction" is the same side than the plane normal.
  66600. */
  66601. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  66602. /**
  66603. * Calculates the distance to a point
  66604. * @param point point to calculate distance to
  66605. * @returns the signed distance (float) from the given point to the Plane.
  66606. */
  66607. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  66608. /**
  66609. * Creates a plane from an array
  66610. * @param array the array to create a plane from
  66611. * @returns a new Plane from the given array.
  66612. */
  66613. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  66614. /**
  66615. * Creates a plane from three points
  66616. * @param point1 point used to create the plane
  66617. * @param point2 point used to create the plane
  66618. * @param point3 point used to create the plane
  66619. * @returns a new Plane defined by the three given points.
  66620. */
  66621. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  66622. /**
  66623. * Creates a plane from an origin point and a normal
  66624. * @param origin origin of the plane to be constructed
  66625. * @param normal normal of the plane to be constructed
  66626. * @returns a new Plane the normal vector to this plane at the given origin point.
  66627. * Note : the vector "normal" is updated because normalized.
  66628. */
  66629. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  66630. /**
  66631. * Calculates the distance from a plane and a point
  66632. * @param origin origin of the plane to be constructed
  66633. * @param normal normal of the plane to be constructed
  66634. * @param point point to calculate distance to
  66635. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  66636. */
  66637. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  66638. }
  66639. /**
  66640. * Class used to represent a viewport on screen
  66641. */
  66642. export class Viewport {
  66643. /** viewport left coordinate */
  66644. x: number;
  66645. /** viewport top coordinate */
  66646. y: number;
  66647. /**viewport width */
  66648. width: number;
  66649. /** viewport height */
  66650. height: number;
  66651. /**
  66652. * Creates a Viewport object located at (x, y) and sized (width, height)
  66653. * @param x defines viewport left coordinate
  66654. * @param y defines viewport top coordinate
  66655. * @param width defines the viewport width
  66656. * @param height defines the viewport height
  66657. */
  66658. constructor(
  66659. /** viewport left coordinate */
  66660. x: number,
  66661. /** viewport top coordinate */
  66662. y: number,
  66663. /**viewport width */
  66664. width: number,
  66665. /** viewport height */
  66666. height: number);
  66667. /**
  66668. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  66669. * @param renderWidth defines the rendering width
  66670. * @param renderHeight defines the rendering height
  66671. * @returns a new Viewport
  66672. */
  66673. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  66674. /**
  66675. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  66676. * @param renderWidth defines the rendering width
  66677. * @param renderHeight defines the rendering height
  66678. * @param ref defines the target viewport
  66679. * @returns the current viewport
  66680. */
  66681. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  66682. /**
  66683. * Returns a new Viewport copied from the current one
  66684. * @returns a new Viewport
  66685. */
  66686. clone(): Viewport;
  66687. }
  66688. /**
  66689. * Reprasents a camera frustum
  66690. */
  66691. export class Frustum {
  66692. /**
  66693. * Gets the planes representing the frustum
  66694. * @param transform matrix to be applied to the returned planes
  66695. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  66696. */
  66697. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  66698. /**
  66699. * Gets the near frustum plane transformed by the transform matrix
  66700. * @param transform transformation matrix to be applied to the resulting frustum plane
  66701. * @param frustumPlane the resuling frustum plane
  66702. */
  66703. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66704. /**
  66705. * Gets the far frustum plane transformed by the transform matrix
  66706. * @param transform transformation matrix to be applied to the resulting frustum plane
  66707. * @param frustumPlane the resuling frustum plane
  66708. */
  66709. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66710. /**
  66711. * Gets the left frustum plane transformed by the transform matrix
  66712. * @param transform transformation matrix to be applied to the resulting frustum plane
  66713. * @param frustumPlane the resuling frustum plane
  66714. */
  66715. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66716. /**
  66717. * Gets the right frustum plane transformed by the transform matrix
  66718. * @param transform transformation matrix to be applied to the resulting frustum plane
  66719. * @param frustumPlane the resuling frustum plane
  66720. */
  66721. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66722. /**
  66723. * Gets the top frustum plane transformed by the transform matrix
  66724. * @param transform transformation matrix to be applied to the resulting frustum plane
  66725. * @param frustumPlane the resuling frustum plane
  66726. */
  66727. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66728. /**
  66729. * Gets the bottom frustum plane transformed by the transform matrix
  66730. * @param transform transformation matrix to be applied to the resulting frustum plane
  66731. * @param frustumPlane the resuling frustum plane
  66732. */
  66733. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66734. /**
  66735. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  66736. * @param transform transformation matrix to be applied to the resulting frustum planes
  66737. * @param frustumPlanes the resuling frustum planes
  66738. */
  66739. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  66740. }
  66741. /** Defines supported spaces */
  66742. export enum Space {
  66743. /** Local (object) space */
  66744. LOCAL = 0,
  66745. /** World space */
  66746. WORLD = 1,
  66747. /** Bone space */
  66748. BONE = 2
  66749. }
  66750. /** Defines the 3 main axes */
  66751. export class Axis {
  66752. /** X axis */
  66753. static X: Vector3;
  66754. /** Y axis */
  66755. static Y: Vector3;
  66756. /** Z axis */
  66757. static Z: Vector3;
  66758. }
  66759. /** Class used to represent a Bezier curve */
  66760. export class BezierCurve {
  66761. /**
  66762. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  66763. * @param t defines the time
  66764. * @param x1 defines the left coordinate on X axis
  66765. * @param y1 defines the left coordinate on Y axis
  66766. * @param x2 defines the right coordinate on X axis
  66767. * @param y2 defines the right coordinate on Y axis
  66768. * @returns the interpolated value
  66769. */
  66770. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  66771. }
  66772. /**
  66773. * Defines potential orientation for back face culling
  66774. */
  66775. export enum Orientation {
  66776. /**
  66777. * Clockwise
  66778. */
  66779. CW = 0,
  66780. /** Counter clockwise */
  66781. CCW = 1
  66782. }
  66783. /**
  66784. * Defines angle representation
  66785. */
  66786. export class Angle {
  66787. private _radians;
  66788. /**
  66789. * Creates an Angle object of "radians" radians (float).
  66790. * @param radians the angle in radians
  66791. */
  66792. constructor(radians: number);
  66793. /**
  66794. * Get value in degrees
  66795. * @returns the Angle value in degrees (float)
  66796. */
  66797. degrees(): number;
  66798. /**
  66799. * Get value in radians
  66800. * @returns the Angle value in radians (float)
  66801. */
  66802. radians(): number;
  66803. /**
  66804. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  66805. * @param a defines first vector
  66806. * @param b defines second vector
  66807. * @returns a new Angle
  66808. */
  66809. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  66810. /**
  66811. * Gets a new Angle object from the given float in radians
  66812. * @param radians defines the angle value in radians
  66813. * @returns a new Angle
  66814. */
  66815. static FromRadians(radians: number): Angle;
  66816. /**
  66817. * Gets a new Angle object from the given float in degrees
  66818. * @param degrees defines the angle value in degrees
  66819. * @returns a new Angle
  66820. */
  66821. static FromDegrees(degrees: number): Angle;
  66822. }
  66823. /**
  66824. * This represents an arc in a 2d space.
  66825. */
  66826. export class Arc2 {
  66827. /** Defines the start point of the arc */
  66828. startPoint: Vector2;
  66829. /** Defines the mid point of the arc */
  66830. midPoint: Vector2;
  66831. /** Defines the end point of the arc */
  66832. endPoint: Vector2;
  66833. /**
  66834. * Defines the center point of the arc.
  66835. */
  66836. centerPoint: Vector2;
  66837. /**
  66838. * Defines the radius of the arc.
  66839. */
  66840. radius: number;
  66841. /**
  66842. * Defines the angle of the arc (from mid point to end point).
  66843. */
  66844. angle: Angle;
  66845. /**
  66846. * Defines the start angle of the arc (from start point to middle point).
  66847. */
  66848. startAngle: Angle;
  66849. /**
  66850. * Defines the orientation of the arc (clock wise/counter clock wise).
  66851. */
  66852. orientation: Orientation;
  66853. /**
  66854. * Creates an Arc object from the three given points : start, middle and end.
  66855. * @param startPoint Defines the start point of the arc
  66856. * @param midPoint Defines the midlle point of the arc
  66857. * @param endPoint Defines the end point of the arc
  66858. */
  66859. constructor(
  66860. /** Defines the start point of the arc */
  66861. startPoint: Vector2,
  66862. /** Defines the mid point of the arc */
  66863. midPoint: Vector2,
  66864. /** Defines the end point of the arc */
  66865. endPoint: Vector2);
  66866. }
  66867. /**
  66868. * Represents a 2D path made up of multiple 2D points
  66869. */
  66870. export class Path2 {
  66871. private _points;
  66872. private _length;
  66873. /**
  66874. * If the path start and end point are the same
  66875. */
  66876. closed: boolean;
  66877. /**
  66878. * Creates a Path2 object from the starting 2D coordinates x and y.
  66879. * @param x the starting points x value
  66880. * @param y the starting points y value
  66881. */
  66882. constructor(x: number, y: number);
  66883. /**
  66884. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  66885. * @param x the added points x value
  66886. * @param y the added points y value
  66887. * @returns the updated Path2.
  66888. */
  66889. addLineTo(x: number, y: number): Path2;
  66890. /**
  66891. * 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.
  66892. * @param midX middle point x value
  66893. * @param midY middle point y value
  66894. * @param endX end point x value
  66895. * @param endY end point y value
  66896. * @param numberOfSegments (default: 36)
  66897. * @returns the updated Path2.
  66898. */
  66899. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  66900. /**
  66901. * Closes the Path2.
  66902. * @returns the Path2.
  66903. */
  66904. close(): Path2;
  66905. /**
  66906. * Gets the sum of the distance between each sequential point in the path
  66907. * @returns the Path2 total length (float).
  66908. */
  66909. length(): number;
  66910. /**
  66911. * Gets the points which construct the path
  66912. * @returns the Path2 internal array of points.
  66913. */
  66914. getPoints(): Vector2[];
  66915. /**
  66916. * Retreives the point at the distance aways from the starting point
  66917. * @param normalizedLengthPosition the length along the path to retreive the point from
  66918. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  66919. */
  66920. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  66921. /**
  66922. * Creates a new path starting from an x and y position
  66923. * @param x starting x value
  66924. * @param y starting y value
  66925. * @returns a new Path2 starting at the coordinates (x, y).
  66926. */
  66927. static StartingAt(x: number, y: number): Path2;
  66928. }
  66929. /**
  66930. * Represents a 3D path made up of multiple 3D points
  66931. */
  66932. export class Path3D {
  66933. /**
  66934. * an array of Vector3, the curve axis of the Path3D
  66935. */
  66936. path: Vector3[];
  66937. private _curve;
  66938. private _distances;
  66939. private _tangents;
  66940. private _normals;
  66941. private _binormals;
  66942. private _raw;
  66943. /**
  66944. * new Path3D(path, normal, raw)
  66945. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  66946. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  66947. * @param path an array of Vector3, the curve axis of the Path3D
  66948. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  66949. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  66950. */
  66951. constructor(
  66952. /**
  66953. * an array of Vector3, the curve axis of the Path3D
  66954. */
  66955. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  66956. /**
  66957. * Returns the Path3D array of successive Vector3 designing its curve.
  66958. * @returns the Path3D array of successive Vector3 designing its curve.
  66959. */
  66960. getCurve(): Vector3[];
  66961. /**
  66962. * Returns an array populated with tangent vectors on each Path3D curve point.
  66963. * @returns an array populated with tangent vectors on each Path3D curve point.
  66964. */
  66965. getTangents(): Vector3[];
  66966. /**
  66967. * Returns an array populated with normal vectors on each Path3D curve point.
  66968. * @returns an array populated with normal vectors on each Path3D curve point.
  66969. */
  66970. getNormals(): Vector3[];
  66971. /**
  66972. * Returns an array populated with binormal vectors on each Path3D curve point.
  66973. * @returns an array populated with binormal vectors on each Path3D curve point.
  66974. */
  66975. getBinormals(): Vector3[];
  66976. /**
  66977. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  66978. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  66979. */
  66980. getDistances(): number[];
  66981. /**
  66982. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  66983. * @param path path which all values are copied into the curves points
  66984. * @param firstNormal which should be projected onto the curve
  66985. * @returns the same object updated.
  66986. */
  66987. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  66988. private _compute;
  66989. private _getFirstNonNullVector;
  66990. private _getLastNonNullVector;
  66991. private _normalVector;
  66992. }
  66993. /**
  66994. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  66995. * A Curve3 is designed from a series of successive Vector3.
  66996. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  66997. */
  66998. export class Curve3 {
  66999. private _points;
  67000. private _length;
  67001. /**
  67002. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  67003. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  67004. * @param v1 (Vector3) the control point
  67005. * @param v2 (Vector3) the end point of the Quadratic Bezier
  67006. * @param nbPoints (integer) the wanted number of points in the curve
  67007. * @returns the created Curve3
  67008. */
  67009. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  67010. /**
  67011. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  67012. * @param v0 (Vector3) the origin point of the Cubic Bezier
  67013. * @param v1 (Vector3) the first control point
  67014. * @param v2 (Vector3) the second control point
  67015. * @param v3 (Vector3) the end point of the Cubic Bezier
  67016. * @param nbPoints (integer) the wanted number of points in the curve
  67017. * @returns the created Curve3
  67018. */
  67019. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  67020. /**
  67021. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  67022. * @param p1 (Vector3) the origin point of the Hermite Spline
  67023. * @param t1 (Vector3) the tangent vector at the origin point
  67024. * @param p2 (Vector3) the end point of the Hermite Spline
  67025. * @param t2 (Vector3) the tangent vector at the end point
  67026. * @param nbPoints (integer) the wanted number of points in the curve
  67027. * @returns the created Curve3
  67028. */
  67029. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  67030. /**
  67031. * Returns a Curve3 object along a CatmullRom Spline curve :
  67032. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  67033. * @param nbPoints (integer) the wanted number of points between each curve control points
  67034. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  67035. * @returns the created Curve3
  67036. */
  67037. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  67038. /**
  67039. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  67040. * A Curve3 is designed from a series of successive Vector3.
  67041. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  67042. * @param points points which make up the curve
  67043. */
  67044. constructor(points: Vector3[]);
  67045. /**
  67046. * @returns the Curve3 stored array of successive Vector3
  67047. */
  67048. getPoints(): Vector3[];
  67049. /**
  67050. * @returns the computed length (float) of the curve.
  67051. */
  67052. length(): number;
  67053. /**
  67054. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  67055. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  67056. * curveA and curveB keep unchanged.
  67057. * @param curve the curve to continue from this curve
  67058. * @returns the newly constructed curve
  67059. */
  67060. continue(curve: DeepImmutable<Curve3>): Curve3;
  67061. private _computeLength;
  67062. }
  67063. /**
  67064. * Contains position and normal vectors for a vertex
  67065. */
  67066. export class PositionNormalVertex {
  67067. /** the position of the vertex (defaut: 0,0,0) */
  67068. position: Vector3;
  67069. /** the normal of the vertex (defaut: 0,1,0) */
  67070. normal: Vector3;
  67071. /**
  67072. * Creates a PositionNormalVertex
  67073. * @param position the position of the vertex (defaut: 0,0,0)
  67074. * @param normal the normal of the vertex (defaut: 0,1,0)
  67075. */
  67076. constructor(
  67077. /** the position of the vertex (defaut: 0,0,0) */
  67078. position?: Vector3,
  67079. /** the normal of the vertex (defaut: 0,1,0) */
  67080. normal?: Vector3);
  67081. /**
  67082. * Clones the PositionNormalVertex
  67083. * @returns the cloned PositionNormalVertex
  67084. */
  67085. clone(): PositionNormalVertex;
  67086. }
  67087. /**
  67088. * Contains position, normal and uv vectors for a vertex
  67089. */
  67090. export class PositionNormalTextureVertex {
  67091. /** the position of the vertex (defaut: 0,0,0) */
  67092. position: Vector3;
  67093. /** the normal of the vertex (defaut: 0,1,0) */
  67094. normal: Vector3;
  67095. /** the uv of the vertex (default: 0,0) */
  67096. uv: Vector2;
  67097. /**
  67098. * Creates a PositionNormalTextureVertex
  67099. * @param position the position of the vertex (defaut: 0,0,0)
  67100. * @param normal the normal of the vertex (defaut: 0,1,0)
  67101. * @param uv the uv of the vertex (default: 0,0)
  67102. */
  67103. constructor(
  67104. /** the position of the vertex (defaut: 0,0,0) */
  67105. position?: Vector3,
  67106. /** the normal of the vertex (defaut: 0,1,0) */
  67107. normal?: Vector3,
  67108. /** the uv of the vertex (default: 0,0) */
  67109. uv?: Vector2);
  67110. /**
  67111. * Clones the PositionNormalTextureVertex
  67112. * @returns the cloned PositionNormalTextureVertex
  67113. */
  67114. clone(): PositionNormalTextureVertex;
  67115. }
  67116. /**
  67117. * @hidden
  67118. */
  67119. export class Tmp {
  67120. static Color3: Color3[];
  67121. static Color4: Color4[];
  67122. static Vector2: Vector2[];
  67123. static Vector3: Vector3[];
  67124. static Vector4: Vector4[];
  67125. static Quaternion: Quaternion[];
  67126. static Matrix: Matrix[];
  67127. }
  67128. }
  67129. declare module BABYLON {
  67130. /**
  67131. * Class used to enable access to offline support
  67132. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  67133. */
  67134. export interface IOfflineProvider {
  67135. /**
  67136. * Gets a boolean indicating if scene must be saved in the database
  67137. */
  67138. enableSceneOffline: boolean;
  67139. /**
  67140. * Gets a boolean indicating if textures must be saved in the database
  67141. */
  67142. enableTexturesOffline: boolean;
  67143. /**
  67144. * Open the offline support and make it available
  67145. * @param successCallback defines the callback to call on success
  67146. * @param errorCallback defines the callback to call on error
  67147. */
  67148. open(successCallback: () => void, errorCallback: () => void): void;
  67149. /**
  67150. * Loads an image from the offline support
  67151. * @param url defines the url to load from
  67152. * @param image defines the target DOM image
  67153. */
  67154. loadImage(url: string, image: HTMLImageElement): void;
  67155. /**
  67156. * Loads a file from offline support
  67157. * @param url defines the URL to load from
  67158. * @param sceneLoaded defines a callback to call on success
  67159. * @param progressCallBack defines a callback to call when progress changed
  67160. * @param errorCallback defines a callback to call on error
  67161. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  67162. */
  67163. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  67164. }
  67165. }
  67166. declare module BABYLON {
  67167. /**
  67168. * A class serves as a medium between the observable and its observers
  67169. */
  67170. export class EventState {
  67171. /**
  67172. * Create a new EventState
  67173. * @param mask defines the mask associated with this state
  67174. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67175. * @param target defines the original target of the state
  67176. * @param currentTarget defines the current target of the state
  67177. */
  67178. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  67179. /**
  67180. * Initialize the current event state
  67181. * @param mask defines the mask associated with this state
  67182. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67183. * @param target defines the original target of the state
  67184. * @param currentTarget defines the current target of the state
  67185. * @returns the current event state
  67186. */
  67187. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  67188. /**
  67189. * An Observer can set this property to true to prevent subsequent observers of being notified
  67190. */
  67191. skipNextObservers: boolean;
  67192. /**
  67193. * Get the mask value that were used to trigger the event corresponding to this EventState object
  67194. */
  67195. mask: number;
  67196. /**
  67197. * The object that originally notified the event
  67198. */
  67199. target?: any;
  67200. /**
  67201. * The current object in the bubbling phase
  67202. */
  67203. currentTarget?: any;
  67204. /**
  67205. * This will be populated with the return value of the last function that was executed.
  67206. * If it is the first function in the callback chain it will be the event data.
  67207. */
  67208. lastReturnValue?: any;
  67209. }
  67210. /**
  67211. * Represent an Observer registered to a given Observable object.
  67212. */
  67213. export class Observer<T> {
  67214. /**
  67215. * Defines the callback to call when the observer is notified
  67216. */
  67217. callback: (eventData: T, eventState: EventState) => void;
  67218. /**
  67219. * Defines the mask of the observer (used to filter notifications)
  67220. */
  67221. mask: number;
  67222. /**
  67223. * Defines the current scope used to restore the JS context
  67224. */
  67225. scope: any;
  67226. /** @hidden */
  67227. _willBeUnregistered: boolean;
  67228. /**
  67229. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  67230. */
  67231. unregisterOnNextCall: boolean;
  67232. /**
  67233. * Creates a new observer
  67234. * @param callback defines the callback to call when the observer is notified
  67235. * @param mask defines the mask of the observer (used to filter notifications)
  67236. * @param scope defines the current scope used to restore the JS context
  67237. */
  67238. constructor(
  67239. /**
  67240. * Defines the callback to call when the observer is notified
  67241. */
  67242. callback: (eventData: T, eventState: EventState) => void,
  67243. /**
  67244. * Defines the mask of the observer (used to filter notifications)
  67245. */
  67246. mask: number,
  67247. /**
  67248. * Defines the current scope used to restore the JS context
  67249. */
  67250. scope?: any);
  67251. }
  67252. /**
  67253. * Represent a list of observers registered to multiple Observables object.
  67254. */
  67255. export class MultiObserver<T> {
  67256. private _observers;
  67257. private _observables;
  67258. /**
  67259. * Release associated resources
  67260. */
  67261. dispose(): void;
  67262. /**
  67263. * Raise a callback when one of the observable will notify
  67264. * @param observables defines a list of observables to watch
  67265. * @param callback defines the callback to call on notification
  67266. * @param mask defines the mask used to filter notifications
  67267. * @param scope defines the current scope used to restore the JS context
  67268. * @returns the new MultiObserver
  67269. */
  67270. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  67271. }
  67272. /**
  67273. * The Observable class is a simple implementation of the Observable pattern.
  67274. *
  67275. * 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.
  67276. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  67277. * 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).
  67278. * 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.
  67279. */
  67280. export class Observable<T> {
  67281. private _observers;
  67282. private _eventState;
  67283. private _onObserverAdded;
  67284. /**
  67285. * Creates a new observable
  67286. * @param onObserverAdded defines a callback to call when a new observer is added
  67287. */
  67288. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  67289. /**
  67290. * Create a new Observer with the specified callback
  67291. * @param callback the callback that will be executed for that Observer
  67292. * @param mask the mask used to filter observers
  67293. * @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.
  67294. * @param scope optional scope for the callback to be called from
  67295. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  67296. * @returns the new observer created for the callback
  67297. */
  67298. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  67299. /**
  67300. * Create a new Observer with the specified callback and unregisters after the next notification
  67301. * @param callback the callback that will be executed for that Observer
  67302. * @returns the new observer created for the callback
  67303. */
  67304. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  67305. /**
  67306. * Remove an Observer from the Observable object
  67307. * @param observer the instance of the Observer to remove
  67308. * @returns false if it doesn't belong to this Observable
  67309. */
  67310. remove(observer: Nullable<Observer<T>>): boolean;
  67311. /**
  67312. * Remove a callback from the Observable object
  67313. * @param callback the callback to remove
  67314. * @param scope optional scope. If used only the callbacks with this scope will be removed
  67315. * @returns false if it doesn't belong to this Observable
  67316. */
  67317. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  67318. private _deferUnregister;
  67319. private _remove;
  67320. /**
  67321. * Moves the observable to the top of the observer list making it get called first when notified
  67322. * @param observer the observer to move
  67323. */
  67324. makeObserverTopPriority(observer: Observer<T>): void;
  67325. /**
  67326. * Moves the observable to the bottom of the observer list making it get called last when notified
  67327. * @param observer the observer to move
  67328. */
  67329. makeObserverBottomPriority(observer: Observer<T>): void;
  67330. /**
  67331. * Notify all Observers by calling their respective callback with the given data
  67332. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  67333. * @param eventData defines the data to send to all observers
  67334. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  67335. * @param target defines the original target of the state
  67336. * @param currentTarget defines the current target of the state
  67337. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  67338. */
  67339. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  67340. /**
  67341. * Calling this will execute each callback, expecting it to be a promise or return a value.
  67342. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  67343. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  67344. * and it is crucial that all callbacks will be executed.
  67345. * The order of the callbacks is kept, callbacks are not executed parallel.
  67346. *
  67347. * @param eventData The data to be sent to each callback
  67348. * @param mask is used to filter observers defaults to -1
  67349. * @param target defines the callback target (see EventState)
  67350. * @param currentTarget defines he current object in the bubbling phase
  67351. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  67352. */
  67353. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  67354. /**
  67355. * Notify a specific observer
  67356. * @param observer defines the observer to notify
  67357. * @param eventData defines the data to be sent to each callback
  67358. * @param mask is used to filter observers defaults to -1
  67359. */
  67360. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  67361. /**
  67362. * Gets a boolean indicating if the observable has at least one observer
  67363. * @returns true is the Observable has at least one Observer registered
  67364. */
  67365. hasObservers(): boolean;
  67366. /**
  67367. * Clear the list of observers
  67368. */
  67369. clear(): void;
  67370. /**
  67371. * Clone the current observable
  67372. * @returns a new observable
  67373. */
  67374. clone(): Observable<T>;
  67375. /**
  67376. * Does this observable handles observer registered with a given mask
  67377. * @param mask defines the mask to be tested
  67378. * @return whether or not one observer registered with the given mask is handeled
  67379. **/
  67380. hasSpecificMask(mask?: number): boolean;
  67381. }
  67382. }
  67383. declare module BABYLON {
  67384. /**
  67385. * Class used to help managing file picking and drag'n'drop
  67386. * File Storage
  67387. */
  67388. export class FilesInputStore {
  67389. /**
  67390. * List of files ready to be loaded
  67391. */
  67392. static FilesToLoad: {
  67393. [key: string]: File;
  67394. };
  67395. }
  67396. }
  67397. declare module BABYLON {
  67398. /** Defines the cross module used constants to avoid circular dependncies */
  67399. export class Constants {
  67400. /** Defines that alpha blending is disabled */
  67401. static readonly ALPHA_DISABLE: number;
  67402. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  67403. static readonly ALPHA_ADD: number;
  67404. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  67405. static readonly ALPHA_COMBINE: number;
  67406. /** Defines that alpha blending to DEST - SRC * DEST */
  67407. static readonly ALPHA_SUBTRACT: number;
  67408. /** Defines that alpha blending to SRC * DEST */
  67409. static readonly ALPHA_MULTIPLY: number;
  67410. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  67411. static readonly ALPHA_MAXIMIZED: number;
  67412. /** Defines that alpha blending to SRC + DEST */
  67413. static readonly ALPHA_ONEONE: number;
  67414. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  67415. static readonly ALPHA_PREMULTIPLIED: number;
  67416. /**
  67417. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  67418. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  67419. */
  67420. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  67421. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  67422. static readonly ALPHA_INTERPOLATE: number;
  67423. /**
  67424. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  67425. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  67426. */
  67427. static readonly ALPHA_SCREENMODE: number;
  67428. /** Defines that the ressource is not delayed*/
  67429. static readonly DELAYLOADSTATE_NONE: number;
  67430. /** Defines that the ressource was successfully delay loaded */
  67431. static readonly DELAYLOADSTATE_LOADED: number;
  67432. /** Defines that the ressource is currently delay loading */
  67433. static readonly DELAYLOADSTATE_LOADING: number;
  67434. /** Defines that the ressource is delayed and has not started loading */
  67435. static readonly DELAYLOADSTATE_NOTLOADED: number;
  67436. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  67437. static readonly NEVER: number;
  67438. /** 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 */
  67439. static readonly ALWAYS: number;
  67440. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  67441. static readonly LESS: number;
  67442. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  67443. static readonly EQUAL: number;
  67444. /** 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 */
  67445. static readonly LEQUAL: number;
  67446. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  67447. static readonly GREATER: number;
  67448. /** 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 */
  67449. static readonly GEQUAL: number;
  67450. /** 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 */
  67451. static readonly NOTEQUAL: number;
  67452. /** Passed to stencilOperation to specify that stencil value must be kept */
  67453. static readonly KEEP: number;
  67454. /** Passed to stencilOperation to specify that stencil value must be replaced */
  67455. static readonly REPLACE: number;
  67456. /** Passed to stencilOperation to specify that stencil value must be incremented */
  67457. static readonly INCR: number;
  67458. /** Passed to stencilOperation to specify that stencil value must be decremented */
  67459. static readonly DECR: number;
  67460. /** Passed to stencilOperation to specify that stencil value must be inverted */
  67461. static readonly INVERT: number;
  67462. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  67463. static readonly INCR_WRAP: number;
  67464. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  67465. static readonly DECR_WRAP: number;
  67466. /** Texture is not repeating outside of 0..1 UVs */
  67467. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  67468. /** Texture is repeating outside of 0..1 UVs */
  67469. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  67470. /** Texture is repeating and mirrored */
  67471. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  67472. /** ALPHA */
  67473. static readonly TEXTUREFORMAT_ALPHA: number;
  67474. /** LUMINANCE */
  67475. static readonly TEXTUREFORMAT_LUMINANCE: number;
  67476. /** LUMINANCE_ALPHA */
  67477. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  67478. /** RGB */
  67479. static readonly TEXTUREFORMAT_RGB: number;
  67480. /** RGBA */
  67481. static readonly TEXTUREFORMAT_RGBA: number;
  67482. /** RED */
  67483. static readonly TEXTUREFORMAT_RED: number;
  67484. /** RED (2nd reference) */
  67485. static readonly TEXTUREFORMAT_R: number;
  67486. /** RG */
  67487. static readonly TEXTUREFORMAT_RG: number;
  67488. /** RED_INTEGER */
  67489. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  67490. /** RED_INTEGER (2nd reference) */
  67491. static readonly TEXTUREFORMAT_R_INTEGER: number;
  67492. /** RG_INTEGER */
  67493. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  67494. /** RGB_INTEGER */
  67495. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  67496. /** RGBA_INTEGER */
  67497. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  67498. /** UNSIGNED_BYTE */
  67499. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  67500. /** UNSIGNED_BYTE (2nd reference) */
  67501. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  67502. /** FLOAT */
  67503. static readonly TEXTURETYPE_FLOAT: number;
  67504. /** HALF_FLOAT */
  67505. static readonly TEXTURETYPE_HALF_FLOAT: number;
  67506. /** BYTE */
  67507. static readonly TEXTURETYPE_BYTE: number;
  67508. /** SHORT */
  67509. static readonly TEXTURETYPE_SHORT: number;
  67510. /** UNSIGNED_SHORT */
  67511. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  67512. /** INT */
  67513. static readonly TEXTURETYPE_INT: number;
  67514. /** UNSIGNED_INT */
  67515. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  67516. /** UNSIGNED_SHORT_4_4_4_4 */
  67517. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  67518. /** UNSIGNED_SHORT_5_5_5_1 */
  67519. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  67520. /** UNSIGNED_SHORT_5_6_5 */
  67521. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  67522. /** UNSIGNED_INT_2_10_10_10_REV */
  67523. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  67524. /** UNSIGNED_INT_24_8 */
  67525. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  67526. /** UNSIGNED_INT_10F_11F_11F_REV */
  67527. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  67528. /** UNSIGNED_INT_5_9_9_9_REV */
  67529. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  67530. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  67531. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  67532. /** nearest is mag = nearest and min = nearest and mip = linear */
  67533. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  67534. /** Bilinear is mag = linear and min = linear and mip = nearest */
  67535. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  67536. /** Trilinear is mag = linear and min = linear and mip = linear */
  67537. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  67538. /** nearest is mag = nearest and min = nearest and mip = linear */
  67539. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  67540. /** Bilinear is mag = linear and min = linear and mip = nearest */
  67541. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  67542. /** Trilinear is mag = linear and min = linear and mip = linear */
  67543. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  67544. /** mag = nearest and min = nearest and mip = nearest */
  67545. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  67546. /** mag = nearest and min = linear and mip = nearest */
  67547. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  67548. /** mag = nearest and min = linear and mip = linear */
  67549. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  67550. /** mag = nearest and min = linear and mip = none */
  67551. static readonly TEXTURE_NEAREST_LINEAR: number;
  67552. /** mag = nearest and min = nearest and mip = none */
  67553. static readonly TEXTURE_NEAREST_NEAREST: number;
  67554. /** mag = linear and min = nearest and mip = nearest */
  67555. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  67556. /** mag = linear and min = nearest and mip = linear */
  67557. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  67558. /** mag = linear and min = linear and mip = none */
  67559. static readonly TEXTURE_LINEAR_LINEAR: number;
  67560. /** mag = linear and min = nearest and mip = none */
  67561. static readonly TEXTURE_LINEAR_NEAREST: number;
  67562. /** Explicit coordinates mode */
  67563. static readonly TEXTURE_EXPLICIT_MODE: number;
  67564. /** Spherical coordinates mode */
  67565. static readonly TEXTURE_SPHERICAL_MODE: number;
  67566. /** Planar coordinates mode */
  67567. static readonly TEXTURE_PLANAR_MODE: number;
  67568. /** Cubic coordinates mode */
  67569. static readonly TEXTURE_CUBIC_MODE: number;
  67570. /** Projection coordinates mode */
  67571. static readonly TEXTURE_PROJECTION_MODE: number;
  67572. /** Skybox coordinates mode */
  67573. static readonly TEXTURE_SKYBOX_MODE: number;
  67574. /** Inverse Cubic coordinates mode */
  67575. static readonly TEXTURE_INVCUBIC_MODE: number;
  67576. /** Equirectangular coordinates mode */
  67577. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  67578. /** Equirectangular Fixed coordinates mode */
  67579. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  67580. /** Equirectangular Fixed Mirrored coordinates mode */
  67581. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  67582. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  67583. static readonly SCALEMODE_FLOOR: number;
  67584. /** Defines that texture rescaling will look for the nearest power of 2 size */
  67585. static readonly SCALEMODE_NEAREST: number;
  67586. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  67587. static readonly SCALEMODE_CEILING: number;
  67588. /**
  67589. * The dirty texture flag value
  67590. */
  67591. static readonly MATERIAL_TextureDirtyFlag: number;
  67592. /**
  67593. * The dirty light flag value
  67594. */
  67595. static readonly MATERIAL_LightDirtyFlag: number;
  67596. /**
  67597. * The dirty fresnel flag value
  67598. */
  67599. static readonly MATERIAL_FresnelDirtyFlag: number;
  67600. /**
  67601. * The dirty attribute flag value
  67602. */
  67603. static readonly MATERIAL_AttributesDirtyFlag: number;
  67604. /**
  67605. * The dirty misc flag value
  67606. */
  67607. static readonly MATERIAL_MiscDirtyFlag: number;
  67608. /**
  67609. * The all dirty flag value
  67610. */
  67611. static readonly MATERIAL_AllDirtyFlag: number;
  67612. /**
  67613. * Returns the triangle fill mode
  67614. */
  67615. static readonly MATERIAL_TriangleFillMode: number;
  67616. /**
  67617. * Returns the wireframe mode
  67618. */
  67619. static readonly MATERIAL_WireFrameFillMode: number;
  67620. /**
  67621. * Returns the point fill mode
  67622. */
  67623. static readonly MATERIAL_PointFillMode: number;
  67624. /**
  67625. * Returns the point list draw mode
  67626. */
  67627. static readonly MATERIAL_PointListDrawMode: number;
  67628. /**
  67629. * Returns the line list draw mode
  67630. */
  67631. static readonly MATERIAL_LineListDrawMode: number;
  67632. /**
  67633. * Returns the line loop draw mode
  67634. */
  67635. static readonly MATERIAL_LineLoopDrawMode: number;
  67636. /**
  67637. * Returns the line strip draw mode
  67638. */
  67639. static readonly MATERIAL_LineStripDrawMode: number;
  67640. /**
  67641. * Returns the triangle strip draw mode
  67642. */
  67643. static readonly MATERIAL_TriangleStripDrawMode: number;
  67644. /**
  67645. * Returns the triangle fan draw mode
  67646. */
  67647. static readonly MATERIAL_TriangleFanDrawMode: number;
  67648. /**
  67649. * Stores the clock-wise side orientation
  67650. */
  67651. static readonly MATERIAL_ClockWiseSideOrientation: number;
  67652. /**
  67653. * Stores the counter clock-wise side orientation
  67654. */
  67655. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  67656. /**
  67657. * Nothing
  67658. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67659. */
  67660. static readonly ACTION_NothingTrigger: number;
  67661. /**
  67662. * On pick
  67663. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67664. */
  67665. static readonly ACTION_OnPickTrigger: number;
  67666. /**
  67667. * On left pick
  67668. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67669. */
  67670. static readonly ACTION_OnLeftPickTrigger: number;
  67671. /**
  67672. * On right pick
  67673. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67674. */
  67675. static readonly ACTION_OnRightPickTrigger: number;
  67676. /**
  67677. * On center pick
  67678. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67679. */
  67680. static readonly ACTION_OnCenterPickTrigger: number;
  67681. /**
  67682. * On pick down
  67683. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67684. */
  67685. static readonly ACTION_OnPickDownTrigger: number;
  67686. /**
  67687. * On double pick
  67688. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67689. */
  67690. static readonly ACTION_OnDoublePickTrigger: number;
  67691. /**
  67692. * On pick up
  67693. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67694. */
  67695. static readonly ACTION_OnPickUpTrigger: number;
  67696. /**
  67697. * On pick out.
  67698. * This trigger will only be raised if you also declared a OnPickDown
  67699. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67700. */
  67701. static readonly ACTION_OnPickOutTrigger: number;
  67702. /**
  67703. * On long press
  67704. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67705. */
  67706. static readonly ACTION_OnLongPressTrigger: number;
  67707. /**
  67708. * On pointer over
  67709. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67710. */
  67711. static readonly ACTION_OnPointerOverTrigger: number;
  67712. /**
  67713. * On pointer out
  67714. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67715. */
  67716. static readonly ACTION_OnPointerOutTrigger: number;
  67717. /**
  67718. * On every frame
  67719. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67720. */
  67721. static readonly ACTION_OnEveryFrameTrigger: number;
  67722. /**
  67723. * On intersection enter
  67724. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67725. */
  67726. static readonly ACTION_OnIntersectionEnterTrigger: number;
  67727. /**
  67728. * On intersection exit
  67729. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67730. */
  67731. static readonly ACTION_OnIntersectionExitTrigger: number;
  67732. /**
  67733. * On key down
  67734. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67735. */
  67736. static readonly ACTION_OnKeyDownTrigger: number;
  67737. /**
  67738. * On key up
  67739. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67740. */
  67741. static readonly ACTION_OnKeyUpTrigger: number;
  67742. /**
  67743. * Billboard mode will only apply to Y axis
  67744. */
  67745. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  67746. /**
  67747. * Billboard mode will apply to all axes
  67748. */
  67749. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  67750. /**
  67751. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  67752. */
  67753. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  67754. /**
  67755. * Gets or sets base Assets URL
  67756. */
  67757. static PARTICLES_BaseAssetsUrl: string;
  67758. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  67759. * Test order :
  67760. * Is the bounding sphere outside the frustum ?
  67761. * If not, are the bounding box vertices outside the frustum ?
  67762. * It not, then the cullable object is in the frustum.
  67763. */
  67764. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  67765. /** Culling strategy : Bounding Sphere Only.
  67766. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  67767. * It's also less accurate than the standard because some not visible objects can still be selected.
  67768. * Test : is the bounding sphere outside the frustum ?
  67769. * If not, then the cullable object is in the frustum.
  67770. */
  67771. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  67772. /** Culling strategy : Optimistic Inclusion.
  67773. * This in an inclusion test first, then the standard exclusion test.
  67774. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  67775. * 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.
  67776. * Anyway, it's as accurate as the standard strategy.
  67777. * Test :
  67778. * Is the cullable object bounding sphere center in the frustum ?
  67779. * If not, apply the default culling strategy.
  67780. */
  67781. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  67782. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  67783. * This in an inclusion test first, then the bounding sphere only exclusion test.
  67784. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  67785. * 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.
  67786. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  67787. * Test :
  67788. * Is the cullable object bounding sphere center in the frustum ?
  67789. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  67790. */
  67791. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  67792. /**
  67793. * No logging while loading
  67794. */
  67795. static readonly SCENELOADER_NO_LOGGING: number;
  67796. /**
  67797. * Minimal logging while loading
  67798. */
  67799. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  67800. /**
  67801. * Summary logging while loading
  67802. */
  67803. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  67804. /**
  67805. * Detailled logging while loading
  67806. */
  67807. static readonly SCENELOADER_DETAILED_LOGGING: number;
  67808. }
  67809. }
  67810. declare module BABYLON {
  67811. /**
  67812. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  67813. * Babylon.js
  67814. */
  67815. export class DomManagement {
  67816. /**
  67817. * Checks if the window object exists
  67818. * @returns true if the window object exists
  67819. */
  67820. static IsWindowObjectExist(): boolean;
  67821. /**
  67822. * Extracts text content from a DOM element hierarchy
  67823. * @param element defines the root element
  67824. * @returns a string
  67825. */
  67826. static GetDOMTextContent(element: HTMLElement): string;
  67827. }
  67828. }
  67829. declare module BABYLON {
  67830. /**
  67831. * Logger used througouht the application to allow configuration of
  67832. * the log level required for the messages.
  67833. */
  67834. export class Logger {
  67835. /**
  67836. * No log
  67837. */
  67838. static readonly NoneLogLevel: number;
  67839. /**
  67840. * Only message logs
  67841. */
  67842. static readonly MessageLogLevel: number;
  67843. /**
  67844. * Only warning logs
  67845. */
  67846. static readonly WarningLogLevel: number;
  67847. /**
  67848. * Only error logs
  67849. */
  67850. static readonly ErrorLogLevel: number;
  67851. /**
  67852. * All logs
  67853. */
  67854. static readonly AllLogLevel: number;
  67855. private static _LogCache;
  67856. /**
  67857. * Gets a value indicating the number of loading errors
  67858. * @ignorenaming
  67859. */
  67860. static errorsCount: number;
  67861. /**
  67862. * Callback called when a new log is added
  67863. */
  67864. static OnNewCacheEntry: (entry: string) => void;
  67865. private static _AddLogEntry;
  67866. private static _FormatMessage;
  67867. private static _LogDisabled;
  67868. private static _LogEnabled;
  67869. private static _WarnDisabled;
  67870. private static _WarnEnabled;
  67871. private static _ErrorDisabled;
  67872. private static _ErrorEnabled;
  67873. /**
  67874. * Log a message to the console
  67875. */
  67876. static Log: (message: string) => void;
  67877. /**
  67878. * Write a warning message to the console
  67879. */
  67880. static Warn: (message: string) => void;
  67881. /**
  67882. * Write an error message to the console
  67883. */
  67884. static Error: (message: string) => void;
  67885. /**
  67886. * Gets current log cache (list of logs)
  67887. */
  67888. static readonly LogCache: string;
  67889. /**
  67890. * Clears the log cache
  67891. */
  67892. static ClearLogCache(): void;
  67893. /**
  67894. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  67895. */
  67896. static LogLevels: number;
  67897. }
  67898. }
  67899. declare module BABYLON {
  67900. /** @hidden */
  67901. export class _TypeStore {
  67902. /** @hidden */
  67903. static RegisteredTypes: {
  67904. [key: string]: Object;
  67905. };
  67906. /** @hidden */
  67907. static GetClass(fqdn: string): any;
  67908. }
  67909. }
  67910. declare module BABYLON {
  67911. /**
  67912. * Class containing a set of static utilities functions for deep copy.
  67913. */
  67914. export class DeepCopier {
  67915. /**
  67916. * Tries to copy an object by duplicating every property
  67917. * @param source defines the source object
  67918. * @param destination defines the target object
  67919. * @param doNotCopyList defines a list of properties to avoid
  67920. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  67921. */
  67922. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  67923. }
  67924. }
  67925. declare module BABYLON {
  67926. /**
  67927. * Class containing a set of static utilities functions for precision date
  67928. */
  67929. export class PrecisionDate {
  67930. /**
  67931. * Gets either window.performance.now() if supported or Date.now() else
  67932. */
  67933. static readonly Now: number;
  67934. }
  67935. }
  67936. declare module BABYLON {
  67937. /** @hidden */
  67938. export class _DevTools {
  67939. static WarnImport(name: string): string;
  67940. }
  67941. }
  67942. declare module BABYLON {
  67943. /**
  67944. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  67945. */
  67946. export class WebRequest {
  67947. private _xhr;
  67948. /**
  67949. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  67950. * i.e. when loading files, where the server/service expects an Authorization header
  67951. */
  67952. static CustomRequestHeaders: {
  67953. [key: string]: string;
  67954. };
  67955. /**
  67956. * Add callback functions in this array to update all the requests before they get sent to the network
  67957. */
  67958. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  67959. private _injectCustomRequestHeaders;
  67960. /**
  67961. * Gets or sets a function to be called when loading progress changes
  67962. */
  67963. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  67964. /**
  67965. * Returns client's state
  67966. */
  67967. readonly readyState: number;
  67968. /**
  67969. * Returns client's status
  67970. */
  67971. readonly status: number;
  67972. /**
  67973. * Returns client's status as a text
  67974. */
  67975. readonly statusText: string;
  67976. /**
  67977. * Returns client's response
  67978. */
  67979. readonly response: any;
  67980. /**
  67981. * Returns client's response url
  67982. */
  67983. readonly responseURL: string;
  67984. /**
  67985. * Returns client's response as text
  67986. */
  67987. readonly responseText: string;
  67988. /**
  67989. * Gets or sets the expected response type
  67990. */
  67991. responseType: XMLHttpRequestResponseType;
  67992. /** @hidden */
  67993. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  67994. /** @hidden */
  67995. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  67996. /**
  67997. * Cancels any network activity
  67998. */
  67999. abort(): void;
  68000. /**
  68001. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  68002. * @param body defines an optional request body
  68003. */
  68004. send(body?: Document | BodyInit | null): void;
  68005. /**
  68006. * Sets the request method, request URL
  68007. * @param method defines the method to use (GET, POST, etc..)
  68008. * @param url defines the url to connect with
  68009. */
  68010. open(method: string, url: string): void;
  68011. }
  68012. }
  68013. declare module BABYLON {
  68014. /**
  68015. * Class used to evalaute queries containing `and` and `or` operators
  68016. */
  68017. export class AndOrNotEvaluator {
  68018. /**
  68019. * Evaluate a query
  68020. * @param query defines the query to evaluate
  68021. * @param evaluateCallback defines the callback used to filter result
  68022. * @returns true if the query matches
  68023. */
  68024. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  68025. private static _HandleParenthesisContent;
  68026. private static _SimplifyNegation;
  68027. }
  68028. }
  68029. declare module BABYLON {
  68030. /**
  68031. * Class used to store custom tags
  68032. */
  68033. export class Tags {
  68034. /**
  68035. * Adds support for tags on the given object
  68036. * @param obj defines the object to use
  68037. */
  68038. static EnableFor(obj: any): void;
  68039. /**
  68040. * Removes tags support
  68041. * @param obj defines the object to use
  68042. */
  68043. static DisableFor(obj: any): void;
  68044. /**
  68045. * Gets a boolean indicating if the given object has tags
  68046. * @param obj defines the object to use
  68047. * @returns a boolean
  68048. */
  68049. static HasTags(obj: any): boolean;
  68050. /**
  68051. * Gets the tags available on a given object
  68052. * @param obj defines the object to use
  68053. * @param asString defines if the tags must be returned as a string instead of an array of strings
  68054. * @returns the tags
  68055. */
  68056. static GetTags(obj: any, asString?: boolean): any;
  68057. /**
  68058. * Adds tags to an object
  68059. * @param obj defines the object to use
  68060. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  68061. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  68062. */
  68063. static AddTagsTo(obj: any, tagsString: string): void;
  68064. /**
  68065. * @hidden
  68066. */
  68067. static _AddTagTo(obj: any, tag: string): void;
  68068. /**
  68069. * Removes specific tags from a specific object
  68070. * @param obj defines the object to use
  68071. * @param tagsString defines the tags to remove
  68072. */
  68073. static RemoveTagsFrom(obj: any, tagsString: string): void;
  68074. /**
  68075. * @hidden
  68076. */
  68077. static _RemoveTagFrom(obj: any, tag: string): void;
  68078. /**
  68079. * Defines if tags hosted on an object match a given query
  68080. * @param obj defines the object to use
  68081. * @param tagsQuery defines the tag query
  68082. * @returns a boolean
  68083. */
  68084. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  68085. }
  68086. }
  68087. declare module BABYLON {
  68088. /**
  68089. * Manages the defines for the Material
  68090. */
  68091. export class MaterialDefines {
  68092. /** @hidden */
  68093. protected _keys: string[];
  68094. private _isDirty;
  68095. /** @hidden */
  68096. _renderId: number;
  68097. /** @hidden */
  68098. _areLightsDirty: boolean;
  68099. /** @hidden */
  68100. _areAttributesDirty: boolean;
  68101. /** @hidden */
  68102. _areTexturesDirty: boolean;
  68103. /** @hidden */
  68104. _areFresnelDirty: boolean;
  68105. /** @hidden */
  68106. _areMiscDirty: boolean;
  68107. /** @hidden */
  68108. _areImageProcessingDirty: boolean;
  68109. /** @hidden */
  68110. _normals: boolean;
  68111. /** @hidden */
  68112. _uvs: boolean;
  68113. /** @hidden */
  68114. _needNormals: boolean;
  68115. /** @hidden */
  68116. _needUVs: boolean;
  68117. [id: string]: any;
  68118. /**
  68119. * Specifies if the material needs to be re-calculated
  68120. */
  68121. readonly isDirty: boolean;
  68122. /**
  68123. * Marks the material to indicate that it has been re-calculated
  68124. */
  68125. markAsProcessed(): void;
  68126. /**
  68127. * Marks the material to indicate that it needs to be re-calculated
  68128. */
  68129. markAsUnprocessed(): void;
  68130. /**
  68131. * Marks the material to indicate all of its defines need to be re-calculated
  68132. */
  68133. markAllAsDirty(): void;
  68134. /**
  68135. * Marks the material to indicate that image processing needs to be re-calculated
  68136. */
  68137. markAsImageProcessingDirty(): void;
  68138. /**
  68139. * Marks the material to indicate the lights need to be re-calculated
  68140. */
  68141. markAsLightDirty(): void;
  68142. /**
  68143. * Marks the attribute state as changed
  68144. */
  68145. markAsAttributesDirty(): void;
  68146. /**
  68147. * Marks the texture state as changed
  68148. */
  68149. markAsTexturesDirty(): void;
  68150. /**
  68151. * Marks the fresnel state as changed
  68152. */
  68153. markAsFresnelDirty(): void;
  68154. /**
  68155. * Marks the misc state as changed
  68156. */
  68157. markAsMiscDirty(): void;
  68158. /**
  68159. * Rebuilds the material defines
  68160. */
  68161. rebuild(): void;
  68162. /**
  68163. * Specifies if two material defines are equal
  68164. * @param other - A material define instance to compare to
  68165. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  68166. */
  68167. isEqual(other: MaterialDefines): boolean;
  68168. /**
  68169. * Clones this instance's defines to another instance
  68170. * @param other - material defines to clone values to
  68171. */
  68172. cloneTo(other: MaterialDefines): void;
  68173. /**
  68174. * Resets the material define values
  68175. */
  68176. reset(): void;
  68177. /**
  68178. * Converts the material define values to a string
  68179. * @returns - String of material define information
  68180. */
  68181. toString(): string;
  68182. }
  68183. }
  68184. declare module BABYLON {
  68185. /**
  68186. * Class used to store and describe the pipeline context associated with an effect
  68187. */
  68188. export interface IPipelineContext {
  68189. /**
  68190. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  68191. */
  68192. isAsync: boolean;
  68193. /**
  68194. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  68195. */
  68196. isReady: boolean;
  68197. /** @hidden */
  68198. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  68199. }
  68200. }
  68201. declare module BABYLON {
  68202. /**
  68203. * Class used to store gfx data (like WebGLBuffer)
  68204. */
  68205. export class DataBuffer {
  68206. /**
  68207. * Gets or sets the number of objects referencing this buffer
  68208. */
  68209. references: number;
  68210. /** Gets or sets the size of the underlying buffer */
  68211. capacity: number;
  68212. /**
  68213. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  68214. */
  68215. is32Bits: boolean;
  68216. /**
  68217. * Gets the underlying buffer
  68218. */
  68219. readonly underlyingResource: any;
  68220. }
  68221. }
  68222. declare module BABYLON {
  68223. /** @hidden */
  68224. export interface IShaderProcessor {
  68225. attributeProcessor?: (attribute: string) => string;
  68226. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  68227. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  68228. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  68229. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  68230. lineProcessor?: (line: string, isFragment: boolean) => string;
  68231. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  68232. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  68233. }
  68234. }
  68235. declare module BABYLON {
  68236. /** @hidden */
  68237. export interface ProcessingOptions {
  68238. defines: string[];
  68239. indexParameters: any;
  68240. isFragment: boolean;
  68241. shouldUseHighPrecisionShader: boolean;
  68242. supportsUniformBuffers: boolean;
  68243. shadersRepository: string;
  68244. includesShadersStore: {
  68245. [key: string]: string;
  68246. };
  68247. processor?: IShaderProcessor;
  68248. version: string;
  68249. platformName: string;
  68250. lookForClosingBracketForUniformBuffer?: boolean;
  68251. }
  68252. }
  68253. declare module BABYLON {
  68254. /** @hidden */
  68255. export class ShaderCodeNode {
  68256. line: string;
  68257. children: ShaderCodeNode[];
  68258. additionalDefineKey?: string;
  68259. additionalDefineValue?: string;
  68260. isValid(preprocessors: {
  68261. [key: string]: string;
  68262. }): boolean;
  68263. process(preprocessors: {
  68264. [key: string]: string;
  68265. }, options: ProcessingOptions): string;
  68266. }
  68267. }
  68268. declare module BABYLON {
  68269. /** @hidden */
  68270. export class ShaderCodeCursor {
  68271. private _lines;
  68272. lineIndex: number;
  68273. readonly currentLine: string;
  68274. readonly canRead: boolean;
  68275. lines: string[];
  68276. }
  68277. }
  68278. declare module BABYLON {
  68279. /** @hidden */
  68280. export class ShaderCodeConditionNode extends ShaderCodeNode {
  68281. process(preprocessors: {
  68282. [key: string]: string;
  68283. }, options: ProcessingOptions): string;
  68284. }
  68285. }
  68286. declare module BABYLON {
  68287. /** @hidden */
  68288. export class ShaderDefineExpression {
  68289. isTrue(preprocessors: {
  68290. [key: string]: string;
  68291. }): boolean;
  68292. }
  68293. }
  68294. declare module BABYLON {
  68295. /** @hidden */
  68296. export class ShaderCodeTestNode extends ShaderCodeNode {
  68297. testExpression: ShaderDefineExpression;
  68298. isValid(preprocessors: {
  68299. [key: string]: string;
  68300. }): boolean;
  68301. }
  68302. }
  68303. declare module BABYLON {
  68304. /** @hidden */
  68305. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  68306. define: string;
  68307. not: boolean;
  68308. constructor(define: string, not?: boolean);
  68309. isTrue(preprocessors: {
  68310. [key: string]: string;
  68311. }): boolean;
  68312. }
  68313. }
  68314. declare module BABYLON {
  68315. /** @hidden */
  68316. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  68317. leftOperand: ShaderDefineExpression;
  68318. rightOperand: ShaderDefineExpression;
  68319. isTrue(preprocessors: {
  68320. [key: string]: string;
  68321. }): boolean;
  68322. }
  68323. }
  68324. declare module BABYLON {
  68325. /** @hidden */
  68326. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  68327. leftOperand: ShaderDefineExpression;
  68328. rightOperand: ShaderDefineExpression;
  68329. isTrue(preprocessors: {
  68330. [key: string]: string;
  68331. }): boolean;
  68332. }
  68333. }
  68334. declare module BABYLON {
  68335. /** @hidden */
  68336. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  68337. define: string;
  68338. operand: string;
  68339. testValue: string;
  68340. constructor(define: string, operand: string, testValue: string);
  68341. isTrue(preprocessors: {
  68342. [key: string]: string;
  68343. }): boolean;
  68344. }
  68345. }
  68346. declare module BABYLON {
  68347. /** @hidden */
  68348. export class ShaderProcessor {
  68349. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  68350. private static _ProcessPrecision;
  68351. private static _ExtractOperation;
  68352. private static _BuildSubExpression;
  68353. private static _BuildExpression;
  68354. private static _MoveCursorWithinIf;
  68355. private static _MoveCursor;
  68356. private static _EvaluatePreProcessors;
  68357. private static _PreparePreProcessors;
  68358. private static _ProcessShaderConversion;
  68359. private static _ProcessIncludes;
  68360. }
  68361. }
  68362. declare module BABYLON {
  68363. /**
  68364. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  68365. */
  68366. export class PerformanceMonitor {
  68367. private _enabled;
  68368. private _rollingFrameTime;
  68369. private _lastFrameTimeMs;
  68370. /**
  68371. * constructor
  68372. * @param frameSampleSize The number of samples required to saturate the sliding window
  68373. */
  68374. constructor(frameSampleSize?: number);
  68375. /**
  68376. * Samples current frame
  68377. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  68378. */
  68379. sampleFrame(timeMs?: number): void;
  68380. /**
  68381. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  68382. */
  68383. readonly averageFrameTime: number;
  68384. /**
  68385. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  68386. */
  68387. readonly averageFrameTimeVariance: number;
  68388. /**
  68389. * Returns the frame time of the most recent frame
  68390. */
  68391. readonly instantaneousFrameTime: number;
  68392. /**
  68393. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  68394. */
  68395. readonly averageFPS: number;
  68396. /**
  68397. * Returns the average framerate in frames per second using the most recent frame time
  68398. */
  68399. readonly instantaneousFPS: number;
  68400. /**
  68401. * Returns true if enough samples have been taken to completely fill the sliding window
  68402. */
  68403. readonly isSaturated: boolean;
  68404. /**
  68405. * Enables contributions to the sliding window sample set
  68406. */
  68407. enable(): void;
  68408. /**
  68409. * Disables contributions to the sliding window sample set
  68410. * Samples will not be interpolated over the disabled period
  68411. */
  68412. disable(): void;
  68413. /**
  68414. * Returns true if sampling is enabled
  68415. */
  68416. readonly isEnabled: boolean;
  68417. /**
  68418. * Resets performance monitor
  68419. */
  68420. reset(): void;
  68421. }
  68422. /**
  68423. * RollingAverage
  68424. *
  68425. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  68426. */
  68427. export class RollingAverage {
  68428. /**
  68429. * Current average
  68430. */
  68431. average: number;
  68432. /**
  68433. * Current variance
  68434. */
  68435. variance: number;
  68436. protected _samples: Array<number>;
  68437. protected _sampleCount: number;
  68438. protected _pos: number;
  68439. protected _m2: number;
  68440. /**
  68441. * constructor
  68442. * @param length The number of samples required to saturate the sliding window
  68443. */
  68444. constructor(length: number);
  68445. /**
  68446. * Adds a sample to the sample set
  68447. * @param v The sample value
  68448. */
  68449. add(v: number): void;
  68450. /**
  68451. * Returns previously added values or null if outside of history or outside the sliding window domain
  68452. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  68453. * @return Value previously recorded with add() or null if outside of range
  68454. */
  68455. history(i: number): number;
  68456. /**
  68457. * Returns true if enough samples have been taken to completely fill the sliding window
  68458. * @return true if sample-set saturated
  68459. */
  68460. isSaturated(): boolean;
  68461. /**
  68462. * Resets the rolling average (equivalent to 0 samples taken so far)
  68463. */
  68464. reset(): void;
  68465. /**
  68466. * Wraps a value around the sample range boundaries
  68467. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  68468. * @return Wrapped position in sample range
  68469. */
  68470. protected _wrapPosition(i: number): number;
  68471. }
  68472. }
  68473. declare module BABYLON {
  68474. /**
  68475. * This class implement a typical dictionary using a string as key and the generic type T as value.
  68476. * The underlying implementation relies on an associative array to ensure the best performances.
  68477. * The value can be anything including 'null' but except 'undefined'
  68478. */
  68479. export class StringDictionary<T> {
  68480. /**
  68481. * This will clear this dictionary and copy the content from the 'source' one.
  68482. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  68483. * @param source the dictionary to take the content from and copy to this dictionary
  68484. */
  68485. copyFrom(source: StringDictionary<T>): void;
  68486. /**
  68487. * Get a value based from its key
  68488. * @param key the given key to get the matching value from
  68489. * @return the value if found, otherwise undefined is returned
  68490. */
  68491. get(key: string): T | undefined;
  68492. /**
  68493. * Get a value from its key or add it if it doesn't exist.
  68494. * This method will ensure you that a given key/data will be present in the dictionary.
  68495. * @param key the given key to get the matching value from
  68496. * @param factory the factory that will create the value if the key is not present in the dictionary.
  68497. * The factory will only be invoked if there's no data for the given key.
  68498. * @return the value corresponding to the key.
  68499. */
  68500. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  68501. /**
  68502. * Get a value from its key if present in the dictionary otherwise add it
  68503. * @param key the key to get the value from
  68504. * @param val if there's no such key/value pair in the dictionary add it with this value
  68505. * @return the value corresponding to the key
  68506. */
  68507. getOrAdd(key: string, val: T): T;
  68508. /**
  68509. * Check if there's a given key in the dictionary
  68510. * @param key the key to check for
  68511. * @return true if the key is present, false otherwise
  68512. */
  68513. contains(key: string): boolean;
  68514. /**
  68515. * Add a new key and its corresponding value
  68516. * @param key the key to add
  68517. * @param value the value corresponding to the key
  68518. * @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
  68519. */
  68520. add(key: string, value: T): boolean;
  68521. /**
  68522. * Update a specific value associated to a key
  68523. * @param key defines the key to use
  68524. * @param value defines the value to store
  68525. * @returns true if the value was updated (or false if the key was not found)
  68526. */
  68527. set(key: string, value: T): boolean;
  68528. /**
  68529. * Get the element of the given key and remove it from the dictionary
  68530. * @param key defines the key to search
  68531. * @returns the value associated with the key or null if not found
  68532. */
  68533. getAndRemove(key: string): Nullable<T>;
  68534. /**
  68535. * Remove a key/value from the dictionary.
  68536. * @param key the key to remove
  68537. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  68538. */
  68539. remove(key: string): boolean;
  68540. /**
  68541. * Clear the whole content of the dictionary
  68542. */
  68543. clear(): void;
  68544. /**
  68545. * Gets the current count
  68546. */
  68547. readonly count: number;
  68548. /**
  68549. * Execute a callback on each key/val of the dictionary.
  68550. * Note that you can remove any element in this dictionary in the callback implementation
  68551. * @param callback the callback to execute on a given key/value pair
  68552. */
  68553. forEach(callback: (key: string, val: T) => void): void;
  68554. /**
  68555. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  68556. * If the callback returns null or undefined the method will iterate to the next key/value pair
  68557. * Note that you can remove any element in this dictionary in the callback implementation
  68558. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  68559. * @returns the first item
  68560. */
  68561. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  68562. private _count;
  68563. private _data;
  68564. }
  68565. }
  68566. declare module BABYLON {
  68567. /**
  68568. * Helper class that provides a small promise polyfill
  68569. */
  68570. export class PromisePolyfill {
  68571. /**
  68572. * Static function used to check if the polyfill is required
  68573. * If this is the case then the function will inject the polyfill to window.Promise
  68574. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  68575. */
  68576. static Apply(force?: boolean): void;
  68577. }
  68578. }
  68579. declare module BABYLON {
  68580. /**
  68581. * Class used to store data that will be store in GPU memory
  68582. */
  68583. export class Buffer {
  68584. private _engine;
  68585. private _buffer;
  68586. /** @hidden */
  68587. _data: Nullable<DataArray>;
  68588. private _updatable;
  68589. private _instanced;
  68590. /**
  68591. * Gets the byte stride.
  68592. */
  68593. readonly byteStride: number;
  68594. /**
  68595. * Constructor
  68596. * @param engine the engine
  68597. * @param data the data to use for this buffer
  68598. * @param updatable whether the data is updatable
  68599. * @param stride the stride (optional)
  68600. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  68601. * @param instanced whether the buffer is instanced (optional)
  68602. * @param useBytes set to true if the stride in in bytes (optional)
  68603. */
  68604. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  68605. /**
  68606. * Create a new VertexBuffer based on the current buffer
  68607. * @param kind defines the vertex buffer kind (position, normal, etc.)
  68608. * @param offset defines offset in the buffer (0 by default)
  68609. * @param size defines the size in floats of attributes (position is 3 for instance)
  68610. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  68611. * @param instanced defines if the vertex buffer contains indexed data
  68612. * @param useBytes defines if the offset and stride are in bytes
  68613. * @returns the new vertex buffer
  68614. */
  68615. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  68616. /**
  68617. * Gets a boolean indicating if the Buffer is updatable?
  68618. * @returns true if the buffer is updatable
  68619. */
  68620. isUpdatable(): boolean;
  68621. /**
  68622. * Gets current buffer's data
  68623. * @returns a DataArray or null
  68624. */
  68625. getData(): Nullable<DataArray>;
  68626. /**
  68627. * Gets underlying native buffer
  68628. * @returns underlying native buffer
  68629. */
  68630. getBuffer(): Nullable<DataBuffer>;
  68631. /**
  68632. * Gets the stride in float32 units (i.e. byte stride / 4).
  68633. * May not be an integer if the byte stride is not divisible by 4.
  68634. * DEPRECATED. Use byteStride instead.
  68635. * @returns the stride in float32 units
  68636. */
  68637. getStrideSize(): number;
  68638. /**
  68639. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  68640. * @param data defines the data to store
  68641. */
  68642. create(data?: Nullable<DataArray>): void;
  68643. /** @hidden */
  68644. _rebuild(): void;
  68645. /**
  68646. * Update current buffer data
  68647. * @param data defines the data to store
  68648. */
  68649. update(data: DataArray): void;
  68650. /**
  68651. * Updates the data directly.
  68652. * @param data the new data
  68653. * @param offset the new offset
  68654. * @param vertexCount the vertex count (optional)
  68655. * @param useBytes set to true if the offset is in bytes
  68656. */
  68657. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  68658. /**
  68659. * Release all resources
  68660. */
  68661. dispose(): void;
  68662. }
  68663. /**
  68664. * Specialized buffer used to store vertex data
  68665. */
  68666. export class VertexBuffer {
  68667. /** @hidden */
  68668. _buffer: Buffer;
  68669. private _kind;
  68670. private _size;
  68671. private _ownsBuffer;
  68672. private _instanced;
  68673. private _instanceDivisor;
  68674. /**
  68675. * The byte type.
  68676. */
  68677. static readonly BYTE: number;
  68678. /**
  68679. * The unsigned byte type.
  68680. */
  68681. static readonly UNSIGNED_BYTE: number;
  68682. /**
  68683. * The short type.
  68684. */
  68685. static readonly SHORT: number;
  68686. /**
  68687. * The unsigned short type.
  68688. */
  68689. static readonly UNSIGNED_SHORT: number;
  68690. /**
  68691. * The integer type.
  68692. */
  68693. static readonly INT: number;
  68694. /**
  68695. * The unsigned integer type.
  68696. */
  68697. static readonly UNSIGNED_INT: number;
  68698. /**
  68699. * The float type.
  68700. */
  68701. static readonly FLOAT: number;
  68702. /**
  68703. * Gets or sets the instance divisor when in instanced mode
  68704. */
  68705. instanceDivisor: number;
  68706. /**
  68707. * Gets the byte stride.
  68708. */
  68709. readonly byteStride: number;
  68710. /**
  68711. * Gets the byte offset.
  68712. */
  68713. readonly byteOffset: number;
  68714. /**
  68715. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  68716. */
  68717. readonly normalized: boolean;
  68718. /**
  68719. * Gets the data type of each component in the array.
  68720. */
  68721. readonly type: number;
  68722. /**
  68723. * Constructor
  68724. * @param engine the engine
  68725. * @param data the data to use for this vertex buffer
  68726. * @param kind the vertex buffer kind
  68727. * @param updatable whether the data is updatable
  68728. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  68729. * @param stride the stride (optional)
  68730. * @param instanced whether the buffer is instanced (optional)
  68731. * @param offset the offset of the data (optional)
  68732. * @param size the number of components (optional)
  68733. * @param type the type of the component (optional)
  68734. * @param normalized whether the data contains normalized data (optional)
  68735. * @param useBytes set to true if stride and offset are in bytes (optional)
  68736. */
  68737. 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);
  68738. /** @hidden */
  68739. _rebuild(): void;
  68740. /**
  68741. * Returns the kind of the VertexBuffer (string)
  68742. * @returns a string
  68743. */
  68744. getKind(): string;
  68745. /**
  68746. * Gets a boolean indicating if the VertexBuffer is updatable?
  68747. * @returns true if the buffer is updatable
  68748. */
  68749. isUpdatable(): boolean;
  68750. /**
  68751. * Gets current buffer's data
  68752. * @returns a DataArray or null
  68753. */
  68754. getData(): Nullable<DataArray>;
  68755. /**
  68756. * Gets underlying native buffer
  68757. * @returns underlying native buffer
  68758. */
  68759. getBuffer(): Nullable<DataBuffer>;
  68760. /**
  68761. * Gets the stride in float32 units (i.e. byte stride / 4).
  68762. * May not be an integer if the byte stride is not divisible by 4.
  68763. * DEPRECATED. Use byteStride instead.
  68764. * @returns the stride in float32 units
  68765. */
  68766. getStrideSize(): number;
  68767. /**
  68768. * Returns the offset as a multiple of the type byte length.
  68769. * DEPRECATED. Use byteOffset instead.
  68770. * @returns the offset in bytes
  68771. */
  68772. getOffset(): number;
  68773. /**
  68774. * Returns the number of components per vertex attribute (integer)
  68775. * @returns the size in float
  68776. */
  68777. getSize(): number;
  68778. /**
  68779. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  68780. * @returns true if this buffer is instanced
  68781. */
  68782. getIsInstanced(): boolean;
  68783. /**
  68784. * Returns the instancing divisor, zero for non-instanced (integer).
  68785. * @returns a number
  68786. */
  68787. getInstanceDivisor(): number;
  68788. /**
  68789. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  68790. * @param data defines the data to store
  68791. */
  68792. create(data?: DataArray): void;
  68793. /**
  68794. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  68795. * This function will create a new buffer if the current one is not updatable
  68796. * @param data defines the data to store
  68797. */
  68798. update(data: DataArray): void;
  68799. /**
  68800. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  68801. * Returns the directly updated WebGLBuffer.
  68802. * @param data the new data
  68803. * @param offset the new offset
  68804. * @param useBytes set to true if the offset is in bytes
  68805. */
  68806. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  68807. /**
  68808. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  68809. */
  68810. dispose(): void;
  68811. /**
  68812. * Enumerates each value of this vertex buffer as numbers.
  68813. * @param count the number of values to enumerate
  68814. * @param callback the callback function called for each value
  68815. */
  68816. forEach(count: number, callback: (value: number, index: number) => void): void;
  68817. /**
  68818. * Positions
  68819. */
  68820. static readonly PositionKind: string;
  68821. /**
  68822. * Normals
  68823. */
  68824. static readonly NormalKind: string;
  68825. /**
  68826. * Tangents
  68827. */
  68828. static readonly TangentKind: string;
  68829. /**
  68830. * Texture coordinates
  68831. */
  68832. static readonly UVKind: string;
  68833. /**
  68834. * Texture coordinates 2
  68835. */
  68836. static readonly UV2Kind: string;
  68837. /**
  68838. * Texture coordinates 3
  68839. */
  68840. static readonly UV3Kind: string;
  68841. /**
  68842. * Texture coordinates 4
  68843. */
  68844. static readonly UV4Kind: string;
  68845. /**
  68846. * Texture coordinates 5
  68847. */
  68848. static readonly UV5Kind: string;
  68849. /**
  68850. * Texture coordinates 6
  68851. */
  68852. static readonly UV6Kind: string;
  68853. /**
  68854. * Colors
  68855. */
  68856. static readonly ColorKind: string;
  68857. /**
  68858. * Matrix indices (for bones)
  68859. */
  68860. static readonly MatricesIndicesKind: string;
  68861. /**
  68862. * Matrix weights (for bones)
  68863. */
  68864. static readonly MatricesWeightsKind: string;
  68865. /**
  68866. * Additional matrix indices (for bones)
  68867. */
  68868. static readonly MatricesIndicesExtraKind: string;
  68869. /**
  68870. * Additional matrix weights (for bones)
  68871. */
  68872. static readonly MatricesWeightsExtraKind: string;
  68873. /**
  68874. * Deduces the stride given a kind.
  68875. * @param kind The kind string to deduce
  68876. * @returns The deduced stride
  68877. */
  68878. static DeduceStride(kind: string): number;
  68879. /**
  68880. * Gets the byte length of the given type.
  68881. * @param type the type
  68882. * @returns the number of bytes
  68883. */
  68884. static GetTypeByteLength(type: number): number;
  68885. /**
  68886. * Enumerates each value of the given parameters as numbers.
  68887. * @param data the data to enumerate
  68888. * @param byteOffset the byte offset of the data
  68889. * @param byteStride the byte stride of the data
  68890. * @param componentCount the number of components per element
  68891. * @param componentType the type of the component
  68892. * @param count the number of values to enumerate
  68893. * @param normalized whether the data is normalized
  68894. * @param callback the callback function called for each value
  68895. */
  68896. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  68897. private static _GetFloatValue;
  68898. }
  68899. }
  68900. declare module BABYLON {
  68901. /**
  68902. * Class representing spherical harmonics coefficients to the 3rd degree
  68903. */
  68904. export class SphericalHarmonics {
  68905. /**
  68906. * Defines whether or not the harmonics have been prescaled for rendering.
  68907. */
  68908. preScaled: boolean;
  68909. /**
  68910. * The l0,0 coefficients of the spherical harmonics
  68911. */
  68912. l00: Vector3;
  68913. /**
  68914. * The l1,-1 coefficients of the spherical harmonics
  68915. */
  68916. l1_1: Vector3;
  68917. /**
  68918. * The l1,0 coefficients of the spherical harmonics
  68919. */
  68920. l10: Vector3;
  68921. /**
  68922. * The l1,1 coefficients of the spherical harmonics
  68923. */
  68924. l11: Vector3;
  68925. /**
  68926. * The l2,-2 coefficients of the spherical harmonics
  68927. */
  68928. l2_2: Vector3;
  68929. /**
  68930. * The l2,-1 coefficients of the spherical harmonics
  68931. */
  68932. l2_1: Vector3;
  68933. /**
  68934. * The l2,0 coefficients of the spherical harmonics
  68935. */
  68936. l20: Vector3;
  68937. /**
  68938. * The l2,1 coefficients of the spherical harmonics
  68939. */
  68940. l21: Vector3;
  68941. /**
  68942. * The l2,2 coefficients of the spherical harmonics
  68943. */
  68944. l22: Vector3;
  68945. /**
  68946. * Adds a light to the spherical harmonics
  68947. * @param direction the direction of the light
  68948. * @param color the color of the light
  68949. * @param deltaSolidAngle the delta solid angle of the light
  68950. */
  68951. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  68952. /**
  68953. * Scales the spherical harmonics by the given amount
  68954. * @param scale the amount to scale
  68955. */
  68956. scaleInPlace(scale: number): void;
  68957. /**
  68958. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  68959. *
  68960. * ```
  68961. * E_lm = A_l * L_lm
  68962. * ```
  68963. *
  68964. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  68965. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  68966. * the scaling factors are given in equation 9.
  68967. */
  68968. convertIncidentRadianceToIrradiance(): void;
  68969. /**
  68970. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  68971. *
  68972. * ```
  68973. * L = (1/pi) * E * rho
  68974. * ```
  68975. *
  68976. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  68977. */
  68978. convertIrradianceToLambertianRadiance(): void;
  68979. /**
  68980. * Integrates the reconstruction coefficients directly in to the SH preventing further
  68981. * required operations at run time.
  68982. *
  68983. * This is simply done by scaling back the SH with Ylm constants parameter.
  68984. * The trigonometric part being applied by the shader at run time.
  68985. */
  68986. preScaleForRendering(): void;
  68987. /**
  68988. * Constructs a spherical harmonics from an array.
  68989. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  68990. * @returns the spherical harmonics
  68991. */
  68992. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  68993. /**
  68994. * Gets the spherical harmonics from polynomial
  68995. * @param polynomial the spherical polynomial
  68996. * @returns the spherical harmonics
  68997. */
  68998. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  68999. }
  69000. /**
  69001. * Class representing spherical polynomial coefficients to the 3rd degree
  69002. */
  69003. export class SphericalPolynomial {
  69004. private _harmonics;
  69005. /**
  69006. * The spherical harmonics used to create the polynomials.
  69007. */
  69008. readonly preScaledHarmonics: SphericalHarmonics;
  69009. /**
  69010. * The x coefficients of the spherical polynomial
  69011. */
  69012. x: Vector3;
  69013. /**
  69014. * The y coefficients of the spherical polynomial
  69015. */
  69016. y: Vector3;
  69017. /**
  69018. * The z coefficients of the spherical polynomial
  69019. */
  69020. z: Vector3;
  69021. /**
  69022. * The xx coefficients of the spherical polynomial
  69023. */
  69024. xx: Vector3;
  69025. /**
  69026. * The yy coefficients of the spherical polynomial
  69027. */
  69028. yy: Vector3;
  69029. /**
  69030. * The zz coefficients of the spherical polynomial
  69031. */
  69032. zz: Vector3;
  69033. /**
  69034. * The xy coefficients of the spherical polynomial
  69035. */
  69036. xy: Vector3;
  69037. /**
  69038. * The yz coefficients of the spherical polynomial
  69039. */
  69040. yz: Vector3;
  69041. /**
  69042. * The zx coefficients of the spherical polynomial
  69043. */
  69044. zx: Vector3;
  69045. /**
  69046. * Adds an ambient color to the spherical polynomial
  69047. * @param color the color to add
  69048. */
  69049. addAmbient(color: Color3): void;
  69050. /**
  69051. * Scales the spherical polynomial by the given amount
  69052. * @param scale the amount to scale
  69053. */
  69054. scaleInPlace(scale: number): void;
  69055. /**
  69056. * Gets the spherical polynomial from harmonics
  69057. * @param harmonics the spherical harmonics
  69058. * @returns the spherical polynomial
  69059. */
  69060. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  69061. /**
  69062. * Constructs a spherical polynomial from an array.
  69063. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  69064. * @returns the spherical polynomial
  69065. */
  69066. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  69067. }
  69068. }
  69069. declare module BABYLON {
  69070. /**
  69071. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  69072. */
  69073. export interface CubeMapInfo {
  69074. /**
  69075. * The pixel array for the front face.
  69076. * This is stored in format, left to right, up to down format.
  69077. */
  69078. front: Nullable<ArrayBufferView>;
  69079. /**
  69080. * The pixel array for the back face.
  69081. * This is stored in format, left to right, up to down format.
  69082. */
  69083. back: Nullable<ArrayBufferView>;
  69084. /**
  69085. * The pixel array for the left face.
  69086. * This is stored in format, left to right, up to down format.
  69087. */
  69088. left: Nullable<ArrayBufferView>;
  69089. /**
  69090. * The pixel array for the right face.
  69091. * This is stored in format, left to right, up to down format.
  69092. */
  69093. right: Nullable<ArrayBufferView>;
  69094. /**
  69095. * The pixel array for the up face.
  69096. * This is stored in format, left to right, up to down format.
  69097. */
  69098. up: Nullable<ArrayBufferView>;
  69099. /**
  69100. * The pixel array for the down face.
  69101. * This is stored in format, left to right, up to down format.
  69102. */
  69103. down: Nullable<ArrayBufferView>;
  69104. /**
  69105. * The size of the cubemap stored.
  69106. *
  69107. * Each faces will be size * size pixels.
  69108. */
  69109. size: number;
  69110. /**
  69111. * The format of the texture.
  69112. *
  69113. * RGBA, RGB.
  69114. */
  69115. format: number;
  69116. /**
  69117. * The type of the texture data.
  69118. *
  69119. * UNSIGNED_INT, FLOAT.
  69120. */
  69121. type: number;
  69122. /**
  69123. * Specifies whether the texture is in gamma space.
  69124. */
  69125. gammaSpace: boolean;
  69126. }
  69127. /**
  69128. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  69129. */
  69130. export class PanoramaToCubeMapTools {
  69131. private static FACE_FRONT;
  69132. private static FACE_BACK;
  69133. private static FACE_RIGHT;
  69134. private static FACE_LEFT;
  69135. private static FACE_DOWN;
  69136. private static FACE_UP;
  69137. /**
  69138. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  69139. *
  69140. * @param float32Array The source data.
  69141. * @param inputWidth The width of the input panorama.
  69142. * @param inputHeight The height of the input panorama.
  69143. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  69144. * @return The cubemap data
  69145. */
  69146. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  69147. private static CreateCubemapTexture;
  69148. private static CalcProjectionSpherical;
  69149. }
  69150. }
  69151. declare module BABYLON {
  69152. /**
  69153. * Helper class dealing with the extraction of spherical polynomial dataArray
  69154. * from a cube map.
  69155. */
  69156. export class CubeMapToSphericalPolynomialTools {
  69157. private static FileFaces;
  69158. /**
  69159. * Converts a texture to the according Spherical Polynomial data.
  69160. * This extracts the first 3 orders only as they are the only one used in the lighting.
  69161. *
  69162. * @param texture The texture to extract the information from.
  69163. * @return The Spherical Polynomial data.
  69164. */
  69165. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  69166. /**
  69167. * Converts a cubemap to the according Spherical Polynomial data.
  69168. * This extracts the first 3 orders only as they are the only one used in the lighting.
  69169. *
  69170. * @param cubeInfo The Cube map to extract the information from.
  69171. * @return The Spherical Polynomial data.
  69172. */
  69173. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  69174. }
  69175. }
  69176. declare module BABYLON {
  69177. /**
  69178. * The engine store class is responsible to hold all the instances of Engine and Scene created
  69179. * during the life time of the application.
  69180. */
  69181. export class EngineStore {
  69182. /** Gets the list of created engines */
  69183. static Instances: Engine[];
  69184. /** @hidden */
  69185. static _LastCreatedScene: Nullable<Scene>;
  69186. /**
  69187. * Gets the latest created engine
  69188. */
  69189. static readonly LastCreatedEngine: Nullable<Engine>;
  69190. /**
  69191. * Gets the latest created scene
  69192. */
  69193. static readonly LastCreatedScene: Nullable<Scene>;
  69194. }
  69195. }
  69196. declare module BABYLON {
  69197. /**
  69198. * Define options used to create a render target texture
  69199. */
  69200. export class RenderTargetCreationOptions {
  69201. /**
  69202. * Specifies is mipmaps must be generated
  69203. */
  69204. generateMipMaps?: boolean;
  69205. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  69206. generateDepthBuffer?: boolean;
  69207. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  69208. generateStencilBuffer?: boolean;
  69209. /** Defines texture type (int by default) */
  69210. type?: number;
  69211. /** Defines sampling mode (trilinear by default) */
  69212. samplingMode?: number;
  69213. /** Defines format (RGBA by default) */
  69214. format?: number;
  69215. }
  69216. }
  69217. declare module BABYLON {
  69218. /**
  69219. * @hidden
  69220. **/
  69221. export class _AlphaState {
  69222. private _isAlphaBlendDirty;
  69223. private _isBlendFunctionParametersDirty;
  69224. private _isBlendEquationParametersDirty;
  69225. private _isBlendConstantsDirty;
  69226. private _alphaBlend;
  69227. private _blendFunctionParameters;
  69228. private _blendEquationParameters;
  69229. private _blendConstants;
  69230. /**
  69231. * Initializes the state.
  69232. */
  69233. constructor();
  69234. readonly isDirty: boolean;
  69235. alphaBlend: boolean;
  69236. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  69237. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  69238. setAlphaEquationParameters(rgb: number, alpha: number): void;
  69239. reset(): void;
  69240. apply(gl: WebGLRenderingContext): void;
  69241. }
  69242. }
  69243. declare module BABYLON {
  69244. /**
  69245. * @hidden
  69246. **/
  69247. export class _DepthCullingState {
  69248. private _isDepthTestDirty;
  69249. private _isDepthMaskDirty;
  69250. private _isDepthFuncDirty;
  69251. private _isCullFaceDirty;
  69252. private _isCullDirty;
  69253. private _isZOffsetDirty;
  69254. private _isFrontFaceDirty;
  69255. private _depthTest;
  69256. private _depthMask;
  69257. private _depthFunc;
  69258. private _cull;
  69259. private _cullFace;
  69260. private _zOffset;
  69261. private _frontFace;
  69262. /**
  69263. * Initializes the state.
  69264. */
  69265. constructor();
  69266. readonly isDirty: boolean;
  69267. zOffset: number;
  69268. cullFace: Nullable<number>;
  69269. cull: Nullable<boolean>;
  69270. depthFunc: Nullable<number>;
  69271. depthMask: boolean;
  69272. depthTest: boolean;
  69273. frontFace: Nullable<number>;
  69274. reset(): void;
  69275. apply(gl: WebGLRenderingContext): void;
  69276. }
  69277. }
  69278. declare module BABYLON {
  69279. /**
  69280. * @hidden
  69281. **/
  69282. export class _StencilState {
  69283. /** 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 */
  69284. static readonly ALWAYS: number;
  69285. /** Passed to stencilOperation to specify that stencil value must be kept */
  69286. static readonly KEEP: number;
  69287. /** Passed to stencilOperation to specify that stencil value must be replaced */
  69288. static readonly REPLACE: number;
  69289. private _isStencilTestDirty;
  69290. private _isStencilMaskDirty;
  69291. private _isStencilFuncDirty;
  69292. private _isStencilOpDirty;
  69293. private _stencilTest;
  69294. private _stencilMask;
  69295. private _stencilFunc;
  69296. private _stencilFuncRef;
  69297. private _stencilFuncMask;
  69298. private _stencilOpStencilFail;
  69299. private _stencilOpDepthFail;
  69300. private _stencilOpStencilDepthPass;
  69301. readonly isDirty: boolean;
  69302. stencilFunc: number;
  69303. stencilFuncRef: number;
  69304. stencilFuncMask: number;
  69305. stencilOpStencilFail: number;
  69306. stencilOpDepthFail: number;
  69307. stencilOpStencilDepthPass: number;
  69308. stencilMask: number;
  69309. stencilTest: boolean;
  69310. constructor();
  69311. reset(): void;
  69312. apply(gl: WebGLRenderingContext): void;
  69313. }
  69314. }
  69315. declare module BABYLON {
  69316. /**
  69317. * @hidden
  69318. **/
  69319. export class _TimeToken {
  69320. _startTimeQuery: Nullable<WebGLQuery>;
  69321. _endTimeQuery: Nullable<WebGLQuery>;
  69322. _timeElapsedQuery: Nullable<WebGLQuery>;
  69323. _timeElapsedQueryEnded: boolean;
  69324. }
  69325. }
  69326. declare module BABYLON {
  69327. /**
  69328. * Class used to store data associated with WebGL texture data for the engine
  69329. * This class should not be used directly
  69330. */
  69331. export class InternalTexture {
  69332. /** @hidden */
  69333. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  69334. /**
  69335. * The source of the texture data is unknown
  69336. */
  69337. static DATASOURCE_UNKNOWN: number;
  69338. /**
  69339. * Texture data comes from an URL
  69340. */
  69341. static DATASOURCE_URL: number;
  69342. /**
  69343. * Texture data is only used for temporary storage
  69344. */
  69345. static DATASOURCE_TEMP: number;
  69346. /**
  69347. * Texture data comes from raw data (ArrayBuffer)
  69348. */
  69349. static DATASOURCE_RAW: number;
  69350. /**
  69351. * Texture content is dynamic (video or dynamic texture)
  69352. */
  69353. static DATASOURCE_DYNAMIC: number;
  69354. /**
  69355. * Texture content is generated by rendering to it
  69356. */
  69357. static DATASOURCE_RENDERTARGET: number;
  69358. /**
  69359. * Texture content is part of a multi render target process
  69360. */
  69361. static DATASOURCE_MULTIRENDERTARGET: number;
  69362. /**
  69363. * Texture data comes from a cube data file
  69364. */
  69365. static DATASOURCE_CUBE: number;
  69366. /**
  69367. * Texture data comes from a raw cube data
  69368. */
  69369. static DATASOURCE_CUBERAW: number;
  69370. /**
  69371. * Texture data come from a prefiltered cube data file
  69372. */
  69373. static DATASOURCE_CUBEPREFILTERED: number;
  69374. /**
  69375. * Texture content is raw 3D data
  69376. */
  69377. static DATASOURCE_RAW3D: number;
  69378. /**
  69379. * Texture content is a depth texture
  69380. */
  69381. static DATASOURCE_DEPTHTEXTURE: number;
  69382. /**
  69383. * Texture data comes from a raw cube data encoded with RGBD
  69384. */
  69385. static DATASOURCE_CUBERAW_RGBD: number;
  69386. /**
  69387. * Defines if the texture is ready
  69388. */
  69389. isReady: boolean;
  69390. /**
  69391. * Defines if the texture is a cube texture
  69392. */
  69393. isCube: boolean;
  69394. /**
  69395. * Defines if the texture contains 3D data
  69396. */
  69397. is3D: boolean;
  69398. /**
  69399. * Defines if the texture contains multiview data
  69400. */
  69401. isMultiview: boolean;
  69402. /**
  69403. * Gets the URL used to load this texture
  69404. */
  69405. url: string;
  69406. /**
  69407. * Gets the sampling mode of the texture
  69408. */
  69409. samplingMode: number;
  69410. /**
  69411. * Gets a boolean indicating if the texture needs mipmaps generation
  69412. */
  69413. generateMipMaps: boolean;
  69414. /**
  69415. * Gets the number of samples used by the texture (WebGL2+ only)
  69416. */
  69417. samples: number;
  69418. /**
  69419. * Gets the type of the texture (int, float...)
  69420. */
  69421. type: number;
  69422. /**
  69423. * Gets the format of the texture (RGB, RGBA...)
  69424. */
  69425. format: number;
  69426. /**
  69427. * Observable called when the texture is loaded
  69428. */
  69429. onLoadedObservable: Observable<InternalTexture>;
  69430. /**
  69431. * Gets the width of the texture
  69432. */
  69433. width: number;
  69434. /**
  69435. * Gets the height of the texture
  69436. */
  69437. height: number;
  69438. /**
  69439. * Gets the depth of the texture
  69440. */
  69441. depth: number;
  69442. /**
  69443. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  69444. */
  69445. baseWidth: number;
  69446. /**
  69447. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  69448. */
  69449. baseHeight: number;
  69450. /**
  69451. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  69452. */
  69453. baseDepth: number;
  69454. /**
  69455. * Gets a boolean indicating if the texture is inverted on Y axis
  69456. */
  69457. invertY: boolean;
  69458. /** @hidden */
  69459. _invertVScale: boolean;
  69460. /** @hidden */
  69461. _associatedChannel: number;
  69462. /** @hidden */
  69463. _dataSource: number;
  69464. /** @hidden */
  69465. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  69466. /** @hidden */
  69467. _bufferView: Nullable<ArrayBufferView>;
  69468. /** @hidden */
  69469. _bufferViewArray: Nullable<ArrayBufferView[]>;
  69470. /** @hidden */
  69471. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  69472. /** @hidden */
  69473. _size: number;
  69474. /** @hidden */
  69475. _extension: string;
  69476. /** @hidden */
  69477. _files: Nullable<string[]>;
  69478. /** @hidden */
  69479. _workingCanvas: Nullable<HTMLCanvasElement>;
  69480. /** @hidden */
  69481. _workingContext: Nullable<CanvasRenderingContext2D>;
  69482. /** @hidden */
  69483. _framebuffer: Nullable<WebGLFramebuffer>;
  69484. /** @hidden */
  69485. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  69486. /** @hidden */
  69487. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  69488. /** @hidden */
  69489. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  69490. /** @hidden */
  69491. _attachments: Nullable<number[]>;
  69492. /** @hidden */
  69493. _cachedCoordinatesMode: Nullable<number>;
  69494. /** @hidden */
  69495. _cachedWrapU: Nullable<number>;
  69496. /** @hidden */
  69497. _cachedWrapV: Nullable<number>;
  69498. /** @hidden */
  69499. _cachedWrapR: Nullable<number>;
  69500. /** @hidden */
  69501. _cachedAnisotropicFilteringLevel: Nullable<number>;
  69502. /** @hidden */
  69503. _isDisabled: boolean;
  69504. /** @hidden */
  69505. _compression: Nullable<string>;
  69506. /** @hidden */
  69507. _generateStencilBuffer: boolean;
  69508. /** @hidden */
  69509. _generateDepthBuffer: boolean;
  69510. /** @hidden */
  69511. _comparisonFunction: number;
  69512. /** @hidden */
  69513. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  69514. /** @hidden */
  69515. _lodGenerationScale: number;
  69516. /** @hidden */
  69517. _lodGenerationOffset: number;
  69518. /** @hidden */
  69519. _colorTextureArray: Nullable<WebGLTexture>;
  69520. /** @hidden */
  69521. _depthStencilTextureArray: Nullable<WebGLTexture>;
  69522. /** @hidden */
  69523. _lodTextureHigh: Nullable<BaseTexture>;
  69524. /** @hidden */
  69525. _lodTextureMid: Nullable<BaseTexture>;
  69526. /** @hidden */
  69527. _lodTextureLow: Nullable<BaseTexture>;
  69528. /** @hidden */
  69529. _isRGBD: boolean;
  69530. /** @hidden */
  69531. _linearSpecularLOD: boolean;
  69532. /** @hidden */
  69533. _irradianceTexture: Nullable<BaseTexture>;
  69534. /** @hidden */
  69535. _webGLTexture: Nullable<WebGLTexture>;
  69536. /** @hidden */
  69537. _references: number;
  69538. private _engine;
  69539. /**
  69540. * Gets the Engine the texture belongs to.
  69541. * @returns The babylon engine
  69542. */
  69543. getEngine(): Engine;
  69544. /**
  69545. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  69546. */
  69547. readonly dataSource: number;
  69548. /**
  69549. * Creates a new InternalTexture
  69550. * @param engine defines the engine to use
  69551. * @param dataSource defines the type of data that will be used
  69552. * @param delayAllocation if the texture allocation should be delayed (default: false)
  69553. */
  69554. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  69555. /**
  69556. * Increments the number of references (ie. the number of Texture that point to it)
  69557. */
  69558. incrementReferences(): void;
  69559. /**
  69560. * Change the size of the texture (not the size of the content)
  69561. * @param width defines the new width
  69562. * @param height defines the new height
  69563. * @param depth defines the new depth (1 by default)
  69564. */
  69565. updateSize(width: int, height: int, depth?: int): void;
  69566. /** @hidden */
  69567. _rebuild(): void;
  69568. /** @hidden */
  69569. _swapAndDie(target: InternalTexture): void;
  69570. /**
  69571. * Dispose the current allocated resources
  69572. */
  69573. dispose(): void;
  69574. }
  69575. }
  69576. declare module BABYLON {
  69577. /**
  69578. * This represents the main contract an easing function should follow.
  69579. * Easing functions are used throughout the animation system.
  69580. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69581. */
  69582. export interface IEasingFunction {
  69583. /**
  69584. * Given an input gradient between 0 and 1, this returns the corrseponding value
  69585. * of the easing function.
  69586. * The link below provides some of the most common examples of easing functions.
  69587. * @see https://easings.net/
  69588. * @param gradient Defines the value between 0 and 1 we want the easing value for
  69589. * @returns the corresponding value on the curve defined by the easing function
  69590. */
  69591. ease(gradient: number): number;
  69592. }
  69593. /**
  69594. * Base class used for every default easing function.
  69595. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69596. */
  69597. export class EasingFunction implements IEasingFunction {
  69598. /**
  69599. * Interpolation follows the mathematical formula associated with the easing function.
  69600. */
  69601. static readonly EASINGMODE_EASEIN: number;
  69602. /**
  69603. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  69604. */
  69605. static readonly EASINGMODE_EASEOUT: number;
  69606. /**
  69607. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  69608. */
  69609. static readonly EASINGMODE_EASEINOUT: number;
  69610. private _easingMode;
  69611. /**
  69612. * Sets the easing mode of the current function.
  69613. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  69614. */
  69615. setEasingMode(easingMode: number): void;
  69616. /**
  69617. * Gets the current easing mode.
  69618. * @returns the easing mode
  69619. */
  69620. getEasingMode(): number;
  69621. /**
  69622. * @hidden
  69623. */
  69624. easeInCore(gradient: number): number;
  69625. /**
  69626. * Given an input gradient between 0 and 1, this returns the corrseponding value
  69627. * of the easing function.
  69628. * @param gradient Defines the value between 0 and 1 we want the easing value for
  69629. * @returns the corresponding value on the curve defined by the easing function
  69630. */
  69631. ease(gradient: number): number;
  69632. }
  69633. /**
  69634. * Easing function with a circle shape (see link below).
  69635. * @see https://easings.net/#easeInCirc
  69636. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69637. */
  69638. export class CircleEase extends EasingFunction implements IEasingFunction {
  69639. /** @hidden */
  69640. easeInCore(gradient: number): number;
  69641. }
  69642. /**
  69643. * Easing function with a ease back shape (see link below).
  69644. * @see https://easings.net/#easeInBack
  69645. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69646. */
  69647. export class BackEase extends EasingFunction implements IEasingFunction {
  69648. /** Defines the amplitude of the function */
  69649. amplitude: number;
  69650. /**
  69651. * Instantiates a back ease easing
  69652. * @see https://easings.net/#easeInBack
  69653. * @param amplitude Defines the amplitude of the function
  69654. */
  69655. constructor(
  69656. /** Defines the amplitude of the function */
  69657. amplitude?: number);
  69658. /** @hidden */
  69659. easeInCore(gradient: number): number;
  69660. }
  69661. /**
  69662. * Easing function with a bouncing shape (see link below).
  69663. * @see https://easings.net/#easeInBounce
  69664. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69665. */
  69666. export class BounceEase extends EasingFunction implements IEasingFunction {
  69667. /** Defines the number of bounces */
  69668. bounces: number;
  69669. /** Defines the amplitude of the bounce */
  69670. bounciness: number;
  69671. /**
  69672. * Instantiates a bounce easing
  69673. * @see https://easings.net/#easeInBounce
  69674. * @param bounces Defines the number of bounces
  69675. * @param bounciness Defines the amplitude of the bounce
  69676. */
  69677. constructor(
  69678. /** Defines the number of bounces */
  69679. bounces?: number,
  69680. /** Defines the amplitude of the bounce */
  69681. bounciness?: number);
  69682. /** @hidden */
  69683. easeInCore(gradient: number): number;
  69684. }
  69685. /**
  69686. * Easing function with a power of 3 shape (see link below).
  69687. * @see https://easings.net/#easeInCubic
  69688. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69689. */
  69690. export class CubicEase extends EasingFunction implements IEasingFunction {
  69691. /** @hidden */
  69692. easeInCore(gradient: number): number;
  69693. }
  69694. /**
  69695. * Easing function with an elastic shape (see link below).
  69696. * @see https://easings.net/#easeInElastic
  69697. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69698. */
  69699. export class ElasticEase extends EasingFunction implements IEasingFunction {
  69700. /** Defines the number of oscillations*/
  69701. oscillations: number;
  69702. /** Defines the amplitude of the oscillations*/
  69703. springiness: number;
  69704. /**
  69705. * Instantiates an elastic easing function
  69706. * @see https://easings.net/#easeInElastic
  69707. * @param oscillations Defines the number of oscillations
  69708. * @param springiness Defines the amplitude of the oscillations
  69709. */
  69710. constructor(
  69711. /** Defines the number of oscillations*/
  69712. oscillations?: number,
  69713. /** Defines the amplitude of the oscillations*/
  69714. springiness?: number);
  69715. /** @hidden */
  69716. easeInCore(gradient: number): number;
  69717. }
  69718. /**
  69719. * Easing function with an exponential shape (see link below).
  69720. * @see https://easings.net/#easeInExpo
  69721. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69722. */
  69723. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  69724. /** Defines the exponent of the function */
  69725. exponent: number;
  69726. /**
  69727. * Instantiates an exponential easing function
  69728. * @see https://easings.net/#easeInExpo
  69729. * @param exponent Defines the exponent of the function
  69730. */
  69731. constructor(
  69732. /** Defines the exponent of the function */
  69733. exponent?: number);
  69734. /** @hidden */
  69735. easeInCore(gradient: number): number;
  69736. }
  69737. /**
  69738. * Easing function with a power shape (see link below).
  69739. * @see https://easings.net/#easeInQuad
  69740. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69741. */
  69742. export class PowerEase extends EasingFunction implements IEasingFunction {
  69743. /** Defines the power of the function */
  69744. power: number;
  69745. /**
  69746. * Instantiates an power base easing function
  69747. * @see https://easings.net/#easeInQuad
  69748. * @param power Defines the power of the function
  69749. */
  69750. constructor(
  69751. /** Defines the power of the function */
  69752. power?: number);
  69753. /** @hidden */
  69754. easeInCore(gradient: number): number;
  69755. }
  69756. /**
  69757. * Easing function with a power of 2 shape (see link below).
  69758. * @see https://easings.net/#easeInQuad
  69759. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69760. */
  69761. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  69762. /** @hidden */
  69763. easeInCore(gradient: number): number;
  69764. }
  69765. /**
  69766. * Easing function with a power of 4 shape (see link below).
  69767. * @see https://easings.net/#easeInQuart
  69768. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69769. */
  69770. export class QuarticEase extends EasingFunction implements IEasingFunction {
  69771. /** @hidden */
  69772. easeInCore(gradient: number): number;
  69773. }
  69774. /**
  69775. * Easing function with a power of 5 shape (see link below).
  69776. * @see https://easings.net/#easeInQuint
  69777. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69778. */
  69779. export class QuinticEase extends EasingFunction implements IEasingFunction {
  69780. /** @hidden */
  69781. easeInCore(gradient: number): number;
  69782. }
  69783. /**
  69784. * Easing function with a sin shape (see link below).
  69785. * @see https://easings.net/#easeInSine
  69786. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69787. */
  69788. export class SineEase extends EasingFunction implements IEasingFunction {
  69789. /** @hidden */
  69790. easeInCore(gradient: number): number;
  69791. }
  69792. /**
  69793. * Easing function with a bezier shape (see link below).
  69794. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  69795. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69796. */
  69797. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  69798. /** Defines the x component of the start tangent in the bezier curve */
  69799. x1: number;
  69800. /** Defines the y component of the start tangent in the bezier curve */
  69801. y1: number;
  69802. /** Defines the x component of the end tangent in the bezier curve */
  69803. x2: number;
  69804. /** Defines the y component of the end tangent in the bezier curve */
  69805. y2: number;
  69806. /**
  69807. * Instantiates a bezier function
  69808. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  69809. * @param x1 Defines the x component of the start tangent in the bezier curve
  69810. * @param y1 Defines the y component of the start tangent in the bezier curve
  69811. * @param x2 Defines the x component of the end tangent in the bezier curve
  69812. * @param y2 Defines the y component of the end tangent in the bezier curve
  69813. */
  69814. constructor(
  69815. /** Defines the x component of the start tangent in the bezier curve */
  69816. x1?: number,
  69817. /** Defines the y component of the start tangent in the bezier curve */
  69818. y1?: number,
  69819. /** Defines the x component of the end tangent in the bezier curve */
  69820. x2?: number,
  69821. /** Defines the y component of the end tangent in the bezier curve */
  69822. y2?: number);
  69823. /** @hidden */
  69824. easeInCore(gradient: number): number;
  69825. }
  69826. }
  69827. declare module BABYLON {
  69828. /**
  69829. * Defines an interface which represents an animation key frame
  69830. */
  69831. export interface IAnimationKey {
  69832. /**
  69833. * Frame of the key frame
  69834. */
  69835. frame: number;
  69836. /**
  69837. * Value at the specifies key frame
  69838. */
  69839. value: any;
  69840. /**
  69841. * The input tangent for the cubic hermite spline
  69842. */
  69843. inTangent?: any;
  69844. /**
  69845. * The output tangent for the cubic hermite spline
  69846. */
  69847. outTangent?: any;
  69848. /**
  69849. * The animation interpolation type
  69850. */
  69851. interpolation?: AnimationKeyInterpolation;
  69852. }
  69853. /**
  69854. * Enum for the animation key frame interpolation type
  69855. */
  69856. export enum AnimationKeyInterpolation {
  69857. /**
  69858. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  69859. */
  69860. STEP = 1
  69861. }
  69862. }
  69863. declare module BABYLON {
  69864. /**
  69865. * Represents the range of an animation
  69866. */
  69867. export class AnimationRange {
  69868. /**The name of the animation range**/
  69869. name: string;
  69870. /**The starting frame of the animation */
  69871. from: number;
  69872. /**The ending frame of the animation*/
  69873. to: number;
  69874. /**
  69875. * Initializes the range of an animation
  69876. * @param name The name of the animation range
  69877. * @param from The starting frame of the animation
  69878. * @param to The ending frame of the animation
  69879. */
  69880. constructor(
  69881. /**The name of the animation range**/
  69882. name: string,
  69883. /**The starting frame of the animation */
  69884. from: number,
  69885. /**The ending frame of the animation*/
  69886. to: number);
  69887. /**
  69888. * Makes a copy of the animation range
  69889. * @returns A copy of the animation range
  69890. */
  69891. clone(): AnimationRange;
  69892. }
  69893. }
  69894. declare module BABYLON {
  69895. /**
  69896. * Composed of a frame, and an action function
  69897. */
  69898. export class AnimationEvent {
  69899. /** The frame for which the event is triggered **/
  69900. frame: number;
  69901. /** The event to perform when triggered **/
  69902. action: (currentFrame: number) => void;
  69903. /** Specifies if the event should be triggered only once**/
  69904. onlyOnce?: boolean | undefined;
  69905. /**
  69906. * Specifies if the animation event is done
  69907. */
  69908. isDone: boolean;
  69909. /**
  69910. * Initializes the animation event
  69911. * @param frame The frame for which the event is triggered
  69912. * @param action The event to perform when triggered
  69913. * @param onlyOnce Specifies if the event should be triggered only once
  69914. */
  69915. constructor(
  69916. /** The frame for which the event is triggered **/
  69917. frame: number,
  69918. /** The event to perform when triggered **/
  69919. action: (currentFrame: number) => void,
  69920. /** Specifies if the event should be triggered only once**/
  69921. onlyOnce?: boolean | undefined);
  69922. /** @hidden */
  69923. _clone(): AnimationEvent;
  69924. }
  69925. }
  69926. declare module BABYLON {
  69927. /**
  69928. * Interface used to define a behavior
  69929. */
  69930. export interface Behavior<T> {
  69931. /** gets or sets behavior's name */
  69932. name: string;
  69933. /**
  69934. * Function called when the behavior needs to be initialized (after attaching it to a target)
  69935. */
  69936. init(): void;
  69937. /**
  69938. * Called when the behavior is attached to a target
  69939. * @param target defines the target where the behavior is attached to
  69940. */
  69941. attach(target: T): void;
  69942. /**
  69943. * Called when the behavior is detached from its target
  69944. */
  69945. detach(): void;
  69946. }
  69947. /**
  69948. * Interface implemented by classes supporting behaviors
  69949. */
  69950. export interface IBehaviorAware<T> {
  69951. /**
  69952. * Attach a behavior
  69953. * @param behavior defines the behavior to attach
  69954. * @returns the current host
  69955. */
  69956. addBehavior(behavior: Behavior<T>): T;
  69957. /**
  69958. * Remove a behavior from the current object
  69959. * @param behavior defines the behavior to detach
  69960. * @returns the current host
  69961. */
  69962. removeBehavior(behavior: Behavior<T>): T;
  69963. /**
  69964. * Gets a behavior using its name to search
  69965. * @param name defines the name to search
  69966. * @returns the behavior or null if not found
  69967. */
  69968. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  69969. }
  69970. }
  69971. declare module BABYLON {
  69972. /**
  69973. * @hidden
  69974. */
  69975. export class IntersectionInfo {
  69976. bu: Nullable<number>;
  69977. bv: Nullable<number>;
  69978. distance: number;
  69979. faceId: number;
  69980. subMeshId: number;
  69981. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  69982. }
  69983. }
  69984. declare module BABYLON {
  69985. /**
  69986. * Class used to store bounding sphere information
  69987. */
  69988. export class BoundingSphere {
  69989. /**
  69990. * Gets the center of the bounding sphere in local space
  69991. */
  69992. readonly center: Vector3;
  69993. /**
  69994. * Radius of the bounding sphere in local space
  69995. */
  69996. radius: number;
  69997. /**
  69998. * Gets the center of the bounding sphere in world space
  69999. */
  70000. readonly centerWorld: Vector3;
  70001. /**
  70002. * Radius of the bounding sphere in world space
  70003. */
  70004. radiusWorld: number;
  70005. /**
  70006. * Gets the minimum vector in local space
  70007. */
  70008. readonly minimum: Vector3;
  70009. /**
  70010. * Gets the maximum vector in local space
  70011. */
  70012. readonly maximum: Vector3;
  70013. private _worldMatrix;
  70014. private static readonly TmpVector3;
  70015. /**
  70016. * Creates a new bounding sphere
  70017. * @param min defines the minimum vector (in local space)
  70018. * @param max defines the maximum vector (in local space)
  70019. * @param worldMatrix defines the new world matrix
  70020. */
  70021. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  70022. /**
  70023. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  70024. * @param min defines the new minimum vector (in local space)
  70025. * @param max defines the new maximum vector (in local space)
  70026. * @param worldMatrix defines the new world matrix
  70027. */
  70028. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  70029. /**
  70030. * Scale the current bounding sphere by applying a scale factor
  70031. * @param factor defines the scale factor to apply
  70032. * @returns the current bounding box
  70033. */
  70034. scale(factor: number): BoundingSphere;
  70035. /**
  70036. * Gets the world matrix of the bounding box
  70037. * @returns a matrix
  70038. */
  70039. getWorldMatrix(): DeepImmutable<Matrix>;
  70040. /** @hidden */
  70041. _update(worldMatrix: DeepImmutable<Matrix>): void;
  70042. /**
  70043. * Tests if the bounding sphere is intersecting the frustum planes
  70044. * @param frustumPlanes defines the frustum planes to test
  70045. * @returns true if there is an intersection
  70046. */
  70047. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70048. /**
  70049. * Tests if the bounding sphere center is in between the frustum planes.
  70050. * Used for optimistic fast inclusion.
  70051. * @param frustumPlanes defines the frustum planes to test
  70052. * @returns true if the sphere center is in between the frustum planes
  70053. */
  70054. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70055. /**
  70056. * Tests if a point is inside the bounding sphere
  70057. * @param point defines the point to test
  70058. * @returns true if the point is inside the bounding sphere
  70059. */
  70060. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  70061. /**
  70062. * Checks if two sphere intersct
  70063. * @param sphere0 sphere 0
  70064. * @param sphere1 sphere 1
  70065. * @returns true if the speres intersect
  70066. */
  70067. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  70068. }
  70069. }
  70070. declare module BABYLON {
  70071. /**
  70072. * Class used to store bounding box information
  70073. */
  70074. export class BoundingBox implements ICullable {
  70075. /**
  70076. * Gets the 8 vectors representing the bounding box in local space
  70077. */
  70078. readonly vectors: Vector3[];
  70079. /**
  70080. * Gets the center of the bounding box in local space
  70081. */
  70082. readonly center: Vector3;
  70083. /**
  70084. * Gets the center of the bounding box in world space
  70085. */
  70086. readonly centerWorld: Vector3;
  70087. /**
  70088. * Gets the extend size in local space
  70089. */
  70090. readonly extendSize: Vector3;
  70091. /**
  70092. * Gets the extend size in world space
  70093. */
  70094. readonly extendSizeWorld: Vector3;
  70095. /**
  70096. * Gets the OBB (object bounding box) directions
  70097. */
  70098. readonly directions: Vector3[];
  70099. /**
  70100. * Gets the 8 vectors representing the bounding box in world space
  70101. */
  70102. readonly vectorsWorld: Vector3[];
  70103. /**
  70104. * Gets the minimum vector in world space
  70105. */
  70106. readonly minimumWorld: Vector3;
  70107. /**
  70108. * Gets the maximum vector in world space
  70109. */
  70110. readonly maximumWorld: Vector3;
  70111. /**
  70112. * Gets the minimum vector in local space
  70113. */
  70114. readonly minimum: Vector3;
  70115. /**
  70116. * Gets the maximum vector in local space
  70117. */
  70118. readonly maximum: Vector3;
  70119. private _worldMatrix;
  70120. private static readonly TmpVector3;
  70121. /**
  70122. * @hidden
  70123. */
  70124. _tag: number;
  70125. /**
  70126. * Creates a new bounding box
  70127. * @param min defines the minimum vector (in local space)
  70128. * @param max defines the maximum vector (in local space)
  70129. * @param worldMatrix defines the new world matrix
  70130. */
  70131. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  70132. /**
  70133. * Recreates the entire bounding box from scratch as if we call the constructor in place
  70134. * @param min defines the new minimum vector (in local space)
  70135. * @param max defines the new maximum vector (in local space)
  70136. * @param worldMatrix defines the new world matrix
  70137. */
  70138. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  70139. /**
  70140. * Scale the current bounding box by applying a scale factor
  70141. * @param factor defines the scale factor to apply
  70142. * @returns the current bounding box
  70143. */
  70144. scale(factor: number): BoundingBox;
  70145. /**
  70146. * Gets the world matrix of the bounding box
  70147. * @returns a matrix
  70148. */
  70149. getWorldMatrix(): DeepImmutable<Matrix>;
  70150. /** @hidden */
  70151. _update(world: DeepImmutable<Matrix>): void;
  70152. /**
  70153. * Tests if the bounding box is intersecting the frustum planes
  70154. * @param frustumPlanes defines the frustum planes to test
  70155. * @returns true if there is an intersection
  70156. */
  70157. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70158. /**
  70159. * Tests if the bounding box is entirely inside the frustum planes
  70160. * @param frustumPlanes defines the frustum planes to test
  70161. * @returns true if there is an inclusion
  70162. */
  70163. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70164. /**
  70165. * Tests if a point is inside the bounding box
  70166. * @param point defines the point to test
  70167. * @returns true if the point is inside the bounding box
  70168. */
  70169. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  70170. /**
  70171. * Tests if the bounding box intersects with a bounding sphere
  70172. * @param sphere defines the sphere to test
  70173. * @returns true if there is an intersection
  70174. */
  70175. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  70176. /**
  70177. * Tests if the bounding box intersects with a box defined by a min and max vectors
  70178. * @param min defines the min vector to use
  70179. * @param max defines the max vector to use
  70180. * @returns true if there is an intersection
  70181. */
  70182. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  70183. /**
  70184. * Tests if two bounding boxes are intersections
  70185. * @param box0 defines the first box to test
  70186. * @param box1 defines the second box to test
  70187. * @returns true if there is an intersection
  70188. */
  70189. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  70190. /**
  70191. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  70192. * @param minPoint defines the minimum vector of the bounding box
  70193. * @param maxPoint defines the maximum vector of the bounding box
  70194. * @param sphereCenter defines the sphere center
  70195. * @param sphereRadius defines the sphere radius
  70196. * @returns true if there is an intersection
  70197. */
  70198. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  70199. /**
  70200. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  70201. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  70202. * @param frustumPlanes defines the frustum planes to test
  70203. * @return true if there is an inclusion
  70204. */
  70205. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70206. /**
  70207. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  70208. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  70209. * @param frustumPlanes defines the frustum planes to test
  70210. * @return true if there is an intersection
  70211. */
  70212. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70213. }
  70214. }
  70215. declare module BABYLON {
  70216. /** @hidden */
  70217. export class Collider {
  70218. /** Define if a collision was found */
  70219. collisionFound: boolean;
  70220. /**
  70221. * Define last intersection point in local space
  70222. */
  70223. intersectionPoint: Vector3;
  70224. /**
  70225. * Define last collided mesh
  70226. */
  70227. collidedMesh: Nullable<AbstractMesh>;
  70228. private _collisionPoint;
  70229. private _planeIntersectionPoint;
  70230. private _tempVector;
  70231. private _tempVector2;
  70232. private _tempVector3;
  70233. private _tempVector4;
  70234. private _edge;
  70235. private _baseToVertex;
  70236. private _destinationPoint;
  70237. private _slidePlaneNormal;
  70238. private _displacementVector;
  70239. /** @hidden */
  70240. _radius: Vector3;
  70241. /** @hidden */
  70242. _retry: number;
  70243. private _velocity;
  70244. private _basePoint;
  70245. private _epsilon;
  70246. /** @hidden */
  70247. _velocityWorldLength: number;
  70248. /** @hidden */
  70249. _basePointWorld: Vector3;
  70250. private _velocityWorld;
  70251. private _normalizedVelocity;
  70252. /** @hidden */
  70253. _initialVelocity: Vector3;
  70254. /** @hidden */
  70255. _initialPosition: Vector3;
  70256. private _nearestDistance;
  70257. private _collisionMask;
  70258. collisionMask: number;
  70259. /**
  70260. * Gets the plane normal used to compute the sliding response (in local space)
  70261. */
  70262. readonly slidePlaneNormal: Vector3;
  70263. /** @hidden */
  70264. _initialize(source: Vector3, dir: Vector3, e: number): void;
  70265. /** @hidden */
  70266. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  70267. /** @hidden */
  70268. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  70269. /** @hidden */
  70270. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  70271. /** @hidden */
  70272. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  70273. /** @hidden */
  70274. _getResponse(pos: Vector3, vel: Vector3): void;
  70275. }
  70276. }
  70277. declare module BABYLON {
  70278. /**
  70279. * Interface for cullable objects
  70280. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  70281. */
  70282. export interface ICullable {
  70283. /**
  70284. * Checks if the object or part of the object is in the frustum
  70285. * @param frustumPlanes Camera near/planes
  70286. * @returns true if the object is in frustum otherwise false
  70287. */
  70288. isInFrustum(frustumPlanes: Plane[]): boolean;
  70289. /**
  70290. * Checks if a cullable object (mesh...) is in the camera frustum
  70291. * Unlike isInFrustum this cheks the full bounding box
  70292. * @param frustumPlanes Camera near/planes
  70293. * @returns true if the object is in frustum otherwise false
  70294. */
  70295. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  70296. }
  70297. /**
  70298. * Info for a bounding data of a mesh
  70299. */
  70300. export class BoundingInfo implements ICullable {
  70301. /**
  70302. * Bounding box for the mesh
  70303. */
  70304. readonly boundingBox: BoundingBox;
  70305. /**
  70306. * Bounding sphere for the mesh
  70307. */
  70308. readonly boundingSphere: BoundingSphere;
  70309. private _isLocked;
  70310. private static readonly TmpVector3;
  70311. /**
  70312. * Constructs bounding info
  70313. * @param minimum min vector of the bounding box/sphere
  70314. * @param maximum max vector of the bounding box/sphere
  70315. * @param worldMatrix defines the new world matrix
  70316. */
  70317. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  70318. /**
  70319. * Recreates the entire bounding info from scratch as if we call the constructor in place
  70320. * @param min defines the new minimum vector (in local space)
  70321. * @param max defines the new maximum vector (in local space)
  70322. * @param worldMatrix defines the new world matrix
  70323. */
  70324. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  70325. /**
  70326. * min vector of the bounding box/sphere
  70327. */
  70328. readonly minimum: Vector3;
  70329. /**
  70330. * max vector of the bounding box/sphere
  70331. */
  70332. readonly maximum: Vector3;
  70333. /**
  70334. * If the info is locked and won't be updated to avoid perf overhead
  70335. */
  70336. isLocked: boolean;
  70337. /**
  70338. * Updates the bounding sphere and box
  70339. * @param world world matrix to be used to update
  70340. */
  70341. update(world: DeepImmutable<Matrix>): void;
  70342. /**
  70343. * Recreate the bounding info to be centered around a specific point given a specific extend.
  70344. * @param center New center of the bounding info
  70345. * @param extend New extend of the bounding info
  70346. * @returns the current bounding info
  70347. */
  70348. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  70349. /**
  70350. * Scale the current bounding info by applying a scale factor
  70351. * @param factor defines the scale factor to apply
  70352. * @returns the current bounding info
  70353. */
  70354. scale(factor: number): BoundingInfo;
  70355. /**
  70356. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  70357. * @param frustumPlanes defines the frustum to test
  70358. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  70359. * @returns true if the bounding info is in the frustum planes
  70360. */
  70361. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  70362. /**
  70363. * Gets the world distance between the min and max points of the bounding box
  70364. */
  70365. readonly diagonalLength: number;
  70366. /**
  70367. * Checks if a cullable object (mesh...) is in the camera frustum
  70368. * Unlike isInFrustum this cheks the full bounding box
  70369. * @param frustumPlanes Camera near/planes
  70370. * @returns true if the object is in frustum otherwise false
  70371. */
  70372. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70373. /** @hidden */
  70374. _checkCollision(collider: Collider): boolean;
  70375. /**
  70376. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  70377. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  70378. * @param point the point to check intersection with
  70379. * @returns if the point intersects
  70380. */
  70381. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  70382. /**
  70383. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  70384. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  70385. * @param boundingInfo the bounding info to check intersection with
  70386. * @param precise if the intersection should be done using OBB
  70387. * @returns if the bounding info intersects
  70388. */
  70389. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  70390. }
  70391. }
  70392. declare module BABYLON {
  70393. /**
  70394. * Defines an array and its length.
  70395. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  70396. */
  70397. export interface ISmartArrayLike<T> {
  70398. /**
  70399. * The data of the array.
  70400. */
  70401. data: Array<T>;
  70402. /**
  70403. * The active length of the array.
  70404. */
  70405. length: number;
  70406. }
  70407. /**
  70408. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  70409. */
  70410. export class SmartArray<T> implements ISmartArrayLike<T> {
  70411. /**
  70412. * The full set of data from the array.
  70413. */
  70414. data: Array<T>;
  70415. /**
  70416. * The active length of the array.
  70417. */
  70418. length: number;
  70419. protected _id: number;
  70420. /**
  70421. * Instantiates a Smart Array.
  70422. * @param capacity defines the default capacity of the array.
  70423. */
  70424. constructor(capacity: number);
  70425. /**
  70426. * Pushes a value at the end of the active data.
  70427. * @param value defines the object to push in the array.
  70428. */
  70429. push(value: T): void;
  70430. /**
  70431. * Iterates over the active data and apply the lambda to them.
  70432. * @param func defines the action to apply on each value.
  70433. */
  70434. forEach(func: (content: T) => void): void;
  70435. /**
  70436. * Sorts the full sets of data.
  70437. * @param compareFn defines the comparison function to apply.
  70438. */
  70439. sort(compareFn: (a: T, b: T) => number): void;
  70440. /**
  70441. * Resets the active data to an empty array.
  70442. */
  70443. reset(): void;
  70444. /**
  70445. * Releases all the data from the array as well as the array.
  70446. */
  70447. dispose(): void;
  70448. /**
  70449. * Concats the active data with a given array.
  70450. * @param array defines the data to concatenate with.
  70451. */
  70452. concat(array: any): void;
  70453. /**
  70454. * Returns the position of a value in the active data.
  70455. * @param value defines the value to find the index for
  70456. * @returns the index if found in the active data otherwise -1
  70457. */
  70458. indexOf(value: T): number;
  70459. /**
  70460. * Returns whether an element is part of the active data.
  70461. * @param value defines the value to look for
  70462. * @returns true if found in the active data otherwise false
  70463. */
  70464. contains(value: T): boolean;
  70465. private static _GlobalId;
  70466. }
  70467. /**
  70468. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  70469. * The data in this array can only be present once
  70470. */
  70471. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  70472. private _duplicateId;
  70473. /**
  70474. * Pushes a value at the end of the active data.
  70475. * THIS DOES NOT PREVENT DUPPLICATE DATA
  70476. * @param value defines the object to push in the array.
  70477. */
  70478. push(value: T): void;
  70479. /**
  70480. * Pushes a value at the end of the active data.
  70481. * If the data is already present, it won t be added again
  70482. * @param value defines the object to push in the array.
  70483. * @returns true if added false if it was already present
  70484. */
  70485. pushNoDuplicate(value: T): boolean;
  70486. /**
  70487. * Resets the active data to an empty array.
  70488. */
  70489. reset(): void;
  70490. /**
  70491. * Concats the active data with a given array.
  70492. * This ensures no dupplicate will be present in the result.
  70493. * @param array defines the data to concatenate with.
  70494. */
  70495. concatWithNoDuplicate(array: any): void;
  70496. }
  70497. }
  70498. declare module BABYLON {
  70499. /**
  70500. * Enum that determines the text-wrapping mode to use.
  70501. */
  70502. export enum InspectableType {
  70503. /**
  70504. * Checkbox for booleans
  70505. */
  70506. Checkbox = 0,
  70507. /**
  70508. * Sliders for numbers
  70509. */
  70510. Slider = 1,
  70511. /**
  70512. * Vector3
  70513. */
  70514. Vector3 = 2,
  70515. /**
  70516. * Quaternions
  70517. */
  70518. Quaternion = 3,
  70519. /**
  70520. * Color3
  70521. */
  70522. Color3 = 4
  70523. }
  70524. /**
  70525. * Interface used to define custom inspectable properties.
  70526. * This interface is used by the inspector to display custom property grids
  70527. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  70528. */
  70529. export interface IInspectable {
  70530. /**
  70531. * Gets the label to display
  70532. */
  70533. label: string;
  70534. /**
  70535. * Gets the name of the property to edit
  70536. */
  70537. propertyName: string;
  70538. /**
  70539. * Gets the type of the editor to use
  70540. */
  70541. type: InspectableType;
  70542. /**
  70543. * Gets the minimum value of the property when using in "slider" mode
  70544. */
  70545. min?: number;
  70546. /**
  70547. * Gets the maximum value of the property when using in "slider" mode
  70548. */
  70549. max?: number;
  70550. /**
  70551. * Gets the setp to use when using in "slider" mode
  70552. */
  70553. step?: number;
  70554. }
  70555. }
  70556. declare module BABYLON {
  70557. /**
  70558. * This represents the required contract to create a new type of texture loader.
  70559. */
  70560. export interface IInternalTextureLoader {
  70561. /**
  70562. * Defines wether the loader supports cascade loading the different faces.
  70563. */
  70564. supportCascades: boolean;
  70565. /**
  70566. * This returns if the loader support the current file information.
  70567. * @param extension defines the file extension of the file being loaded
  70568. * @param textureFormatInUse defines the current compressed format in use iun the engine
  70569. * @param fallback defines the fallback internal texture if any
  70570. * @param isBase64 defines whether the texture is encoded as a base64
  70571. * @param isBuffer defines whether the texture data are stored as a buffer
  70572. * @returns true if the loader can load the specified file
  70573. */
  70574. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  70575. /**
  70576. * Transform the url before loading if required.
  70577. * @param rootUrl the url of the texture
  70578. * @param textureFormatInUse defines the current compressed format in use iun the engine
  70579. * @returns the transformed texture
  70580. */
  70581. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  70582. /**
  70583. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  70584. * @param rootUrl the url of the texture
  70585. * @param textureFormatInUse defines the current compressed format in use iun the engine
  70586. * @returns the fallback texture
  70587. */
  70588. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  70589. /**
  70590. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  70591. * @param data contains the texture data
  70592. * @param texture defines the BabylonJS internal texture
  70593. * @param createPolynomials will be true if polynomials have been requested
  70594. * @param onLoad defines the callback to trigger once the texture is ready
  70595. * @param onError defines the callback to trigger in case of error
  70596. */
  70597. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  70598. /**
  70599. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  70600. * @param data contains the texture data
  70601. * @param texture defines the BabylonJS internal texture
  70602. * @param callback defines the method to call once ready to upload
  70603. */
  70604. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  70605. }
  70606. }
  70607. declare module BABYLON {
  70608. interface Engine {
  70609. /**
  70610. * Creates a depth stencil cube texture.
  70611. * This is only available in WebGL 2.
  70612. * @param size The size of face edge in the cube texture.
  70613. * @param options The options defining the cube texture.
  70614. * @returns The cube texture
  70615. */
  70616. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  70617. /**
  70618. * Creates a cube texture
  70619. * @param rootUrl defines the url where the files to load is located
  70620. * @param scene defines the current scene
  70621. * @param files defines the list of files to load (1 per face)
  70622. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  70623. * @param onLoad defines an optional callback raised when the texture is loaded
  70624. * @param onError defines an optional callback raised if there is an issue to load the texture
  70625. * @param format defines the format of the data
  70626. * @param forcedExtension defines the extension to use to pick the right loader
  70627. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  70628. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  70629. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  70630. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  70631. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  70632. * @returns the cube texture as an InternalTexture
  70633. */
  70634. 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;
  70635. /**
  70636. * Creates a cube texture
  70637. * @param rootUrl defines the url where the files to load is located
  70638. * @param scene defines the current scene
  70639. * @param files defines the list of files to load (1 per face)
  70640. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  70641. * @param onLoad defines an optional callback raised when the texture is loaded
  70642. * @param onError defines an optional callback raised if there is an issue to load the texture
  70643. * @param format defines the format of the data
  70644. * @param forcedExtension defines the extension to use to pick the right loader
  70645. * @returns the cube texture as an InternalTexture
  70646. */
  70647. 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;
  70648. /**
  70649. * Creates a cube texture
  70650. * @param rootUrl defines the url where the files to load is located
  70651. * @param scene defines the current scene
  70652. * @param files defines the list of files to load (1 per face)
  70653. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  70654. * @param onLoad defines an optional callback raised when the texture is loaded
  70655. * @param onError defines an optional callback raised if there is an issue to load the texture
  70656. * @param format defines the format of the data
  70657. * @param forcedExtension defines the extension to use to pick the right loader
  70658. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  70659. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  70660. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  70661. * @returns the cube texture as an InternalTexture
  70662. */
  70663. 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;
  70664. /** @hidden */
  70665. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  70666. /** @hidden */
  70667. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  70668. /** @hidden */
  70669. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  70670. /** @hidden */
  70671. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  70672. }
  70673. }
  70674. declare module BABYLON {
  70675. /**
  70676. * Class for creating a cube texture
  70677. */
  70678. export class CubeTexture extends BaseTexture {
  70679. private _delayedOnLoad;
  70680. /**
  70681. * The url of the texture
  70682. */
  70683. url: string;
  70684. /**
  70685. * Gets or sets the center of the bounding box associated with the cube texture.
  70686. * It must define where the camera used to render the texture was set
  70687. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  70688. */
  70689. boundingBoxPosition: Vector3;
  70690. private _boundingBoxSize;
  70691. /**
  70692. * Gets or sets the size of the bounding box associated with the cube texture
  70693. * When defined, the cubemap will switch to local mode
  70694. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  70695. * @example https://www.babylonjs-playground.com/#RNASML
  70696. */
  70697. /**
  70698. * Returns the bounding box size
  70699. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  70700. */
  70701. boundingBoxSize: Vector3;
  70702. protected _rotationY: number;
  70703. /**
  70704. * Sets texture matrix rotation angle around Y axis in radians.
  70705. */
  70706. /**
  70707. * Gets texture matrix rotation angle around Y axis radians.
  70708. */
  70709. rotationY: number;
  70710. /**
  70711. * Are mip maps generated for this texture or not.
  70712. */
  70713. readonly noMipmap: boolean;
  70714. private _noMipmap;
  70715. private _files;
  70716. private _extensions;
  70717. private _textureMatrix;
  70718. private _format;
  70719. private _createPolynomials;
  70720. /** @hidden */
  70721. _prefiltered: boolean;
  70722. /**
  70723. * Creates a cube texture from an array of image urls
  70724. * @param files defines an array of image urls
  70725. * @param scene defines the hosting scene
  70726. * @param noMipmap specifies if mip maps are not used
  70727. * @returns a cube texture
  70728. */
  70729. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  70730. /**
  70731. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  70732. * @param url defines the url of the prefiltered texture
  70733. * @param scene defines the scene the texture is attached to
  70734. * @param forcedExtension defines the extension of the file if different from the url
  70735. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  70736. * @return the prefiltered texture
  70737. */
  70738. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  70739. /**
  70740. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  70741. * as prefiltered data.
  70742. * @param rootUrl defines the url of the texture or the root name of the six images
  70743. * @param scene defines the scene the texture is attached to
  70744. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  70745. * @param noMipmap defines if mipmaps should be created or not
  70746. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  70747. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  70748. * @param onError defines a callback triggered in case of error during load
  70749. * @param format defines the internal format to use for the texture once loaded
  70750. * @param prefiltered defines whether or not the texture is created from prefiltered data
  70751. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  70752. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  70753. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  70754. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  70755. * @return the cube texture
  70756. */
  70757. 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);
  70758. /**
  70759. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  70760. */
  70761. readonly isPrefiltered: boolean;
  70762. /**
  70763. * Get the current class name of the texture useful for serialization or dynamic coding.
  70764. * @returns "CubeTexture"
  70765. */
  70766. getClassName(): string;
  70767. /**
  70768. * Update the url (and optional buffer) of this texture if url was null during construction.
  70769. * @param url the url of the texture
  70770. * @param forcedExtension defines the extension to use
  70771. * @param onLoad callback called when the texture is loaded (defaults to null)
  70772. */
  70773. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  70774. /**
  70775. * Delays loading of the cube texture
  70776. * @param forcedExtension defines the extension to use
  70777. */
  70778. delayLoad(forcedExtension?: string): void;
  70779. /**
  70780. * Returns the reflection texture matrix
  70781. * @returns the reflection texture matrix
  70782. */
  70783. getReflectionTextureMatrix(): Matrix;
  70784. /**
  70785. * Sets the reflection texture matrix
  70786. * @param value Reflection texture matrix
  70787. */
  70788. setReflectionTextureMatrix(value: Matrix): void;
  70789. /**
  70790. * Parses text to create a cube texture
  70791. * @param parsedTexture define the serialized text to read from
  70792. * @param scene defines the hosting scene
  70793. * @param rootUrl defines the root url of the cube texture
  70794. * @returns a cube texture
  70795. */
  70796. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  70797. /**
  70798. * Makes a clone, or deep copy, of the cube texture
  70799. * @returns a new cube texture
  70800. */
  70801. clone(): CubeTexture;
  70802. }
  70803. }
  70804. declare module BABYLON {
  70805. /** @hidden */
  70806. export var postprocessVertexShader: {
  70807. name: string;
  70808. shader: string;
  70809. };
  70810. }
  70811. declare module BABYLON {
  70812. /**
  70813. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  70814. * This is the base of the follow, arc rotate cameras and Free camera
  70815. * @see http://doc.babylonjs.com/features/cameras
  70816. */
  70817. export class TargetCamera extends Camera {
  70818. private static _RigCamTransformMatrix;
  70819. private static _TargetTransformMatrix;
  70820. private static _TargetFocalPoint;
  70821. /**
  70822. * Define the current direction the camera is moving to
  70823. */
  70824. cameraDirection: Vector3;
  70825. /**
  70826. * Define the current rotation the camera is rotating to
  70827. */
  70828. cameraRotation: Vector2;
  70829. /**
  70830. * When set, the up vector of the camera will be updated by the rotation of the camera
  70831. */
  70832. updateUpVectorFromRotation: boolean;
  70833. private _tmpQuaternion;
  70834. /**
  70835. * Define the current rotation of the camera
  70836. */
  70837. rotation: Vector3;
  70838. /**
  70839. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  70840. */
  70841. rotationQuaternion: Quaternion;
  70842. /**
  70843. * Define the current speed of the camera
  70844. */
  70845. speed: number;
  70846. /**
  70847. * Add cconstraint to the camera to prevent it to move freely in all directions and
  70848. * around all axis.
  70849. */
  70850. noRotationConstraint: boolean;
  70851. /**
  70852. * Define the current target of the camera as an object or a position.
  70853. */
  70854. lockedTarget: any;
  70855. /** @hidden */
  70856. _currentTarget: Vector3;
  70857. /** @hidden */
  70858. _initialFocalDistance: number;
  70859. /** @hidden */
  70860. _viewMatrix: Matrix;
  70861. /** @hidden */
  70862. _camMatrix: Matrix;
  70863. /** @hidden */
  70864. _cameraTransformMatrix: Matrix;
  70865. /** @hidden */
  70866. _cameraRotationMatrix: Matrix;
  70867. /** @hidden */
  70868. _referencePoint: Vector3;
  70869. /** @hidden */
  70870. _transformedReferencePoint: Vector3;
  70871. protected _globalCurrentTarget: Vector3;
  70872. protected _globalCurrentUpVector: Vector3;
  70873. /** @hidden */
  70874. _reset: () => void;
  70875. private _defaultUp;
  70876. /**
  70877. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  70878. * This is the base of the follow, arc rotate cameras and Free camera
  70879. * @see http://doc.babylonjs.com/features/cameras
  70880. * @param name Defines the name of the camera in the scene
  70881. * @param position Defines the start position of the camera in the scene
  70882. * @param scene Defines the scene the camera belongs to
  70883. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  70884. */
  70885. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  70886. /**
  70887. * Gets the position in front of the camera at a given distance.
  70888. * @param distance The distance from the camera we want the position to be
  70889. * @returns the position
  70890. */
  70891. getFrontPosition(distance: number): Vector3;
  70892. /** @hidden */
  70893. _getLockedTargetPosition(): Nullable<Vector3>;
  70894. private _storedPosition;
  70895. private _storedRotation;
  70896. private _storedRotationQuaternion;
  70897. /**
  70898. * Store current camera state of the camera (fov, position, rotation, etc..)
  70899. * @returns the camera
  70900. */
  70901. storeState(): Camera;
  70902. /**
  70903. * Restored camera state. You must call storeState() first
  70904. * @returns whether it was successful or not
  70905. * @hidden
  70906. */
  70907. _restoreStateValues(): boolean;
  70908. /** @hidden */
  70909. _initCache(): void;
  70910. /** @hidden */
  70911. _updateCache(ignoreParentClass?: boolean): void;
  70912. /** @hidden */
  70913. _isSynchronizedViewMatrix(): boolean;
  70914. /** @hidden */
  70915. _computeLocalCameraSpeed(): number;
  70916. /**
  70917. * Defines the target the camera should look at.
  70918. * This will automatically adapt alpha beta and radius to fit within the new target.
  70919. * @param target Defines the new target as a Vector or a mesh
  70920. */
  70921. setTarget(target: Vector3): void;
  70922. /**
  70923. * Return the current target position of the camera. This value is expressed in local space.
  70924. * @returns the target position
  70925. */
  70926. getTarget(): Vector3;
  70927. /** @hidden */
  70928. _decideIfNeedsToMove(): boolean;
  70929. /** @hidden */
  70930. _updatePosition(): void;
  70931. /** @hidden */
  70932. _checkInputs(): void;
  70933. protected _updateCameraRotationMatrix(): void;
  70934. /**
  70935. * 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)
  70936. * @returns the current camera
  70937. */
  70938. private _rotateUpVectorWithCameraRotationMatrix;
  70939. private _cachedRotationZ;
  70940. private _cachedQuaternionRotationZ;
  70941. /** @hidden */
  70942. _getViewMatrix(): Matrix;
  70943. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  70944. /**
  70945. * @hidden
  70946. */
  70947. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  70948. /**
  70949. * @hidden
  70950. */
  70951. _updateRigCameras(): void;
  70952. private _getRigCamPositionAndTarget;
  70953. /**
  70954. * Gets the current object class name.
  70955. * @return the class name
  70956. */
  70957. getClassName(): string;
  70958. }
  70959. }
  70960. declare module BABYLON {
  70961. /**
  70962. * @ignore
  70963. * This is a list of all the different input types that are available in the application.
  70964. * Fo instance: ArcRotateCameraGamepadInput...
  70965. */
  70966. export var CameraInputTypes: {};
  70967. /**
  70968. * This is the contract to implement in order to create a new input class.
  70969. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  70970. */
  70971. export interface ICameraInput<TCamera extends Camera> {
  70972. /**
  70973. * Defines the camera the input is attached to.
  70974. */
  70975. camera: Nullable<TCamera>;
  70976. /**
  70977. * Gets the class name of the current intput.
  70978. * @returns the class name
  70979. */
  70980. getClassName(): string;
  70981. /**
  70982. * Get the friendly name associated with the input class.
  70983. * @returns the input friendly name
  70984. */
  70985. getSimpleName(): string;
  70986. /**
  70987. * Attach the input controls to a specific dom element to get the input from.
  70988. * @param element Defines the element the controls should be listened from
  70989. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70990. */
  70991. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  70992. /**
  70993. * Detach the current controls from the specified dom element.
  70994. * @param element Defines the element to stop listening the inputs from
  70995. */
  70996. detachControl(element: Nullable<HTMLElement>): void;
  70997. /**
  70998. * Update the current camera state depending on the inputs that have been used this frame.
  70999. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  71000. */
  71001. checkInputs?: () => void;
  71002. }
  71003. /**
  71004. * Represents a map of input types to input instance or input index to input instance.
  71005. */
  71006. export interface CameraInputsMap<TCamera extends Camera> {
  71007. /**
  71008. * Accessor to the input by input type.
  71009. */
  71010. [name: string]: ICameraInput<TCamera>;
  71011. /**
  71012. * Accessor to the input by input index.
  71013. */
  71014. [idx: number]: ICameraInput<TCamera>;
  71015. }
  71016. /**
  71017. * This represents the input manager used within a camera.
  71018. * It helps dealing with all the different kind of input attached to a camera.
  71019. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71020. */
  71021. export class CameraInputsManager<TCamera extends Camera> {
  71022. /**
  71023. * Defines the list of inputs attahed to the camera.
  71024. */
  71025. attached: CameraInputsMap<TCamera>;
  71026. /**
  71027. * Defines the dom element the camera is collecting inputs from.
  71028. * This is null if the controls have not been attached.
  71029. */
  71030. attachedElement: Nullable<HTMLElement>;
  71031. /**
  71032. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71033. */
  71034. noPreventDefault: boolean;
  71035. /**
  71036. * Defined the camera the input manager belongs to.
  71037. */
  71038. camera: TCamera;
  71039. /**
  71040. * Update the current camera state depending on the inputs that have been used this frame.
  71041. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  71042. */
  71043. checkInputs: () => void;
  71044. /**
  71045. * Instantiate a new Camera Input Manager.
  71046. * @param camera Defines the camera the input manager blongs to
  71047. */
  71048. constructor(camera: TCamera);
  71049. /**
  71050. * Add an input method to a camera
  71051. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71052. * @param input camera input method
  71053. */
  71054. add(input: ICameraInput<TCamera>): void;
  71055. /**
  71056. * Remove a specific input method from a camera
  71057. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  71058. * @param inputToRemove camera input method
  71059. */
  71060. remove(inputToRemove: ICameraInput<TCamera>): void;
  71061. /**
  71062. * Remove a specific input type from a camera
  71063. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  71064. * @param inputType the type of the input to remove
  71065. */
  71066. removeByType(inputType: string): void;
  71067. private _addCheckInputs;
  71068. /**
  71069. * Attach the input controls to the currently attached dom element to listen the events from.
  71070. * @param input Defines the input to attach
  71071. */
  71072. attachInput(input: ICameraInput<TCamera>): void;
  71073. /**
  71074. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  71075. * @param element Defines the dom element to collect the events from
  71076. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71077. */
  71078. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  71079. /**
  71080. * Detach the current manager inputs controls from a specific dom element.
  71081. * @param element Defines the dom element to collect the events from
  71082. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  71083. */
  71084. detachElement(element: HTMLElement, disconnect?: boolean): void;
  71085. /**
  71086. * Rebuild the dynamic inputCheck function from the current list of
  71087. * defined inputs in the manager.
  71088. */
  71089. rebuildInputCheck(): void;
  71090. /**
  71091. * Remove all attached input methods from a camera
  71092. */
  71093. clear(): void;
  71094. /**
  71095. * Serialize the current input manager attached to a camera.
  71096. * This ensures than once parsed,
  71097. * the input associated to the camera will be identical to the current ones
  71098. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  71099. */
  71100. serialize(serializedCamera: any): void;
  71101. /**
  71102. * Parses an input manager serialized JSON to restore the previous list of inputs
  71103. * and states associated to a camera.
  71104. * @param parsedCamera Defines the JSON to parse
  71105. */
  71106. parse(parsedCamera: any): void;
  71107. }
  71108. }
  71109. declare module BABYLON {
  71110. /**
  71111. * Gather the list of keyboard event types as constants.
  71112. */
  71113. export class KeyboardEventTypes {
  71114. /**
  71115. * The keydown event is fired when a key becomes active (pressed).
  71116. */
  71117. static readonly KEYDOWN: number;
  71118. /**
  71119. * The keyup event is fired when a key has been released.
  71120. */
  71121. static readonly KEYUP: number;
  71122. }
  71123. /**
  71124. * This class is used to store keyboard related info for the onKeyboardObservable event.
  71125. */
  71126. export class KeyboardInfo {
  71127. /**
  71128. * Defines the type of event (KeyboardEventTypes)
  71129. */
  71130. type: number;
  71131. /**
  71132. * Defines the related dom event
  71133. */
  71134. event: KeyboardEvent;
  71135. /**
  71136. * Instantiates a new keyboard info.
  71137. * This class is used to store keyboard related info for the onKeyboardObservable event.
  71138. * @param type Defines the type of event (KeyboardEventTypes)
  71139. * @param event Defines the related dom event
  71140. */
  71141. constructor(
  71142. /**
  71143. * Defines the type of event (KeyboardEventTypes)
  71144. */
  71145. type: number,
  71146. /**
  71147. * Defines the related dom event
  71148. */
  71149. event: KeyboardEvent);
  71150. }
  71151. /**
  71152. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  71153. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  71154. */
  71155. export class KeyboardInfoPre extends KeyboardInfo {
  71156. /**
  71157. * Defines the type of event (KeyboardEventTypes)
  71158. */
  71159. type: number;
  71160. /**
  71161. * Defines the related dom event
  71162. */
  71163. event: KeyboardEvent;
  71164. /**
  71165. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  71166. */
  71167. skipOnPointerObservable: boolean;
  71168. /**
  71169. * Instantiates a new keyboard pre info.
  71170. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  71171. * @param type Defines the type of event (KeyboardEventTypes)
  71172. * @param event Defines the related dom event
  71173. */
  71174. constructor(
  71175. /**
  71176. * Defines the type of event (KeyboardEventTypes)
  71177. */
  71178. type: number,
  71179. /**
  71180. * Defines the related dom event
  71181. */
  71182. event: KeyboardEvent);
  71183. }
  71184. }
  71185. declare module BABYLON {
  71186. /**
  71187. * Manage the keyboard inputs to control the movement of a free camera.
  71188. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71189. */
  71190. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  71191. /**
  71192. * Defines the camera the input is attached to.
  71193. */
  71194. camera: FreeCamera;
  71195. /**
  71196. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  71197. */
  71198. keysUp: number[];
  71199. /**
  71200. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  71201. */
  71202. keysDown: number[];
  71203. /**
  71204. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  71205. */
  71206. keysLeft: number[];
  71207. /**
  71208. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  71209. */
  71210. keysRight: number[];
  71211. private _keys;
  71212. private _onCanvasBlurObserver;
  71213. private _onKeyboardObserver;
  71214. private _engine;
  71215. private _scene;
  71216. /**
  71217. * Attach the input controls to a specific dom element to get the input from.
  71218. * @param element Defines the element the controls should be listened from
  71219. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71220. */
  71221. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  71222. /**
  71223. * Detach the current controls from the specified dom element.
  71224. * @param element Defines the element to stop listening the inputs from
  71225. */
  71226. detachControl(element: Nullable<HTMLElement>): void;
  71227. /**
  71228. * Update the current camera state depending on the inputs that have been used this frame.
  71229. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  71230. */
  71231. checkInputs(): void;
  71232. /**
  71233. * Gets the class name of the current intput.
  71234. * @returns the class name
  71235. */
  71236. getClassName(): string;
  71237. /** @hidden */
  71238. _onLostFocus(): void;
  71239. /**
  71240. * Get the friendly name associated with the input class.
  71241. * @returns the input friendly name
  71242. */
  71243. getSimpleName(): string;
  71244. }
  71245. }
  71246. declare module BABYLON {
  71247. /**
  71248. * A multi-material is used to apply different materials to different parts of the same object without the need of
  71249. * separate meshes. This can be use to improve performances.
  71250. * @see http://doc.babylonjs.com/how_to/multi_materials
  71251. */
  71252. export class MultiMaterial extends Material {
  71253. private _subMaterials;
  71254. /**
  71255. * Gets or Sets the list of Materials used within the multi material.
  71256. * They need to be ordered according to the submeshes order in the associated mesh
  71257. */
  71258. subMaterials: Nullable<Material>[];
  71259. /**
  71260. * Function used to align with Node.getChildren()
  71261. * @returns the list of Materials used within the multi material
  71262. */
  71263. getChildren(): Nullable<Material>[];
  71264. /**
  71265. * Instantiates a new Multi Material
  71266. * A multi-material is used to apply different materials to different parts of the same object without the need of
  71267. * separate meshes. This can be use to improve performances.
  71268. * @see http://doc.babylonjs.com/how_to/multi_materials
  71269. * @param name Define the name in the scene
  71270. * @param scene Define the scene the material belongs to
  71271. */
  71272. constructor(name: string, scene: Scene);
  71273. private _hookArray;
  71274. /**
  71275. * Get one of the submaterial by its index in the submaterials array
  71276. * @param index The index to look the sub material at
  71277. * @returns The Material if the index has been defined
  71278. */
  71279. getSubMaterial(index: number): Nullable<Material>;
  71280. /**
  71281. * Get the list of active textures for the whole sub materials list.
  71282. * @returns All the textures that will be used during the rendering
  71283. */
  71284. getActiveTextures(): BaseTexture[];
  71285. /**
  71286. * Gets the current class name of the material e.g. "MultiMaterial"
  71287. * Mainly use in serialization.
  71288. * @returns the class name
  71289. */
  71290. getClassName(): string;
  71291. /**
  71292. * Checks if the material is ready to render the requested sub mesh
  71293. * @param mesh Define the mesh the submesh belongs to
  71294. * @param subMesh Define the sub mesh to look readyness for
  71295. * @param useInstances Define whether or not the material is used with instances
  71296. * @returns true if ready, otherwise false
  71297. */
  71298. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  71299. /**
  71300. * Clones the current material and its related sub materials
  71301. * @param name Define the name of the newly cloned material
  71302. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  71303. * @returns the cloned material
  71304. */
  71305. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  71306. /**
  71307. * Serializes the materials into a JSON representation.
  71308. * @returns the JSON representation
  71309. */
  71310. serialize(): any;
  71311. /**
  71312. * Dispose the material and release its associated resources
  71313. * @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)
  71314. * @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)
  71315. * @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)
  71316. */
  71317. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  71318. /**
  71319. * Creates a MultiMaterial from parsed MultiMaterial data.
  71320. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  71321. * @param scene defines the hosting scene
  71322. * @returns a new MultiMaterial
  71323. */
  71324. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  71325. }
  71326. }
  71327. declare module BABYLON {
  71328. /**
  71329. * Class used to represent data loading progression
  71330. */
  71331. export class SceneLoaderFlags {
  71332. private static _ForceFullSceneLoadingForIncremental;
  71333. private static _ShowLoadingScreen;
  71334. private static _CleanBoneMatrixWeights;
  71335. private static _loggingLevel;
  71336. /**
  71337. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  71338. */
  71339. static ForceFullSceneLoadingForIncremental: boolean;
  71340. /**
  71341. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  71342. */
  71343. static ShowLoadingScreen: boolean;
  71344. /**
  71345. * Defines the current logging level (while loading the scene)
  71346. * @ignorenaming
  71347. */
  71348. static loggingLevel: number;
  71349. /**
  71350. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  71351. */
  71352. static CleanBoneMatrixWeights: boolean;
  71353. }
  71354. }
  71355. declare module BABYLON {
  71356. /**
  71357. * 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.
  71358. * @see https://doc.babylonjs.com/how_to/transformnode
  71359. */
  71360. export class TransformNode extends Node {
  71361. /**
  71362. * Object will not rotate to face the camera
  71363. */
  71364. static BILLBOARDMODE_NONE: number;
  71365. /**
  71366. * Object will rotate to face the camera but only on the x axis
  71367. */
  71368. static BILLBOARDMODE_X: number;
  71369. /**
  71370. * Object will rotate to face the camera but only on the y axis
  71371. */
  71372. static BILLBOARDMODE_Y: number;
  71373. /**
  71374. * Object will rotate to face the camera but only on the z axis
  71375. */
  71376. static BILLBOARDMODE_Z: number;
  71377. /**
  71378. * Object will rotate to face the camera
  71379. */
  71380. static BILLBOARDMODE_ALL: number;
  71381. private _forward;
  71382. private _forwardInverted;
  71383. private _up;
  71384. private _right;
  71385. private _rightInverted;
  71386. private _position;
  71387. private _rotation;
  71388. private _rotationQuaternion;
  71389. protected _scaling: Vector3;
  71390. protected _isDirty: boolean;
  71391. private _transformToBoneReferal;
  71392. private _billboardMode;
  71393. /**
  71394. * Gets or sets the billboard mode. Default is 0.
  71395. *
  71396. * | Value | Type | Description |
  71397. * | --- | --- | --- |
  71398. * | 0 | BILLBOARDMODE_NONE | |
  71399. * | 1 | BILLBOARDMODE_X | |
  71400. * | 2 | BILLBOARDMODE_Y | |
  71401. * | 4 | BILLBOARDMODE_Z | |
  71402. * | 7 | BILLBOARDMODE_ALL | |
  71403. *
  71404. */
  71405. billboardMode: number;
  71406. private _preserveParentRotationForBillboard;
  71407. /**
  71408. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  71409. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  71410. */
  71411. preserveParentRotationForBillboard: boolean;
  71412. /**
  71413. * 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
  71414. */
  71415. scalingDeterminant: number;
  71416. private _infiniteDistance;
  71417. /**
  71418. * Gets or sets the distance of the object to max, often used by skybox
  71419. */
  71420. infiniteDistance: boolean;
  71421. /**
  71422. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  71423. * By default the system will update normals to compensate
  71424. */
  71425. ignoreNonUniformScaling: boolean;
  71426. /**
  71427. * 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
  71428. */
  71429. reIntegrateRotationIntoRotationQuaternion: boolean;
  71430. /** @hidden */
  71431. _poseMatrix: Nullable<Matrix>;
  71432. /** @hidden */
  71433. _localMatrix: Matrix;
  71434. private _usePivotMatrix;
  71435. private _absolutePosition;
  71436. private _pivotMatrix;
  71437. private _pivotMatrixInverse;
  71438. protected _postMultiplyPivotMatrix: boolean;
  71439. protected _isWorldMatrixFrozen: boolean;
  71440. /** @hidden */
  71441. _indexInSceneTransformNodesArray: number;
  71442. /**
  71443. * An event triggered after the world matrix is updated
  71444. */
  71445. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  71446. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  71447. /**
  71448. * Gets a string identifying the name of the class
  71449. * @returns "TransformNode" string
  71450. */
  71451. getClassName(): string;
  71452. /**
  71453. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  71454. */
  71455. position: Vector3;
  71456. /**
  71457. * 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)).
  71458. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  71459. */
  71460. rotation: Vector3;
  71461. /**
  71462. * 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)).
  71463. */
  71464. scaling: Vector3;
  71465. /**
  71466. * 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).
  71467. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  71468. */
  71469. rotationQuaternion: Nullable<Quaternion>;
  71470. /**
  71471. * The forward direction of that transform in world space.
  71472. */
  71473. readonly forward: Vector3;
  71474. /**
  71475. * The up direction of that transform in world space.
  71476. */
  71477. readonly up: Vector3;
  71478. /**
  71479. * The right direction of that transform in world space.
  71480. */
  71481. readonly right: Vector3;
  71482. /**
  71483. * Copies the parameter passed Matrix into the mesh Pose matrix.
  71484. * @param matrix the matrix to copy the pose from
  71485. * @returns this TransformNode.
  71486. */
  71487. updatePoseMatrix(matrix: Matrix): TransformNode;
  71488. /**
  71489. * Returns the mesh Pose matrix.
  71490. * @returns the pose matrix
  71491. */
  71492. getPoseMatrix(): Matrix;
  71493. /** @hidden */
  71494. _isSynchronized(): boolean;
  71495. /** @hidden */
  71496. _initCache(): void;
  71497. /**
  71498. * Flag the transform node as dirty (Forcing it to update everything)
  71499. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  71500. * @returns this transform node
  71501. */
  71502. markAsDirty(property: string): TransformNode;
  71503. /**
  71504. * Returns the current mesh absolute position.
  71505. * Returns a Vector3.
  71506. */
  71507. readonly absolutePosition: Vector3;
  71508. /**
  71509. * Sets a new matrix to apply before all other transformation
  71510. * @param matrix defines the transform matrix
  71511. * @returns the current TransformNode
  71512. */
  71513. setPreTransformMatrix(matrix: Matrix): TransformNode;
  71514. /**
  71515. * Sets a new pivot matrix to the current node
  71516. * @param matrix defines the new pivot matrix to use
  71517. * @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
  71518. * @returns the current TransformNode
  71519. */
  71520. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  71521. /**
  71522. * Returns the mesh pivot matrix.
  71523. * Default : Identity.
  71524. * @returns the matrix
  71525. */
  71526. getPivotMatrix(): Matrix;
  71527. /**
  71528. * Prevents the World matrix to be computed any longer.
  71529. * @returns the TransformNode.
  71530. */
  71531. freezeWorldMatrix(): TransformNode;
  71532. /**
  71533. * Allows back the World matrix computation.
  71534. * @returns the TransformNode.
  71535. */
  71536. unfreezeWorldMatrix(): this;
  71537. /**
  71538. * True if the World matrix has been frozen.
  71539. */
  71540. readonly isWorldMatrixFrozen: boolean;
  71541. /**
  71542. * Retuns the mesh absolute position in the World.
  71543. * @returns a Vector3.
  71544. */
  71545. getAbsolutePosition(): Vector3;
  71546. /**
  71547. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  71548. * @param absolutePosition the absolute position to set
  71549. * @returns the TransformNode.
  71550. */
  71551. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  71552. /**
  71553. * Sets the mesh position in its local space.
  71554. * @param vector3 the position to set in localspace
  71555. * @returns the TransformNode.
  71556. */
  71557. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  71558. /**
  71559. * Returns the mesh position in the local space from the current World matrix values.
  71560. * @returns a new Vector3.
  71561. */
  71562. getPositionExpressedInLocalSpace(): Vector3;
  71563. /**
  71564. * Translates the mesh along the passed Vector3 in its local space.
  71565. * @param vector3 the distance to translate in localspace
  71566. * @returns the TransformNode.
  71567. */
  71568. locallyTranslate(vector3: Vector3): TransformNode;
  71569. private static _lookAtVectorCache;
  71570. /**
  71571. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  71572. * @param targetPoint the position (must be in same space as current mesh) to look at
  71573. * @param yawCor optional yaw (y-axis) correction in radians
  71574. * @param pitchCor optional pitch (x-axis) correction in radians
  71575. * @param rollCor optional roll (z-axis) correction in radians
  71576. * @param space the choosen space of the target
  71577. * @returns the TransformNode.
  71578. */
  71579. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  71580. /**
  71581. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  71582. * This Vector3 is expressed in the World space.
  71583. * @param localAxis axis to rotate
  71584. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  71585. */
  71586. getDirection(localAxis: Vector3): Vector3;
  71587. /**
  71588. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  71589. * localAxis is expressed in the mesh local space.
  71590. * result is computed in the Wordl space from the mesh World matrix.
  71591. * @param localAxis axis to rotate
  71592. * @param result the resulting transformnode
  71593. * @returns this TransformNode.
  71594. */
  71595. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  71596. /**
  71597. * Sets this transform node rotation to the given local axis.
  71598. * @param localAxis the axis in local space
  71599. * @param yawCor optional yaw (y-axis) correction in radians
  71600. * @param pitchCor optional pitch (x-axis) correction in radians
  71601. * @param rollCor optional roll (z-axis) correction in radians
  71602. * @returns this TransformNode
  71603. */
  71604. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  71605. /**
  71606. * Sets a new pivot point to the current node
  71607. * @param point defines the new pivot point to use
  71608. * @param space defines if the point is in world or local space (local by default)
  71609. * @returns the current TransformNode
  71610. */
  71611. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  71612. /**
  71613. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  71614. * @returns the pivot point
  71615. */
  71616. getPivotPoint(): Vector3;
  71617. /**
  71618. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  71619. * @param result the vector3 to store the result
  71620. * @returns this TransformNode.
  71621. */
  71622. getPivotPointToRef(result: Vector3): TransformNode;
  71623. /**
  71624. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  71625. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  71626. */
  71627. getAbsolutePivotPoint(): Vector3;
  71628. /**
  71629. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  71630. * @param result vector3 to store the result
  71631. * @returns this TransformNode.
  71632. */
  71633. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  71634. /**
  71635. * Defines the passed node as the parent of the current node.
  71636. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  71637. * @see https://doc.babylonjs.com/how_to/parenting
  71638. * @param node the node ot set as the parent
  71639. * @returns this TransformNode.
  71640. */
  71641. setParent(node: Nullable<Node>): TransformNode;
  71642. private _nonUniformScaling;
  71643. /**
  71644. * True if the scaling property of this object is non uniform eg. (1,2,1)
  71645. */
  71646. readonly nonUniformScaling: boolean;
  71647. /** @hidden */
  71648. _updateNonUniformScalingState(value: boolean): boolean;
  71649. /**
  71650. * Attach the current TransformNode to another TransformNode associated with a bone
  71651. * @param bone Bone affecting the TransformNode
  71652. * @param affectedTransformNode TransformNode associated with the bone
  71653. * @returns this object
  71654. */
  71655. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  71656. /**
  71657. * Detach the transform node if its associated with a bone
  71658. * @returns this object
  71659. */
  71660. detachFromBone(): TransformNode;
  71661. private static _rotationAxisCache;
  71662. /**
  71663. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  71664. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  71665. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  71666. * The passed axis is also normalized.
  71667. * @param axis the axis to rotate around
  71668. * @param amount the amount to rotate in radians
  71669. * @param space Space to rotate in (Default: local)
  71670. * @returns the TransformNode.
  71671. */
  71672. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  71673. /**
  71674. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  71675. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  71676. * The passed axis is also normalized. .
  71677. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  71678. * @param point the point to rotate around
  71679. * @param axis the axis to rotate around
  71680. * @param amount the amount to rotate in radians
  71681. * @returns the TransformNode
  71682. */
  71683. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  71684. /**
  71685. * Translates the mesh along the axis vector for the passed distance in the given space.
  71686. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  71687. * @param axis the axis to translate in
  71688. * @param distance the distance to translate
  71689. * @param space Space to rotate in (Default: local)
  71690. * @returns the TransformNode.
  71691. */
  71692. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  71693. /**
  71694. * Adds a rotation step to the mesh current rotation.
  71695. * x, y, z are Euler angles expressed in radians.
  71696. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  71697. * This means this rotation is made in the mesh local space only.
  71698. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  71699. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  71700. * ```javascript
  71701. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  71702. * ```
  71703. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  71704. * 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.
  71705. * @param x Rotation to add
  71706. * @param y Rotation to add
  71707. * @param z Rotation to add
  71708. * @returns the TransformNode.
  71709. */
  71710. addRotation(x: number, y: number, z: number): TransformNode;
  71711. /**
  71712. * @hidden
  71713. */
  71714. protected _getEffectiveParent(): Nullable<Node>;
  71715. /**
  71716. * Computes the world matrix of the node
  71717. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  71718. * @returns the world matrix
  71719. */
  71720. computeWorldMatrix(force?: boolean): Matrix;
  71721. protected _afterComputeWorldMatrix(): void;
  71722. /**
  71723. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  71724. * @param func callback function to add
  71725. *
  71726. * @returns the TransformNode.
  71727. */
  71728. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  71729. /**
  71730. * Removes a registered callback function.
  71731. * @param func callback function to remove
  71732. * @returns the TransformNode.
  71733. */
  71734. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  71735. /**
  71736. * Gets the position of the current mesh in camera space
  71737. * @param camera defines the camera to use
  71738. * @returns a position
  71739. */
  71740. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  71741. /**
  71742. * Returns the distance from the mesh to the active camera
  71743. * @param camera defines the camera to use
  71744. * @returns the distance
  71745. */
  71746. getDistanceToCamera(camera?: Nullable<Camera>): number;
  71747. /**
  71748. * Clone the current transform node
  71749. * @param name Name of the new clone
  71750. * @param newParent New parent for the clone
  71751. * @param doNotCloneChildren Do not clone children hierarchy
  71752. * @returns the new transform node
  71753. */
  71754. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  71755. /**
  71756. * Serializes the objects information.
  71757. * @param currentSerializationObject defines the object to serialize in
  71758. * @returns the serialized object
  71759. */
  71760. serialize(currentSerializationObject?: any): any;
  71761. /**
  71762. * Returns a new TransformNode object parsed from the source provided.
  71763. * @param parsedTransformNode is the source.
  71764. * @param scene the scne the object belongs to
  71765. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  71766. * @returns a new TransformNode object parsed from the source provided.
  71767. */
  71768. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  71769. /**
  71770. * Get all child-transformNodes of this node
  71771. * @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
  71772. * @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
  71773. * @returns an array of TransformNode
  71774. */
  71775. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  71776. /**
  71777. * Releases resources associated with this transform node.
  71778. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  71779. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  71780. */
  71781. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  71782. /**
  71783. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  71784. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  71785. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  71786. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  71787. * @returns the current mesh
  71788. */
  71789. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  71790. }
  71791. }
  71792. declare module BABYLON {
  71793. /**
  71794. * Class used to override all child animations of a given target
  71795. */
  71796. export class AnimationPropertiesOverride {
  71797. /**
  71798. * Gets or sets a value indicating if animation blending must be used
  71799. */
  71800. enableBlending: boolean;
  71801. /**
  71802. * Gets or sets the blending speed to use when enableBlending is true
  71803. */
  71804. blendingSpeed: number;
  71805. /**
  71806. * Gets or sets the default loop mode to use
  71807. */
  71808. loopMode: number;
  71809. }
  71810. }
  71811. declare module BABYLON {
  71812. /**
  71813. * Class used to store bone information
  71814. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  71815. */
  71816. export class Bone extends Node {
  71817. /**
  71818. * defines the bone name
  71819. */
  71820. name: string;
  71821. private static _tmpVecs;
  71822. private static _tmpQuat;
  71823. private static _tmpMats;
  71824. /**
  71825. * Gets the list of child bones
  71826. */
  71827. children: Bone[];
  71828. /** Gets the animations associated with this bone */
  71829. animations: Animation[];
  71830. /**
  71831. * Gets or sets bone length
  71832. */
  71833. length: number;
  71834. /**
  71835. * @hidden Internal only
  71836. * Set this value to map this bone to a different index in the transform matrices
  71837. * Set this value to -1 to exclude the bone from the transform matrices
  71838. */
  71839. _index: Nullable<number>;
  71840. private _skeleton;
  71841. private _localMatrix;
  71842. private _restPose;
  71843. private _baseMatrix;
  71844. private _absoluteTransform;
  71845. private _invertedAbsoluteTransform;
  71846. private _parent;
  71847. private _scalingDeterminant;
  71848. private _worldTransform;
  71849. private _localScaling;
  71850. private _localRotation;
  71851. private _localPosition;
  71852. private _needToDecompose;
  71853. private _needToCompose;
  71854. /** @hidden */
  71855. _linkedTransformNode: Nullable<TransformNode>;
  71856. /** @hidden */
  71857. _waitingTransformNodeId: Nullable<string>;
  71858. /** @hidden */
  71859. /** @hidden */
  71860. _matrix: Matrix;
  71861. /**
  71862. * Create a new bone
  71863. * @param name defines the bone name
  71864. * @param skeleton defines the parent skeleton
  71865. * @param parentBone defines the parent (can be null if the bone is the root)
  71866. * @param localMatrix defines the local matrix
  71867. * @param restPose defines the rest pose matrix
  71868. * @param baseMatrix defines the base matrix
  71869. * @param index defines index of the bone in the hiearchy
  71870. */
  71871. constructor(
  71872. /**
  71873. * defines the bone name
  71874. */
  71875. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  71876. /**
  71877. * Gets the current object class name.
  71878. * @return the class name
  71879. */
  71880. getClassName(): string;
  71881. /**
  71882. * Gets the parent skeleton
  71883. * @returns a skeleton
  71884. */
  71885. getSkeleton(): Skeleton;
  71886. /**
  71887. * Gets parent bone
  71888. * @returns a bone or null if the bone is the root of the bone hierarchy
  71889. */
  71890. getParent(): Nullable<Bone>;
  71891. /**
  71892. * Returns an array containing the root bones
  71893. * @returns an array containing the root bones
  71894. */
  71895. getChildren(): Array<Bone>;
  71896. /**
  71897. * Sets the parent bone
  71898. * @param parent defines the parent (can be null if the bone is the root)
  71899. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  71900. */
  71901. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  71902. /**
  71903. * Gets the local matrix
  71904. * @returns a matrix
  71905. */
  71906. getLocalMatrix(): Matrix;
  71907. /**
  71908. * Gets the base matrix (initial matrix which remains unchanged)
  71909. * @returns a matrix
  71910. */
  71911. getBaseMatrix(): Matrix;
  71912. /**
  71913. * Gets the rest pose matrix
  71914. * @returns a matrix
  71915. */
  71916. getRestPose(): Matrix;
  71917. /**
  71918. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  71919. */
  71920. getWorldMatrix(): Matrix;
  71921. /**
  71922. * Sets the local matrix to rest pose matrix
  71923. */
  71924. returnToRest(): void;
  71925. /**
  71926. * Gets the inverse of the absolute transform matrix.
  71927. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  71928. * @returns a matrix
  71929. */
  71930. getInvertedAbsoluteTransform(): Matrix;
  71931. /**
  71932. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  71933. * @returns a matrix
  71934. */
  71935. getAbsoluteTransform(): Matrix;
  71936. /**
  71937. * Links with the given transform node.
  71938. * The local matrix of this bone is copied from the transform node every frame.
  71939. * @param transformNode defines the transform node to link to
  71940. */
  71941. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  71942. /** Gets or sets current position (in local space) */
  71943. position: Vector3;
  71944. /** Gets or sets current rotation (in local space) */
  71945. rotation: Vector3;
  71946. /** Gets or sets current rotation quaternion (in local space) */
  71947. rotationQuaternion: Quaternion;
  71948. /** Gets or sets current scaling (in local space) */
  71949. scaling: Vector3;
  71950. /**
  71951. * Gets the animation properties override
  71952. */
  71953. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  71954. private _decompose;
  71955. private _compose;
  71956. /**
  71957. * Update the base and local matrices
  71958. * @param matrix defines the new base or local matrix
  71959. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  71960. * @param updateLocalMatrix defines if the local matrix should be updated
  71961. */
  71962. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  71963. /** @hidden */
  71964. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  71965. /**
  71966. * Flag the bone as dirty (Forcing it to update everything)
  71967. */
  71968. markAsDirty(): void;
  71969. /** @hidden */
  71970. _markAsDirtyAndCompose(): void;
  71971. private _markAsDirtyAndDecompose;
  71972. /**
  71973. * Translate the bone in local or world space
  71974. * @param vec The amount to translate the bone
  71975. * @param space The space that the translation is in
  71976. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71977. */
  71978. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  71979. /**
  71980. * Set the postion of the bone in local or world space
  71981. * @param position The position to set the bone
  71982. * @param space The space that the position is in
  71983. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71984. */
  71985. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  71986. /**
  71987. * Set the absolute position of the bone (world space)
  71988. * @param position The position to set the bone
  71989. * @param mesh The mesh that this bone is attached to
  71990. */
  71991. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  71992. /**
  71993. * Scale the bone on the x, y and z axes (in local space)
  71994. * @param x The amount to scale the bone on the x axis
  71995. * @param y The amount to scale the bone on the y axis
  71996. * @param z The amount to scale the bone on the z axis
  71997. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  71998. */
  71999. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  72000. /**
  72001. * Set the bone scaling in local space
  72002. * @param scale defines the scaling vector
  72003. */
  72004. setScale(scale: Vector3): void;
  72005. /**
  72006. * Gets the current scaling in local space
  72007. * @returns the current scaling vector
  72008. */
  72009. getScale(): Vector3;
  72010. /**
  72011. * Gets the current scaling in local space and stores it in a target vector
  72012. * @param result defines the target vector
  72013. */
  72014. getScaleToRef(result: Vector3): void;
  72015. /**
  72016. * Set the yaw, pitch, and roll of the bone in local or world space
  72017. * @param yaw The rotation of the bone on the y axis
  72018. * @param pitch The rotation of the bone on the x axis
  72019. * @param roll The rotation of the bone on the z axis
  72020. * @param space The space that the axes of rotation are in
  72021. * @param mesh The mesh that this bone is attached to. This is only used in world space
  72022. */
  72023. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  72024. /**
  72025. * Add a rotation to the bone on an axis in local or world space
  72026. * @param axis The axis to rotate the bone on
  72027. * @param amount The amount to rotate the bone
  72028. * @param space The space that the axis is in
  72029. * @param mesh The mesh that this bone is attached to. This is only used in world space
  72030. */
  72031. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  72032. /**
  72033. * Set the rotation of the bone to a particular axis angle in local or world space
  72034. * @param axis The axis to rotate the bone on
  72035. * @param angle The angle that the bone should be rotated to
  72036. * @param space The space that the axis is in
  72037. * @param mesh The mesh that this bone is attached to. This is only used in world space
  72038. */
  72039. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  72040. /**
  72041. * Set the euler rotation of the bone in local of world space
  72042. * @param rotation The euler rotation that the bone should be set to
  72043. * @param space The space that the rotation is in
  72044. * @param mesh The mesh that this bone is attached to. This is only used in world space
  72045. */
  72046. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  72047. /**
  72048. * Set the quaternion rotation of the bone in local of world space
  72049. * @param quat The quaternion rotation that the bone should be set to
  72050. * @param space The space that the rotation is in
  72051. * @param mesh The mesh that this bone is attached to. This is only used in world space
  72052. */
  72053. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  72054. /**
  72055. * Set the rotation matrix of the bone in local of world space
  72056. * @param rotMat The rotation matrix that the bone should be set to
  72057. * @param space The space that the rotation is in
  72058. * @param mesh The mesh that this bone is attached to. This is only used in world space
  72059. */
  72060. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  72061. private _rotateWithMatrix;
  72062. private _getNegativeRotationToRef;
  72063. /**
  72064. * Get the position of the bone in local or world space
  72065. * @param space The space that the returned position is in
  72066. * @param mesh The mesh that this bone is attached to. This is only used in world space
  72067. * @returns The position of the bone
  72068. */
  72069. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  72070. /**
  72071. * Copy the position of the bone to a vector3 in local or world space
  72072. * @param space The space that the returned position is in
  72073. * @param mesh The mesh that this bone is attached to. This is only used in world space
  72074. * @param result The vector3 to copy the position to
  72075. */
  72076. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  72077. /**
  72078. * Get the absolute position of the bone (world space)
  72079. * @param mesh The mesh that this bone is attached to
  72080. * @returns The absolute position of the bone
  72081. */
  72082. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  72083. /**
  72084. * Copy the absolute position of the bone (world space) to the result param
  72085. * @param mesh The mesh that this bone is attached to
  72086. * @param result The vector3 to copy the absolute position to
  72087. */
  72088. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  72089. /**
  72090. * Compute the absolute transforms of this bone and its children
  72091. */
  72092. computeAbsoluteTransforms(): void;
  72093. /**
  72094. * Get the world direction from an axis that is in the local space of the bone
  72095. * @param localAxis The local direction that is used to compute the world direction
  72096. * @param mesh The mesh that this bone is attached to
  72097. * @returns The world direction
  72098. */
  72099. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  72100. /**
  72101. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  72102. * @param localAxis The local direction that is used to compute the world direction
  72103. * @param mesh The mesh that this bone is attached to
  72104. * @param result The vector3 that the world direction will be copied to
  72105. */
  72106. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  72107. /**
  72108. * Get the euler rotation of the bone in local or world space
  72109. * @param space The space that the rotation should be in
  72110. * @param mesh The mesh that this bone is attached to. This is only used in world space
  72111. * @returns The euler rotation
  72112. */
  72113. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  72114. /**
  72115. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  72116. * @param space The space that the rotation should be in
  72117. * @param mesh The mesh that this bone is attached to. This is only used in world space
  72118. * @param result The vector3 that the rotation should be copied to
  72119. */
  72120. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  72121. /**
  72122. * Get the quaternion rotation of the bone in either local or world space
  72123. * @param space The space that the rotation should be in
  72124. * @param mesh The mesh that this bone is attached to. This is only used in world space
  72125. * @returns The quaternion rotation
  72126. */
  72127. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  72128. /**
  72129. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  72130. * @param space The space that the rotation should be in
  72131. * @param mesh The mesh that this bone is attached to. This is only used in world space
  72132. * @param result The quaternion that the rotation should be copied to
  72133. */
  72134. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  72135. /**
  72136. * Get the rotation matrix of the bone in local or world space
  72137. * @param space The space that the rotation should be in
  72138. * @param mesh The mesh that this bone is attached to. This is only used in world space
  72139. * @returns The rotation matrix
  72140. */
  72141. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  72142. /**
  72143. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  72144. * @param space The space that the rotation should be in
  72145. * @param mesh The mesh that this bone is attached to. This is only used in world space
  72146. * @param result The quaternion that the rotation should be copied to
  72147. */
  72148. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  72149. /**
  72150. * Get the world position of a point that is in the local space of the bone
  72151. * @param position The local position
  72152. * @param mesh The mesh that this bone is attached to
  72153. * @returns The world position
  72154. */
  72155. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  72156. /**
  72157. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  72158. * @param position The local position
  72159. * @param mesh The mesh that this bone is attached to
  72160. * @param result The vector3 that the world position should be copied to
  72161. */
  72162. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  72163. /**
  72164. * Get the local position of a point that is in world space
  72165. * @param position The world position
  72166. * @param mesh The mesh that this bone is attached to
  72167. * @returns The local position
  72168. */
  72169. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  72170. /**
  72171. * Get the local position of a point that is in world space and copy it to the result param
  72172. * @param position The world position
  72173. * @param mesh The mesh that this bone is attached to
  72174. * @param result The vector3 that the local position should be copied to
  72175. */
  72176. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  72177. }
  72178. }
  72179. declare module BABYLON {
  72180. interface Engine {
  72181. /**
  72182. * Creates a raw texture
  72183. * @param data defines the data to store in the texture
  72184. * @param width defines the width of the texture
  72185. * @param height defines the height of the texture
  72186. * @param format defines the format of the data
  72187. * @param generateMipMaps defines if the engine should generate the mip levels
  72188. * @param invertY defines if data must be stored with Y axis inverted
  72189. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  72190. * @param compression defines the compression used (null by default)
  72191. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  72192. * @returns the raw texture inside an InternalTexture
  72193. */
  72194. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  72195. /**
  72196. * Update a raw texture
  72197. * @param texture defines the texture to update
  72198. * @param data defines the data to store in the texture
  72199. * @param format defines the format of the data
  72200. * @param invertY defines if data must be stored with Y axis inverted
  72201. */
  72202. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  72203. /**
  72204. * Update a raw texture
  72205. * @param texture defines the texture to update
  72206. * @param data defines the data to store in the texture
  72207. * @param format defines the format of the data
  72208. * @param invertY defines if data must be stored with Y axis inverted
  72209. * @param compression defines the compression used (null by default)
  72210. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  72211. */
  72212. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  72213. /**
  72214. * Creates a new raw cube texture
  72215. * @param data defines the array of data to use to create each face
  72216. * @param size defines the size of the textures
  72217. * @param format defines the format of the data
  72218. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  72219. * @param generateMipMaps defines if the engine should generate the mip levels
  72220. * @param invertY defines if data must be stored with Y axis inverted
  72221. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  72222. * @param compression defines the compression used (null by default)
  72223. * @returns the cube texture as an InternalTexture
  72224. */
  72225. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  72226. /**
  72227. * Update a raw cube texture
  72228. * @param texture defines the texture to udpdate
  72229. * @param data defines the data to store
  72230. * @param format defines the data format
  72231. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  72232. * @param invertY defines if data must be stored with Y axis inverted
  72233. */
  72234. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  72235. /**
  72236. * Update a raw cube texture
  72237. * @param texture defines the texture to udpdate
  72238. * @param data defines the data to store
  72239. * @param format defines the data format
  72240. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  72241. * @param invertY defines if data must be stored with Y axis inverted
  72242. * @param compression defines the compression used (null by default)
  72243. */
  72244. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  72245. /**
  72246. * Update a raw cube texture
  72247. * @param texture defines the texture to udpdate
  72248. * @param data defines the data to store
  72249. * @param format defines the data format
  72250. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  72251. * @param invertY defines if data must be stored with Y axis inverted
  72252. * @param compression defines the compression used (null by default)
  72253. * @param level defines which level of the texture to update
  72254. */
  72255. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  72256. /**
  72257. * Creates a new raw cube texture from a specified url
  72258. * @param url defines the url where the data is located
  72259. * @param scene defines the current scene
  72260. * @param size defines the size of the textures
  72261. * @param format defines the format of the data
  72262. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  72263. * @param noMipmap defines if the engine should avoid generating the mip levels
  72264. * @param callback defines a callback used to extract texture data from loaded data
  72265. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  72266. * @param onLoad defines a callback called when texture is loaded
  72267. * @param onError defines a callback called if there is an error
  72268. * @returns the cube texture as an InternalTexture
  72269. */
  72270. 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;
  72271. /**
  72272. * Creates a new raw cube texture from a specified url
  72273. * @param url defines the url where the data is located
  72274. * @param scene defines the current scene
  72275. * @param size defines the size of the textures
  72276. * @param format defines the format of the data
  72277. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  72278. * @param noMipmap defines if the engine should avoid generating the mip levels
  72279. * @param callback defines a callback used to extract texture data from loaded data
  72280. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  72281. * @param onLoad defines a callback called when texture is loaded
  72282. * @param onError defines a callback called if there is an error
  72283. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  72284. * @param invertY defines if data must be stored with Y axis inverted
  72285. * @returns the cube texture as an InternalTexture
  72286. */
  72287. 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;
  72288. /**
  72289. * Creates a new raw 3D texture
  72290. * @param data defines the data used to create the texture
  72291. * @param width defines the width of the texture
  72292. * @param height defines the height of the texture
  72293. * @param depth defines the depth of the texture
  72294. * @param format defines the format of the texture
  72295. * @param generateMipMaps defines if the engine must generate mip levels
  72296. * @param invertY defines if data must be stored with Y axis inverted
  72297. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  72298. * @param compression defines the compressed used (can be null)
  72299. * @param textureType defines the compressed used (can be null)
  72300. * @returns a new raw 3D texture (stored in an InternalTexture)
  72301. */
  72302. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  72303. /**
  72304. * Update a raw 3D texture
  72305. * @param texture defines the texture to update
  72306. * @param data defines the data to store
  72307. * @param format defines the data format
  72308. * @param invertY defines if data must be stored with Y axis inverted
  72309. */
  72310. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  72311. /**
  72312. * Update a raw 3D texture
  72313. * @param texture defines the texture to update
  72314. * @param data defines the data to store
  72315. * @param format defines the data format
  72316. * @param invertY defines if data must be stored with Y axis inverted
  72317. * @param compression defines the used compression (can be null)
  72318. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  72319. */
  72320. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  72321. }
  72322. }
  72323. declare module BABYLON {
  72324. /**
  72325. * Raw texture can help creating a texture directly from an array of data.
  72326. * This can be super useful if you either get the data from an uncompressed source or
  72327. * if you wish to create your texture pixel by pixel.
  72328. */
  72329. export class RawTexture extends Texture {
  72330. /**
  72331. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  72332. */
  72333. format: number;
  72334. private _engine;
  72335. /**
  72336. * Instantiates a new RawTexture.
  72337. * Raw texture can help creating a texture directly from an array of data.
  72338. * This can be super useful if you either get the data from an uncompressed source or
  72339. * if you wish to create your texture pixel by pixel.
  72340. * @param data define the array of data to use to create the texture
  72341. * @param width define the width of the texture
  72342. * @param height define the height of the texture
  72343. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  72344. * @param scene define the scene the texture belongs to
  72345. * @param generateMipMaps define whether mip maps should be generated or not
  72346. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72347. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72348. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  72349. */
  72350. constructor(data: ArrayBufferView, width: number, height: number,
  72351. /**
  72352. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  72353. */
  72354. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  72355. /**
  72356. * Updates the texture underlying data.
  72357. * @param data Define the new data of the texture
  72358. */
  72359. update(data: ArrayBufferView): void;
  72360. /**
  72361. * Creates a luminance texture from some data.
  72362. * @param data Define the texture data
  72363. * @param width Define the width of the texture
  72364. * @param height Define the height of the texture
  72365. * @param scene Define the scene the texture belongs to
  72366. * @param generateMipMaps Define whether or not to create mip maps for the texture
  72367. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72368. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72369. * @returns the luminance texture
  72370. */
  72371. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  72372. /**
  72373. * Creates a luminance alpha texture from some data.
  72374. * @param data Define the texture data
  72375. * @param width Define the width of the texture
  72376. * @param height Define the height of the texture
  72377. * @param scene Define the scene the texture belongs to
  72378. * @param generateMipMaps Define whether or not to create mip maps for the texture
  72379. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72380. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72381. * @returns the luminance alpha texture
  72382. */
  72383. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  72384. /**
  72385. * Creates an alpha texture from some data.
  72386. * @param data Define the texture data
  72387. * @param width Define the width of the texture
  72388. * @param height Define the height of the texture
  72389. * @param scene Define the scene the texture belongs to
  72390. * @param generateMipMaps Define whether or not to create mip maps for the texture
  72391. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72392. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72393. * @returns the alpha texture
  72394. */
  72395. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  72396. /**
  72397. * Creates a RGB texture from some data.
  72398. * @param data Define the texture data
  72399. * @param width Define the width of the texture
  72400. * @param height Define the height of the texture
  72401. * @param scene Define the scene the texture belongs to
  72402. * @param generateMipMaps Define whether or not to create mip maps for the texture
  72403. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72404. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72405. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  72406. * @returns the RGB alpha texture
  72407. */
  72408. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  72409. /**
  72410. * Creates a RGBA texture from some data.
  72411. * @param data Define the texture data
  72412. * @param width Define the width of the texture
  72413. * @param height Define the height of the texture
  72414. * @param scene Define the scene the texture belongs to
  72415. * @param generateMipMaps Define whether or not to create mip maps for the texture
  72416. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72417. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72418. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  72419. * @returns the RGBA texture
  72420. */
  72421. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  72422. /**
  72423. * Creates a R texture from some data.
  72424. * @param data Define the texture data
  72425. * @param width Define the width of the texture
  72426. * @param height Define the height of the texture
  72427. * @param scene Define the scene the texture belongs to
  72428. * @param generateMipMaps Define whether or not to create mip maps for the texture
  72429. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72430. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72431. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  72432. * @returns the R texture
  72433. */
  72434. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  72435. }
  72436. }
  72437. declare module BABYLON {
  72438. /**
  72439. * Defines a runtime animation
  72440. */
  72441. export class RuntimeAnimation {
  72442. private _events;
  72443. /**
  72444. * The current frame of the runtime animation
  72445. */
  72446. private _currentFrame;
  72447. /**
  72448. * The animation used by the runtime animation
  72449. */
  72450. private _animation;
  72451. /**
  72452. * The target of the runtime animation
  72453. */
  72454. private _target;
  72455. /**
  72456. * The initiating animatable
  72457. */
  72458. private _host;
  72459. /**
  72460. * The original value of the runtime animation
  72461. */
  72462. private _originalValue;
  72463. /**
  72464. * The original blend value of the runtime animation
  72465. */
  72466. private _originalBlendValue;
  72467. /**
  72468. * The offsets cache of the runtime animation
  72469. */
  72470. private _offsetsCache;
  72471. /**
  72472. * The high limits cache of the runtime animation
  72473. */
  72474. private _highLimitsCache;
  72475. /**
  72476. * Specifies if the runtime animation has been stopped
  72477. */
  72478. private _stopped;
  72479. /**
  72480. * The blending factor of the runtime animation
  72481. */
  72482. private _blendingFactor;
  72483. /**
  72484. * The BabylonJS scene
  72485. */
  72486. private _scene;
  72487. /**
  72488. * The current value of the runtime animation
  72489. */
  72490. private _currentValue;
  72491. /** @hidden */
  72492. _animationState: _IAnimationState;
  72493. /**
  72494. * The active target of the runtime animation
  72495. */
  72496. private _activeTargets;
  72497. private _currentActiveTarget;
  72498. private _directTarget;
  72499. /**
  72500. * The target path of the runtime animation
  72501. */
  72502. private _targetPath;
  72503. /**
  72504. * The weight of the runtime animation
  72505. */
  72506. private _weight;
  72507. /**
  72508. * The ratio offset of the runtime animation
  72509. */
  72510. private _ratioOffset;
  72511. /**
  72512. * The previous delay of the runtime animation
  72513. */
  72514. private _previousDelay;
  72515. /**
  72516. * The previous ratio of the runtime animation
  72517. */
  72518. private _previousRatio;
  72519. private _enableBlending;
  72520. private _keys;
  72521. private _minFrame;
  72522. private _maxFrame;
  72523. private _minValue;
  72524. private _maxValue;
  72525. private _targetIsArray;
  72526. /**
  72527. * Gets the current frame of the runtime animation
  72528. */
  72529. readonly currentFrame: number;
  72530. /**
  72531. * Gets the weight of the runtime animation
  72532. */
  72533. readonly weight: number;
  72534. /**
  72535. * Gets the current value of the runtime animation
  72536. */
  72537. readonly currentValue: any;
  72538. /**
  72539. * Gets the target path of the runtime animation
  72540. */
  72541. readonly targetPath: string;
  72542. /**
  72543. * Gets the actual target of the runtime animation
  72544. */
  72545. readonly target: any;
  72546. /** @hidden */
  72547. _onLoop: () => void;
  72548. /**
  72549. * Create a new RuntimeAnimation object
  72550. * @param target defines the target of the animation
  72551. * @param animation defines the source animation object
  72552. * @param scene defines the hosting scene
  72553. * @param host defines the initiating Animatable
  72554. */
  72555. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  72556. private _preparePath;
  72557. /**
  72558. * Gets the animation from the runtime animation
  72559. */
  72560. readonly animation: Animation;
  72561. /**
  72562. * Resets the runtime animation to the beginning
  72563. * @param restoreOriginal defines whether to restore the target property to the original value
  72564. */
  72565. reset(restoreOriginal?: boolean): void;
  72566. /**
  72567. * Specifies if the runtime animation is stopped
  72568. * @returns Boolean specifying if the runtime animation is stopped
  72569. */
  72570. isStopped(): boolean;
  72571. /**
  72572. * Disposes of the runtime animation
  72573. */
  72574. dispose(): void;
  72575. /**
  72576. * Apply the interpolated value to the target
  72577. * @param currentValue defines the value computed by the animation
  72578. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  72579. */
  72580. setValue(currentValue: any, weight: number): void;
  72581. private _getOriginalValues;
  72582. private _setValue;
  72583. /**
  72584. * Gets the loop pmode of the runtime animation
  72585. * @returns Loop Mode
  72586. */
  72587. private _getCorrectLoopMode;
  72588. /**
  72589. * Move the current animation to a given frame
  72590. * @param frame defines the frame to move to
  72591. */
  72592. goToFrame(frame: number): void;
  72593. /**
  72594. * @hidden Internal use only
  72595. */
  72596. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  72597. /**
  72598. * Execute the current animation
  72599. * @param delay defines the delay to add to the current frame
  72600. * @param from defines the lower bound of the animation range
  72601. * @param to defines the upper bound of the animation range
  72602. * @param loop defines if the current animation must loop
  72603. * @param speedRatio defines the current speed ratio
  72604. * @param weight defines the weight of the animation (default is -1 so no weight)
  72605. * @param onLoop optional callback called when animation loops
  72606. * @returns a boolean indicating if the animation is running
  72607. */
  72608. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  72609. }
  72610. }
  72611. declare module BABYLON {
  72612. /**
  72613. * Class used to store an actual running animation
  72614. */
  72615. export class Animatable {
  72616. /** defines the target object */
  72617. target: any;
  72618. /** defines the starting frame number (default is 0) */
  72619. fromFrame: number;
  72620. /** defines the ending frame number (default is 100) */
  72621. toFrame: number;
  72622. /** defines if the animation must loop (default is false) */
  72623. loopAnimation: boolean;
  72624. /** defines a callback to call when animation ends if it is not looping */
  72625. onAnimationEnd?: (() => void) | null | undefined;
  72626. /** defines a callback to call when animation loops */
  72627. onAnimationLoop?: (() => void) | null | undefined;
  72628. private _localDelayOffset;
  72629. private _pausedDelay;
  72630. private _runtimeAnimations;
  72631. private _paused;
  72632. private _scene;
  72633. private _speedRatio;
  72634. private _weight;
  72635. private _syncRoot;
  72636. /**
  72637. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  72638. * This will only apply for non looping animation (default is true)
  72639. */
  72640. disposeOnEnd: boolean;
  72641. /**
  72642. * Gets a boolean indicating if the animation has started
  72643. */
  72644. animationStarted: boolean;
  72645. /**
  72646. * Observer raised when the animation ends
  72647. */
  72648. onAnimationEndObservable: Observable<Animatable>;
  72649. /**
  72650. * Observer raised when the animation loops
  72651. */
  72652. onAnimationLoopObservable: Observable<Animatable>;
  72653. /**
  72654. * Gets the root Animatable used to synchronize and normalize animations
  72655. */
  72656. readonly syncRoot: Nullable<Animatable>;
  72657. /**
  72658. * Gets the current frame of the first RuntimeAnimation
  72659. * Used to synchronize Animatables
  72660. */
  72661. readonly masterFrame: number;
  72662. /**
  72663. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  72664. */
  72665. weight: number;
  72666. /**
  72667. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  72668. */
  72669. speedRatio: number;
  72670. /**
  72671. * Creates a new Animatable
  72672. * @param scene defines the hosting scene
  72673. * @param target defines the target object
  72674. * @param fromFrame defines the starting frame number (default is 0)
  72675. * @param toFrame defines the ending frame number (default is 100)
  72676. * @param loopAnimation defines if the animation must loop (default is false)
  72677. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  72678. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  72679. * @param animations defines a group of animation to add to the new Animatable
  72680. * @param onAnimationLoop defines a callback to call when animation loops
  72681. */
  72682. constructor(scene: Scene,
  72683. /** defines the target object */
  72684. target: any,
  72685. /** defines the starting frame number (default is 0) */
  72686. fromFrame?: number,
  72687. /** defines the ending frame number (default is 100) */
  72688. toFrame?: number,
  72689. /** defines if the animation must loop (default is false) */
  72690. loopAnimation?: boolean, speedRatio?: number,
  72691. /** defines a callback to call when animation ends if it is not looping */
  72692. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  72693. /** defines a callback to call when animation loops */
  72694. onAnimationLoop?: (() => void) | null | undefined);
  72695. /**
  72696. * Synchronize and normalize current Animatable with a source Animatable
  72697. * This is useful when using animation weights and when animations are not of the same length
  72698. * @param root defines the root Animatable to synchronize with
  72699. * @returns the current Animatable
  72700. */
  72701. syncWith(root: Animatable): Animatable;
  72702. /**
  72703. * Gets the list of runtime animations
  72704. * @returns an array of RuntimeAnimation
  72705. */
  72706. getAnimations(): RuntimeAnimation[];
  72707. /**
  72708. * Adds more animations to the current animatable
  72709. * @param target defines the target of the animations
  72710. * @param animations defines the new animations to add
  72711. */
  72712. appendAnimations(target: any, animations: Animation[]): void;
  72713. /**
  72714. * Gets the source animation for a specific property
  72715. * @param property defines the propertyu to look for
  72716. * @returns null or the source animation for the given property
  72717. */
  72718. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  72719. /**
  72720. * Gets the runtime animation for a specific property
  72721. * @param property defines the propertyu to look for
  72722. * @returns null or the runtime animation for the given property
  72723. */
  72724. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  72725. /**
  72726. * Resets the animatable to its original state
  72727. */
  72728. reset(): void;
  72729. /**
  72730. * Allows the animatable to blend with current running animations
  72731. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  72732. * @param blendingSpeed defines the blending speed to use
  72733. */
  72734. enableBlending(blendingSpeed: number): void;
  72735. /**
  72736. * Disable animation blending
  72737. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  72738. */
  72739. disableBlending(): void;
  72740. /**
  72741. * Jump directly to a given frame
  72742. * @param frame defines the frame to jump to
  72743. */
  72744. goToFrame(frame: number): void;
  72745. /**
  72746. * Pause the animation
  72747. */
  72748. pause(): void;
  72749. /**
  72750. * Restart the animation
  72751. */
  72752. restart(): void;
  72753. private _raiseOnAnimationEnd;
  72754. /**
  72755. * Stop and delete the current animation
  72756. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  72757. * @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)
  72758. */
  72759. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  72760. /**
  72761. * Wait asynchronously for the animation to end
  72762. * @returns a promise which will be fullfilled when the animation ends
  72763. */
  72764. waitAsync(): Promise<Animatable>;
  72765. /** @hidden */
  72766. _animate(delay: number): boolean;
  72767. }
  72768. interface Scene {
  72769. /** @hidden */
  72770. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  72771. /** @hidden */
  72772. _processLateAnimationBindingsForMatrices(holder: {
  72773. totalWeight: number;
  72774. animations: RuntimeAnimation[];
  72775. originalValue: Matrix;
  72776. }): any;
  72777. /** @hidden */
  72778. _processLateAnimationBindingsForQuaternions(holder: {
  72779. totalWeight: number;
  72780. animations: RuntimeAnimation[];
  72781. originalValue: Quaternion;
  72782. }, refQuaternion: Quaternion): Quaternion;
  72783. /** @hidden */
  72784. _processLateAnimationBindings(): void;
  72785. /**
  72786. * Will start the animation sequence of a given target
  72787. * @param target defines the target
  72788. * @param from defines from which frame should animation start
  72789. * @param to defines until which frame should animation run.
  72790. * @param weight defines the weight to apply to the animation (1.0 by default)
  72791. * @param loop defines if the animation loops
  72792. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  72793. * @param onAnimationEnd defines the function to be executed when the animation ends
  72794. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  72795. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  72796. * @param onAnimationLoop defines the callback to call when an animation loops
  72797. * @returns the animatable object created for this animation
  72798. */
  72799. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  72800. /**
  72801. * Will start the animation sequence of a given target
  72802. * @param target defines the target
  72803. * @param from defines from which frame should animation start
  72804. * @param to defines until which frame should animation run.
  72805. * @param loop defines if the animation loops
  72806. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  72807. * @param onAnimationEnd defines the function to be executed when the animation ends
  72808. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  72809. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  72810. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  72811. * @param onAnimationLoop defines the callback to call when an animation loops
  72812. * @returns the animatable object created for this animation
  72813. */
  72814. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  72815. /**
  72816. * Will start the animation sequence of a given target and its hierarchy
  72817. * @param target defines the target
  72818. * @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.
  72819. * @param from defines from which frame should animation start
  72820. * @param to defines until which frame should animation run.
  72821. * @param loop defines if the animation loops
  72822. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  72823. * @param onAnimationEnd defines the function to be executed when the animation ends
  72824. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  72825. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  72826. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  72827. * @param onAnimationLoop defines the callback to call when an animation loops
  72828. * @returns the list of created animatables
  72829. */
  72830. 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[];
  72831. /**
  72832. * Begin a new animation on a given node
  72833. * @param target defines the target where the animation will take place
  72834. * @param animations defines the list of animations to start
  72835. * @param from defines the initial value
  72836. * @param to defines the final value
  72837. * @param loop defines if you want animation to loop (off by default)
  72838. * @param speedRatio defines the speed ratio to apply to all animations
  72839. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  72840. * @param onAnimationLoop defines the callback to call when an animation loops
  72841. * @returns the list of created animatables
  72842. */
  72843. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  72844. /**
  72845. * Begin a new animation on a given node and its hierarchy
  72846. * @param target defines the root node where the animation will take place
  72847. * @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.
  72848. * @param animations defines the list of animations to start
  72849. * @param from defines the initial value
  72850. * @param to defines the final value
  72851. * @param loop defines if you want animation to loop (off by default)
  72852. * @param speedRatio defines the speed ratio to apply to all animations
  72853. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  72854. * @param onAnimationLoop defines the callback to call when an animation loops
  72855. * @returns the list of animatables created for all nodes
  72856. */
  72857. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  72858. /**
  72859. * Gets the animatable associated with a specific target
  72860. * @param target defines the target of the animatable
  72861. * @returns the required animatable if found
  72862. */
  72863. getAnimatableByTarget(target: any): Nullable<Animatable>;
  72864. /**
  72865. * Gets all animatables associated with a given target
  72866. * @param target defines the target to look animatables for
  72867. * @returns an array of Animatables
  72868. */
  72869. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  72870. /**
  72871. * Stops and removes all animations that have been applied to the scene
  72872. */
  72873. stopAllAnimations(): void;
  72874. }
  72875. interface Bone {
  72876. /**
  72877. * Copy an animation range from another bone
  72878. * @param source defines the source bone
  72879. * @param rangeName defines the range name to copy
  72880. * @param frameOffset defines the frame offset
  72881. * @param rescaleAsRequired defines if rescaling must be applied if required
  72882. * @param skelDimensionsRatio defines the scaling ratio
  72883. * @returns true if operation was successful
  72884. */
  72885. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  72886. }
  72887. }
  72888. declare module BABYLON {
  72889. /**
  72890. * Class used to handle skinning animations
  72891. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  72892. */
  72893. export class Skeleton implements IAnimatable {
  72894. /** defines the skeleton name */
  72895. name: string;
  72896. /** defines the skeleton Id */
  72897. id: string;
  72898. /**
  72899. * Defines the list of child bones
  72900. */
  72901. bones: Bone[];
  72902. /**
  72903. * Defines an estimate of the dimension of the skeleton at rest
  72904. */
  72905. dimensionsAtRest: Vector3;
  72906. /**
  72907. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  72908. */
  72909. needInitialSkinMatrix: boolean;
  72910. /**
  72911. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  72912. */
  72913. overrideMesh: Nullable<AbstractMesh>;
  72914. /**
  72915. * Gets the list of animations attached to this skeleton
  72916. */
  72917. animations: Array<Animation>;
  72918. private _scene;
  72919. private _isDirty;
  72920. private _transformMatrices;
  72921. private _transformMatrixTexture;
  72922. private _meshesWithPoseMatrix;
  72923. private _animatables;
  72924. private _identity;
  72925. private _synchronizedWithMesh;
  72926. private _ranges;
  72927. private _lastAbsoluteTransformsUpdateId;
  72928. private _canUseTextureForBones;
  72929. private _uniqueId;
  72930. /** @hidden */
  72931. _numBonesWithLinkedTransformNode: number;
  72932. /** @hidden */
  72933. _hasWaitingData: Nullable<boolean>;
  72934. /**
  72935. * Specifies if the skeleton should be serialized
  72936. */
  72937. doNotSerialize: boolean;
  72938. private _useTextureToStoreBoneMatrices;
  72939. /**
  72940. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  72941. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  72942. */
  72943. useTextureToStoreBoneMatrices: boolean;
  72944. private _animationPropertiesOverride;
  72945. /**
  72946. * Gets or sets the animation properties override
  72947. */
  72948. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  72949. /**
  72950. * List of inspectable custom properties (used by the Inspector)
  72951. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  72952. */
  72953. inspectableCustomProperties: IInspectable[];
  72954. /**
  72955. * An observable triggered before computing the skeleton's matrices
  72956. */
  72957. onBeforeComputeObservable: Observable<Skeleton>;
  72958. /**
  72959. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  72960. */
  72961. readonly isUsingTextureForMatrices: boolean;
  72962. /**
  72963. * Gets the unique ID of this skeleton
  72964. */
  72965. readonly uniqueId: number;
  72966. /**
  72967. * Creates a new skeleton
  72968. * @param name defines the skeleton name
  72969. * @param id defines the skeleton Id
  72970. * @param scene defines the hosting scene
  72971. */
  72972. constructor(
  72973. /** defines the skeleton name */
  72974. name: string,
  72975. /** defines the skeleton Id */
  72976. id: string, scene: Scene);
  72977. /**
  72978. * Gets the current object class name.
  72979. * @return the class name
  72980. */
  72981. getClassName(): string;
  72982. /**
  72983. * Returns an array containing the root bones
  72984. * @returns an array containing the root bones
  72985. */
  72986. getChildren(): Array<Bone>;
  72987. /**
  72988. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  72989. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  72990. * @returns a Float32Array containing matrices data
  72991. */
  72992. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  72993. /**
  72994. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  72995. * @returns a raw texture containing the data
  72996. */
  72997. getTransformMatrixTexture(): Nullable<RawTexture>;
  72998. /**
  72999. * Gets the current hosting scene
  73000. * @returns a scene object
  73001. */
  73002. getScene(): Scene;
  73003. /**
  73004. * Gets a string representing the current skeleton data
  73005. * @param fullDetails defines a boolean indicating if we want a verbose version
  73006. * @returns a string representing the current skeleton data
  73007. */
  73008. toString(fullDetails?: boolean): string;
  73009. /**
  73010. * Get bone's index searching by name
  73011. * @param name defines bone's name to search for
  73012. * @return the indice of the bone. Returns -1 if not found
  73013. */
  73014. getBoneIndexByName(name: string): number;
  73015. /**
  73016. * Creater a new animation range
  73017. * @param name defines the name of the range
  73018. * @param from defines the start key
  73019. * @param to defines the end key
  73020. */
  73021. createAnimationRange(name: string, from: number, to: number): void;
  73022. /**
  73023. * Delete a specific animation range
  73024. * @param name defines the name of the range
  73025. * @param deleteFrames defines if frames must be removed as well
  73026. */
  73027. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  73028. /**
  73029. * Gets a specific animation range
  73030. * @param name defines the name of the range to look for
  73031. * @returns the requested animation range or null if not found
  73032. */
  73033. getAnimationRange(name: string): Nullable<AnimationRange>;
  73034. /**
  73035. * Gets the list of all animation ranges defined on this skeleton
  73036. * @returns an array
  73037. */
  73038. getAnimationRanges(): Nullable<AnimationRange>[];
  73039. /**
  73040. * Copy animation range from a source skeleton.
  73041. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  73042. * @param source defines the source skeleton
  73043. * @param name defines the name of the range to copy
  73044. * @param rescaleAsRequired defines if rescaling must be applied if required
  73045. * @returns true if operation was successful
  73046. */
  73047. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  73048. /**
  73049. * Forces the skeleton to go to rest pose
  73050. */
  73051. returnToRest(): void;
  73052. private _getHighestAnimationFrame;
  73053. /**
  73054. * Begin a specific animation range
  73055. * @param name defines the name of the range to start
  73056. * @param loop defines if looping must be turned on (false by default)
  73057. * @param speedRatio defines the speed ratio to apply (1 by default)
  73058. * @param onAnimationEnd defines a callback which will be called when animation will end
  73059. * @returns a new animatable
  73060. */
  73061. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  73062. /** @hidden */
  73063. _markAsDirty(): void;
  73064. /** @hidden */
  73065. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  73066. /** @hidden */
  73067. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  73068. private _computeTransformMatrices;
  73069. /**
  73070. * Build all resources required to render a skeleton
  73071. */
  73072. prepare(): void;
  73073. /**
  73074. * Gets the list of animatables currently running for this skeleton
  73075. * @returns an array of animatables
  73076. */
  73077. getAnimatables(): IAnimatable[];
  73078. /**
  73079. * Clone the current skeleton
  73080. * @param name defines the name of the new skeleton
  73081. * @param id defines the id of the new skeleton
  73082. * @returns the new skeleton
  73083. */
  73084. clone(name: string, id: string): Skeleton;
  73085. /**
  73086. * Enable animation blending for this skeleton
  73087. * @param blendingSpeed defines the blending speed to apply
  73088. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  73089. */
  73090. enableBlending(blendingSpeed?: number): void;
  73091. /**
  73092. * Releases all resources associated with the current skeleton
  73093. */
  73094. dispose(): void;
  73095. /**
  73096. * Serialize the skeleton in a JSON object
  73097. * @returns a JSON object
  73098. */
  73099. serialize(): any;
  73100. /**
  73101. * Creates a new skeleton from serialized data
  73102. * @param parsedSkeleton defines the serialized data
  73103. * @param scene defines the hosting scene
  73104. * @returns a new skeleton
  73105. */
  73106. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  73107. /**
  73108. * Compute all node absolute transforms
  73109. * @param forceUpdate defines if computation must be done even if cache is up to date
  73110. */
  73111. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  73112. /**
  73113. * Gets the root pose matrix
  73114. * @returns a matrix
  73115. */
  73116. getPoseMatrix(): Nullable<Matrix>;
  73117. /**
  73118. * Sorts bones per internal index
  73119. */
  73120. sortBones(): void;
  73121. private _sortBones;
  73122. }
  73123. }
  73124. declare module BABYLON {
  73125. /**
  73126. * Defines a target to use with MorphTargetManager
  73127. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  73128. */
  73129. export class MorphTarget implements IAnimatable {
  73130. /** defines the name of the target */
  73131. name: string;
  73132. /**
  73133. * Gets or sets the list of animations
  73134. */
  73135. animations: Animation[];
  73136. private _scene;
  73137. private _positions;
  73138. private _normals;
  73139. private _tangents;
  73140. private _uvs;
  73141. private _influence;
  73142. /**
  73143. * Observable raised when the influence changes
  73144. */
  73145. onInfluenceChanged: Observable<boolean>;
  73146. /** @hidden */
  73147. _onDataLayoutChanged: Observable<void>;
  73148. /**
  73149. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  73150. */
  73151. influence: number;
  73152. /**
  73153. * Gets or sets the id of the morph Target
  73154. */
  73155. id: string;
  73156. private _animationPropertiesOverride;
  73157. /**
  73158. * Gets or sets the animation properties override
  73159. */
  73160. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  73161. /**
  73162. * Creates a new MorphTarget
  73163. * @param name defines the name of the target
  73164. * @param influence defines the influence to use
  73165. * @param scene defines the scene the morphtarget belongs to
  73166. */
  73167. constructor(
  73168. /** defines the name of the target */
  73169. name: string, influence?: number, scene?: Nullable<Scene>);
  73170. /**
  73171. * Gets a boolean defining if the target contains position data
  73172. */
  73173. readonly hasPositions: boolean;
  73174. /**
  73175. * Gets a boolean defining if the target contains normal data
  73176. */
  73177. readonly hasNormals: boolean;
  73178. /**
  73179. * Gets a boolean defining if the target contains tangent data
  73180. */
  73181. readonly hasTangents: boolean;
  73182. /**
  73183. * Gets a boolean defining if the target contains texture coordinates data
  73184. */
  73185. readonly hasUVs: boolean;
  73186. /**
  73187. * Affects position data to this target
  73188. * @param data defines the position data to use
  73189. */
  73190. setPositions(data: Nullable<FloatArray>): void;
  73191. /**
  73192. * Gets the position data stored in this target
  73193. * @returns a FloatArray containing the position data (or null if not present)
  73194. */
  73195. getPositions(): Nullable<FloatArray>;
  73196. /**
  73197. * Affects normal data to this target
  73198. * @param data defines the normal data to use
  73199. */
  73200. setNormals(data: Nullable<FloatArray>): void;
  73201. /**
  73202. * Gets the normal data stored in this target
  73203. * @returns a FloatArray containing the normal data (or null if not present)
  73204. */
  73205. getNormals(): Nullable<FloatArray>;
  73206. /**
  73207. * Affects tangent data to this target
  73208. * @param data defines the tangent data to use
  73209. */
  73210. setTangents(data: Nullable<FloatArray>): void;
  73211. /**
  73212. * Gets the tangent data stored in this target
  73213. * @returns a FloatArray containing the tangent data (or null if not present)
  73214. */
  73215. getTangents(): Nullable<FloatArray>;
  73216. /**
  73217. * Affects texture coordinates data to this target
  73218. * @param data defines the texture coordinates data to use
  73219. */
  73220. setUVs(data: Nullable<FloatArray>): void;
  73221. /**
  73222. * Gets the texture coordinates data stored in this target
  73223. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  73224. */
  73225. getUVs(): Nullable<FloatArray>;
  73226. /**
  73227. * Serializes the current target into a Serialization object
  73228. * @returns the serialized object
  73229. */
  73230. serialize(): any;
  73231. /**
  73232. * Returns the string "MorphTarget"
  73233. * @returns "MorphTarget"
  73234. */
  73235. getClassName(): string;
  73236. /**
  73237. * Creates a new target from serialized data
  73238. * @param serializationObject defines the serialized data to use
  73239. * @returns a new MorphTarget
  73240. */
  73241. static Parse(serializationObject: any): MorphTarget;
  73242. /**
  73243. * Creates a MorphTarget from mesh data
  73244. * @param mesh defines the source mesh
  73245. * @param name defines the name to use for the new target
  73246. * @param influence defines the influence to attach to the target
  73247. * @returns a new MorphTarget
  73248. */
  73249. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  73250. }
  73251. }
  73252. declare module BABYLON {
  73253. /**
  73254. * This class is used to deform meshes using morphing between different targets
  73255. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  73256. */
  73257. export class MorphTargetManager {
  73258. private _targets;
  73259. private _targetInfluenceChangedObservers;
  73260. private _targetDataLayoutChangedObservers;
  73261. private _activeTargets;
  73262. private _scene;
  73263. private _influences;
  73264. private _supportsNormals;
  73265. private _supportsTangents;
  73266. private _supportsUVs;
  73267. private _vertexCount;
  73268. private _uniqueId;
  73269. private _tempInfluences;
  73270. /**
  73271. * Creates a new MorphTargetManager
  73272. * @param scene defines the current scene
  73273. */
  73274. constructor(scene?: Nullable<Scene>);
  73275. /**
  73276. * Gets the unique ID of this manager
  73277. */
  73278. readonly uniqueId: number;
  73279. /**
  73280. * Gets the number of vertices handled by this manager
  73281. */
  73282. readonly vertexCount: number;
  73283. /**
  73284. * Gets a boolean indicating if this manager supports morphing of normals
  73285. */
  73286. readonly supportsNormals: boolean;
  73287. /**
  73288. * Gets a boolean indicating if this manager supports morphing of tangents
  73289. */
  73290. readonly supportsTangents: boolean;
  73291. /**
  73292. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  73293. */
  73294. readonly supportsUVs: boolean;
  73295. /**
  73296. * Gets the number of targets stored in this manager
  73297. */
  73298. readonly numTargets: number;
  73299. /**
  73300. * Gets the number of influencers (ie. the number of targets with influences > 0)
  73301. */
  73302. readonly numInfluencers: number;
  73303. /**
  73304. * Gets the list of influences (one per target)
  73305. */
  73306. readonly influences: Float32Array;
  73307. /**
  73308. * Gets the active target at specified index. An active target is a target with an influence > 0
  73309. * @param index defines the index to check
  73310. * @returns the requested target
  73311. */
  73312. getActiveTarget(index: number): MorphTarget;
  73313. /**
  73314. * Gets the target at specified index
  73315. * @param index defines the index to check
  73316. * @returns the requested target
  73317. */
  73318. getTarget(index: number): MorphTarget;
  73319. /**
  73320. * Add a new target to this manager
  73321. * @param target defines the target to add
  73322. */
  73323. addTarget(target: MorphTarget): void;
  73324. /**
  73325. * Removes a target from the manager
  73326. * @param target defines the target to remove
  73327. */
  73328. removeTarget(target: MorphTarget): void;
  73329. /**
  73330. * Serializes the current manager into a Serialization object
  73331. * @returns the serialized object
  73332. */
  73333. serialize(): any;
  73334. private _syncActiveTargets;
  73335. /**
  73336. * Syncrhonize the targets with all the meshes using this morph target manager
  73337. */
  73338. synchronize(): void;
  73339. /**
  73340. * Creates a new MorphTargetManager from serialized data
  73341. * @param serializationObject defines the serialized data
  73342. * @param scene defines the hosting scene
  73343. * @returns the new MorphTargetManager
  73344. */
  73345. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  73346. }
  73347. }
  73348. declare module BABYLON {
  73349. /**
  73350. * Groups all the scene component constants in one place to ease maintenance.
  73351. * @hidden
  73352. */
  73353. export class SceneComponentConstants {
  73354. static readonly NAME_EFFECTLAYER: string;
  73355. static readonly NAME_LAYER: string;
  73356. static readonly NAME_LENSFLARESYSTEM: string;
  73357. static readonly NAME_BOUNDINGBOXRENDERER: string;
  73358. static readonly NAME_PARTICLESYSTEM: string;
  73359. static readonly NAME_GAMEPAD: string;
  73360. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  73361. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  73362. static readonly NAME_DEPTHRENDERER: string;
  73363. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  73364. static readonly NAME_SPRITE: string;
  73365. static readonly NAME_OUTLINERENDERER: string;
  73366. static readonly NAME_PROCEDURALTEXTURE: string;
  73367. static readonly NAME_SHADOWGENERATOR: string;
  73368. static readonly NAME_OCTREE: string;
  73369. static readonly NAME_PHYSICSENGINE: string;
  73370. static readonly NAME_AUDIO: string;
  73371. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  73372. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  73373. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  73374. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  73375. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  73376. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  73377. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  73378. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  73379. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  73380. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  73381. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  73382. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  73383. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  73384. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  73385. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  73386. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  73387. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  73388. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  73389. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  73390. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  73391. static readonly STEP_AFTERRENDER_AUDIO: number;
  73392. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  73393. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  73394. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  73395. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  73396. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  73397. static readonly STEP_POINTERMOVE_SPRITE: number;
  73398. static readonly STEP_POINTERDOWN_SPRITE: number;
  73399. static readonly STEP_POINTERUP_SPRITE: number;
  73400. }
  73401. /**
  73402. * This represents a scene component.
  73403. *
  73404. * This is used to decouple the dependency the scene is having on the different workloads like
  73405. * layers, post processes...
  73406. */
  73407. export interface ISceneComponent {
  73408. /**
  73409. * The name of the component. Each component must have a unique name.
  73410. */
  73411. name: string;
  73412. /**
  73413. * The scene the component belongs to.
  73414. */
  73415. scene: Scene;
  73416. /**
  73417. * Register the component to one instance of a scene.
  73418. */
  73419. register(): void;
  73420. /**
  73421. * Rebuilds the elements related to this component in case of
  73422. * context lost for instance.
  73423. */
  73424. rebuild(): void;
  73425. /**
  73426. * Disposes the component and the associated ressources.
  73427. */
  73428. dispose(): void;
  73429. }
  73430. /**
  73431. * This represents a SERIALIZABLE scene component.
  73432. *
  73433. * This extends Scene Component to add Serialization methods on top.
  73434. */
  73435. export interface ISceneSerializableComponent extends ISceneComponent {
  73436. /**
  73437. * Adds all the elements from the container to the scene
  73438. * @param container the container holding the elements
  73439. */
  73440. addFromContainer(container: AbstractScene): void;
  73441. /**
  73442. * Removes all the elements in the container from the scene
  73443. * @param container contains the elements to remove
  73444. * @param dispose if the removed element should be disposed (default: false)
  73445. */
  73446. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  73447. /**
  73448. * Serializes the component data to the specified json object
  73449. * @param serializationObject The object to serialize to
  73450. */
  73451. serialize(serializationObject: any): void;
  73452. }
  73453. /**
  73454. * Strong typing of a Mesh related stage step action
  73455. */
  73456. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  73457. /**
  73458. * Strong typing of a Evaluate Sub Mesh related stage step action
  73459. */
  73460. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  73461. /**
  73462. * Strong typing of a Active Mesh related stage step action
  73463. */
  73464. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  73465. /**
  73466. * Strong typing of a Camera related stage step action
  73467. */
  73468. export type CameraStageAction = (camera: Camera) => void;
  73469. /**
  73470. * Strong typing of a Camera Frame buffer related stage step action
  73471. */
  73472. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  73473. /**
  73474. * Strong typing of a Render Target related stage step action
  73475. */
  73476. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  73477. /**
  73478. * Strong typing of a RenderingGroup related stage step action
  73479. */
  73480. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  73481. /**
  73482. * Strong typing of a Mesh Render related stage step action
  73483. */
  73484. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  73485. /**
  73486. * Strong typing of a simple stage step action
  73487. */
  73488. export type SimpleStageAction = () => void;
  73489. /**
  73490. * Strong typing of a render target action.
  73491. */
  73492. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  73493. /**
  73494. * Strong typing of a pointer move action.
  73495. */
  73496. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  73497. /**
  73498. * Strong typing of a pointer up/down action.
  73499. */
  73500. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  73501. /**
  73502. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  73503. * @hidden
  73504. */
  73505. export class Stage<T extends Function> extends Array<{
  73506. index: number;
  73507. component: ISceneComponent;
  73508. action: T;
  73509. }> {
  73510. /**
  73511. * Hide ctor from the rest of the world.
  73512. * @param items The items to add.
  73513. */
  73514. private constructor();
  73515. /**
  73516. * Creates a new Stage.
  73517. * @returns A new instance of a Stage
  73518. */
  73519. static Create<T extends Function>(): Stage<T>;
  73520. /**
  73521. * Registers a step in an ordered way in the targeted stage.
  73522. * @param index Defines the position to register the step in
  73523. * @param component Defines the component attached to the step
  73524. * @param action Defines the action to launch during the step
  73525. */
  73526. registerStep(index: number, component: ISceneComponent, action: T): void;
  73527. /**
  73528. * Clears all the steps from the stage.
  73529. */
  73530. clear(): void;
  73531. }
  73532. }
  73533. declare module BABYLON {
  73534. /**
  73535. * Class used to represent a specific level of detail of a mesh
  73536. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  73537. */
  73538. export class MeshLODLevel {
  73539. /** Defines the distance where this level should star being displayed */
  73540. distance: number;
  73541. /** Defines the mesh to use to render this level */
  73542. mesh: Nullable<Mesh>;
  73543. /**
  73544. * Creates a new LOD level
  73545. * @param distance defines the distance where this level should star being displayed
  73546. * @param mesh defines the mesh to use to render this level
  73547. */
  73548. constructor(
  73549. /** Defines the distance where this level should star being displayed */
  73550. distance: number,
  73551. /** Defines the mesh to use to render this level */
  73552. mesh: Nullable<Mesh>);
  73553. }
  73554. }
  73555. declare module BABYLON {
  73556. /**
  73557. * Interface describing all the common properties and methods a shadow light needs to implement.
  73558. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  73559. * as well as binding the different shadow properties to the effects.
  73560. */
  73561. export interface IShadowLight extends Light {
  73562. /**
  73563. * The light id in the scene (used in scene.findLighById for instance)
  73564. */
  73565. id: string;
  73566. /**
  73567. * The position the shdow will be casted from.
  73568. */
  73569. position: Vector3;
  73570. /**
  73571. * In 2d mode (needCube being false), the direction used to cast the shadow.
  73572. */
  73573. direction: Vector3;
  73574. /**
  73575. * The transformed position. Position of the light in world space taking parenting in account.
  73576. */
  73577. transformedPosition: Vector3;
  73578. /**
  73579. * The transformed direction. Direction of the light in world space taking parenting in account.
  73580. */
  73581. transformedDirection: Vector3;
  73582. /**
  73583. * The friendly name of the light in the scene.
  73584. */
  73585. name: string;
  73586. /**
  73587. * Defines the shadow projection clipping minimum z value.
  73588. */
  73589. shadowMinZ: number;
  73590. /**
  73591. * Defines the shadow projection clipping maximum z value.
  73592. */
  73593. shadowMaxZ: number;
  73594. /**
  73595. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  73596. * @returns true if the information has been computed, false if it does not need to (no parenting)
  73597. */
  73598. computeTransformedInformation(): boolean;
  73599. /**
  73600. * Gets the scene the light belongs to.
  73601. * @returns The scene
  73602. */
  73603. getScene(): Scene;
  73604. /**
  73605. * Callback defining a custom Projection Matrix Builder.
  73606. * This can be used to override the default projection matrix computation.
  73607. */
  73608. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  73609. /**
  73610. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  73611. * @param matrix The materix to updated with the projection information
  73612. * @param viewMatrix The transform matrix of the light
  73613. * @param renderList The list of mesh to render in the map
  73614. * @returns The current light
  73615. */
  73616. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  73617. /**
  73618. * Gets the current depth scale used in ESM.
  73619. * @returns The scale
  73620. */
  73621. getDepthScale(): number;
  73622. /**
  73623. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  73624. * @returns true if a cube texture needs to be use
  73625. */
  73626. needCube(): boolean;
  73627. /**
  73628. * Detects if the projection matrix requires to be recomputed this frame.
  73629. * @returns true if it requires to be recomputed otherwise, false.
  73630. */
  73631. needProjectionMatrixCompute(): boolean;
  73632. /**
  73633. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  73634. */
  73635. forceProjectionMatrixCompute(): void;
  73636. /**
  73637. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  73638. * @param faceIndex The index of the face we are computed the direction to generate shadow
  73639. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  73640. */
  73641. getShadowDirection(faceIndex?: number): Vector3;
  73642. /**
  73643. * Gets the minZ used for shadow according to both the scene and the light.
  73644. * @param activeCamera The camera we are returning the min for
  73645. * @returns the depth min z
  73646. */
  73647. getDepthMinZ(activeCamera: Camera): number;
  73648. /**
  73649. * Gets the maxZ used for shadow according to both the scene and the light.
  73650. * @param activeCamera The camera we are returning the max for
  73651. * @returns the depth max z
  73652. */
  73653. getDepthMaxZ(activeCamera: Camera): number;
  73654. }
  73655. /**
  73656. * Base implementation IShadowLight
  73657. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  73658. */
  73659. export abstract class ShadowLight extends Light implements IShadowLight {
  73660. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  73661. protected _position: Vector3;
  73662. protected _setPosition(value: Vector3): void;
  73663. /**
  73664. * Sets the position the shadow will be casted from. Also use as the light position for both
  73665. * point and spot lights.
  73666. */
  73667. /**
  73668. * Sets the position the shadow will be casted from. Also use as the light position for both
  73669. * point and spot lights.
  73670. */
  73671. position: Vector3;
  73672. protected _direction: Vector3;
  73673. protected _setDirection(value: Vector3): void;
  73674. /**
  73675. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  73676. * Also use as the light direction on spot and directional lights.
  73677. */
  73678. /**
  73679. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  73680. * Also use as the light direction on spot and directional lights.
  73681. */
  73682. direction: Vector3;
  73683. private _shadowMinZ;
  73684. /**
  73685. * Gets the shadow projection clipping minimum z value.
  73686. */
  73687. /**
  73688. * Sets the shadow projection clipping minimum z value.
  73689. */
  73690. shadowMinZ: number;
  73691. private _shadowMaxZ;
  73692. /**
  73693. * Sets the shadow projection clipping maximum z value.
  73694. */
  73695. /**
  73696. * Gets the shadow projection clipping maximum z value.
  73697. */
  73698. shadowMaxZ: number;
  73699. /**
  73700. * Callback defining a custom Projection Matrix Builder.
  73701. * This can be used to override the default projection matrix computation.
  73702. */
  73703. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  73704. /**
  73705. * The transformed position. Position of the light in world space taking parenting in account.
  73706. */
  73707. transformedPosition: Vector3;
  73708. /**
  73709. * The transformed direction. Direction of the light in world space taking parenting in account.
  73710. */
  73711. transformedDirection: Vector3;
  73712. private _needProjectionMatrixCompute;
  73713. /**
  73714. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  73715. * @returns true if the information has been computed, false if it does not need to (no parenting)
  73716. */
  73717. computeTransformedInformation(): boolean;
  73718. /**
  73719. * Return the depth scale used for the shadow map.
  73720. * @returns the depth scale.
  73721. */
  73722. getDepthScale(): number;
  73723. /**
  73724. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  73725. * @param faceIndex The index of the face we are computed the direction to generate shadow
  73726. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  73727. */
  73728. getShadowDirection(faceIndex?: number): Vector3;
  73729. /**
  73730. * Returns the ShadowLight absolute position in the World.
  73731. * @returns the position vector in world space
  73732. */
  73733. getAbsolutePosition(): Vector3;
  73734. /**
  73735. * Sets the ShadowLight direction toward the passed target.
  73736. * @param target The point to target in local space
  73737. * @returns the updated ShadowLight direction
  73738. */
  73739. setDirectionToTarget(target: Vector3): Vector3;
  73740. /**
  73741. * Returns the light rotation in euler definition.
  73742. * @returns the x y z rotation in local space.
  73743. */
  73744. getRotation(): Vector3;
  73745. /**
  73746. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  73747. * @returns true if a cube texture needs to be use
  73748. */
  73749. needCube(): boolean;
  73750. /**
  73751. * Detects if the projection matrix requires to be recomputed this frame.
  73752. * @returns true if it requires to be recomputed otherwise, false.
  73753. */
  73754. needProjectionMatrixCompute(): boolean;
  73755. /**
  73756. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  73757. */
  73758. forceProjectionMatrixCompute(): void;
  73759. /** @hidden */
  73760. _initCache(): void;
  73761. /** @hidden */
  73762. _isSynchronized(): boolean;
  73763. /**
  73764. * Computes the world matrix of the node
  73765. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  73766. * @returns the world matrix
  73767. */
  73768. computeWorldMatrix(force?: boolean): Matrix;
  73769. /**
  73770. * Gets the minZ used for shadow according to both the scene and the light.
  73771. * @param activeCamera The camera we are returning the min for
  73772. * @returns the depth min z
  73773. */
  73774. getDepthMinZ(activeCamera: Camera): number;
  73775. /**
  73776. * Gets the maxZ used for shadow according to both the scene and the light.
  73777. * @param activeCamera The camera we are returning the max for
  73778. * @returns the depth max z
  73779. */
  73780. getDepthMaxZ(activeCamera: Camera): number;
  73781. /**
  73782. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  73783. * @param matrix The materix to updated with the projection information
  73784. * @param viewMatrix The transform matrix of the light
  73785. * @param renderList The list of mesh to render in the map
  73786. * @returns The current light
  73787. */
  73788. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  73789. }
  73790. }
  73791. declare module BABYLON {
  73792. /**
  73793. * "Static Class" containing the most commonly used helper while dealing with material for
  73794. * rendering purpose.
  73795. *
  73796. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  73797. *
  73798. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  73799. */
  73800. export class MaterialHelper {
  73801. /**
  73802. * Bind the current view position to an effect.
  73803. * @param effect The effect to be bound
  73804. * @param scene The scene the eyes position is used from
  73805. */
  73806. static BindEyePosition(effect: Effect, scene: Scene): void;
  73807. /**
  73808. * Helps preparing the defines values about the UVs in used in the effect.
  73809. * UVs are shared as much as we can accross channels in the shaders.
  73810. * @param texture The texture we are preparing the UVs for
  73811. * @param defines The defines to update
  73812. * @param key The channel key "diffuse", "specular"... used in the shader
  73813. */
  73814. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  73815. /**
  73816. * Binds a texture matrix value to its corrsponding uniform
  73817. * @param texture The texture to bind the matrix for
  73818. * @param uniformBuffer The uniform buffer receivin the data
  73819. * @param key The channel key "diffuse", "specular"... used in the shader
  73820. */
  73821. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  73822. /**
  73823. * Gets the current status of the fog (should it be enabled?)
  73824. * @param mesh defines the mesh to evaluate for fog support
  73825. * @param scene defines the hosting scene
  73826. * @returns true if fog must be enabled
  73827. */
  73828. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  73829. /**
  73830. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  73831. * @param mesh defines the current mesh
  73832. * @param scene defines the current scene
  73833. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  73834. * @param pointsCloud defines if point cloud rendering has to be turned on
  73835. * @param fogEnabled defines if fog has to be turned on
  73836. * @param alphaTest defines if alpha testing has to be turned on
  73837. * @param defines defines the current list of defines
  73838. */
  73839. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  73840. /**
  73841. * Helper used to prepare the list of defines associated with frame values for shader compilation
  73842. * @param scene defines the current scene
  73843. * @param engine defines the current engine
  73844. * @param defines specifies the list of active defines
  73845. * @param useInstances defines if instances have to be turned on
  73846. * @param useClipPlane defines if clip plane have to be turned on
  73847. */
  73848. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  73849. /**
  73850. * Prepares the defines for bones
  73851. * @param mesh The mesh containing the geometry data we will draw
  73852. * @param defines The defines to update
  73853. */
  73854. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  73855. /**
  73856. * Prepares the defines for morph targets
  73857. * @param mesh The mesh containing the geometry data we will draw
  73858. * @param defines The defines to update
  73859. */
  73860. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  73861. /**
  73862. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  73863. * @param mesh The mesh containing the geometry data we will draw
  73864. * @param defines The defines to update
  73865. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  73866. * @param useBones Precise whether bones should be used or not (override mesh info)
  73867. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  73868. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  73869. * @returns false if defines are considered not dirty and have not been checked
  73870. */
  73871. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  73872. /**
  73873. * Prepares the defines related to multiview
  73874. * @param scene The scene we are intending to draw
  73875. * @param defines The defines to update
  73876. */
  73877. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  73878. /**
  73879. * Prepares the defines related to the light information passed in parameter
  73880. * @param scene The scene we are intending to draw
  73881. * @param mesh The mesh the effect is compiling for
  73882. * @param light The light the effect is compiling for
  73883. * @param lightIndex The index of the light
  73884. * @param defines The defines to update
  73885. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  73886. * @param state Defines the current state regarding what is needed (normals, etc...)
  73887. */
  73888. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  73889. needNormals: boolean;
  73890. needRebuild: boolean;
  73891. shadowEnabled: boolean;
  73892. specularEnabled: boolean;
  73893. lightmapMode: boolean;
  73894. }): void;
  73895. /**
  73896. * Prepares the defines related to the light information passed in parameter
  73897. * @param scene The scene we are intending to draw
  73898. * @param mesh The mesh the effect is compiling for
  73899. * @param defines The defines to update
  73900. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  73901. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  73902. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  73903. * @returns true if normals will be required for the rest of the effect
  73904. */
  73905. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  73906. /**
  73907. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  73908. * @param lightIndex defines the light index
  73909. * @param uniformsList The uniform list
  73910. * @param samplersList The sampler list
  73911. * @param projectedLightTexture defines if projected texture must be used
  73912. * @param uniformBuffersList defines an optional list of uniform buffers
  73913. */
  73914. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  73915. /**
  73916. * Prepares the uniforms and samplers list to be used in the effect
  73917. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  73918. * @param samplersList The sampler list
  73919. * @param defines The defines helping in the list generation
  73920. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  73921. */
  73922. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  73923. /**
  73924. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  73925. * @param defines The defines to update while falling back
  73926. * @param fallbacks The authorized effect fallbacks
  73927. * @param maxSimultaneousLights The maximum number of lights allowed
  73928. * @param rank the current rank of the Effect
  73929. * @returns The newly affected rank
  73930. */
  73931. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  73932. private static _TmpMorphInfluencers;
  73933. /**
  73934. * Prepares the list of attributes required for morph targets according to the effect defines.
  73935. * @param attribs The current list of supported attribs
  73936. * @param mesh The mesh to prepare the morph targets attributes for
  73937. * @param influencers The number of influencers
  73938. */
  73939. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  73940. /**
  73941. * Prepares the list of attributes required for morph targets according to the effect defines.
  73942. * @param attribs The current list of supported attribs
  73943. * @param mesh The mesh to prepare the morph targets attributes for
  73944. * @param defines The current Defines of the effect
  73945. */
  73946. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  73947. /**
  73948. * Prepares the list of attributes required for bones according to the effect defines.
  73949. * @param attribs The current list of supported attribs
  73950. * @param mesh The mesh to prepare the bones attributes for
  73951. * @param defines The current Defines of the effect
  73952. * @param fallbacks The current efffect fallback strategy
  73953. */
  73954. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  73955. /**
  73956. * Check and prepare the list of attributes required for instances according to the effect defines.
  73957. * @param attribs The current list of supported attribs
  73958. * @param defines The current MaterialDefines of the effect
  73959. */
  73960. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  73961. /**
  73962. * Add the list of attributes required for instances to the attribs array.
  73963. * @param attribs The current list of supported attribs
  73964. */
  73965. static PushAttributesForInstances(attribs: string[]): void;
  73966. /**
  73967. * Binds the light shadow information to the effect for the given mesh.
  73968. * @param light The light containing the generator
  73969. * @param scene The scene the lights belongs to
  73970. * @param mesh The mesh we are binding the information to render
  73971. * @param lightIndex The light index in the effect used to render the mesh
  73972. * @param effect The effect we are binding the data to
  73973. */
  73974. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  73975. /**
  73976. * Binds the light information to the effect.
  73977. * @param light The light containing the generator
  73978. * @param effect The effect we are binding the data to
  73979. * @param lightIndex The light index in the effect used to render
  73980. */
  73981. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  73982. /**
  73983. * Binds the lights information from the scene to the effect for the given mesh.
  73984. * @param light Light to bind
  73985. * @param lightIndex Light index
  73986. * @param scene The scene where the light belongs to
  73987. * @param mesh The mesh we are binding the information to render
  73988. * @param effect The effect we are binding the data to
  73989. * @param useSpecular Defines if specular is supported
  73990. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  73991. */
  73992. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean): void;
  73993. /**
  73994. * Binds the lights information from the scene to the effect for the given mesh.
  73995. * @param scene The scene the lights belongs to
  73996. * @param mesh The mesh we are binding the information to render
  73997. * @param effect The effect we are binding the data to
  73998. * @param defines The generated defines for the effect
  73999. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  74000. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  74001. */
  74002. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  74003. private static _tempFogColor;
  74004. /**
  74005. * Binds the fog information from the scene to the effect for the given mesh.
  74006. * @param scene The scene the lights belongs to
  74007. * @param mesh The mesh we are binding the information to render
  74008. * @param effect The effect we are binding the data to
  74009. * @param linearSpace Defines if the fog effect is applied in linear space
  74010. */
  74011. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  74012. /**
  74013. * Binds the bones information from the mesh to the effect.
  74014. * @param mesh The mesh we are binding the information to render
  74015. * @param effect The effect we are binding the data to
  74016. */
  74017. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  74018. /**
  74019. * Binds the morph targets information from the mesh to the effect.
  74020. * @param abstractMesh The mesh we are binding the information to render
  74021. * @param effect The effect we are binding the data to
  74022. */
  74023. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  74024. /**
  74025. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  74026. * @param defines The generated defines used in the effect
  74027. * @param effect The effect we are binding the data to
  74028. * @param scene The scene we are willing to render with logarithmic scale for
  74029. */
  74030. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  74031. /**
  74032. * Binds the clip plane information from the scene to the effect.
  74033. * @param scene The scene the clip plane information are extracted from
  74034. * @param effect The effect we are binding the data to
  74035. */
  74036. static BindClipPlane(effect: Effect, scene: Scene): void;
  74037. }
  74038. }
  74039. declare module BABYLON {
  74040. /** @hidden */
  74041. export var shadowMapPixelShader: {
  74042. name: string;
  74043. shader: string;
  74044. };
  74045. }
  74046. declare module BABYLON {
  74047. /** @hidden */
  74048. export var bonesDeclaration: {
  74049. name: string;
  74050. shader: string;
  74051. };
  74052. }
  74053. declare module BABYLON {
  74054. /** @hidden */
  74055. export var morphTargetsVertexGlobalDeclaration: {
  74056. name: string;
  74057. shader: string;
  74058. };
  74059. }
  74060. declare module BABYLON {
  74061. /** @hidden */
  74062. export var morphTargetsVertexDeclaration: {
  74063. name: string;
  74064. shader: string;
  74065. };
  74066. }
  74067. declare module BABYLON {
  74068. /** @hidden */
  74069. export var instancesDeclaration: {
  74070. name: string;
  74071. shader: string;
  74072. };
  74073. }
  74074. declare module BABYLON {
  74075. /** @hidden */
  74076. export var helperFunctions: {
  74077. name: string;
  74078. shader: string;
  74079. };
  74080. }
  74081. declare module BABYLON {
  74082. /** @hidden */
  74083. export var morphTargetsVertex: {
  74084. name: string;
  74085. shader: string;
  74086. };
  74087. }
  74088. declare module BABYLON {
  74089. /** @hidden */
  74090. export var instancesVertex: {
  74091. name: string;
  74092. shader: string;
  74093. };
  74094. }
  74095. declare module BABYLON {
  74096. /** @hidden */
  74097. export var bonesVertex: {
  74098. name: string;
  74099. shader: string;
  74100. };
  74101. }
  74102. declare module BABYLON {
  74103. /** @hidden */
  74104. export var shadowMapVertexShader: {
  74105. name: string;
  74106. shader: string;
  74107. };
  74108. }
  74109. declare module BABYLON {
  74110. /** @hidden */
  74111. export var depthBoxBlurPixelShader: {
  74112. name: string;
  74113. shader: string;
  74114. };
  74115. }
  74116. declare module BABYLON {
  74117. /**
  74118. * Defines the options associated with the creation of a custom shader for a shadow generator.
  74119. */
  74120. export interface ICustomShaderOptions {
  74121. /**
  74122. * Gets or sets the custom shader name to use
  74123. */
  74124. shaderName: string;
  74125. /**
  74126. * The list of attribute names used in the shader
  74127. */
  74128. attributes?: string[];
  74129. /**
  74130. * The list of unifrom names used in the shader
  74131. */
  74132. uniforms?: string[];
  74133. /**
  74134. * The list of sampler names used in the shader
  74135. */
  74136. samplers?: string[];
  74137. /**
  74138. * The list of defines used in the shader
  74139. */
  74140. defines?: string[];
  74141. }
  74142. /**
  74143. * Interface to implement to create a shadow generator compatible with BJS.
  74144. */
  74145. export interface IShadowGenerator {
  74146. /**
  74147. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  74148. * @returns The render target texture if present otherwise, null
  74149. */
  74150. getShadowMap(): Nullable<RenderTargetTexture>;
  74151. /**
  74152. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  74153. * @returns The render target texture if the shadow map is present otherwise, null
  74154. */
  74155. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  74156. /**
  74157. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  74158. * @param subMesh The submesh we want to render in the shadow map
  74159. * @param useInstances Defines wether will draw in the map using instances
  74160. * @returns true if ready otherwise, false
  74161. */
  74162. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  74163. /**
  74164. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  74165. * @param defines Defines of the material we want to update
  74166. * @param lightIndex Index of the light in the enabled light list of the material
  74167. */
  74168. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  74169. /**
  74170. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  74171. * defined in the generator but impacting the effect).
  74172. * It implies the unifroms available on the materials are the standard BJS ones.
  74173. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  74174. * @param effect The effect we are binfing the information for
  74175. */
  74176. bindShadowLight(lightIndex: string, effect: Effect): void;
  74177. /**
  74178. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  74179. * (eq to shadow prjection matrix * light transform matrix)
  74180. * @returns The transform matrix used to create the shadow map
  74181. */
  74182. getTransformMatrix(): Matrix;
  74183. /**
  74184. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  74185. * Cube and 2D textures for instance.
  74186. */
  74187. recreateShadowMap(): void;
  74188. /**
  74189. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  74190. * @param onCompiled Callback triggered at the and of the effects compilation
  74191. * @param options Sets of optional options forcing the compilation with different modes
  74192. */
  74193. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  74194. useInstances: boolean;
  74195. }>): void;
  74196. /**
  74197. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  74198. * @param options Sets of optional options forcing the compilation with different modes
  74199. * @returns A promise that resolves when the compilation completes
  74200. */
  74201. forceCompilationAsync(options?: Partial<{
  74202. useInstances: boolean;
  74203. }>): Promise<void>;
  74204. /**
  74205. * Serializes the shadow generator setup to a json object.
  74206. * @returns The serialized JSON object
  74207. */
  74208. serialize(): any;
  74209. /**
  74210. * Disposes the Shadow map and related Textures and effects.
  74211. */
  74212. dispose(): void;
  74213. }
  74214. /**
  74215. * Default implementation IShadowGenerator.
  74216. * This is the main object responsible of generating shadows in the framework.
  74217. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  74218. */
  74219. export class ShadowGenerator implements IShadowGenerator {
  74220. /**
  74221. * Shadow generator mode None: no filtering applied.
  74222. */
  74223. static readonly FILTER_NONE: number;
  74224. /**
  74225. * Shadow generator mode ESM: Exponential Shadow Mapping.
  74226. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  74227. */
  74228. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  74229. /**
  74230. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  74231. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  74232. */
  74233. static readonly FILTER_POISSONSAMPLING: number;
  74234. /**
  74235. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  74236. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  74237. */
  74238. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  74239. /**
  74240. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  74241. * edge artifacts on steep falloff.
  74242. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  74243. */
  74244. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  74245. /**
  74246. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  74247. * edge artifacts on steep falloff.
  74248. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  74249. */
  74250. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  74251. /**
  74252. * Shadow generator mode PCF: Percentage Closer Filtering
  74253. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  74254. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  74255. */
  74256. static readonly FILTER_PCF: number;
  74257. /**
  74258. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  74259. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  74260. * Contact Hardening
  74261. */
  74262. static readonly FILTER_PCSS: number;
  74263. /**
  74264. * Reserved for PCF and PCSS
  74265. * Highest Quality.
  74266. *
  74267. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  74268. *
  74269. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  74270. */
  74271. static readonly QUALITY_HIGH: number;
  74272. /**
  74273. * Reserved for PCF and PCSS
  74274. * Good tradeoff for quality/perf cross devices
  74275. *
  74276. * Execute PCF on a 3*3 kernel.
  74277. *
  74278. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  74279. */
  74280. static readonly QUALITY_MEDIUM: number;
  74281. /**
  74282. * Reserved for PCF and PCSS
  74283. * The lowest quality but the fastest.
  74284. *
  74285. * Execute PCF on a 1*1 kernel.
  74286. *
  74287. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  74288. */
  74289. static readonly QUALITY_LOW: number;
  74290. /** Gets or sets the custom shader name to use */
  74291. customShaderOptions: ICustomShaderOptions;
  74292. /**
  74293. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  74294. */
  74295. onBeforeShadowMapRenderObservable: Observable<Effect>;
  74296. /**
  74297. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  74298. */
  74299. onAfterShadowMapRenderObservable: Observable<Effect>;
  74300. /**
  74301. * Observable triggered before a mesh is rendered in the shadow map.
  74302. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  74303. */
  74304. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  74305. /**
  74306. * Observable triggered after a mesh is rendered in the shadow map.
  74307. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  74308. */
  74309. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  74310. private _bias;
  74311. /**
  74312. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  74313. */
  74314. /**
  74315. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  74316. */
  74317. bias: number;
  74318. private _normalBias;
  74319. /**
  74320. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  74321. */
  74322. /**
  74323. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  74324. */
  74325. normalBias: number;
  74326. private _blurBoxOffset;
  74327. /**
  74328. * Gets the blur box offset: offset applied during the blur pass.
  74329. * Only useful if useKernelBlur = false
  74330. */
  74331. /**
  74332. * Sets the blur box offset: offset applied during the blur pass.
  74333. * Only useful if useKernelBlur = false
  74334. */
  74335. blurBoxOffset: number;
  74336. private _blurScale;
  74337. /**
  74338. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  74339. * 2 means half of the size.
  74340. */
  74341. /**
  74342. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  74343. * 2 means half of the size.
  74344. */
  74345. blurScale: number;
  74346. private _blurKernel;
  74347. /**
  74348. * Gets the blur kernel: kernel size of the blur pass.
  74349. * Only useful if useKernelBlur = true
  74350. */
  74351. /**
  74352. * Sets the blur kernel: kernel size of the blur pass.
  74353. * Only useful if useKernelBlur = true
  74354. */
  74355. blurKernel: number;
  74356. private _useKernelBlur;
  74357. /**
  74358. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  74359. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  74360. */
  74361. /**
  74362. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  74363. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  74364. */
  74365. useKernelBlur: boolean;
  74366. private _depthScale;
  74367. /**
  74368. * Gets the depth scale used in ESM mode.
  74369. */
  74370. /**
  74371. * Sets the depth scale used in ESM mode.
  74372. * This can override the scale stored on the light.
  74373. */
  74374. depthScale: number;
  74375. private _filter;
  74376. /**
  74377. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  74378. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  74379. */
  74380. /**
  74381. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  74382. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  74383. */
  74384. filter: number;
  74385. /**
  74386. * Gets if the current filter is set to Poisson Sampling.
  74387. */
  74388. /**
  74389. * Sets the current filter to Poisson Sampling.
  74390. */
  74391. usePoissonSampling: boolean;
  74392. /**
  74393. * Gets if the current filter is set to ESM.
  74394. */
  74395. /**
  74396. * Sets the current filter is to ESM.
  74397. */
  74398. useExponentialShadowMap: boolean;
  74399. /**
  74400. * Gets if the current filter is set to filtered ESM.
  74401. */
  74402. /**
  74403. * Gets if the current filter is set to filtered ESM.
  74404. */
  74405. useBlurExponentialShadowMap: boolean;
  74406. /**
  74407. * Gets if the current filter is set to "close ESM" (using the inverse of the
  74408. * exponential to prevent steep falloff artifacts).
  74409. */
  74410. /**
  74411. * Sets the current filter to "close ESM" (using the inverse of the
  74412. * exponential to prevent steep falloff artifacts).
  74413. */
  74414. useCloseExponentialShadowMap: boolean;
  74415. /**
  74416. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  74417. * exponential to prevent steep falloff artifacts).
  74418. */
  74419. /**
  74420. * Sets the current filter to filtered "close ESM" (using the inverse of the
  74421. * exponential to prevent steep falloff artifacts).
  74422. */
  74423. useBlurCloseExponentialShadowMap: boolean;
  74424. /**
  74425. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  74426. */
  74427. /**
  74428. * Sets the current filter to "PCF" (percentage closer filtering).
  74429. */
  74430. usePercentageCloserFiltering: boolean;
  74431. private _filteringQuality;
  74432. /**
  74433. * Gets the PCF or PCSS Quality.
  74434. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  74435. */
  74436. /**
  74437. * Sets the PCF or PCSS Quality.
  74438. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  74439. */
  74440. filteringQuality: number;
  74441. /**
  74442. * Gets if the current filter is set to "PCSS" (contact hardening).
  74443. */
  74444. /**
  74445. * Sets the current filter to "PCSS" (contact hardening).
  74446. */
  74447. useContactHardeningShadow: boolean;
  74448. private _contactHardeningLightSizeUVRatio;
  74449. /**
  74450. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  74451. * Using a ratio helps keeping shape stability independently of the map size.
  74452. *
  74453. * It does not account for the light projection as it was having too much
  74454. * instability during the light setup or during light position changes.
  74455. *
  74456. * Only valid if useContactHardeningShadow is true.
  74457. */
  74458. /**
  74459. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  74460. * Using a ratio helps keeping shape stability independently of the map size.
  74461. *
  74462. * It does not account for the light projection as it was having too much
  74463. * instability during the light setup or during light position changes.
  74464. *
  74465. * Only valid if useContactHardeningShadow is true.
  74466. */
  74467. contactHardeningLightSizeUVRatio: number;
  74468. private _darkness;
  74469. /** Gets or sets the actual darkness of a shadow */
  74470. darkness: number;
  74471. /**
  74472. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  74473. * 0 means strongest and 1 would means no shadow.
  74474. * @returns the darkness.
  74475. */
  74476. getDarkness(): number;
  74477. /**
  74478. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  74479. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  74480. * @returns the shadow generator allowing fluent coding.
  74481. */
  74482. setDarkness(darkness: number): ShadowGenerator;
  74483. private _transparencyShadow;
  74484. /** Gets or sets the ability to have transparent shadow */
  74485. transparencyShadow: boolean;
  74486. /**
  74487. * Sets the ability to have transparent shadow (boolean).
  74488. * @param transparent True if transparent else False
  74489. * @returns the shadow generator allowing fluent coding
  74490. */
  74491. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  74492. private _shadowMap;
  74493. private _shadowMap2;
  74494. /**
  74495. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  74496. * @returns The render target texture if present otherwise, null
  74497. */
  74498. getShadowMap(): Nullable<RenderTargetTexture>;
  74499. /**
  74500. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  74501. * @returns The render target texture if the shadow map is present otherwise, null
  74502. */
  74503. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  74504. /**
  74505. * Gets the class name of that object
  74506. * @returns "ShadowGenerator"
  74507. */
  74508. getClassName(): string;
  74509. /**
  74510. * Helper function to add a mesh and its descendants to the list of shadow casters.
  74511. * @param mesh Mesh to add
  74512. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  74513. * @returns the Shadow Generator itself
  74514. */
  74515. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  74516. /**
  74517. * Helper function to remove a mesh and its descendants from the list of shadow casters
  74518. * @param mesh Mesh to remove
  74519. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  74520. * @returns the Shadow Generator itself
  74521. */
  74522. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  74523. /**
  74524. * Controls the extent to which the shadows fade out at the edge of the frustum
  74525. * Used only by directionals and spots
  74526. */
  74527. frustumEdgeFalloff: number;
  74528. private _light;
  74529. /**
  74530. * Returns the associated light object.
  74531. * @returns the light generating the shadow
  74532. */
  74533. getLight(): IShadowLight;
  74534. /**
  74535. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  74536. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  74537. * It might on the other hand introduce peter panning.
  74538. */
  74539. forceBackFacesOnly: boolean;
  74540. private _scene;
  74541. private _lightDirection;
  74542. private _effect;
  74543. private _viewMatrix;
  74544. private _projectionMatrix;
  74545. private _transformMatrix;
  74546. private _cachedPosition;
  74547. private _cachedDirection;
  74548. private _cachedDefines;
  74549. private _currentRenderID;
  74550. private _boxBlurPostprocess;
  74551. private _kernelBlurXPostprocess;
  74552. private _kernelBlurYPostprocess;
  74553. private _blurPostProcesses;
  74554. private _mapSize;
  74555. private _currentFaceIndex;
  74556. private _currentFaceIndexCache;
  74557. private _textureType;
  74558. private _defaultTextureMatrix;
  74559. /** @hidden */
  74560. static _SceneComponentInitialization: (scene: Scene) => void;
  74561. /**
  74562. * Creates a ShadowGenerator object.
  74563. * A ShadowGenerator is the required tool to use the shadows.
  74564. * Each light casting shadows needs to use its own ShadowGenerator.
  74565. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  74566. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  74567. * @param light The light object generating the shadows.
  74568. * @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.
  74569. */
  74570. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  74571. private _initializeGenerator;
  74572. private _initializeShadowMap;
  74573. private _initializeBlurRTTAndPostProcesses;
  74574. private _renderForShadowMap;
  74575. private _renderSubMeshForShadowMap;
  74576. private _applyFilterValues;
  74577. /**
  74578. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  74579. * @param onCompiled Callback triggered at the and of the effects compilation
  74580. * @param options Sets of optional options forcing the compilation with different modes
  74581. */
  74582. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  74583. useInstances: boolean;
  74584. }>): void;
  74585. /**
  74586. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  74587. * @param options Sets of optional options forcing the compilation with different modes
  74588. * @returns A promise that resolves when the compilation completes
  74589. */
  74590. forceCompilationAsync(options?: Partial<{
  74591. useInstances: boolean;
  74592. }>): Promise<void>;
  74593. /**
  74594. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  74595. * @param subMesh The submesh we want to render in the shadow map
  74596. * @param useInstances Defines wether will draw in the map using instances
  74597. * @returns true if ready otherwise, false
  74598. */
  74599. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  74600. /**
  74601. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  74602. * @param defines Defines of the material we want to update
  74603. * @param lightIndex Index of the light in the enabled light list of the material
  74604. */
  74605. prepareDefines(defines: any, lightIndex: number): void;
  74606. /**
  74607. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  74608. * defined in the generator but impacting the effect).
  74609. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  74610. * @param effect The effect we are binfing the information for
  74611. */
  74612. bindShadowLight(lightIndex: string, effect: Effect): void;
  74613. /**
  74614. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  74615. * (eq to shadow prjection matrix * light transform matrix)
  74616. * @returns The transform matrix used to create the shadow map
  74617. */
  74618. getTransformMatrix(): Matrix;
  74619. /**
  74620. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  74621. * Cube and 2D textures for instance.
  74622. */
  74623. recreateShadowMap(): void;
  74624. private _disposeBlurPostProcesses;
  74625. private _disposeRTTandPostProcesses;
  74626. /**
  74627. * Disposes the ShadowGenerator.
  74628. * Returns nothing.
  74629. */
  74630. dispose(): void;
  74631. /**
  74632. * Serializes the shadow generator setup to a json object.
  74633. * @returns The serialized JSON object
  74634. */
  74635. serialize(): any;
  74636. /**
  74637. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  74638. * @param parsedShadowGenerator The JSON object to parse
  74639. * @param scene The scene to create the shadow map for
  74640. * @returns The parsed shadow generator
  74641. */
  74642. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  74643. }
  74644. }
  74645. declare module BABYLON {
  74646. /**
  74647. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  74648. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  74649. * 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.
  74650. */
  74651. export abstract class Light extends Node {
  74652. /**
  74653. * Falloff Default: light is falling off following the material specification:
  74654. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  74655. */
  74656. static readonly FALLOFF_DEFAULT: number;
  74657. /**
  74658. * Falloff Physical: light is falling off following the inverse squared distance law.
  74659. */
  74660. static readonly FALLOFF_PHYSICAL: number;
  74661. /**
  74662. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  74663. * to enhance interoperability with other engines.
  74664. */
  74665. static readonly FALLOFF_GLTF: number;
  74666. /**
  74667. * Falloff Standard: light is falling off like in the standard material
  74668. * to enhance interoperability with other materials.
  74669. */
  74670. static readonly FALLOFF_STANDARD: number;
  74671. /**
  74672. * If every light affecting the material is in this lightmapMode,
  74673. * material.lightmapTexture adds or multiplies
  74674. * (depends on material.useLightmapAsShadowmap)
  74675. * after every other light calculations.
  74676. */
  74677. static readonly LIGHTMAP_DEFAULT: number;
  74678. /**
  74679. * material.lightmapTexture as only diffuse lighting from this light
  74680. * adds only specular lighting from this light
  74681. * adds dynamic shadows
  74682. */
  74683. static readonly LIGHTMAP_SPECULAR: number;
  74684. /**
  74685. * material.lightmapTexture as only lighting
  74686. * no light calculation from this light
  74687. * only adds dynamic shadows from this light
  74688. */
  74689. static readonly LIGHTMAP_SHADOWSONLY: number;
  74690. /**
  74691. * Each light type uses the default quantity according to its type:
  74692. * point/spot lights use luminous intensity
  74693. * directional lights use illuminance
  74694. */
  74695. static readonly INTENSITYMODE_AUTOMATIC: number;
  74696. /**
  74697. * lumen (lm)
  74698. */
  74699. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  74700. /**
  74701. * candela (lm/sr)
  74702. */
  74703. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  74704. /**
  74705. * lux (lm/m^2)
  74706. */
  74707. static readonly INTENSITYMODE_ILLUMINANCE: number;
  74708. /**
  74709. * nit (cd/m^2)
  74710. */
  74711. static readonly INTENSITYMODE_LUMINANCE: number;
  74712. /**
  74713. * Light type const id of the point light.
  74714. */
  74715. static readonly LIGHTTYPEID_POINTLIGHT: number;
  74716. /**
  74717. * Light type const id of the directional light.
  74718. */
  74719. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  74720. /**
  74721. * Light type const id of the spot light.
  74722. */
  74723. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  74724. /**
  74725. * Light type const id of the hemispheric light.
  74726. */
  74727. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  74728. /**
  74729. * Diffuse gives the basic color to an object.
  74730. */
  74731. diffuse: Color3;
  74732. /**
  74733. * Specular produces a highlight color on an object.
  74734. * Note: This is note affecting PBR materials.
  74735. */
  74736. specular: Color3;
  74737. /**
  74738. * Defines the falloff type for this light. This lets overrriding how punctual light are
  74739. * falling off base on range or angle.
  74740. * This can be set to any values in Light.FALLOFF_x.
  74741. *
  74742. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  74743. * other types of materials.
  74744. */
  74745. falloffType: number;
  74746. /**
  74747. * Strength of the light.
  74748. * Note: By default it is define in the framework own unit.
  74749. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  74750. */
  74751. intensity: number;
  74752. private _range;
  74753. protected _inverseSquaredRange: number;
  74754. /**
  74755. * Defines how far from the source the light is impacting in scene units.
  74756. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  74757. */
  74758. /**
  74759. * Defines how far from the source the light is impacting in scene units.
  74760. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  74761. */
  74762. range: number;
  74763. /**
  74764. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  74765. * of light.
  74766. */
  74767. private _photometricScale;
  74768. private _intensityMode;
  74769. /**
  74770. * Gets the photometric scale used to interpret the intensity.
  74771. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  74772. */
  74773. /**
  74774. * Sets the photometric scale used to interpret the intensity.
  74775. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  74776. */
  74777. intensityMode: number;
  74778. private _radius;
  74779. /**
  74780. * Gets the light radius used by PBR Materials to simulate soft area lights.
  74781. */
  74782. /**
  74783. * sets the light radius used by PBR Materials to simulate soft area lights.
  74784. */
  74785. radius: number;
  74786. private _renderPriority;
  74787. /**
  74788. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  74789. * exceeding the number allowed of the materials.
  74790. */
  74791. renderPriority: number;
  74792. private _shadowEnabled;
  74793. /**
  74794. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  74795. * the current shadow generator.
  74796. */
  74797. /**
  74798. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  74799. * the current shadow generator.
  74800. */
  74801. shadowEnabled: boolean;
  74802. private _includedOnlyMeshes;
  74803. /**
  74804. * Gets the only meshes impacted by this light.
  74805. */
  74806. /**
  74807. * Sets the only meshes impacted by this light.
  74808. */
  74809. includedOnlyMeshes: AbstractMesh[];
  74810. private _excludedMeshes;
  74811. /**
  74812. * Gets the meshes not impacted by this light.
  74813. */
  74814. /**
  74815. * Sets the meshes not impacted by this light.
  74816. */
  74817. excludedMeshes: AbstractMesh[];
  74818. private _excludeWithLayerMask;
  74819. /**
  74820. * Gets the layer id use to find what meshes are not impacted by the light.
  74821. * Inactive if 0
  74822. */
  74823. /**
  74824. * Sets the layer id use to find what meshes are not impacted by the light.
  74825. * Inactive if 0
  74826. */
  74827. excludeWithLayerMask: number;
  74828. private _includeOnlyWithLayerMask;
  74829. /**
  74830. * Gets the layer id use to find what meshes are impacted by the light.
  74831. * Inactive if 0
  74832. */
  74833. /**
  74834. * Sets the layer id use to find what meshes are impacted by the light.
  74835. * Inactive if 0
  74836. */
  74837. includeOnlyWithLayerMask: number;
  74838. private _lightmapMode;
  74839. /**
  74840. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  74841. */
  74842. /**
  74843. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  74844. */
  74845. lightmapMode: number;
  74846. /**
  74847. * Shadow generator associted to the light.
  74848. * @hidden Internal use only.
  74849. */
  74850. _shadowGenerator: Nullable<IShadowGenerator>;
  74851. /**
  74852. * @hidden Internal use only.
  74853. */
  74854. _excludedMeshesIds: string[];
  74855. /**
  74856. * @hidden Internal use only.
  74857. */
  74858. _includedOnlyMeshesIds: string[];
  74859. /**
  74860. * The current light unifom buffer.
  74861. * @hidden Internal use only.
  74862. */
  74863. _uniformBuffer: UniformBuffer;
  74864. /**
  74865. * Creates a Light object in the scene.
  74866. * Documentation : https://doc.babylonjs.com/babylon101/lights
  74867. * @param name The firendly name of the light
  74868. * @param scene The scene the light belongs too
  74869. */
  74870. constructor(name: string, scene: Scene);
  74871. protected abstract _buildUniformLayout(): void;
  74872. /**
  74873. * Sets the passed Effect "effect" with the Light information.
  74874. * @param effect The effect to update
  74875. * @param lightIndex The index of the light in the effect to update
  74876. * @returns The light
  74877. */
  74878. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  74879. /**
  74880. * Returns the string "Light".
  74881. * @returns the class name
  74882. */
  74883. getClassName(): string;
  74884. /** @hidden */
  74885. readonly _isLight: boolean;
  74886. /**
  74887. * Converts the light information to a readable string for debug purpose.
  74888. * @param fullDetails Supports for multiple levels of logging within scene loading
  74889. * @returns the human readable light info
  74890. */
  74891. toString(fullDetails?: boolean): string;
  74892. /** @hidden */
  74893. protected _syncParentEnabledState(): void;
  74894. /**
  74895. * Set the enabled state of this node.
  74896. * @param value - the new enabled state
  74897. */
  74898. setEnabled(value: boolean): void;
  74899. /**
  74900. * Returns the Light associated shadow generator if any.
  74901. * @return the associated shadow generator.
  74902. */
  74903. getShadowGenerator(): Nullable<IShadowGenerator>;
  74904. /**
  74905. * Returns a Vector3, the absolute light position in the World.
  74906. * @returns the world space position of the light
  74907. */
  74908. getAbsolutePosition(): Vector3;
  74909. /**
  74910. * Specifies if the light will affect the passed mesh.
  74911. * @param mesh The mesh to test against the light
  74912. * @return true the mesh is affected otherwise, false.
  74913. */
  74914. canAffectMesh(mesh: AbstractMesh): boolean;
  74915. /**
  74916. * Sort function to order lights for rendering.
  74917. * @param a First Light object to compare to second.
  74918. * @param b Second Light object to compare first.
  74919. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  74920. */
  74921. static CompareLightsPriority(a: Light, b: Light): number;
  74922. /**
  74923. * Releases resources associated with this node.
  74924. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  74925. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  74926. */
  74927. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  74928. /**
  74929. * Returns the light type ID (integer).
  74930. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  74931. */
  74932. getTypeID(): number;
  74933. /**
  74934. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  74935. * @returns the scaled intensity in intensity mode unit
  74936. */
  74937. getScaledIntensity(): number;
  74938. /**
  74939. * Returns a new Light object, named "name", from the current one.
  74940. * @param name The name of the cloned light
  74941. * @returns the new created light
  74942. */
  74943. clone(name: string): Nullable<Light>;
  74944. /**
  74945. * Serializes the current light into a Serialization object.
  74946. * @returns the serialized object.
  74947. */
  74948. serialize(): any;
  74949. /**
  74950. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  74951. * This new light is named "name" and added to the passed scene.
  74952. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  74953. * @param name The friendly name of the light
  74954. * @param scene The scene the new light will belong to
  74955. * @returns the constructor function
  74956. */
  74957. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  74958. /**
  74959. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  74960. * @param parsedLight The JSON representation of the light
  74961. * @param scene The scene to create the parsed light in
  74962. * @returns the created light after parsing
  74963. */
  74964. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  74965. private _hookArrayForExcluded;
  74966. private _hookArrayForIncludedOnly;
  74967. private _resyncMeshes;
  74968. /**
  74969. * Forces the meshes to update their light related information in their rendering used effects
  74970. * @hidden Internal Use Only
  74971. */
  74972. _markMeshesAsLightDirty(): void;
  74973. /**
  74974. * Recomputes the cached photometric scale if needed.
  74975. */
  74976. private _computePhotometricScale;
  74977. /**
  74978. * Returns the Photometric Scale according to the light type and intensity mode.
  74979. */
  74980. private _getPhotometricScale;
  74981. /**
  74982. * Reorder the light in the scene according to their defined priority.
  74983. * @hidden Internal Use Only
  74984. */
  74985. _reorderLightsInScene(): void;
  74986. /**
  74987. * Prepares the list of defines specific to the light type.
  74988. * @param defines the list of defines
  74989. * @param lightIndex defines the index of the light for the effect
  74990. */
  74991. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  74992. }
  74993. }
  74994. declare module BABYLON {
  74995. /**
  74996. * Creates an instance based on a source mesh.
  74997. */
  74998. export class InstancedMesh extends AbstractMesh {
  74999. private _sourceMesh;
  75000. private _currentLOD;
  75001. /** @hidden */
  75002. _indexInSourceMeshInstanceArray: number;
  75003. constructor(name: string, source: Mesh);
  75004. /**
  75005. * Returns the string "InstancedMesh".
  75006. */
  75007. getClassName(): string;
  75008. /** Gets the list of lights affecting that mesh */
  75009. readonly lightSources: Light[];
  75010. _resyncLightSources(): void;
  75011. _resyncLighSource(light: Light): void;
  75012. _removeLightSource(light: Light): void;
  75013. /**
  75014. * If the source mesh receives shadows
  75015. */
  75016. readonly receiveShadows: boolean;
  75017. /**
  75018. * The material of the source mesh
  75019. */
  75020. readonly material: Nullable<Material>;
  75021. /**
  75022. * Visibility of the source mesh
  75023. */
  75024. readonly visibility: number;
  75025. /**
  75026. * Skeleton of the source mesh
  75027. */
  75028. readonly skeleton: Nullable<Skeleton>;
  75029. /**
  75030. * Rendering ground id of the source mesh
  75031. */
  75032. renderingGroupId: number;
  75033. /**
  75034. * Returns the total number of vertices (integer).
  75035. */
  75036. getTotalVertices(): number;
  75037. /**
  75038. * Returns a positive integer : the total number of indices in this mesh geometry.
  75039. * @returns the numner of indices or zero if the mesh has no geometry.
  75040. */
  75041. getTotalIndices(): number;
  75042. /**
  75043. * The source mesh of the instance
  75044. */
  75045. readonly sourceMesh: Mesh;
  75046. /**
  75047. * Is this node ready to be used/rendered
  75048. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  75049. * @return {boolean} is it ready
  75050. */
  75051. isReady(completeCheck?: boolean): boolean;
  75052. /**
  75053. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  75054. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  75055. * @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.
  75056. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  75057. */
  75058. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  75059. /**
  75060. * Sets the vertex data of the mesh geometry for the requested `kind`.
  75061. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  75062. * The `data` are either a numeric array either a Float32Array.
  75063. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  75064. * 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).
  75065. * Note that a new underlying VertexBuffer object is created each call.
  75066. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  75067. *
  75068. * Possible `kind` values :
  75069. * - VertexBuffer.PositionKind
  75070. * - VertexBuffer.UVKind
  75071. * - VertexBuffer.UV2Kind
  75072. * - VertexBuffer.UV3Kind
  75073. * - VertexBuffer.UV4Kind
  75074. * - VertexBuffer.UV5Kind
  75075. * - VertexBuffer.UV6Kind
  75076. * - VertexBuffer.ColorKind
  75077. * - VertexBuffer.MatricesIndicesKind
  75078. * - VertexBuffer.MatricesIndicesExtraKind
  75079. * - VertexBuffer.MatricesWeightsKind
  75080. * - VertexBuffer.MatricesWeightsExtraKind
  75081. *
  75082. * Returns the Mesh.
  75083. */
  75084. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  75085. /**
  75086. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  75087. * If the mesh has no geometry, it is simply returned as it is.
  75088. * The `data` are either a numeric array either a Float32Array.
  75089. * No new underlying VertexBuffer object is created.
  75090. * 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.
  75091. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  75092. *
  75093. * Possible `kind` values :
  75094. * - VertexBuffer.PositionKind
  75095. * - VertexBuffer.UVKind
  75096. * - VertexBuffer.UV2Kind
  75097. * - VertexBuffer.UV3Kind
  75098. * - VertexBuffer.UV4Kind
  75099. * - VertexBuffer.UV5Kind
  75100. * - VertexBuffer.UV6Kind
  75101. * - VertexBuffer.ColorKind
  75102. * - VertexBuffer.MatricesIndicesKind
  75103. * - VertexBuffer.MatricesIndicesExtraKind
  75104. * - VertexBuffer.MatricesWeightsKind
  75105. * - VertexBuffer.MatricesWeightsExtraKind
  75106. *
  75107. * Returns the Mesh.
  75108. */
  75109. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  75110. /**
  75111. * Sets the mesh indices.
  75112. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  75113. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  75114. * This method creates a new index buffer each call.
  75115. * Returns the Mesh.
  75116. */
  75117. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  75118. /**
  75119. * Boolean : True if the mesh owns the requested kind of data.
  75120. */
  75121. isVerticesDataPresent(kind: string): boolean;
  75122. /**
  75123. * Returns an array of indices (IndicesArray).
  75124. */
  75125. getIndices(): Nullable<IndicesArray>;
  75126. readonly _positions: Nullable<Vector3[]>;
  75127. /**
  75128. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  75129. * This means the mesh underlying bounding box and sphere are recomputed.
  75130. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  75131. * @returns the current mesh
  75132. */
  75133. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  75134. /** @hidden */
  75135. _preActivate(): InstancedMesh;
  75136. /** @hidden */
  75137. _activate(renderId: number, intermediateRendering: boolean): boolean;
  75138. /** @hidden */
  75139. _postActivate(): void;
  75140. getWorldMatrix(): Matrix;
  75141. readonly isAnInstance: boolean;
  75142. /**
  75143. * Returns the current associated LOD AbstractMesh.
  75144. */
  75145. getLOD(camera: Camera): AbstractMesh;
  75146. /** @hidden */
  75147. _syncSubMeshes(): InstancedMesh;
  75148. /** @hidden */
  75149. _generatePointsArray(): boolean;
  75150. /**
  75151. * Creates a new InstancedMesh from the current mesh.
  75152. * - name (string) : the cloned mesh name
  75153. * - newParent (optional Node) : the optional Node to parent the clone to.
  75154. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  75155. *
  75156. * Returns the clone.
  75157. */
  75158. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  75159. /**
  75160. * Disposes the InstancedMesh.
  75161. * Returns nothing.
  75162. */
  75163. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  75164. }
  75165. }
  75166. declare module BABYLON {
  75167. /**
  75168. * Defines the options associated with the creation of a shader material.
  75169. */
  75170. export interface IShaderMaterialOptions {
  75171. /**
  75172. * Does the material work in alpha blend mode
  75173. */
  75174. needAlphaBlending: boolean;
  75175. /**
  75176. * Does the material work in alpha test mode
  75177. */
  75178. needAlphaTesting: boolean;
  75179. /**
  75180. * The list of attribute names used in the shader
  75181. */
  75182. attributes: string[];
  75183. /**
  75184. * The list of unifrom names used in the shader
  75185. */
  75186. uniforms: string[];
  75187. /**
  75188. * The list of UBO names used in the shader
  75189. */
  75190. uniformBuffers: string[];
  75191. /**
  75192. * The list of sampler names used in the shader
  75193. */
  75194. samplers: string[];
  75195. /**
  75196. * The list of defines used in the shader
  75197. */
  75198. defines: string[];
  75199. }
  75200. /**
  75201. * 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.
  75202. *
  75203. * This returned material effects how the mesh will look based on the code in the shaders.
  75204. *
  75205. * @see http://doc.babylonjs.com/how_to/shader_material
  75206. */
  75207. export class ShaderMaterial extends Material {
  75208. private _shaderPath;
  75209. private _options;
  75210. private _textures;
  75211. private _textureArrays;
  75212. private _floats;
  75213. private _ints;
  75214. private _floatsArrays;
  75215. private _colors3;
  75216. private _colors3Arrays;
  75217. private _colors4;
  75218. private _colors4Arrays;
  75219. private _vectors2;
  75220. private _vectors3;
  75221. private _vectors4;
  75222. private _matrices;
  75223. private _matrices3x3;
  75224. private _matrices2x2;
  75225. private _vectors2Arrays;
  75226. private _vectors3Arrays;
  75227. private _vectors4Arrays;
  75228. private _cachedWorldViewMatrix;
  75229. private _cachedWorldViewProjectionMatrix;
  75230. private _renderId;
  75231. /**
  75232. * Instantiate a new shader material.
  75233. * 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.
  75234. * This returned material effects how the mesh will look based on the code in the shaders.
  75235. * @see http://doc.babylonjs.com/how_to/shader_material
  75236. * @param name Define the name of the material in the scene
  75237. * @param scene Define the scene the material belongs to
  75238. * @param shaderPath Defines the route to the shader code in one of three ways:
  75239. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  75240. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  75241. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  75242. * @param options Define the options used to create the shader
  75243. */
  75244. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  75245. /**
  75246. * Gets the options used to compile the shader.
  75247. * They can be modified to trigger a new compilation
  75248. */
  75249. readonly options: IShaderMaterialOptions;
  75250. /**
  75251. * Gets the current class name of the material e.g. "ShaderMaterial"
  75252. * Mainly use in serialization.
  75253. * @returns the class name
  75254. */
  75255. getClassName(): string;
  75256. /**
  75257. * Specifies if the material will require alpha blending
  75258. * @returns a boolean specifying if alpha blending is needed
  75259. */
  75260. needAlphaBlending(): boolean;
  75261. /**
  75262. * Specifies if this material should be rendered in alpha test mode
  75263. * @returns a boolean specifying if an alpha test is needed.
  75264. */
  75265. needAlphaTesting(): boolean;
  75266. private _checkUniform;
  75267. /**
  75268. * Set a texture in the shader.
  75269. * @param name Define the name of the uniform samplers as defined in the shader
  75270. * @param texture Define the texture to bind to this sampler
  75271. * @return the material itself allowing "fluent" like uniform updates
  75272. */
  75273. setTexture(name: string, texture: Texture): ShaderMaterial;
  75274. /**
  75275. * Set a texture array in the shader.
  75276. * @param name Define the name of the uniform sampler array as defined in the shader
  75277. * @param textures Define the list of textures to bind to this sampler
  75278. * @return the material itself allowing "fluent" like uniform updates
  75279. */
  75280. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  75281. /**
  75282. * Set a float in the shader.
  75283. * @param name Define the name of the uniform as defined in the shader
  75284. * @param value Define the value to give to the uniform
  75285. * @return the material itself allowing "fluent" like uniform updates
  75286. */
  75287. setFloat(name: string, value: number): ShaderMaterial;
  75288. /**
  75289. * Set a int in the shader.
  75290. * @param name Define the name of the uniform as defined in the shader
  75291. * @param value Define the value to give to the uniform
  75292. * @return the material itself allowing "fluent" like uniform updates
  75293. */
  75294. setInt(name: string, value: number): ShaderMaterial;
  75295. /**
  75296. * Set an array of floats in the shader.
  75297. * @param name Define the name of the uniform as defined in the shader
  75298. * @param value Define the value to give to the uniform
  75299. * @return the material itself allowing "fluent" like uniform updates
  75300. */
  75301. setFloats(name: string, value: number[]): ShaderMaterial;
  75302. /**
  75303. * Set a vec3 in the shader from a Color3.
  75304. * @param name Define the name of the uniform as defined in the shader
  75305. * @param value Define the value to give to the uniform
  75306. * @return the material itself allowing "fluent" like uniform updates
  75307. */
  75308. setColor3(name: string, value: Color3): ShaderMaterial;
  75309. /**
  75310. * Set a vec3 array in the shader from a Color3 array.
  75311. * @param name Define the name of the uniform as defined in the shader
  75312. * @param value Define the value to give to the uniform
  75313. * @return the material itself allowing "fluent" like uniform updates
  75314. */
  75315. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  75316. /**
  75317. * Set a vec4 in the shader from a Color4.
  75318. * @param name Define the name of the uniform as defined in the shader
  75319. * @param value Define the value to give to the uniform
  75320. * @return the material itself allowing "fluent" like uniform updates
  75321. */
  75322. setColor4(name: string, value: Color4): ShaderMaterial;
  75323. /**
  75324. * Set a vec4 array in the shader from a Color4 array.
  75325. * @param name Define the name of the uniform as defined in the shader
  75326. * @param value Define the value to give to the uniform
  75327. * @return the material itself allowing "fluent" like uniform updates
  75328. */
  75329. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  75330. /**
  75331. * Set a vec2 in the shader from a Vector2.
  75332. * @param name Define the name of the uniform as defined in the shader
  75333. * @param value Define the value to give to the uniform
  75334. * @return the material itself allowing "fluent" like uniform updates
  75335. */
  75336. setVector2(name: string, value: Vector2): ShaderMaterial;
  75337. /**
  75338. * Set a vec3 in the shader from a Vector3.
  75339. * @param name Define the name of the uniform as defined in the shader
  75340. * @param value Define the value to give to the uniform
  75341. * @return the material itself allowing "fluent" like uniform updates
  75342. */
  75343. setVector3(name: string, value: Vector3): ShaderMaterial;
  75344. /**
  75345. * Set a vec4 in the shader from a Vector4.
  75346. * @param name Define the name of the uniform as defined in the shader
  75347. * @param value Define the value to give to the uniform
  75348. * @return the material itself allowing "fluent" like uniform updates
  75349. */
  75350. setVector4(name: string, value: Vector4): ShaderMaterial;
  75351. /**
  75352. * Set a mat4 in the shader from a Matrix.
  75353. * @param name Define the name of the uniform as defined in the shader
  75354. * @param value Define the value to give to the uniform
  75355. * @return the material itself allowing "fluent" like uniform updates
  75356. */
  75357. setMatrix(name: string, value: Matrix): ShaderMaterial;
  75358. /**
  75359. * Set a mat3 in the shader from a Float32Array.
  75360. * @param name Define the name of the uniform as defined in the shader
  75361. * @param value Define the value to give to the uniform
  75362. * @return the material itself allowing "fluent" like uniform updates
  75363. */
  75364. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  75365. /**
  75366. * Set a mat2 in the shader from a Float32Array.
  75367. * @param name Define the name of the uniform as defined in the shader
  75368. * @param value Define the value to give to the uniform
  75369. * @return the material itself allowing "fluent" like uniform updates
  75370. */
  75371. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  75372. /**
  75373. * Set a vec2 array in the shader from a number array.
  75374. * @param name Define the name of the uniform as defined in the shader
  75375. * @param value Define the value to give to the uniform
  75376. * @return the material itself allowing "fluent" like uniform updates
  75377. */
  75378. setArray2(name: string, value: number[]): ShaderMaterial;
  75379. /**
  75380. * Set a vec3 array in the shader from a number array.
  75381. * @param name Define the name of the uniform as defined in the shader
  75382. * @param value Define the value to give to the uniform
  75383. * @return the material itself allowing "fluent" like uniform updates
  75384. */
  75385. setArray3(name: string, value: number[]): ShaderMaterial;
  75386. /**
  75387. * Set a vec4 array in the shader from a number array.
  75388. * @param name Define the name of the uniform as defined in the shader
  75389. * @param value Define the value to give to the uniform
  75390. * @return the material itself allowing "fluent" like uniform updates
  75391. */
  75392. setArray4(name: string, value: number[]): ShaderMaterial;
  75393. private _checkCache;
  75394. /**
  75395. * Specifies that the submesh is ready to be used
  75396. * @param mesh defines the mesh to check
  75397. * @param subMesh defines which submesh to check
  75398. * @param useInstances specifies that instances should be used
  75399. * @returns a boolean indicating that the submesh is ready or not
  75400. */
  75401. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  75402. /**
  75403. * Checks if the material is ready to render the requested mesh
  75404. * @param mesh Define the mesh to render
  75405. * @param useInstances Define whether or not the material is used with instances
  75406. * @returns true if ready, otherwise false
  75407. */
  75408. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  75409. /**
  75410. * Binds the world matrix to the material
  75411. * @param world defines the world transformation matrix
  75412. */
  75413. bindOnlyWorldMatrix(world: Matrix): void;
  75414. /**
  75415. * Binds the material to the mesh
  75416. * @param world defines the world transformation matrix
  75417. * @param mesh defines the mesh to bind the material to
  75418. */
  75419. bind(world: Matrix, mesh?: Mesh): void;
  75420. /**
  75421. * Gets the active textures from the material
  75422. * @returns an array of textures
  75423. */
  75424. getActiveTextures(): BaseTexture[];
  75425. /**
  75426. * Specifies if the material uses a texture
  75427. * @param texture defines the texture to check against the material
  75428. * @returns a boolean specifying if the material uses the texture
  75429. */
  75430. hasTexture(texture: BaseTexture): boolean;
  75431. /**
  75432. * Makes a duplicate of the material, and gives it a new name
  75433. * @param name defines the new name for the duplicated material
  75434. * @returns the cloned material
  75435. */
  75436. clone(name: string): ShaderMaterial;
  75437. /**
  75438. * Disposes the material
  75439. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  75440. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  75441. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  75442. */
  75443. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  75444. /**
  75445. * Serializes this material in a JSON representation
  75446. * @returns the serialized material object
  75447. */
  75448. serialize(): any;
  75449. /**
  75450. * Creates a shader material from parsed shader material data
  75451. * @param source defines the JSON represnetation of the material
  75452. * @param scene defines the hosting scene
  75453. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  75454. * @returns a new material
  75455. */
  75456. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  75457. }
  75458. }
  75459. declare module BABYLON {
  75460. /** @hidden */
  75461. export var clipPlaneFragmentDeclaration: {
  75462. name: string;
  75463. shader: string;
  75464. };
  75465. }
  75466. declare module BABYLON {
  75467. /** @hidden */
  75468. export var clipPlaneFragment: {
  75469. name: string;
  75470. shader: string;
  75471. };
  75472. }
  75473. declare module BABYLON {
  75474. /** @hidden */
  75475. export var colorPixelShader: {
  75476. name: string;
  75477. shader: string;
  75478. };
  75479. }
  75480. declare module BABYLON {
  75481. /** @hidden */
  75482. export var clipPlaneVertexDeclaration: {
  75483. name: string;
  75484. shader: string;
  75485. };
  75486. }
  75487. declare module BABYLON {
  75488. /** @hidden */
  75489. export var clipPlaneVertex: {
  75490. name: string;
  75491. shader: string;
  75492. };
  75493. }
  75494. declare module BABYLON {
  75495. /** @hidden */
  75496. export var colorVertexShader: {
  75497. name: string;
  75498. shader: string;
  75499. };
  75500. }
  75501. declare module BABYLON {
  75502. /**
  75503. * Line mesh
  75504. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  75505. */
  75506. export class LinesMesh extends Mesh {
  75507. /**
  75508. * If vertex color should be applied to the mesh
  75509. */
  75510. readonly useVertexColor?: boolean | undefined;
  75511. /**
  75512. * If vertex alpha should be applied to the mesh
  75513. */
  75514. readonly useVertexAlpha?: boolean | undefined;
  75515. /**
  75516. * Color of the line (Default: White)
  75517. */
  75518. color: Color3;
  75519. /**
  75520. * Alpha of the line (Default: 1)
  75521. */
  75522. alpha: number;
  75523. /**
  75524. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  75525. * This margin is expressed in world space coordinates, so its value may vary.
  75526. * Default value is 0.1
  75527. */
  75528. intersectionThreshold: number;
  75529. private _colorShader;
  75530. private color4;
  75531. /**
  75532. * Creates a new LinesMesh
  75533. * @param name defines the name
  75534. * @param scene defines the hosting scene
  75535. * @param parent defines the parent mesh if any
  75536. * @param source defines the optional source LinesMesh used to clone data from
  75537. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  75538. * When false, achieved by calling a clone(), also passing False.
  75539. * This will make creation of children, recursive.
  75540. * @param useVertexColor defines if this LinesMesh supports vertex color
  75541. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  75542. */
  75543. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  75544. /**
  75545. * If vertex color should be applied to the mesh
  75546. */
  75547. useVertexColor?: boolean | undefined,
  75548. /**
  75549. * If vertex alpha should be applied to the mesh
  75550. */
  75551. useVertexAlpha?: boolean | undefined);
  75552. private _addClipPlaneDefine;
  75553. private _removeClipPlaneDefine;
  75554. isReady(): boolean;
  75555. /**
  75556. * Returns the string "LineMesh"
  75557. */
  75558. getClassName(): string;
  75559. /**
  75560. * @hidden
  75561. */
  75562. /**
  75563. * @hidden
  75564. */
  75565. material: Material;
  75566. /**
  75567. * @hidden
  75568. */
  75569. readonly checkCollisions: boolean;
  75570. /** @hidden */
  75571. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  75572. /** @hidden */
  75573. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  75574. /**
  75575. * Disposes of the line mesh
  75576. * @param doNotRecurse If children should be disposed
  75577. */
  75578. dispose(doNotRecurse?: boolean): void;
  75579. /**
  75580. * Returns a new LineMesh object cloned from the current one.
  75581. */
  75582. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  75583. /**
  75584. * Creates a new InstancedLinesMesh object from the mesh model.
  75585. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  75586. * @param name defines the name of the new instance
  75587. * @returns a new InstancedLinesMesh
  75588. */
  75589. createInstance(name: string): InstancedLinesMesh;
  75590. }
  75591. /**
  75592. * Creates an instance based on a source LinesMesh
  75593. */
  75594. export class InstancedLinesMesh extends InstancedMesh {
  75595. /**
  75596. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  75597. * This margin is expressed in world space coordinates, so its value may vary.
  75598. * Initilized with the intersectionThreshold value of the source LinesMesh
  75599. */
  75600. intersectionThreshold: number;
  75601. constructor(name: string, source: LinesMesh);
  75602. /**
  75603. * Returns the string "InstancedLinesMesh".
  75604. */
  75605. getClassName(): string;
  75606. }
  75607. }
  75608. declare module BABYLON {
  75609. /**
  75610. * Mesh representing the gorund
  75611. */
  75612. export class GroundMesh extends Mesh {
  75613. /** If octree should be generated */
  75614. generateOctree: boolean;
  75615. private _heightQuads;
  75616. /** @hidden */
  75617. _subdivisionsX: number;
  75618. /** @hidden */
  75619. _subdivisionsY: number;
  75620. /** @hidden */
  75621. _width: number;
  75622. /** @hidden */
  75623. _height: number;
  75624. /** @hidden */
  75625. _minX: number;
  75626. /** @hidden */
  75627. _maxX: number;
  75628. /** @hidden */
  75629. _minZ: number;
  75630. /** @hidden */
  75631. _maxZ: number;
  75632. constructor(name: string, scene: Scene);
  75633. /**
  75634. * "GroundMesh"
  75635. * @returns "GroundMesh"
  75636. */
  75637. getClassName(): string;
  75638. /**
  75639. * The minimum of x and y subdivisions
  75640. */
  75641. readonly subdivisions: number;
  75642. /**
  75643. * X subdivisions
  75644. */
  75645. readonly subdivisionsX: number;
  75646. /**
  75647. * Y subdivisions
  75648. */
  75649. readonly subdivisionsY: number;
  75650. /**
  75651. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  75652. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  75653. * @param chunksCount the number of subdivisions for x and y
  75654. * @param octreeBlocksSize (Default: 32)
  75655. */
  75656. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  75657. /**
  75658. * Returns a height (y) value in the Worl system :
  75659. * the ground altitude at the coordinates (x, z) expressed in the World system.
  75660. * @param x x coordinate
  75661. * @param z z coordinate
  75662. * @returns the ground y position if (x, z) are outside the ground surface.
  75663. */
  75664. getHeightAtCoordinates(x: number, z: number): number;
  75665. /**
  75666. * Returns a normalized vector (Vector3) orthogonal to the ground
  75667. * at the ground coordinates (x, z) expressed in the World system.
  75668. * @param x x coordinate
  75669. * @param z z coordinate
  75670. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  75671. */
  75672. getNormalAtCoordinates(x: number, z: number): Vector3;
  75673. /**
  75674. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  75675. * at the ground coordinates (x, z) expressed in the World system.
  75676. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  75677. * @param x x coordinate
  75678. * @param z z coordinate
  75679. * @param ref vector to store the result
  75680. * @returns the GroundMesh.
  75681. */
  75682. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  75683. /**
  75684. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  75685. * if the ground has been updated.
  75686. * This can be used in the render loop.
  75687. * @returns the GroundMesh.
  75688. */
  75689. updateCoordinateHeights(): GroundMesh;
  75690. private _getFacetAt;
  75691. private _initHeightQuads;
  75692. private _computeHeightQuads;
  75693. /**
  75694. * Serializes this ground mesh
  75695. * @param serializationObject object to write serialization to
  75696. */
  75697. serialize(serializationObject: any): void;
  75698. /**
  75699. * Parses a serialized ground mesh
  75700. * @param parsedMesh the serialized mesh
  75701. * @param scene the scene to create the ground mesh in
  75702. * @returns the created ground mesh
  75703. */
  75704. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  75705. }
  75706. }
  75707. declare module BABYLON {
  75708. /**
  75709. * Interface for Physics-Joint data
  75710. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75711. */
  75712. export interface PhysicsJointData {
  75713. /**
  75714. * The main pivot of the joint
  75715. */
  75716. mainPivot?: Vector3;
  75717. /**
  75718. * The connected pivot of the joint
  75719. */
  75720. connectedPivot?: Vector3;
  75721. /**
  75722. * The main axis of the joint
  75723. */
  75724. mainAxis?: Vector3;
  75725. /**
  75726. * The connected axis of the joint
  75727. */
  75728. connectedAxis?: Vector3;
  75729. /**
  75730. * The collision of the joint
  75731. */
  75732. collision?: boolean;
  75733. /**
  75734. * Native Oimo/Cannon/Energy data
  75735. */
  75736. nativeParams?: any;
  75737. }
  75738. /**
  75739. * This is a holder class for the physics joint created by the physics plugin
  75740. * It holds a set of functions to control the underlying joint
  75741. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75742. */
  75743. export class PhysicsJoint {
  75744. /**
  75745. * The type of the physics joint
  75746. */
  75747. type: number;
  75748. /**
  75749. * The data for the physics joint
  75750. */
  75751. jointData: PhysicsJointData;
  75752. private _physicsJoint;
  75753. protected _physicsPlugin: IPhysicsEnginePlugin;
  75754. /**
  75755. * Initializes the physics joint
  75756. * @param type The type of the physics joint
  75757. * @param jointData The data for the physics joint
  75758. */
  75759. constructor(
  75760. /**
  75761. * The type of the physics joint
  75762. */
  75763. type: number,
  75764. /**
  75765. * The data for the physics joint
  75766. */
  75767. jointData: PhysicsJointData);
  75768. /**
  75769. * Gets the physics joint
  75770. */
  75771. /**
  75772. * Sets the physics joint
  75773. */
  75774. physicsJoint: any;
  75775. /**
  75776. * Sets the physics plugin
  75777. */
  75778. physicsPlugin: IPhysicsEnginePlugin;
  75779. /**
  75780. * Execute a function that is physics-plugin specific.
  75781. * @param {Function} func the function that will be executed.
  75782. * It accepts two parameters: the physics world and the physics joint
  75783. */
  75784. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  75785. /**
  75786. * Distance-Joint type
  75787. */
  75788. static DistanceJoint: number;
  75789. /**
  75790. * Hinge-Joint type
  75791. */
  75792. static HingeJoint: number;
  75793. /**
  75794. * Ball-and-Socket joint type
  75795. */
  75796. static BallAndSocketJoint: number;
  75797. /**
  75798. * Wheel-Joint type
  75799. */
  75800. static WheelJoint: number;
  75801. /**
  75802. * Slider-Joint type
  75803. */
  75804. static SliderJoint: number;
  75805. /**
  75806. * Prismatic-Joint type
  75807. */
  75808. static PrismaticJoint: number;
  75809. /**
  75810. * Universal-Joint type
  75811. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  75812. */
  75813. static UniversalJoint: number;
  75814. /**
  75815. * Hinge-Joint 2 type
  75816. */
  75817. static Hinge2Joint: number;
  75818. /**
  75819. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  75820. */
  75821. static PointToPointJoint: number;
  75822. /**
  75823. * Spring-Joint type
  75824. */
  75825. static SpringJoint: number;
  75826. /**
  75827. * Lock-Joint type
  75828. */
  75829. static LockJoint: number;
  75830. }
  75831. /**
  75832. * A class representing a physics distance joint
  75833. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75834. */
  75835. export class DistanceJoint extends PhysicsJoint {
  75836. /**
  75837. *
  75838. * @param jointData The data for the Distance-Joint
  75839. */
  75840. constructor(jointData: DistanceJointData);
  75841. /**
  75842. * Update the predefined distance.
  75843. * @param maxDistance The maximum preferred distance
  75844. * @param minDistance The minimum preferred distance
  75845. */
  75846. updateDistance(maxDistance: number, minDistance?: number): void;
  75847. }
  75848. /**
  75849. * Represents a Motor-Enabled Joint
  75850. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75851. */
  75852. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  75853. /**
  75854. * Initializes the Motor-Enabled Joint
  75855. * @param type The type of the joint
  75856. * @param jointData The physica joint data for the joint
  75857. */
  75858. constructor(type: number, jointData: PhysicsJointData);
  75859. /**
  75860. * Set the motor values.
  75861. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75862. * @param force the force to apply
  75863. * @param maxForce max force for this motor.
  75864. */
  75865. setMotor(force?: number, maxForce?: number): void;
  75866. /**
  75867. * Set the motor's limits.
  75868. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75869. * @param upperLimit The upper limit of the motor
  75870. * @param lowerLimit The lower limit of the motor
  75871. */
  75872. setLimit(upperLimit: number, lowerLimit?: number): void;
  75873. }
  75874. /**
  75875. * This class represents a single physics Hinge-Joint
  75876. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75877. */
  75878. export class HingeJoint extends MotorEnabledJoint {
  75879. /**
  75880. * Initializes the Hinge-Joint
  75881. * @param jointData The joint data for the Hinge-Joint
  75882. */
  75883. constructor(jointData: PhysicsJointData);
  75884. /**
  75885. * Set the motor values.
  75886. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75887. * @param {number} force the force to apply
  75888. * @param {number} maxForce max force for this motor.
  75889. */
  75890. setMotor(force?: number, maxForce?: number): void;
  75891. /**
  75892. * Set the motor's limits.
  75893. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75894. * @param upperLimit The upper limit of the motor
  75895. * @param lowerLimit The lower limit of the motor
  75896. */
  75897. setLimit(upperLimit: number, lowerLimit?: number): void;
  75898. }
  75899. /**
  75900. * This class represents a dual hinge physics joint (same as wheel joint)
  75901. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75902. */
  75903. export class Hinge2Joint extends MotorEnabledJoint {
  75904. /**
  75905. * Initializes the Hinge2-Joint
  75906. * @param jointData The joint data for the Hinge2-Joint
  75907. */
  75908. constructor(jointData: PhysicsJointData);
  75909. /**
  75910. * Set the motor values.
  75911. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75912. * @param {number} targetSpeed the speed the motor is to reach
  75913. * @param {number} maxForce max force for this motor.
  75914. * @param {motorIndex} the motor's index, 0 or 1.
  75915. */
  75916. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  75917. /**
  75918. * Set the motor limits.
  75919. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75920. * @param {number} upperLimit the upper limit
  75921. * @param {number} lowerLimit lower limit
  75922. * @param {motorIndex} the motor's index, 0 or 1.
  75923. */
  75924. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  75925. }
  75926. /**
  75927. * Interface for a motor enabled joint
  75928. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75929. */
  75930. export interface IMotorEnabledJoint {
  75931. /**
  75932. * Physics joint
  75933. */
  75934. physicsJoint: any;
  75935. /**
  75936. * Sets the motor of the motor-enabled joint
  75937. * @param force The force of the motor
  75938. * @param maxForce The maximum force of the motor
  75939. * @param motorIndex The index of the motor
  75940. */
  75941. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  75942. /**
  75943. * Sets the limit of the motor
  75944. * @param upperLimit The upper limit of the motor
  75945. * @param lowerLimit The lower limit of the motor
  75946. * @param motorIndex The index of the motor
  75947. */
  75948. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  75949. }
  75950. /**
  75951. * Joint data for a Distance-Joint
  75952. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75953. */
  75954. export interface DistanceJointData extends PhysicsJointData {
  75955. /**
  75956. * Max distance the 2 joint objects can be apart
  75957. */
  75958. maxDistance: number;
  75959. }
  75960. /**
  75961. * Joint data from a spring joint
  75962. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75963. */
  75964. export interface SpringJointData extends PhysicsJointData {
  75965. /**
  75966. * Length of the spring
  75967. */
  75968. length: number;
  75969. /**
  75970. * Stiffness of the spring
  75971. */
  75972. stiffness: number;
  75973. /**
  75974. * Damping of the spring
  75975. */
  75976. damping: number;
  75977. /** this callback will be called when applying the force to the impostors. */
  75978. forceApplicationCallback: () => void;
  75979. }
  75980. }
  75981. declare module BABYLON {
  75982. /**
  75983. * Holds the data for the raycast result
  75984. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75985. */
  75986. export class PhysicsRaycastResult {
  75987. private _hasHit;
  75988. private _hitDistance;
  75989. private _hitNormalWorld;
  75990. private _hitPointWorld;
  75991. private _rayFromWorld;
  75992. private _rayToWorld;
  75993. /**
  75994. * Gets if there was a hit
  75995. */
  75996. readonly hasHit: boolean;
  75997. /**
  75998. * Gets the distance from the hit
  75999. */
  76000. readonly hitDistance: number;
  76001. /**
  76002. * Gets the hit normal/direction in the world
  76003. */
  76004. readonly hitNormalWorld: Vector3;
  76005. /**
  76006. * Gets the hit point in the world
  76007. */
  76008. readonly hitPointWorld: Vector3;
  76009. /**
  76010. * Gets the ray "start point" of the ray in the world
  76011. */
  76012. readonly rayFromWorld: Vector3;
  76013. /**
  76014. * Gets the ray "end point" of the ray in the world
  76015. */
  76016. readonly rayToWorld: Vector3;
  76017. /**
  76018. * Sets the hit data (normal & point in world space)
  76019. * @param hitNormalWorld defines the normal in world space
  76020. * @param hitPointWorld defines the point in world space
  76021. */
  76022. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  76023. /**
  76024. * Sets the distance from the start point to the hit point
  76025. * @param distance
  76026. */
  76027. setHitDistance(distance: number): void;
  76028. /**
  76029. * Calculates the distance manually
  76030. */
  76031. calculateHitDistance(): void;
  76032. /**
  76033. * Resets all the values to default
  76034. * @param from The from point on world space
  76035. * @param to The to point on world space
  76036. */
  76037. reset(from?: Vector3, to?: Vector3): void;
  76038. }
  76039. /**
  76040. * Interface for the size containing width and height
  76041. */
  76042. interface IXYZ {
  76043. /**
  76044. * X
  76045. */
  76046. x: number;
  76047. /**
  76048. * Y
  76049. */
  76050. y: number;
  76051. /**
  76052. * Z
  76053. */
  76054. z: number;
  76055. }
  76056. }
  76057. declare module BABYLON {
  76058. /**
  76059. * Interface used to describe a physics joint
  76060. */
  76061. export interface PhysicsImpostorJoint {
  76062. /** Defines the main impostor to which the joint is linked */
  76063. mainImpostor: PhysicsImpostor;
  76064. /** Defines the impostor that is connected to the main impostor using this joint */
  76065. connectedImpostor: PhysicsImpostor;
  76066. /** Defines the joint itself */
  76067. joint: PhysicsJoint;
  76068. }
  76069. /** @hidden */
  76070. export interface IPhysicsEnginePlugin {
  76071. world: any;
  76072. name: string;
  76073. setGravity(gravity: Vector3): void;
  76074. setTimeStep(timeStep: number): void;
  76075. getTimeStep(): number;
  76076. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  76077. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  76078. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  76079. generatePhysicsBody(impostor: PhysicsImpostor): void;
  76080. removePhysicsBody(impostor: PhysicsImpostor): void;
  76081. generateJoint(joint: PhysicsImpostorJoint): void;
  76082. removeJoint(joint: PhysicsImpostorJoint): void;
  76083. isSupported(): boolean;
  76084. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  76085. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  76086. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  76087. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  76088. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  76089. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  76090. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  76091. getBodyMass(impostor: PhysicsImpostor): number;
  76092. getBodyFriction(impostor: PhysicsImpostor): number;
  76093. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  76094. getBodyRestitution(impostor: PhysicsImpostor): number;
  76095. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  76096. getBodyPressure?(impostor: PhysicsImpostor): number;
  76097. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  76098. getBodyStiffness?(impostor: PhysicsImpostor): number;
  76099. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  76100. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  76101. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  76102. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  76103. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  76104. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  76105. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  76106. sleepBody(impostor: PhysicsImpostor): void;
  76107. wakeUpBody(impostor: PhysicsImpostor): void;
  76108. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  76109. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  76110. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  76111. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  76112. getRadius(impostor: PhysicsImpostor): number;
  76113. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  76114. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  76115. dispose(): void;
  76116. }
  76117. /**
  76118. * Interface used to define a physics engine
  76119. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  76120. */
  76121. export interface IPhysicsEngine {
  76122. /**
  76123. * Gets the gravity vector used by the simulation
  76124. */
  76125. gravity: Vector3;
  76126. /**
  76127. * Sets the gravity vector used by the simulation
  76128. * @param gravity defines the gravity vector to use
  76129. */
  76130. setGravity(gravity: Vector3): void;
  76131. /**
  76132. * Set the time step of the physics engine.
  76133. * Default is 1/60.
  76134. * To slow it down, enter 1/600 for example.
  76135. * To speed it up, 1/30
  76136. * @param newTimeStep the new timestep to apply to this world.
  76137. */
  76138. setTimeStep(newTimeStep: number): void;
  76139. /**
  76140. * Get the time step of the physics engine.
  76141. * @returns the current time step
  76142. */
  76143. getTimeStep(): number;
  76144. /**
  76145. * Release all resources
  76146. */
  76147. dispose(): void;
  76148. /**
  76149. * Gets the name of the current physics plugin
  76150. * @returns the name of the plugin
  76151. */
  76152. getPhysicsPluginName(): string;
  76153. /**
  76154. * Adding a new impostor for the impostor tracking.
  76155. * This will be done by the impostor itself.
  76156. * @param impostor the impostor to add
  76157. */
  76158. addImpostor(impostor: PhysicsImpostor): void;
  76159. /**
  76160. * Remove an impostor from the engine.
  76161. * This impostor and its mesh will not longer be updated by the physics engine.
  76162. * @param impostor the impostor to remove
  76163. */
  76164. removeImpostor(impostor: PhysicsImpostor): void;
  76165. /**
  76166. * Add a joint to the physics engine
  76167. * @param mainImpostor defines the main impostor to which the joint is added.
  76168. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  76169. * @param joint defines the joint that will connect both impostors.
  76170. */
  76171. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  76172. /**
  76173. * Removes a joint from the simulation
  76174. * @param mainImpostor defines the impostor used with the joint
  76175. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  76176. * @param joint defines the joint to remove
  76177. */
  76178. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  76179. /**
  76180. * Gets the current plugin used to run the simulation
  76181. * @returns current plugin
  76182. */
  76183. getPhysicsPlugin(): IPhysicsEnginePlugin;
  76184. /**
  76185. * Gets the list of physic impostors
  76186. * @returns an array of PhysicsImpostor
  76187. */
  76188. getImpostors(): Array<PhysicsImpostor>;
  76189. /**
  76190. * Gets the impostor for a physics enabled object
  76191. * @param object defines the object impersonated by the impostor
  76192. * @returns the PhysicsImpostor or null if not found
  76193. */
  76194. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  76195. /**
  76196. * Gets the impostor for a physics body object
  76197. * @param body defines physics body used by the impostor
  76198. * @returns the PhysicsImpostor or null if not found
  76199. */
  76200. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  76201. /**
  76202. * Does a raycast in the physics world
  76203. * @param from when should the ray start?
  76204. * @param to when should the ray end?
  76205. * @returns PhysicsRaycastResult
  76206. */
  76207. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  76208. /**
  76209. * Called by the scene. No need to call it.
  76210. * @param delta defines the timespam between frames
  76211. */
  76212. _step(delta: number): void;
  76213. }
  76214. }
  76215. declare module BABYLON {
  76216. /**
  76217. * The interface for the physics imposter parameters
  76218. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76219. */
  76220. export interface PhysicsImpostorParameters {
  76221. /**
  76222. * The mass of the physics imposter
  76223. */
  76224. mass: number;
  76225. /**
  76226. * The friction of the physics imposter
  76227. */
  76228. friction?: number;
  76229. /**
  76230. * The coefficient of restitution of the physics imposter
  76231. */
  76232. restitution?: number;
  76233. /**
  76234. * The native options of the physics imposter
  76235. */
  76236. nativeOptions?: any;
  76237. /**
  76238. * Specifies if the parent should be ignored
  76239. */
  76240. ignoreParent?: boolean;
  76241. /**
  76242. * Specifies if bi-directional transformations should be disabled
  76243. */
  76244. disableBidirectionalTransformation?: boolean;
  76245. /**
  76246. * The pressure inside the physics imposter, soft object only
  76247. */
  76248. pressure?: number;
  76249. /**
  76250. * The stiffness the physics imposter, soft object only
  76251. */
  76252. stiffness?: number;
  76253. /**
  76254. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  76255. */
  76256. velocityIterations?: number;
  76257. /**
  76258. * The number of iterations used in maintaining consistent vertex positions, soft object only
  76259. */
  76260. positionIterations?: number;
  76261. /**
  76262. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  76263. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  76264. * Add to fix multiple points
  76265. */
  76266. fixedPoints?: number;
  76267. /**
  76268. * The collision margin around a soft object
  76269. */
  76270. margin?: number;
  76271. /**
  76272. * The collision margin around a soft object
  76273. */
  76274. damping?: number;
  76275. /**
  76276. * The path for a rope based on an extrusion
  76277. */
  76278. path?: any;
  76279. /**
  76280. * The shape of an extrusion used for a rope based on an extrusion
  76281. */
  76282. shape?: any;
  76283. }
  76284. /**
  76285. * Interface for a physics-enabled object
  76286. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76287. */
  76288. export interface IPhysicsEnabledObject {
  76289. /**
  76290. * The position of the physics-enabled object
  76291. */
  76292. position: Vector3;
  76293. /**
  76294. * The rotation of the physics-enabled object
  76295. */
  76296. rotationQuaternion: Nullable<Quaternion>;
  76297. /**
  76298. * The scale of the physics-enabled object
  76299. */
  76300. scaling: Vector3;
  76301. /**
  76302. * The rotation of the physics-enabled object
  76303. */
  76304. rotation?: Vector3;
  76305. /**
  76306. * The parent of the physics-enabled object
  76307. */
  76308. parent?: any;
  76309. /**
  76310. * The bounding info of the physics-enabled object
  76311. * @returns The bounding info of the physics-enabled object
  76312. */
  76313. getBoundingInfo(): BoundingInfo;
  76314. /**
  76315. * Computes the world matrix
  76316. * @param force Specifies if the world matrix should be computed by force
  76317. * @returns A world matrix
  76318. */
  76319. computeWorldMatrix(force: boolean): Matrix;
  76320. /**
  76321. * Gets the world matrix
  76322. * @returns A world matrix
  76323. */
  76324. getWorldMatrix?(): Matrix;
  76325. /**
  76326. * Gets the child meshes
  76327. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  76328. * @returns An array of abstract meshes
  76329. */
  76330. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  76331. /**
  76332. * Gets the vertex data
  76333. * @param kind The type of vertex data
  76334. * @returns A nullable array of numbers, or a float32 array
  76335. */
  76336. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  76337. /**
  76338. * Gets the indices from the mesh
  76339. * @returns A nullable array of index arrays
  76340. */
  76341. getIndices?(): Nullable<IndicesArray>;
  76342. /**
  76343. * Gets the scene from the mesh
  76344. * @returns the indices array or null
  76345. */
  76346. getScene?(): Scene;
  76347. /**
  76348. * Gets the absolute position from the mesh
  76349. * @returns the absolute position
  76350. */
  76351. getAbsolutePosition(): Vector3;
  76352. /**
  76353. * Gets the absolute pivot point from the mesh
  76354. * @returns the absolute pivot point
  76355. */
  76356. getAbsolutePivotPoint(): Vector3;
  76357. /**
  76358. * Rotates the mesh
  76359. * @param axis The axis of rotation
  76360. * @param amount The amount of rotation
  76361. * @param space The space of the rotation
  76362. * @returns The rotation transform node
  76363. */
  76364. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  76365. /**
  76366. * Translates the mesh
  76367. * @param axis The axis of translation
  76368. * @param distance The distance of translation
  76369. * @param space The space of the translation
  76370. * @returns The transform node
  76371. */
  76372. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  76373. /**
  76374. * Sets the absolute position of the mesh
  76375. * @param absolutePosition The absolute position of the mesh
  76376. * @returns The transform node
  76377. */
  76378. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  76379. /**
  76380. * Gets the class name of the mesh
  76381. * @returns The class name
  76382. */
  76383. getClassName(): string;
  76384. }
  76385. /**
  76386. * Represents a physics imposter
  76387. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76388. */
  76389. export class PhysicsImpostor {
  76390. /**
  76391. * The physics-enabled object used as the physics imposter
  76392. */
  76393. object: IPhysicsEnabledObject;
  76394. /**
  76395. * The type of the physics imposter
  76396. */
  76397. type: number;
  76398. private _options;
  76399. private _scene?;
  76400. /**
  76401. * The default object size of the imposter
  76402. */
  76403. static DEFAULT_OBJECT_SIZE: Vector3;
  76404. /**
  76405. * The identity quaternion of the imposter
  76406. */
  76407. static IDENTITY_QUATERNION: Quaternion;
  76408. /** @hidden */
  76409. _pluginData: any;
  76410. private _physicsEngine;
  76411. private _physicsBody;
  76412. private _bodyUpdateRequired;
  76413. private _onBeforePhysicsStepCallbacks;
  76414. private _onAfterPhysicsStepCallbacks;
  76415. /** @hidden */
  76416. _onPhysicsCollideCallbacks: Array<{
  76417. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  76418. otherImpostors: Array<PhysicsImpostor>;
  76419. }>;
  76420. private _deltaPosition;
  76421. private _deltaRotation;
  76422. private _deltaRotationConjugated;
  76423. /** @hidden */
  76424. _isFromLine: boolean;
  76425. private _parent;
  76426. private _isDisposed;
  76427. private static _tmpVecs;
  76428. private static _tmpQuat;
  76429. /**
  76430. * Specifies if the physics imposter is disposed
  76431. */
  76432. readonly isDisposed: boolean;
  76433. /**
  76434. * Gets the mass of the physics imposter
  76435. */
  76436. mass: number;
  76437. /**
  76438. * Gets the coefficient of friction
  76439. */
  76440. /**
  76441. * Sets the coefficient of friction
  76442. */
  76443. friction: number;
  76444. /**
  76445. * Gets the coefficient of restitution
  76446. */
  76447. /**
  76448. * Sets the coefficient of restitution
  76449. */
  76450. restitution: number;
  76451. /**
  76452. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  76453. */
  76454. /**
  76455. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  76456. */
  76457. pressure: number;
  76458. /**
  76459. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  76460. */
  76461. /**
  76462. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  76463. */
  76464. stiffness: number;
  76465. /**
  76466. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  76467. */
  76468. /**
  76469. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  76470. */
  76471. velocityIterations: number;
  76472. /**
  76473. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  76474. */
  76475. /**
  76476. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  76477. */
  76478. positionIterations: number;
  76479. /**
  76480. * The unique id of the physics imposter
  76481. * set by the physics engine when adding this impostor to the array
  76482. */
  76483. uniqueId: number;
  76484. /**
  76485. * @hidden
  76486. */
  76487. soft: boolean;
  76488. /**
  76489. * @hidden
  76490. */
  76491. segments: number;
  76492. private _joints;
  76493. /**
  76494. * Initializes the physics imposter
  76495. * @param object The physics-enabled object used as the physics imposter
  76496. * @param type The type of the physics imposter
  76497. * @param _options The options for the physics imposter
  76498. * @param _scene The Babylon scene
  76499. */
  76500. constructor(
  76501. /**
  76502. * The physics-enabled object used as the physics imposter
  76503. */
  76504. object: IPhysicsEnabledObject,
  76505. /**
  76506. * The type of the physics imposter
  76507. */
  76508. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  76509. /**
  76510. * This function will completly initialize this impostor.
  76511. * It will create a new body - but only if this mesh has no parent.
  76512. * If it has, this impostor will not be used other than to define the impostor
  76513. * of the child mesh.
  76514. * @hidden
  76515. */
  76516. _init(): void;
  76517. private _getPhysicsParent;
  76518. /**
  76519. * Should a new body be generated.
  76520. * @returns boolean specifying if body initialization is required
  76521. */
  76522. isBodyInitRequired(): boolean;
  76523. /**
  76524. * Sets the updated scaling
  76525. * @param updated Specifies if the scaling is updated
  76526. */
  76527. setScalingUpdated(): void;
  76528. /**
  76529. * Force a regeneration of this or the parent's impostor's body.
  76530. * Use under cautious - This will remove all joints already implemented.
  76531. */
  76532. forceUpdate(): void;
  76533. /**
  76534. * Gets the body that holds this impostor. Either its own, or its parent.
  76535. */
  76536. /**
  76537. * Set the physics body. Used mainly by the physics engine/plugin
  76538. */
  76539. physicsBody: any;
  76540. /**
  76541. * Get the parent of the physics imposter
  76542. * @returns Physics imposter or null
  76543. */
  76544. /**
  76545. * Sets the parent of the physics imposter
  76546. */
  76547. parent: Nullable<PhysicsImpostor>;
  76548. /**
  76549. * Resets the update flags
  76550. */
  76551. resetUpdateFlags(): void;
  76552. /**
  76553. * Gets the object extend size
  76554. * @returns the object extend size
  76555. */
  76556. getObjectExtendSize(): Vector3;
  76557. /**
  76558. * Gets the object center
  76559. * @returns The object center
  76560. */
  76561. getObjectCenter(): Vector3;
  76562. /**
  76563. * Get a specific parametes from the options parameter
  76564. * @param paramName The object parameter name
  76565. * @returns The object parameter
  76566. */
  76567. getParam(paramName: string): any;
  76568. /**
  76569. * Sets a specific parameter in the options given to the physics plugin
  76570. * @param paramName The parameter name
  76571. * @param value The value of the parameter
  76572. */
  76573. setParam(paramName: string, value: number): void;
  76574. /**
  76575. * Specifically change the body's mass option. Won't recreate the physics body object
  76576. * @param mass The mass of the physics imposter
  76577. */
  76578. setMass(mass: number): void;
  76579. /**
  76580. * Gets the linear velocity
  76581. * @returns linear velocity or null
  76582. */
  76583. getLinearVelocity(): Nullable<Vector3>;
  76584. /**
  76585. * Sets the linear velocity
  76586. * @param velocity linear velocity or null
  76587. */
  76588. setLinearVelocity(velocity: Nullable<Vector3>): void;
  76589. /**
  76590. * Gets the angular velocity
  76591. * @returns angular velocity or null
  76592. */
  76593. getAngularVelocity(): Nullable<Vector3>;
  76594. /**
  76595. * Sets the angular velocity
  76596. * @param velocity The velocity or null
  76597. */
  76598. setAngularVelocity(velocity: Nullable<Vector3>): void;
  76599. /**
  76600. * Execute a function with the physics plugin native code
  76601. * Provide a function the will have two variables - the world object and the physics body object
  76602. * @param func The function to execute with the physics plugin native code
  76603. */
  76604. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  76605. /**
  76606. * Register a function that will be executed before the physics world is stepping forward
  76607. * @param func The function to execute before the physics world is stepped forward
  76608. */
  76609. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  76610. /**
  76611. * Unregister a function that will be executed before the physics world is stepping forward
  76612. * @param func The function to execute before the physics world is stepped forward
  76613. */
  76614. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  76615. /**
  76616. * Register a function that will be executed after the physics step
  76617. * @param func The function to execute after physics step
  76618. */
  76619. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  76620. /**
  76621. * Unregisters a function that will be executed after the physics step
  76622. * @param func The function to execute after physics step
  76623. */
  76624. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  76625. /**
  76626. * register a function that will be executed when this impostor collides against a different body
  76627. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  76628. * @param func Callback that is executed on collision
  76629. */
  76630. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  76631. /**
  76632. * Unregisters the physics imposter on contact
  76633. * @param collideAgainst The physics object to collide against
  76634. * @param func Callback to execute on collision
  76635. */
  76636. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  76637. private _tmpQuat;
  76638. private _tmpQuat2;
  76639. /**
  76640. * Get the parent rotation
  76641. * @returns The parent rotation
  76642. */
  76643. getParentsRotation(): Quaternion;
  76644. /**
  76645. * this function is executed by the physics engine.
  76646. */
  76647. beforeStep: () => void;
  76648. /**
  76649. * this function is executed by the physics engine
  76650. */
  76651. afterStep: () => void;
  76652. /**
  76653. * Legacy collision detection event support
  76654. */
  76655. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  76656. /**
  76657. * event and body object due to cannon's event-based architecture.
  76658. */
  76659. onCollide: (e: {
  76660. body: any;
  76661. }) => void;
  76662. /**
  76663. * Apply a force
  76664. * @param force The force to apply
  76665. * @param contactPoint The contact point for the force
  76666. * @returns The physics imposter
  76667. */
  76668. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  76669. /**
  76670. * Apply an impulse
  76671. * @param force The impulse force
  76672. * @param contactPoint The contact point for the impulse force
  76673. * @returns The physics imposter
  76674. */
  76675. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  76676. /**
  76677. * A help function to create a joint
  76678. * @param otherImpostor A physics imposter used to create a joint
  76679. * @param jointType The type of joint
  76680. * @param jointData The data for the joint
  76681. * @returns The physics imposter
  76682. */
  76683. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  76684. /**
  76685. * Add a joint to this impostor with a different impostor
  76686. * @param otherImpostor A physics imposter used to add a joint
  76687. * @param joint The joint to add
  76688. * @returns The physics imposter
  76689. */
  76690. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  76691. /**
  76692. * Add an anchor to a cloth impostor
  76693. * @param otherImpostor rigid impostor to anchor to
  76694. * @param width ratio across width from 0 to 1
  76695. * @param height ratio up height from 0 to 1
  76696. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  76697. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  76698. * @returns impostor the soft imposter
  76699. */
  76700. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  76701. /**
  76702. * Add a hook to a rope impostor
  76703. * @param otherImpostor rigid impostor to anchor to
  76704. * @param length ratio across rope from 0 to 1
  76705. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  76706. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  76707. * @returns impostor the rope imposter
  76708. */
  76709. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  76710. /**
  76711. * Will keep this body still, in a sleep mode.
  76712. * @returns the physics imposter
  76713. */
  76714. sleep(): PhysicsImpostor;
  76715. /**
  76716. * Wake the body up.
  76717. * @returns The physics imposter
  76718. */
  76719. wakeUp(): PhysicsImpostor;
  76720. /**
  76721. * Clones the physics imposter
  76722. * @param newObject The physics imposter clones to this physics-enabled object
  76723. * @returns A nullable physics imposter
  76724. */
  76725. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  76726. /**
  76727. * Disposes the physics imposter
  76728. */
  76729. dispose(): void;
  76730. /**
  76731. * Sets the delta position
  76732. * @param position The delta position amount
  76733. */
  76734. setDeltaPosition(position: Vector3): void;
  76735. /**
  76736. * Sets the delta rotation
  76737. * @param rotation The delta rotation amount
  76738. */
  76739. setDeltaRotation(rotation: Quaternion): void;
  76740. /**
  76741. * Gets the box size of the physics imposter and stores the result in the input parameter
  76742. * @param result Stores the box size
  76743. * @returns The physics imposter
  76744. */
  76745. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  76746. /**
  76747. * Gets the radius of the physics imposter
  76748. * @returns Radius of the physics imposter
  76749. */
  76750. getRadius(): number;
  76751. /**
  76752. * Sync a bone with this impostor
  76753. * @param bone The bone to sync to the impostor.
  76754. * @param boneMesh The mesh that the bone is influencing.
  76755. * @param jointPivot The pivot of the joint / bone in local space.
  76756. * @param distToJoint Optional distance from the impostor to the joint.
  76757. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  76758. */
  76759. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  76760. /**
  76761. * Sync impostor to a bone
  76762. * @param bone The bone that the impostor will be synced to.
  76763. * @param boneMesh The mesh that the bone is influencing.
  76764. * @param jointPivot The pivot of the joint / bone in local space.
  76765. * @param distToJoint Optional distance from the impostor to the joint.
  76766. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  76767. * @param boneAxis Optional vector3 axis the bone is aligned with
  76768. */
  76769. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  76770. /**
  76771. * No-Imposter type
  76772. */
  76773. static NoImpostor: number;
  76774. /**
  76775. * Sphere-Imposter type
  76776. */
  76777. static SphereImpostor: number;
  76778. /**
  76779. * Box-Imposter type
  76780. */
  76781. static BoxImpostor: number;
  76782. /**
  76783. * Plane-Imposter type
  76784. */
  76785. static PlaneImpostor: number;
  76786. /**
  76787. * Mesh-imposter type
  76788. */
  76789. static MeshImpostor: number;
  76790. /**
  76791. * Capsule-Impostor type (Ammo.js plugin only)
  76792. */
  76793. static CapsuleImpostor: number;
  76794. /**
  76795. * Cylinder-Imposter type
  76796. */
  76797. static CylinderImpostor: number;
  76798. /**
  76799. * Particle-Imposter type
  76800. */
  76801. static ParticleImpostor: number;
  76802. /**
  76803. * Heightmap-Imposter type
  76804. */
  76805. static HeightmapImpostor: number;
  76806. /**
  76807. * ConvexHull-Impostor type (Ammo.js plugin only)
  76808. */
  76809. static ConvexHullImpostor: number;
  76810. /**
  76811. * Rope-Imposter type
  76812. */
  76813. static RopeImpostor: number;
  76814. /**
  76815. * Cloth-Imposter type
  76816. */
  76817. static ClothImpostor: number;
  76818. /**
  76819. * Softbody-Imposter type
  76820. */
  76821. static SoftbodyImpostor: number;
  76822. }
  76823. }
  76824. declare module BABYLON {
  76825. /**
  76826. * @hidden
  76827. **/
  76828. export class _CreationDataStorage {
  76829. closePath?: boolean;
  76830. closeArray?: boolean;
  76831. idx: number[];
  76832. dashSize: number;
  76833. gapSize: number;
  76834. path3D: Path3D;
  76835. pathArray: Vector3[][];
  76836. arc: number;
  76837. radius: number;
  76838. cap: number;
  76839. tessellation: number;
  76840. }
  76841. /**
  76842. * @hidden
  76843. **/
  76844. class _InstanceDataStorage {
  76845. visibleInstances: any;
  76846. batchCache: _InstancesBatch;
  76847. instancesBufferSize: number;
  76848. instancesBuffer: Nullable<Buffer>;
  76849. instancesData: Float32Array;
  76850. overridenInstanceCount: number;
  76851. isFrozen: boolean;
  76852. previousBatch: Nullable<_InstancesBatch>;
  76853. hardwareInstancedRendering: boolean;
  76854. sideOrientation: number;
  76855. }
  76856. /**
  76857. * @hidden
  76858. **/
  76859. export class _InstancesBatch {
  76860. mustReturn: boolean;
  76861. visibleInstances: Nullable<InstancedMesh[]>[];
  76862. renderSelf: boolean[];
  76863. hardwareInstancedRendering: boolean[];
  76864. }
  76865. /**
  76866. * Class used to represent renderable models
  76867. */
  76868. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  76869. /**
  76870. * Mesh side orientation : usually the external or front surface
  76871. */
  76872. static readonly FRONTSIDE: number;
  76873. /**
  76874. * Mesh side orientation : usually the internal or back surface
  76875. */
  76876. static readonly BACKSIDE: number;
  76877. /**
  76878. * Mesh side orientation : both internal and external or front and back surfaces
  76879. */
  76880. static readonly DOUBLESIDE: number;
  76881. /**
  76882. * Mesh side orientation : by default, `FRONTSIDE`
  76883. */
  76884. static readonly DEFAULTSIDE: number;
  76885. /**
  76886. * Mesh cap setting : no cap
  76887. */
  76888. static readonly NO_CAP: number;
  76889. /**
  76890. * Mesh cap setting : one cap at the beginning of the mesh
  76891. */
  76892. static readonly CAP_START: number;
  76893. /**
  76894. * Mesh cap setting : one cap at the end of the mesh
  76895. */
  76896. static readonly CAP_END: number;
  76897. /**
  76898. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  76899. */
  76900. static readonly CAP_ALL: number;
  76901. /**
  76902. * Mesh pattern setting : no flip or rotate
  76903. */
  76904. static readonly NO_FLIP: number;
  76905. /**
  76906. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  76907. */
  76908. static readonly FLIP_TILE: number;
  76909. /**
  76910. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  76911. */
  76912. static readonly ROTATE_TILE: number;
  76913. /**
  76914. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  76915. */
  76916. static readonly FLIP_ROW: number;
  76917. /**
  76918. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  76919. */
  76920. static readonly ROTATE_ROW: number;
  76921. /**
  76922. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  76923. */
  76924. static readonly FLIP_N_ROTATE_TILE: number;
  76925. /**
  76926. * Mesh pattern setting : rotate pattern and rotate
  76927. */
  76928. static readonly FLIP_N_ROTATE_ROW: number;
  76929. /**
  76930. * Mesh tile positioning : part tiles same on left/right or top/bottom
  76931. */
  76932. static readonly CENTER: number;
  76933. /**
  76934. * Mesh tile positioning : part tiles on left
  76935. */
  76936. static readonly LEFT: number;
  76937. /**
  76938. * Mesh tile positioning : part tiles on right
  76939. */
  76940. static readonly RIGHT: number;
  76941. /**
  76942. * Mesh tile positioning : part tiles on top
  76943. */
  76944. static readonly TOP: number;
  76945. /**
  76946. * Mesh tile positioning : part tiles on bottom
  76947. */
  76948. static readonly BOTTOM: number;
  76949. /**
  76950. * Gets the default side orientation.
  76951. * @param orientation the orientation to value to attempt to get
  76952. * @returns the default orientation
  76953. * @hidden
  76954. */
  76955. static _GetDefaultSideOrientation(orientation?: number): number;
  76956. private _internalMeshDataInfo;
  76957. /**
  76958. * An event triggered before rendering the mesh
  76959. */
  76960. readonly onBeforeRenderObservable: Observable<Mesh>;
  76961. /**
  76962. * An event triggered before binding the mesh
  76963. */
  76964. readonly onBeforeBindObservable: Observable<Mesh>;
  76965. /**
  76966. * An event triggered after rendering the mesh
  76967. */
  76968. readonly onAfterRenderObservable: Observable<Mesh>;
  76969. /**
  76970. * An event triggered before drawing the mesh
  76971. */
  76972. readonly onBeforeDrawObservable: Observable<Mesh>;
  76973. private _onBeforeDrawObserver;
  76974. /**
  76975. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  76976. */
  76977. onBeforeDraw: () => void;
  76978. /**
  76979. * Gets the delay loading state of the mesh (when delay loading is turned on)
  76980. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  76981. */
  76982. delayLoadState: number;
  76983. /**
  76984. * Gets the list of instances created from this mesh
  76985. * it is not supposed to be modified manually.
  76986. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  76987. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  76988. */
  76989. instances: InstancedMesh[];
  76990. /**
  76991. * Gets the file containing delay loading data for this mesh
  76992. */
  76993. delayLoadingFile: string;
  76994. /** @hidden */
  76995. _binaryInfo: any;
  76996. /**
  76997. * User defined function used to change how LOD level selection is done
  76998. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  76999. */
  77000. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  77001. /**
  77002. * Gets or sets the morph target manager
  77003. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  77004. */
  77005. morphTargetManager: Nullable<MorphTargetManager>;
  77006. /** @hidden */
  77007. _creationDataStorage: Nullable<_CreationDataStorage>;
  77008. /** @hidden */
  77009. _geometry: Nullable<Geometry>;
  77010. /** @hidden */
  77011. _delayInfo: Array<string>;
  77012. /** @hidden */
  77013. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  77014. /** @hidden */
  77015. _instanceDataStorage: _InstanceDataStorage;
  77016. private _effectiveMaterial;
  77017. /** @hidden */
  77018. _shouldGenerateFlatShading: boolean;
  77019. /** @hidden */
  77020. _originalBuilderSideOrientation: number;
  77021. /**
  77022. * Use this property to change the original side orientation defined at construction time
  77023. */
  77024. overrideMaterialSideOrientation: Nullable<number>;
  77025. /**
  77026. * Gets the source mesh (the one used to clone this one from)
  77027. */
  77028. readonly source: Nullable<Mesh>;
  77029. /**
  77030. * Gets or sets a boolean indicating that this mesh does not use index buffer
  77031. */
  77032. isUnIndexed: boolean;
  77033. /**
  77034. * @constructor
  77035. * @param name The value used by scene.getMeshByName() to do a lookup.
  77036. * @param scene The scene to add this mesh to.
  77037. * @param parent The parent of this mesh, if it has one
  77038. * @param source An optional Mesh from which geometry is shared, cloned.
  77039. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  77040. * When false, achieved by calling a clone(), also passing False.
  77041. * This will make creation of children, recursive.
  77042. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  77043. */
  77044. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  77045. /**
  77046. * Gets the class name
  77047. * @returns the string "Mesh".
  77048. */
  77049. getClassName(): string;
  77050. /** @hidden */
  77051. readonly _isMesh: boolean;
  77052. /**
  77053. * Returns a description of this mesh
  77054. * @param fullDetails define if full details about this mesh must be used
  77055. * @returns a descriptive string representing this mesh
  77056. */
  77057. toString(fullDetails?: boolean): string;
  77058. /** @hidden */
  77059. _unBindEffect(): void;
  77060. /**
  77061. * Gets a boolean indicating if this mesh has LOD
  77062. */
  77063. readonly hasLODLevels: boolean;
  77064. /**
  77065. * Gets the list of MeshLODLevel associated with the current mesh
  77066. * @returns an array of MeshLODLevel
  77067. */
  77068. getLODLevels(): MeshLODLevel[];
  77069. private _sortLODLevels;
  77070. /**
  77071. * Add a mesh as LOD level triggered at the given distance.
  77072. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  77073. * @param distance The distance from the center of the object to show this level
  77074. * @param mesh The mesh to be added as LOD level (can be null)
  77075. * @return This mesh (for chaining)
  77076. */
  77077. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  77078. /**
  77079. * Returns the LOD level mesh at the passed distance or null if not found.
  77080. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  77081. * @param distance The distance from the center of the object to show this level
  77082. * @returns a Mesh or `null`
  77083. */
  77084. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  77085. /**
  77086. * Remove a mesh from the LOD array
  77087. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  77088. * @param mesh defines the mesh to be removed
  77089. * @return This mesh (for chaining)
  77090. */
  77091. removeLODLevel(mesh: Mesh): Mesh;
  77092. /**
  77093. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  77094. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  77095. * @param camera defines the camera to use to compute distance
  77096. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  77097. * @return This mesh (for chaining)
  77098. */
  77099. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  77100. /**
  77101. * Gets the mesh internal Geometry object
  77102. */
  77103. readonly geometry: Nullable<Geometry>;
  77104. /**
  77105. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  77106. * @returns the total number of vertices
  77107. */
  77108. getTotalVertices(): number;
  77109. /**
  77110. * Returns the content of an associated vertex buffer
  77111. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  77112. * - VertexBuffer.PositionKind
  77113. * - VertexBuffer.UVKind
  77114. * - VertexBuffer.UV2Kind
  77115. * - VertexBuffer.UV3Kind
  77116. * - VertexBuffer.UV4Kind
  77117. * - VertexBuffer.UV5Kind
  77118. * - VertexBuffer.UV6Kind
  77119. * - VertexBuffer.ColorKind
  77120. * - VertexBuffer.MatricesIndicesKind
  77121. * - VertexBuffer.MatricesIndicesExtraKind
  77122. * - VertexBuffer.MatricesWeightsKind
  77123. * - VertexBuffer.MatricesWeightsExtraKind
  77124. * @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
  77125. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  77126. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  77127. */
  77128. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  77129. /**
  77130. * Returns the mesh VertexBuffer object from the requested `kind`
  77131. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  77132. * - VertexBuffer.PositionKind
  77133. * - VertexBuffer.NormalKind
  77134. * - VertexBuffer.UVKind
  77135. * - VertexBuffer.UV2Kind
  77136. * - VertexBuffer.UV3Kind
  77137. * - VertexBuffer.UV4Kind
  77138. * - VertexBuffer.UV5Kind
  77139. * - VertexBuffer.UV6Kind
  77140. * - VertexBuffer.ColorKind
  77141. * - VertexBuffer.MatricesIndicesKind
  77142. * - VertexBuffer.MatricesIndicesExtraKind
  77143. * - VertexBuffer.MatricesWeightsKind
  77144. * - VertexBuffer.MatricesWeightsExtraKind
  77145. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  77146. */
  77147. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  77148. /**
  77149. * Tests if a specific vertex buffer is associated with this mesh
  77150. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  77151. * - VertexBuffer.PositionKind
  77152. * - VertexBuffer.NormalKind
  77153. * - VertexBuffer.UVKind
  77154. * - VertexBuffer.UV2Kind
  77155. * - VertexBuffer.UV3Kind
  77156. * - VertexBuffer.UV4Kind
  77157. * - VertexBuffer.UV5Kind
  77158. * - VertexBuffer.UV6Kind
  77159. * - VertexBuffer.ColorKind
  77160. * - VertexBuffer.MatricesIndicesKind
  77161. * - VertexBuffer.MatricesIndicesExtraKind
  77162. * - VertexBuffer.MatricesWeightsKind
  77163. * - VertexBuffer.MatricesWeightsExtraKind
  77164. * @returns a boolean
  77165. */
  77166. isVerticesDataPresent(kind: string): boolean;
  77167. /**
  77168. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  77169. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  77170. * - VertexBuffer.PositionKind
  77171. * - VertexBuffer.UVKind
  77172. * - VertexBuffer.UV2Kind
  77173. * - VertexBuffer.UV3Kind
  77174. * - VertexBuffer.UV4Kind
  77175. * - VertexBuffer.UV5Kind
  77176. * - VertexBuffer.UV6Kind
  77177. * - VertexBuffer.ColorKind
  77178. * - VertexBuffer.MatricesIndicesKind
  77179. * - VertexBuffer.MatricesIndicesExtraKind
  77180. * - VertexBuffer.MatricesWeightsKind
  77181. * - VertexBuffer.MatricesWeightsExtraKind
  77182. * @returns a boolean
  77183. */
  77184. isVertexBufferUpdatable(kind: string): boolean;
  77185. /**
  77186. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  77187. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  77188. * - VertexBuffer.PositionKind
  77189. * - VertexBuffer.NormalKind
  77190. * - VertexBuffer.UVKind
  77191. * - VertexBuffer.UV2Kind
  77192. * - VertexBuffer.UV3Kind
  77193. * - VertexBuffer.UV4Kind
  77194. * - VertexBuffer.UV5Kind
  77195. * - VertexBuffer.UV6Kind
  77196. * - VertexBuffer.ColorKind
  77197. * - VertexBuffer.MatricesIndicesKind
  77198. * - VertexBuffer.MatricesIndicesExtraKind
  77199. * - VertexBuffer.MatricesWeightsKind
  77200. * - VertexBuffer.MatricesWeightsExtraKind
  77201. * @returns an array of strings
  77202. */
  77203. getVerticesDataKinds(): string[];
  77204. /**
  77205. * Returns a positive integer : the total number of indices in this mesh geometry.
  77206. * @returns the numner of indices or zero if the mesh has no geometry.
  77207. */
  77208. getTotalIndices(): number;
  77209. /**
  77210. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  77211. * @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.
  77212. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  77213. * @returns the indices array or an empty array if the mesh has no geometry
  77214. */
  77215. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  77216. readonly isBlocked: boolean;
  77217. /**
  77218. * Determine if the current mesh is ready to be rendered
  77219. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  77220. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  77221. * @returns true if all associated assets are ready (material, textures, shaders)
  77222. */
  77223. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  77224. /**
  77225. * 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.
  77226. */
  77227. readonly areNormalsFrozen: boolean;
  77228. /**
  77229. * 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.
  77230. * @returns the current mesh
  77231. */
  77232. freezeNormals(): Mesh;
  77233. /**
  77234. * 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
  77235. * @returns the current mesh
  77236. */
  77237. unfreezeNormals(): Mesh;
  77238. /**
  77239. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  77240. */
  77241. overridenInstanceCount: number;
  77242. /** @hidden */
  77243. _preActivate(): Mesh;
  77244. /** @hidden */
  77245. _preActivateForIntermediateRendering(renderId: number): Mesh;
  77246. /** @hidden */
  77247. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  77248. /**
  77249. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  77250. * This means the mesh underlying bounding box and sphere are recomputed.
  77251. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  77252. * @returns the current mesh
  77253. */
  77254. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  77255. /** @hidden */
  77256. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  77257. /**
  77258. * This function will subdivide the mesh into multiple submeshes
  77259. * @param count defines the expected number of submeshes
  77260. */
  77261. subdivide(count: number): void;
  77262. /**
  77263. * Copy a FloatArray into a specific associated vertex buffer
  77264. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  77265. * - VertexBuffer.PositionKind
  77266. * - VertexBuffer.UVKind
  77267. * - VertexBuffer.UV2Kind
  77268. * - VertexBuffer.UV3Kind
  77269. * - VertexBuffer.UV4Kind
  77270. * - VertexBuffer.UV5Kind
  77271. * - VertexBuffer.UV6Kind
  77272. * - VertexBuffer.ColorKind
  77273. * - VertexBuffer.MatricesIndicesKind
  77274. * - VertexBuffer.MatricesIndicesExtraKind
  77275. * - VertexBuffer.MatricesWeightsKind
  77276. * - VertexBuffer.MatricesWeightsExtraKind
  77277. * @param data defines the data source
  77278. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  77279. * @param stride defines the data stride size (can be null)
  77280. * @returns the current mesh
  77281. */
  77282. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  77283. /**
  77284. * Flags an associated vertex buffer as updatable
  77285. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  77286. * - VertexBuffer.PositionKind
  77287. * - VertexBuffer.UVKind
  77288. * - VertexBuffer.UV2Kind
  77289. * - VertexBuffer.UV3Kind
  77290. * - VertexBuffer.UV4Kind
  77291. * - VertexBuffer.UV5Kind
  77292. * - VertexBuffer.UV6Kind
  77293. * - VertexBuffer.ColorKind
  77294. * - VertexBuffer.MatricesIndicesKind
  77295. * - VertexBuffer.MatricesIndicesExtraKind
  77296. * - VertexBuffer.MatricesWeightsKind
  77297. * - VertexBuffer.MatricesWeightsExtraKind
  77298. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  77299. */
  77300. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  77301. /**
  77302. * Sets the mesh global Vertex Buffer
  77303. * @param buffer defines the buffer to use
  77304. * @returns the current mesh
  77305. */
  77306. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  77307. /**
  77308. * Update a specific associated vertex buffer
  77309. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  77310. * - VertexBuffer.PositionKind
  77311. * - VertexBuffer.UVKind
  77312. * - VertexBuffer.UV2Kind
  77313. * - VertexBuffer.UV3Kind
  77314. * - VertexBuffer.UV4Kind
  77315. * - VertexBuffer.UV5Kind
  77316. * - VertexBuffer.UV6Kind
  77317. * - VertexBuffer.ColorKind
  77318. * - VertexBuffer.MatricesIndicesKind
  77319. * - VertexBuffer.MatricesIndicesExtraKind
  77320. * - VertexBuffer.MatricesWeightsKind
  77321. * - VertexBuffer.MatricesWeightsExtraKind
  77322. * @param data defines the data source
  77323. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  77324. * @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)
  77325. * @returns the current mesh
  77326. */
  77327. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  77328. /**
  77329. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  77330. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  77331. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  77332. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  77333. * @returns the current mesh
  77334. */
  77335. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  77336. /**
  77337. * Creates a un-shared specific occurence of the geometry for the mesh.
  77338. * @returns the current mesh
  77339. */
  77340. makeGeometryUnique(): Mesh;
  77341. /**
  77342. * Set the index buffer of this mesh
  77343. * @param indices defines the source data
  77344. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  77345. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  77346. * @returns the current mesh
  77347. */
  77348. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  77349. /**
  77350. * Update the current index buffer
  77351. * @param indices defines the source data
  77352. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  77353. * @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)
  77354. * @returns the current mesh
  77355. */
  77356. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  77357. /**
  77358. * Invert the geometry to move from a right handed system to a left handed one.
  77359. * @returns the current mesh
  77360. */
  77361. toLeftHanded(): Mesh;
  77362. /** @hidden */
  77363. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  77364. /** @hidden */
  77365. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  77366. /**
  77367. * Registers for this mesh a javascript function called just before the rendering process
  77368. * @param func defines the function to call before rendering this mesh
  77369. * @returns the current mesh
  77370. */
  77371. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  77372. /**
  77373. * Disposes a previously registered javascript function called before the rendering
  77374. * @param func defines the function to remove
  77375. * @returns the current mesh
  77376. */
  77377. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  77378. /**
  77379. * Registers for this mesh a javascript function called just after the rendering is complete
  77380. * @param func defines the function to call after rendering this mesh
  77381. * @returns the current mesh
  77382. */
  77383. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  77384. /**
  77385. * Disposes a previously registered javascript function called after the rendering.
  77386. * @param func defines the function to remove
  77387. * @returns the current mesh
  77388. */
  77389. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  77390. /** @hidden */
  77391. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  77392. /** @hidden */
  77393. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  77394. /** @hidden */
  77395. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  77396. /** @hidden */
  77397. _rebuild(): void;
  77398. /** @hidden */
  77399. _freeze(): void;
  77400. /** @hidden */
  77401. _unFreeze(): void;
  77402. /**
  77403. * 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
  77404. * @param subMesh defines the subMesh to render
  77405. * @param enableAlphaMode defines if alpha mode can be changed
  77406. * @returns the current mesh
  77407. */
  77408. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  77409. private _onBeforeDraw;
  77410. /**
  77411. * Renormalize the mesh and patch it up if there are no weights
  77412. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  77413. * However in the case of zero weights then we set just a single influence to 1.
  77414. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  77415. */
  77416. cleanMatrixWeights(): void;
  77417. private normalizeSkinFourWeights;
  77418. private normalizeSkinWeightsAndExtra;
  77419. /**
  77420. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  77421. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  77422. * the user know there was an issue with importing the mesh
  77423. * @returns a validation object with skinned, valid and report string
  77424. */
  77425. validateSkinning(): {
  77426. skinned: boolean;
  77427. valid: boolean;
  77428. report: string;
  77429. };
  77430. /** @hidden */
  77431. _checkDelayState(): Mesh;
  77432. private _queueLoad;
  77433. /**
  77434. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  77435. * A mesh is in the frustum if its bounding box intersects the frustum
  77436. * @param frustumPlanes defines the frustum to test
  77437. * @returns true if the mesh is in the frustum planes
  77438. */
  77439. isInFrustum(frustumPlanes: Plane[]): boolean;
  77440. /**
  77441. * Sets the mesh material by the material or multiMaterial `id` property
  77442. * @param id is a string identifying the material or the multiMaterial
  77443. * @returns the current mesh
  77444. */
  77445. setMaterialByID(id: string): Mesh;
  77446. /**
  77447. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  77448. * @returns an array of IAnimatable
  77449. */
  77450. getAnimatables(): IAnimatable[];
  77451. /**
  77452. * Modifies the mesh geometry according to the passed transformation matrix.
  77453. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  77454. * The mesh normals are modified using the same transformation.
  77455. * Note that, under the hood, this method sets a new VertexBuffer each call.
  77456. * @param transform defines the transform matrix to use
  77457. * @see http://doc.babylonjs.com/resources/baking_transformations
  77458. * @returns the current mesh
  77459. */
  77460. bakeTransformIntoVertices(transform: Matrix): Mesh;
  77461. /**
  77462. * Modifies the mesh geometry according to its own current World Matrix.
  77463. * The mesh World Matrix is then reset.
  77464. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  77465. * Note that, under the hood, this method sets a new VertexBuffer each call.
  77466. * @see http://doc.babylonjs.com/resources/baking_transformations
  77467. * @returns the current mesh
  77468. */
  77469. bakeCurrentTransformIntoVertices(): Mesh;
  77470. /** @hidden */
  77471. readonly _positions: Nullable<Vector3[]>;
  77472. /** @hidden */
  77473. _resetPointsArrayCache(): Mesh;
  77474. /** @hidden */
  77475. _generatePointsArray(): boolean;
  77476. /**
  77477. * Returns a new Mesh object generated from the current mesh properties.
  77478. * This method must not get confused with createInstance()
  77479. * @param name is a string, the name given to the new mesh
  77480. * @param newParent can be any Node object (default `null`)
  77481. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  77482. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  77483. * @returns a new mesh
  77484. */
  77485. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  77486. /**
  77487. * Releases resources associated with this mesh.
  77488. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  77489. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  77490. */
  77491. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  77492. /**
  77493. * Modifies the mesh geometry according to a displacement map.
  77494. * 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.
  77495. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  77496. * @param url is a string, the URL from the image file is to be downloaded.
  77497. * @param minHeight is the lower limit of the displacement.
  77498. * @param maxHeight is the upper limit of the displacement.
  77499. * @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.
  77500. * @param uvOffset is an optional vector2 used to offset UV.
  77501. * @param uvScale is an optional vector2 used to scale UV.
  77502. * @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.
  77503. * @returns the Mesh.
  77504. */
  77505. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  77506. /**
  77507. * Modifies the mesh geometry according to a displacementMap buffer.
  77508. * 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.
  77509. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  77510. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  77511. * @param heightMapWidth is the width of the buffer image.
  77512. * @param heightMapHeight is the height of the buffer image.
  77513. * @param minHeight is the lower limit of the displacement.
  77514. * @param maxHeight is the upper limit of the displacement.
  77515. * @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.
  77516. * @param uvOffset is an optional vector2 used to offset UV.
  77517. * @param uvScale is an optional vector2 used to scale UV.
  77518. * @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.
  77519. * @returns the Mesh.
  77520. */
  77521. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  77522. /**
  77523. * Modify the mesh to get a flat shading rendering.
  77524. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  77525. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  77526. * @returns current mesh
  77527. */
  77528. convertToFlatShadedMesh(): Mesh;
  77529. /**
  77530. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  77531. * In other words, more vertices, no more indices and a single bigger VBO.
  77532. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  77533. * @returns current mesh
  77534. */
  77535. convertToUnIndexedMesh(): Mesh;
  77536. /**
  77537. * Inverses facet orientations.
  77538. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  77539. * @param flipNormals will also inverts the normals
  77540. * @returns current mesh
  77541. */
  77542. flipFaces(flipNormals?: boolean): Mesh;
  77543. /**
  77544. * Increase the number of facets and hence vertices in a mesh
  77545. * Vertex normals are interpolated from existing vertex normals
  77546. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  77547. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  77548. */
  77549. increaseVertices(numberPerEdge: number): void;
  77550. /**
  77551. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  77552. * This will undo any application of covertToFlatShadedMesh
  77553. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  77554. */
  77555. forceSharedVertices(): void;
  77556. /** @hidden */
  77557. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  77558. /** @hidden */
  77559. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  77560. /**
  77561. * Creates a new InstancedMesh object from the mesh model.
  77562. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  77563. * @param name defines the name of the new instance
  77564. * @returns a new InstancedMesh
  77565. */
  77566. createInstance(name: string): InstancedMesh;
  77567. /**
  77568. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  77569. * After this call, all the mesh instances have the same submeshes than the current mesh.
  77570. * @returns the current mesh
  77571. */
  77572. synchronizeInstances(): Mesh;
  77573. /**
  77574. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  77575. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  77576. * This should be used together with the simplification to avoid disappearing triangles.
  77577. * @param successCallback an optional success callback to be called after the optimization finished.
  77578. * @returns the current mesh
  77579. */
  77580. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  77581. /**
  77582. * Serialize current mesh
  77583. * @param serializationObject defines the object which will receive the serialization data
  77584. */
  77585. serialize(serializationObject: any): void;
  77586. /** @hidden */
  77587. _syncGeometryWithMorphTargetManager(): void;
  77588. /** @hidden */
  77589. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  77590. /**
  77591. * Returns a new Mesh object parsed from the source provided.
  77592. * @param parsedMesh is the source
  77593. * @param scene defines the hosting scene
  77594. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  77595. * @returns a new Mesh
  77596. */
  77597. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  77598. /**
  77599. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  77600. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  77601. * @param name defines the name of the mesh to create
  77602. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  77603. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  77604. * @param closePath creates a seam between the first and the last points of each path of the path array
  77605. * @param offset is taken in account only if the `pathArray` is containing a single path
  77606. * @param scene defines the hosting scene
  77607. * @param updatable defines if the mesh must be flagged as updatable
  77608. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77609. * @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)
  77610. * @returns a new Mesh
  77611. */
  77612. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  77613. /**
  77614. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  77615. * @param name defines the name of the mesh to create
  77616. * @param radius sets the radius size (float) of the polygon (default 0.5)
  77617. * @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
  77618. * @param scene defines the hosting scene
  77619. * @param updatable defines if the mesh must be flagged as updatable
  77620. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77621. * @returns a new Mesh
  77622. */
  77623. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  77624. /**
  77625. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  77626. * @param name defines the name of the mesh to create
  77627. * @param size sets the size (float) of each box side (default 1)
  77628. * @param scene defines the hosting scene
  77629. * @param updatable defines if the mesh must be flagged as updatable
  77630. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77631. * @returns a new Mesh
  77632. */
  77633. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  77634. /**
  77635. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  77636. * @param name defines the name of the mesh to create
  77637. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  77638. * @param diameter sets the diameter size (float) of the sphere (default 1)
  77639. * @param scene defines the hosting scene
  77640. * @param updatable defines if the mesh must be flagged as updatable
  77641. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77642. * @returns a new Mesh
  77643. */
  77644. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77645. /**
  77646. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  77647. * @param name defines the name of the mesh to create
  77648. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  77649. * @param diameter sets the diameter size (float) of the sphere (default 1)
  77650. * @param scene defines the hosting scene
  77651. * @returns a new Mesh
  77652. */
  77653. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  77654. /**
  77655. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  77656. * @param name defines the name of the mesh to create
  77657. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  77658. * @param diameterTop set the top cap diameter (floats, default 1)
  77659. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  77660. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  77661. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  77662. * @param scene defines the hosting scene
  77663. * @param updatable defines if the mesh must be flagged as updatable
  77664. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77665. * @returns a new Mesh
  77666. */
  77667. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  77668. /**
  77669. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  77670. * @param name defines the name of the mesh to create
  77671. * @param diameter sets the diameter size (float) of the torus (default 1)
  77672. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  77673. * @param tessellation sets the number of torus sides (postive integer, default 16)
  77674. * @param scene defines the hosting scene
  77675. * @param updatable defines if the mesh must be flagged as updatable
  77676. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77677. * @returns a new Mesh
  77678. */
  77679. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77680. /**
  77681. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  77682. * @param name defines the name of the mesh to create
  77683. * @param radius sets the global radius size (float) of the torus knot (default 2)
  77684. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  77685. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  77686. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  77687. * @param p the number of windings on X axis (positive integers, default 2)
  77688. * @param q the number of windings on Y axis (positive integers, default 3)
  77689. * @param scene defines the hosting scene
  77690. * @param updatable defines if the mesh must be flagged as updatable
  77691. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77692. * @returns a new Mesh
  77693. */
  77694. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77695. /**
  77696. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  77697. * @param name defines the name of the mesh to create
  77698. * @param points is an array successive Vector3
  77699. * @param scene defines the hosting scene
  77700. * @param updatable defines if the mesh must be flagged as updatable
  77701. * @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).
  77702. * @returns a new Mesh
  77703. */
  77704. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  77705. /**
  77706. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  77707. * @param name defines the name of the mesh to create
  77708. * @param points is an array successive Vector3
  77709. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  77710. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  77711. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  77712. * @param scene defines the hosting scene
  77713. * @param updatable defines if the mesh must be flagged as updatable
  77714. * @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)
  77715. * @returns a new Mesh
  77716. */
  77717. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  77718. /**
  77719. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  77720. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  77721. * 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.
  77722. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  77723. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  77724. * Remember you can only change the shape positions, not their number when updating a polygon.
  77725. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  77726. * @param name defines the name of the mesh to create
  77727. * @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
  77728. * @param scene defines the hosting scene
  77729. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  77730. * @param updatable defines if the mesh must be flagged as updatable
  77731. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77732. * @param earcutInjection can be used to inject your own earcut reference
  77733. * @returns a new Mesh
  77734. */
  77735. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  77736. /**
  77737. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  77738. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  77739. * @param name defines the name of the mesh to create
  77740. * @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
  77741. * @param depth defines the height of extrusion
  77742. * @param scene defines the hosting scene
  77743. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  77744. * @param updatable defines if the mesh must be flagged as updatable
  77745. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77746. * @param earcutInjection can be used to inject your own earcut reference
  77747. * @returns a new Mesh
  77748. */
  77749. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  77750. /**
  77751. * Creates an extruded shape mesh.
  77752. * 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
  77753. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  77754. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  77755. * @param name defines the name of the mesh to create
  77756. * @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
  77757. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  77758. * @param scale is the value to scale the shape
  77759. * @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
  77760. * @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
  77761. * @param scene defines the hosting scene
  77762. * @param updatable defines if the mesh must be flagged as updatable
  77763. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77764. * @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)
  77765. * @returns a new Mesh
  77766. */
  77767. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  77768. /**
  77769. * Creates an custom extruded shape mesh.
  77770. * The custom extrusion is a parametric shape.
  77771. * It has no predefined shape. Its final shape will depend on the input parameters.
  77772. * Please consider using the same method from the MeshBuilder class instead
  77773. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  77774. * @param name defines the name of the mesh to create
  77775. * @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
  77776. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  77777. * @param scaleFunction is a custom Javascript function called on each path point
  77778. * @param rotationFunction is a custom Javascript function called on each path point
  77779. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  77780. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  77781. * @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
  77782. * @param scene defines the hosting scene
  77783. * @param updatable defines if the mesh must be flagged as updatable
  77784. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77785. * @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)
  77786. * @returns a new Mesh
  77787. */
  77788. 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;
  77789. /**
  77790. * Creates lathe mesh.
  77791. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  77792. * Please consider using the same method from the MeshBuilder class instead
  77793. * @param name defines the name of the mesh to create
  77794. * @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
  77795. * @param radius is the radius value of the lathe
  77796. * @param tessellation is the side number of the lathe.
  77797. * @param scene defines the hosting scene
  77798. * @param updatable defines if the mesh must be flagged as updatable
  77799. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77800. * @returns a new Mesh
  77801. */
  77802. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77803. /**
  77804. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  77805. * @param name defines the name of the mesh to create
  77806. * @param size sets the size (float) of both sides of the plane at once (default 1)
  77807. * @param scene defines the hosting scene
  77808. * @param updatable defines if the mesh must be flagged as updatable
  77809. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77810. * @returns a new Mesh
  77811. */
  77812. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77813. /**
  77814. * Creates a ground mesh.
  77815. * Please consider using the same method from the MeshBuilder class instead
  77816. * @param name defines the name of the mesh to create
  77817. * @param width set the width of the ground
  77818. * @param height set the height of the ground
  77819. * @param subdivisions sets the number of subdivisions per side
  77820. * @param scene defines the hosting scene
  77821. * @param updatable defines if the mesh must be flagged as updatable
  77822. * @returns a new Mesh
  77823. */
  77824. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  77825. /**
  77826. * Creates a tiled ground mesh.
  77827. * Please consider using the same method from the MeshBuilder class instead
  77828. * @param name defines the name of the mesh to create
  77829. * @param xmin set the ground minimum X coordinate
  77830. * @param zmin set the ground minimum Y coordinate
  77831. * @param xmax set the ground maximum X coordinate
  77832. * @param zmax set the ground maximum Z coordinate
  77833. * @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
  77834. * @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
  77835. * @param scene defines the hosting scene
  77836. * @param updatable defines if the mesh must be flagged as updatable
  77837. * @returns a new Mesh
  77838. */
  77839. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  77840. w: number;
  77841. h: number;
  77842. }, precision: {
  77843. w: number;
  77844. h: number;
  77845. }, scene: Scene, updatable?: boolean): Mesh;
  77846. /**
  77847. * Creates a ground mesh from a height map.
  77848. * Please consider using the same method from the MeshBuilder class instead
  77849. * @see http://doc.babylonjs.com/babylon101/height_map
  77850. * @param name defines the name of the mesh to create
  77851. * @param url sets the URL of the height map image resource
  77852. * @param width set the ground width size
  77853. * @param height set the ground height size
  77854. * @param subdivisions sets the number of subdivision per side
  77855. * @param minHeight is the minimum altitude on the ground
  77856. * @param maxHeight is the maximum altitude on the ground
  77857. * @param scene defines the hosting scene
  77858. * @param updatable defines if the mesh must be flagged as updatable
  77859. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  77860. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  77861. * @returns a new Mesh
  77862. */
  77863. 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;
  77864. /**
  77865. * Creates a tube mesh.
  77866. * The tube is a parametric shape.
  77867. * It has no predefined shape. Its final shape will depend on the input parameters.
  77868. * Please consider using the same method from the MeshBuilder class instead
  77869. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  77870. * @param name defines the name of the mesh to create
  77871. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  77872. * @param radius sets the tube radius size
  77873. * @param tessellation is the number of sides on the tubular surface
  77874. * @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
  77875. * @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
  77876. * @param scene defines the hosting scene
  77877. * @param updatable defines if the mesh must be flagged as updatable
  77878. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77879. * @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)
  77880. * @returns a new Mesh
  77881. */
  77882. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  77883. (i: number, distance: number): number;
  77884. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  77885. /**
  77886. * Creates a polyhedron mesh.
  77887. * Please consider using the same method from the MeshBuilder class instead.
  77888. * * 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
  77889. * * The parameter `size` (positive float, default 1) sets the polygon size
  77890. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  77891. * * 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`
  77892. * * 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
  77893. * * 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)`)
  77894. * * 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
  77895. * * 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
  77896. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  77897. * * If you create a double-sided mesh, you can choose what parts of 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
  77898. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  77899. * @param name defines the name of the mesh to create
  77900. * @param options defines the options used to create the mesh
  77901. * @param scene defines the hosting scene
  77902. * @returns a new Mesh
  77903. */
  77904. static CreatePolyhedron(name: string, options: {
  77905. type?: number;
  77906. size?: number;
  77907. sizeX?: number;
  77908. sizeY?: number;
  77909. sizeZ?: number;
  77910. custom?: any;
  77911. faceUV?: Vector4[];
  77912. faceColors?: Color4[];
  77913. updatable?: boolean;
  77914. sideOrientation?: number;
  77915. }, scene: Scene): Mesh;
  77916. /**
  77917. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  77918. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  77919. * * 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`)
  77920. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  77921. * * 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
  77922. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  77923. * * If you create a double-sided mesh, you can choose what parts of 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
  77924. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  77925. * @param name defines the name of the mesh
  77926. * @param options defines the options used to create the mesh
  77927. * @param scene defines the hosting scene
  77928. * @returns a new Mesh
  77929. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  77930. */
  77931. static CreateIcoSphere(name: string, options: {
  77932. radius?: number;
  77933. flat?: boolean;
  77934. subdivisions?: number;
  77935. sideOrientation?: number;
  77936. updatable?: boolean;
  77937. }, scene: Scene): Mesh;
  77938. /**
  77939. * Creates a decal mesh.
  77940. * Please consider using the same method from the MeshBuilder class instead.
  77941. * A decal is a mesh usually applied as a model onto the surface of another mesh
  77942. * @param name defines the name of the mesh
  77943. * @param sourceMesh defines the mesh receiving the decal
  77944. * @param position sets the position of the decal in world coordinates
  77945. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  77946. * @param size sets the decal scaling
  77947. * @param angle sets the angle to rotate the decal
  77948. * @returns a new Mesh
  77949. */
  77950. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  77951. /**
  77952. * Prepare internal position array for software CPU skinning
  77953. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  77954. */
  77955. setPositionsForCPUSkinning(): Float32Array;
  77956. /**
  77957. * Prepare internal normal array for software CPU skinning
  77958. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  77959. */
  77960. setNormalsForCPUSkinning(): Float32Array;
  77961. /**
  77962. * Updates the vertex buffer by applying transformation from the bones
  77963. * @param skeleton defines the skeleton to apply to current mesh
  77964. * @returns the current mesh
  77965. */
  77966. applySkeleton(skeleton: Skeleton): Mesh;
  77967. /**
  77968. * 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
  77969. * @param meshes defines the list of meshes to scan
  77970. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  77971. */
  77972. static MinMax(meshes: AbstractMesh[]): {
  77973. min: Vector3;
  77974. max: Vector3;
  77975. };
  77976. /**
  77977. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  77978. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  77979. * @returns a vector3
  77980. */
  77981. static Center(meshesOrMinMaxVector: {
  77982. min: Vector3;
  77983. max: Vector3;
  77984. } | AbstractMesh[]): Vector3;
  77985. /**
  77986. * Merge the array of meshes into a single mesh for performance reasons.
  77987. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  77988. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  77989. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  77990. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  77991. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  77992. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  77993. * @returns a new mesh
  77994. */
  77995. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  77996. /** @hidden */
  77997. addInstance(instance: InstancedMesh): void;
  77998. /** @hidden */
  77999. removeInstance(instance: InstancedMesh): void;
  78000. }
  78001. }
  78002. declare module BABYLON {
  78003. /**
  78004. * Interface used to define Action
  78005. */
  78006. export interface IAction {
  78007. /**
  78008. * Trigger for the action
  78009. */
  78010. trigger: number;
  78011. /** Options of the trigger */
  78012. triggerOptions: any;
  78013. /**
  78014. * Gets the trigger parameters
  78015. * @returns the trigger parameters
  78016. */
  78017. getTriggerParameter(): any;
  78018. /**
  78019. * Internal only - executes current action event
  78020. * @hidden
  78021. */
  78022. _executeCurrent(evt?: ActionEvent): void;
  78023. /**
  78024. * Serialize placeholder for child classes
  78025. * @param parent of child
  78026. * @returns the serialized object
  78027. */
  78028. serialize(parent: any): any;
  78029. /**
  78030. * Internal only
  78031. * @hidden
  78032. */
  78033. _prepare(): void;
  78034. /**
  78035. * Internal only - manager for action
  78036. * @hidden
  78037. */
  78038. _actionManager: AbstractActionManager;
  78039. /**
  78040. * Adds action to chain of actions, may be a DoNothingAction
  78041. * @param action defines the next action to execute
  78042. * @returns The action passed in
  78043. * @see https://www.babylonjs-playground.com/#1T30HR#0
  78044. */
  78045. then(action: IAction): IAction;
  78046. }
  78047. /**
  78048. * The action to be carried out following a trigger
  78049. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  78050. */
  78051. export class Action implements IAction {
  78052. /** the trigger, with or without parameters, for the action */
  78053. triggerOptions: any;
  78054. /**
  78055. * Trigger for the action
  78056. */
  78057. trigger: number;
  78058. /**
  78059. * Internal only - manager for action
  78060. * @hidden
  78061. */
  78062. _actionManager: ActionManager;
  78063. private _nextActiveAction;
  78064. private _child;
  78065. private _condition?;
  78066. private _triggerParameter;
  78067. /**
  78068. * An event triggered prior to action being executed.
  78069. */
  78070. onBeforeExecuteObservable: Observable<Action>;
  78071. /**
  78072. * Creates a new Action
  78073. * @param triggerOptions the trigger, with or without parameters, for the action
  78074. * @param condition an optional determinant of action
  78075. */
  78076. constructor(
  78077. /** the trigger, with or without parameters, for the action */
  78078. triggerOptions: any, condition?: Condition);
  78079. /**
  78080. * Internal only
  78081. * @hidden
  78082. */
  78083. _prepare(): void;
  78084. /**
  78085. * Gets the trigger parameters
  78086. * @returns the trigger parameters
  78087. */
  78088. getTriggerParameter(): any;
  78089. /**
  78090. * Internal only - executes current action event
  78091. * @hidden
  78092. */
  78093. _executeCurrent(evt?: ActionEvent): void;
  78094. /**
  78095. * Execute placeholder for child classes
  78096. * @param evt optional action event
  78097. */
  78098. execute(evt?: ActionEvent): void;
  78099. /**
  78100. * Skips to next active action
  78101. */
  78102. skipToNextActiveAction(): void;
  78103. /**
  78104. * Adds action to chain of actions, may be a DoNothingAction
  78105. * @param action defines the next action to execute
  78106. * @returns The action passed in
  78107. * @see https://www.babylonjs-playground.com/#1T30HR#0
  78108. */
  78109. then(action: Action): Action;
  78110. /**
  78111. * Internal only
  78112. * @hidden
  78113. */
  78114. _getProperty(propertyPath: string): string;
  78115. /**
  78116. * Internal only
  78117. * @hidden
  78118. */
  78119. _getEffectiveTarget(target: any, propertyPath: string): any;
  78120. /**
  78121. * Serialize placeholder for child classes
  78122. * @param parent of child
  78123. * @returns the serialized object
  78124. */
  78125. serialize(parent: any): any;
  78126. /**
  78127. * Internal only called by serialize
  78128. * @hidden
  78129. */
  78130. protected _serialize(serializedAction: any, parent?: any): any;
  78131. /**
  78132. * Internal only
  78133. * @hidden
  78134. */
  78135. static _SerializeValueAsString: (value: any) => string;
  78136. /**
  78137. * Internal only
  78138. * @hidden
  78139. */
  78140. static _GetTargetProperty: (target: Scene | Node) => {
  78141. name: string;
  78142. targetType: string;
  78143. value: string;
  78144. };
  78145. }
  78146. }
  78147. declare module BABYLON {
  78148. /**
  78149. * A Condition applied to an Action
  78150. */
  78151. export class Condition {
  78152. /**
  78153. * Internal only - manager for action
  78154. * @hidden
  78155. */
  78156. _actionManager: ActionManager;
  78157. /**
  78158. * Internal only
  78159. * @hidden
  78160. */
  78161. _evaluationId: number;
  78162. /**
  78163. * Internal only
  78164. * @hidden
  78165. */
  78166. _currentResult: boolean;
  78167. /**
  78168. * Creates a new Condition
  78169. * @param actionManager the manager of the action the condition is applied to
  78170. */
  78171. constructor(actionManager: ActionManager);
  78172. /**
  78173. * Check if the current condition is valid
  78174. * @returns a boolean
  78175. */
  78176. isValid(): boolean;
  78177. /**
  78178. * Internal only
  78179. * @hidden
  78180. */
  78181. _getProperty(propertyPath: string): string;
  78182. /**
  78183. * Internal only
  78184. * @hidden
  78185. */
  78186. _getEffectiveTarget(target: any, propertyPath: string): any;
  78187. /**
  78188. * Serialize placeholder for child classes
  78189. * @returns the serialized object
  78190. */
  78191. serialize(): any;
  78192. /**
  78193. * Internal only
  78194. * @hidden
  78195. */
  78196. protected _serialize(serializedCondition: any): any;
  78197. }
  78198. /**
  78199. * Defines specific conditional operators as extensions of Condition
  78200. */
  78201. export class ValueCondition extends Condition {
  78202. /** path to specify the property of the target the conditional operator uses */
  78203. propertyPath: string;
  78204. /** the value compared by the conditional operator against the current value of the property */
  78205. value: any;
  78206. /** the conditional operator, default ValueCondition.IsEqual */
  78207. operator: number;
  78208. /**
  78209. * Internal only
  78210. * @hidden
  78211. */
  78212. private static _IsEqual;
  78213. /**
  78214. * Internal only
  78215. * @hidden
  78216. */
  78217. private static _IsDifferent;
  78218. /**
  78219. * Internal only
  78220. * @hidden
  78221. */
  78222. private static _IsGreater;
  78223. /**
  78224. * Internal only
  78225. * @hidden
  78226. */
  78227. private static _IsLesser;
  78228. /**
  78229. * returns the number for IsEqual
  78230. */
  78231. static readonly IsEqual: number;
  78232. /**
  78233. * Returns the number for IsDifferent
  78234. */
  78235. static readonly IsDifferent: number;
  78236. /**
  78237. * Returns the number for IsGreater
  78238. */
  78239. static readonly IsGreater: number;
  78240. /**
  78241. * Returns the number for IsLesser
  78242. */
  78243. static readonly IsLesser: number;
  78244. /**
  78245. * Internal only The action manager for the condition
  78246. * @hidden
  78247. */
  78248. _actionManager: ActionManager;
  78249. /**
  78250. * Internal only
  78251. * @hidden
  78252. */
  78253. private _target;
  78254. /**
  78255. * Internal only
  78256. * @hidden
  78257. */
  78258. private _effectiveTarget;
  78259. /**
  78260. * Internal only
  78261. * @hidden
  78262. */
  78263. private _property;
  78264. /**
  78265. * Creates a new ValueCondition
  78266. * @param actionManager manager for the action the condition applies to
  78267. * @param target for the action
  78268. * @param propertyPath path to specify the property of the target the conditional operator uses
  78269. * @param value the value compared by the conditional operator against the current value of the property
  78270. * @param operator the conditional operator, default ValueCondition.IsEqual
  78271. */
  78272. constructor(actionManager: ActionManager, target: any,
  78273. /** path to specify the property of the target the conditional operator uses */
  78274. propertyPath: string,
  78275. /** the value compared by the conditional operator against the current value of the property */
  78276. value: any,
  78277. /** the conditional operator, default ValueCondition.IsEqual */
  78278. operator?: number);
  78279. /**
  78280. * Compares the given value with the property value for the specified conditional operator
  78281. * @returns the result of the comparison
  78282. */
  78283. isValid(): boolean;
  78284. /**
  78285. * Serialize the ValueCondition into a JSON compatible object
  78286. * @returns serialization object
  78287. */
  78288. serialize(): any;
  78289. /**
  78290. * Gets the name of the conditional operator for the ValueCondition
  78291. * @param operator the conditional operator
  78292. * @returns the name
  78293. */
  78294. static GetOperatorName(operator: number): string;
  78295. }
  78296. /**
  78297. * Defines a predicate condition as an extension of Condition
  78298. */
  78299. export class PredicateCondition extends Condition {
  78300. /** defines the predicate function used to validate the condition */
  78301. predicate: () => boolean;
  78302. /**
  78303. * Internal only - manager for action
  78304. * @hidden
  78305. */
  78306. _actionManager: ActionManager;
  78307. /**
  78308. * Creates a new PredicateCondition
  78309. * @param actionManager manager for the action the condition applies to
  78310. * @param predicate defines the predicate function used to validate the condition
  78311. */
  78312. constructor(actionManager: ActionManager,
  78313. /** defines the predicate function used to validate the condition */
  78314. predicate: () => boolean);
  78315. /**
  78316. * @returns the validity of the predicate condition
  78317. */
  78318. isValid(): boolean;
  78319. }
  78320. /**
  78321. * Defines a state condition as an extension of Condition
  78322. */
  78323. export class StateCondition extends Condition {
  78324. /** Value to compare with target state */
  78325. value: string;
  78326. /**
  78327. * Internal only - manager for action
  78328. * @hidden
  78329. */
  78330. _actionManager: ActionManager;
  78331. /**
  78332. * Internal only
  78333. * @hidden
  78334. */
  78335. private _target;
  78336. /**
  78337. * Creates a new StateCondition
  78338. * @param actionManager manager for the action the condition applies to
  78339. * @param target of the condition
  78340. * @param value to compare with target state
  78341. */
  78342. constructor(actionManager: ActionManager, target: any,
  78343. /** Value to compare with target state */
  78344. value: string);
  78345. /**
  78346. * Gets a boolean indicating if the current condition is met
  78347. * @returns the validity of the state
  78348. */
  78349. isValid(): boolean;
  78350. /**
  78351. * Serialize the StateCondition into a JSON compatible object
  78352. * @returns serialization object
  78353. */
  78354. serialize(): any;
  78355. }
  78356. }
  78357. declare module BABYLON {
  78358. /**
  78359. * This defines an action responsible to toggle a boolean once triggered.
  78360. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78361. */
  78362. export class SwitchBooleanAction extends Action {
  78363. /**
  78364. * The path to the boolean property in the target object
  78365. */
  78366. propertyPath: string;
  78367. private _target;
  78368. private _effectiveTarget;
  78369. private _property;
  78370. /**
  78371. * Instantiate the action
  78372. * @param triggerOptions defines the trigger options
  78373. * @param target defines the object containing the boolean
  78374. * @param propertyPath defines the path to the boolean property in the target object
  78375. * @param condition defines the trigger related conditions
  78376. */
  78377. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  78378. /** @hidden */
  78379. _prepare(): void;
  78380. /**
  78381. * Execute the action toggle the boolean value.
  78382. */
  78383. execute(): void;
  78384. /**
  78385. * Serializes the actions and its related information.
  78386. * @param parent defines the object to serialize in
  78387. * @returns the serialized object
  78388. */
  78389. serialize(parent: any): any;
  78390. }
  78391. /**
  78392. * This defines an action responsible to set a the state field of the target
  78393. * to a desired value once triggered.
  78394. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78395. */
  78396. export class SetStateAction extends Action {
  78397. /**
  78398. * The value to store in the state field.
  78399. */
  78400. value: string;
  78401. private _target;
  78402. /**
  78403. * Instantiate the action
  78404. * @param triggerOptions defines the trigger options
  78405. * @param target defines the object containing the state property
  78406. * @param value defines the value to store in the state field
  78407. * @param condition defines the trigger related conditions
  78408. */
  78409. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  78410. /**
  78411. * Execute the action and store the value on the target state property.
  78412. */
  78413. execute(): void;
  78414. /**
  78415. * Serializes the actions and its related information.
  78416. * @param parent defines the object to serialize in
  78417. * @returns the serialized object
  78418. */
  78419. serialize(parent: any): any;
  78420. }
  78421. /**
  78422. * This defines an action responsible to set a property of the target
  78423. * to a desired value once triggered.
  78424. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78425. */
  78426. export class SetValueAction extends Action {
  78427. /**
  78428. * The path of the property to set in the target.
  78429. */
  78430. propertyPath: string;
  78431. /**
  78432. * The value to set in the property
  78433. */
  78434. value: any;
  78435. private _target;
  78436. private _effectiveTarget;
  78437. private _property;
  78438. /**
  78439. * Instantiate the action
  78440. * @param triggerOptions defines the trigger options
  78441. * @param target defines the object containing the property
  78442. * @param propertyPath defines the path of the property to set in the target
  78443. * @param value defines the value to set in the property
  78444. * @param condition defines the trigger related conditions
  78445. */
  78446. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  78447. /** @hidden */
  78448. _prepare(): void;
  78449. /**
  78450. * Execute the action and set the targetted property to the desired value.
  78451. */
  78452. execute(): void;
  78453. /**
  78454. * Serializes the actions and its related information.
  78455. * @param parent defines the object to serialize in
  78456. * @returns the serialized object
  78457. */
  78458. serialize(parent: any): any;
  78459. }
  78460. /**
  78461. * This defines an action responsible to increment the target value
  78462. * to a desired value once triggered.
  78463. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78464. */
  78465. export class IncrementValueAction extends Action {
  78466. /**
  78467. * The path of the property to increment in the target.
  78468. */
  78469. propertyPath: string;
  78470. /**
  78471. * The value we should increment the property by.
  78472. */
  78473. value: any;
  78474. private _target;
  78475. private _effectiveTarget;
  78476. private _property;
  78477. /**
  78478. * Instantiate the action
  78479. * @param triggerOptions defines the trigger options
  78480. * @param target defines the object containing the property
  78481. * @param propertyPath defines the path of the property to increment in the target
  78482. * @param value defines the value value we should increment the property by
  78483. * @param condition defines the trigger related conditions
  78484. */
  78485. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  78486. /** @hidden */
  78487. _prepare(): void;
  78488. /**
  78489. * Execute the action and increment the target of the value amount.
  78490. */
  78491. execute(): void;
  78492. /**
  78493. * Serializes the actions and its related information.
  78494. * @param parent defines the object to serialize in
  78495. * @returns the serialized object
  78496. */
  78497. serialize(parent: any): any;
  78498. }
  78499. /**
  78500. * This defines an action responsible to start an animation once triggered.
  78501. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78502. */
  78503. export class PlayAnimationAction extends Action {
  78504. /**
  78505. * Where the animation should start (animation frame)
  78506. */
  78507. from: number;
  78508. /**
  78509. * Where the animation should stop (animation frame)
  78510. */
  78511. to: number;
  78512. /**
  78513. * Define if the animation should loop or stop after the first play.
  78514. */
  78515. loop?: boolean;
  78516. private _target;
  78517. /**
  78518. * Instantiate the action
  78519. * @param triggerOptions defines the trigger options
  78520. * @param target defines the target animation or animation name
  78521. * @param from defines from where the animation should start (animation frame)
  78522. * @param end defines where the animation should stop (animation frame)
  78523. * @param loop defines if the animation should loop or stop after the first play
  78524. * @param condition defines the trigger related conditions
  78525. */
  78526. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  78527. /** @hidden */
  78528. _prepare(): void;
  78529. /**
  78530. * Execute the action and play the animation.
  78531. */
  78532. execute(): void;
  78533. /**
  78534. * Serializes the actions and its related information.
  78535. * @param parent defines the object to serialize in
  78536. * @returns the serialized object
  78537. */
  78538. serialize(parent: any): any;
  78539. }
  78540. /**
  78541. * This defines an action responsible to stop an animation once triggered.
  78542. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78543. */
  78544. export class StopAnimationAction extends Action {
  78545. private _target;
  78546. /**
  78547. * Instantiate the action
  78548. * @param triggerOptions defines the trigger options
  78549. * @param target defines the target animation or animation name
  78550. * @param condition defines the trigger related conditions
  78551. */
  78552. constructor(triggerOptions: any, target: any, condition?: Condition);
  78553. /** @hidden */
  78554. _prepare(): void;
  78555. /**
  78556. * Execute the action and stop the animation.
  78557. */
  78558. execute(): void;
  78559. /**
  78560. * Serializes the actions and its related information.
  78561. * @param parent defines the object to serialize in
  78562. * @returns the serialized object
  78563. */
  78564. serialize(parent: any): any;
  78565. }
  78566. /**
  78567. * This defines an action responsible that does nothing once triggered.
  78568. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78569. */
  78570. export class DoNothingAction extends Action {
  78571. /**
  78572. * Instantiate the action
  78573. * @param triggerOptions defines the trigger options
  78574. * @param condition defines the trigger related conditions
  78575. */
  78576. constructor(triggerOptions?: any, condition?: Condition);
  78577. /**
  78578. * Execute the action and do nothing.
  78579. */
  78580. execute(): void;
  78581. /**
  78582. * Serializes the actions and its related information.
  78583. * @param parent defines the object to serialize in
  78584. * @returns the serialized object
  78585. */
  78586. serialize(parent: any): any;
  78587. }
  78588. /**
  78589. * This defines an action responsible to trigger several actions once triggered.
  78590. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78591. */
  78592. export class CombineAction extends Action {
  78593. /**
  78594. * The list of aggregated animations to run.
  78595. */
  78596. children: Action[];
  78597. /**
  78598. * Instantiate the action
  78599. * @param triggerOptions defines the trigger options
  78600. * @param children defines the list of aggregated animations to run
  78601. * @param condition defines the trigger related conditions
  78602. */
  78603. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  78604. /** @hidden */
  78605. _prepare(): void;
  78606. /**
  78607. * Execute the action and executes all the aggregated actions.
  78608. */
  78609. execute(evt: ActionEvent): void;
  78610. /**
  78611. * Serializes the actions and its related information.
  78612. * @param parent defines the object to serialize in
  78613. * @returns the serialized object
  78614. */
  78615. serialize(parent: any): any;
  78616. }
  78617. /**
  78618. * This defines an action responsible to run code (external event) once triggered.
  78619. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78620. */
  78621. export class ExecuteCodeAction extends Action {
  78622. /**
  78623. * The callback function to run.
  78624. */
  78625. func: (evt: ActionEvent) => void;
  78626. /**
  78627. * Instantiate the action
  78628. * @param triggerOptions defines the trigger options
  78629. * @param func defines the callback function to run
  78630. * @param condition defines the trigger related conditions
  78631. */
  78632. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  78633. /**
  78634. * Execute the action and run the attached code.
  78635. */
  78636. execute(evt: ActionEvent): void;
  78637. }
  78638. /**
  78639. * This defines an action responsible to set the parent property of the target once triggered.
  78640. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78641. */
  78642. export class SetParentAction extends Action {
  78643. private _parent;
  78644. private _target;
  78645. /**
  78646. * Instantiate the action
  78647. * @param triggerOptions defines the trigger options
  78648. * @param target defines the target containing the parent property
  78649. * @param parent defines from where the animation should start (animation frame)
  78650. * @param condition defines the trigger related conditions
  78651. */
  78652. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  78653. /** @hidden */
  78654. _prepare(): void;
  78655. /**
  78656. * Execute the action and set the parent property.
  78657. */
  78658. execute(): void;
  78659. /**
  78660. * Serializes the actions and its related information.
  78661. * @param parent defines the object to serialize in
  78662. * @returns the serialized object
  78663. */
  78664. serialize(parent: any): any;
  78665. }
  78666. }
  78667. declare module BABYLON {
  78668. /**
  78669. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  78670. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  78671. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78672. */
  78673. export class ActionManager extends AbstractActionManager {
  78674. /**
  78675. * Nothing
  78676. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78677. */
  78678. static readonly NothingTrigger: number;
  78679. /**
  78680. * On pick
  78681. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78682. */
  78683. static readonly OnPickTrigger: number;
  78684. /**
  78685. * On left pick
  78686. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78687. */
  78688. static readonly OnLeftPickTrigger: number;
  78689. /**
  78690. * On right pick
  78691. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78692. */
  78693. static readonly OnRightPickTrigger: number;
  78694. /**
  78695. * On center pick
  78696. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78697. */
  78698. static readonly OnCenterPickTrigger: number;
  78699. /**
  78700. * On pick down
  78701. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78702. */
  78703. static readonly OnPickDownTrigger: number;
  78704. /**
  78705. * On double pick
  78706. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78707. */
  78708. static readonly OnDoublePickTrigger: number;
  78709. /**
  78710. * On pick up
  78711. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78712. */
  78713. static readonly OnPickUpTrigger: number;
  78714. /**
  78715. * On pick out.
  78716. * This trigger will only be raised if you also declared a OnPickDown
  78717. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78718. */
  78719. static readonly OnPickOutTrigger: number;
  78720. /**
  78721. * On long press
  78722. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78723. */
  78724. static readonly OnLongPressTrigger: number;
  78725. /**
  78726. * On pointer over
  78727. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78728. */
  78729. static readonly OnPointerOverTrigger: number;
  78730. /**
  78731. * On pointer out
  78732. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78733. */
  78734. static readonly OnPointerOutTrigger: number;
  78735. /**
  78736. * On every frame
  78737. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78738. */
  78739. static readonly OnEveryFrameTrigger: number;
  78740. /**
  78741. * On intersection enter
  78742. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78743. */
  78744. static readonly OnIntersectionEnterTrigger: number;
  78745. /**
  78746. * On intersection exit
  78747. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78748. */
  78749. static readonly OnIntersectionExitTrigger: number;
  78750. /**
  78751. * On key down
  78752. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78753. */
  78754. static readonly OnKeyDownTrigger: number;
  78755. /**
  78756. * On key up
  78757. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78758. */
  78759. static readonly OnKeyUpTrigger: number;
  78760. private _scene;
  78761. /**
  78762. * Creates a new action manager
  78763. * @param scene defines the hosting scene
  78764. */
  78765. constructor(scene: Scene);
  78766. /**
  78767. * Releases all associated resources
  78768. */
  78769. dispose(): void;
  78770. /**
  78771. * Gets hosting scene
  78772. * @returns the hosting scene
  78773. */
  78774. getScene(): Scene;
  78775. /**
  78776. * Does this action manager handles actions of any of the given triggers
  78777. * @param triggers defines the triggers to be tested
  78778. * @return a boolean indicating whether one (or more) of the triggers is handled
  78779. */
  78780. hasSpecificTriggers(triggers: number[]): boolean;
  78781. /**
  78782. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  78783. * speed.
  78784. * @param triggerA defines the trigger to be tested
  78785. * @param triggerB defines the trigger to be tested
  78786. * @return a boolean indicating whether one (or more) of the triggers is handled
  78787. */
  78788. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  78789. /**
  78790. * Does this action manager handles actions of a given trigger
  78791. * @param trigger defines the trigger to be tested
  78792. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  78793. * @return whether the trigger is handled
  78794. */
  78795. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  78796. /**
  78797. * Does this action manager has pointer triggers
  78798. */
  78799. readonly hasPointerTriggers: boolean;
  78800. /**
  78801. * Does this action manager has pick triggers
  78802. */
  78803. readonly hasPickTriggers: boolean;
  78804. /**
  78805. * Registers an action to this action manager
  78806. * @param action defines the action to be registered
  78807. * @return the action amended (prepared) after registration
  78808. */
  78809. registerAction(action: IAction): Nullable<IAction>;
  78810. /**
  78811. * Unregisters an action to this action manager
  78812. * @param action defines the action to be unregistered
  78813. * @return a boolean indicating whether the action has been unregistered
  78814. */
  78815. unregisterAction(action: IAction): Boolean;
  78816. /**
  78817. * Process a specific trigger
  78818. * @param trigger defines the trigger to process
  78819. * @param evt defines the event details to be processed
  78820. */
  78821. processTrigger(trigger: number, evt?: IActionEvent): void;
  78822. /** @hidden */
  78823. _getEffectiveTarget(target: any, propertyPath: string): any;
  78824. /** @hidden */
  78825. _getProperty(propertyPath: string): string;
  78826. /**
  78827. * Serialize this manager to a JSON object
  78828. * @param name defines the property name to store this manager
  78829. * @returns a JSON representation of this manager
  78830. */
  78831. serialize(name: string): any;
  78832. /**
  78833. * Creates a new ActionManager from a JSON data
  78834. * @param parsedActions defines the JSON data to read from
  78835. * @param object defines the hosting mesh
  78836. * @param scene defines the hosting scene
  78837. */
  78838. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  78839. /**
  78840. * Get a trigger name by index
  78841. * @param trigger defines the trigger index
  78842. * @returns a trigger name
  78843. */
  78844. static GetTriggerName(trigger: number): string;
  78845. }
  78846. }
  78847. declare module BABYLON {
  78848. /**
  78849. * Class representing a ray with position and direction
  78850. */
  78851. export class Ray {
  78852. /** origin point */
  78853. origin: Vector3;
  78854. /** direction */
  78855. direction: Vector3;
  78856. /** length of the ray */
  78857. length: number;
  78858. private static readonly TmpVector3;
  78859. private _tmpRay;
  78860. /**
  78861. * Creates a new ray
  78862. * @param origin origin point
  78863. * @param direction direction
  78864. * @param length length of the ray
  78865. */
  78866. constructor(
  78867. /** origin point */
  78868. origin: Vector3,
  78869. /** direction */
  78870. direction: Vector3,
  78871. /** length of the ray */
  78872. length?: number);
  78873. /**
  78874. * Checks if the ray intersects a box
  78875. * @param minimum bound of the box
  78876. * @param maximum bound of the box
  78877. * @param intersectionTreshold extra extend to be added to the box in all direction
  78878. * @returns if the box was hit
  78879. */
  78880. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  78881. /**
  78882. * Checks if the ray intersects a box
  78883. * @param box the bounding box to check
  78884. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  78885. * @returns if the box was hit
  78886. */
  78887. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  78888. /**
  78889. * If the ray hits a sphere
  78890. * @param sphere the bounding sphere to check
  78891. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  78892. * @returns true if it hits the sphere
  78893. */
  78894. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  78895. /**
  78896. * If the ray hits a triange
  78897. * @param vertex0 triangle vertex
  78898. * @param vertex1 triangle vertex
  78899. * @param vertex2 triangle vertex
  78900. * @returns intersection information if hit
  78901. */
  78902. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  78903. /**
  78904. * Checks if ray intersects a plane
  78905. * @param plane the plane to check
  78906. * @returns the distance away it was hit
  78907. */
  78908. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  78909. /**
  78910. * Checks if ray intersects a mesh
  78911. * @param mesh the mesh to check
  78912. * @param fastCheck if only the bounding box should checked
  78913. * @returns picking info of the intersecton
  78914. */
  78915. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  78916. /**
  78917. * Checks if ray intersects a mesh
  78918. * @param meshes the meshes to check
  78919. * @param fastCheck if only the bounding box should checked
  78920. * @param results array to store result in
  78921. * @returns Array of picking infos
  78922. */
  78923. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  78924. private _comparePickingInfo;
  78925. private static smallnum;
  78926. private static rayl;
  78927. /**
  78928. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  78929. * @param sega the first point of the segment to test the intersection against
  78930. * @param segb the second point of the segment to test the intersection against
  78931. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  78932. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  78933. */
  78934. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  78935. /**
  78936. * Update the ray from viewport position
  78937. * @param x position
  78938. * @param y y position
  78939. * @param viewportWidth viewport width
  78940. * @param viewportHeight viewport height
  78941. * @param world world matrix
  78942. * @param view view matrix
  78943. * @param projection projection matrix
  78944. * @returns this ray updated
  78945. */
  78946. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  78947. /**
  78948. * Creates a ray with origin and direction of 0,0,0
  78949. * @returns the new ray
  78950. */
  78951. static Zero(): Ray;
  78952. /**
  78953. * Creates a new ray from screen space and viewport
  78954. * @param x position
  78955. * @param y y position
  78956. * @param viewportWidth viewport width
  78957. * @param viewportHeight viewport height
  78958. * @param world world matrix
  78959. * @param view view matrix
  78960. * @param projection projection matrix
  78961. * @returns new ray
  78962. */
  78963. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  78964. /**
  78965. * 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
  78966. * transformed to the given world matrix.
  78967. * @param origin The origin point
  78968. * @param end The end point
  78969. * @param world a matrix to transform the ray to. Default is the identity matrix.
  78970. * @returns the new ray
  78971. */
  78972. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  78973. /**
  78974. * Transforms a ray by a matrix
  78975. * @param ray ray to transform
  78976. * @param matrix matrix to apply
  78977. * @returns the resulting new ray
  78978. */
  78979. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  78980. /**
  78981. * Transforms a ray by a matrix
  78982. * @param ray ray to transform
  78983. * @param matrix matrix to apply
  78984. * @param result ray to store result in
  78985. */
  78986. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  78987. /**
  78988. * Unproject a ray from screen space to object space
  78989. * @param sourceX defines the screen space x coordinate to use
  78990. * @param sourceY defines the screen space y coordinate to use
  78991. * @param viewportWidth defines the current width of the viewport
  78992. * @param viewportHeight defines the current height of the viewport
  78993. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  78994. * @param view defines the view matrix to use
  78995. * @param projection defines the projection matrix to use
  78996. */
  78997. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  78998. }
  78999. /**
  79000. * Type used to define predicate used to select faces when a mesh intersection is detected
  79001. */
  79002. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  79003. interface Scene {
  79004. /** @hidden */
  79005. _tempPickingRay: Nullable<Ray>;
  79006. /** @hidden */
  79007. _cachedRayForTransform: Ray;
  79008. /** @hidden */
  79009. _pickWithRayInverseMatrix: Matrix;
  79010. /** @hidden */
  79011. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  79012. /** @hidden */
  79013. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  79014. }
  79015. }
  79016. declare module BABYLON {
  79017. interface Scene {
  79018. /** @hidden */
  79019. _pointerOverSprite: Nullable<Sprite>;
  79020. /** @hidden */
  79021. _pickedDownSprite: Nullable<Sprite>;
  79022. /** @hidden */
  79023. _tempSpritePickingRay: Nullable<Ray>;
  79024. /**
  79025. * All of the sprite managers added to this scene
  79026. * @see http://doc.babylonjs.com/babylon101/sprites
  79027. */
  79028. spriteManagers: Array<ISpriteManager>;
  79029. /**
  79030. * An event triggered when sprites rendering is about to start
  79031. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  79032. */
  79033. onBeforeSpritesRenderingObservable: Observable<Scene>;
  79034. /**
  79035. * An event triggered when sprites rendering is done
  79036. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  79037. */
  79038. onAfterSpritesRenderingObservable: Observable<Scene>;
  79039. /** @hidden */
  79040. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  79041. /** Launch a ray to try to pick a sprite in the scene
  79042. * @param x position on screen
  79043. * @param y position on screen
  79044. * @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
  79045. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  79046. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  79047. * @returns a PickingInfo
  79048. */
  79049. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  79050. /** Use the given ray to pick a sprite in the scene
  79051. * @param ray The ray (in world space) to use to pick meshes
  79052. * @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
  79053. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  79054. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  79055. * @returns a PickingInfo
  79056. */
  79057. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  79058. /**
  79059. * Force the sprite under the pointer
  79060. * @param sprite defines the sprite to use
  79061. */
  79062. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  79063. /**
  79064. * Gets the sprite under the pointer
  79065. * @returns a Sprite or null if no sprite is under the pointer
  79066. */
  79067. getPointerOverSprite(): Nullable<Sprite>;
  79068. }
  79069. /**
  79070. * Defines the sprite scene component responsible to manage sprites
  79071. * in a given scene.
  79072. */
  79073. export class SpriteSceneComponent implements ISceneComponent {
  79074. /**
  79075. * The component name helpfull to identify the component in the list of scene components.
  79076. */
  79077. readonly name: string;
  79078. /**
  79079. * The scene the component belongs to.
  79080. */
  79081. scene: Scene;
  79082. /** @hidden */
  79083. private _spritePredicate;
  79084. /**
  79085. * Creates a new instance of the component for the given scene
  79086. * @param scene Defines the scene to register the component in
  79087. */
  79088. constructor(scene: Scene);
  79089. /**
  79090. * Registers the component in a given scene
  79091. */
  79092. register(): void;
  79093. /**
  79094. * Rebuilds the elements related to this component in case of
  79095. * context lost for instance.
  79096. */
  79097. rebuild(): void;
  79098. /**
  79099. * Disposes the component and the associated ressources.
  79100. */
  79101. dispose(): void;
  79102. private _pickSpriteButKeepRay;
  79103. private _pointerMove;
  79104. private _pointerDown;
  79105. private _pointerUp;
  79106. }
  79107. }
  79108. declare module BABYLON {
  79109. /** @hidden */
  79110. export var fogFragmentDeclaration: {
  79111. name: string;
  79112. shader: string;
  79113. };
  79114. }
  79115. declare module BABYLON {
  79116. /** @hidden */
  79117. export var fogFragment: {
  79118. name: string;
  79119. shader: string;
  79120. };
  79121. }
  79122. declare module BABYLON {
  79123. /** @hidden */
  79124. export var spritesPixelShader: {
  79125. name: string;
  79126. shader: string;
  79127. };
  79128. }
  79129. declare module BABYLON {
  79130. /** @hidden */
  79131. export var fogVertexDeclaration: {
  79132. name: string;
  79133. shader: string;
  79134. };
  79135. }
  79136. declare module BABYLON {
  79137. /** @hidden */
  79138. export var spritesVertexShader: {
  79139. name: string;
  79140. shader: string;
  79141. };
  79142. }
  79143. declare module BABYLON {
  79144. /**
  79145. * Defines the minimum interface to fullfil in order to be a sprite manager.
  79146. */
  79147. export interface ISpriteManager extends IDisposable {
  79148. /**
  79149. * Restricts the camera to viewing objects with the same layerMask.
  79150. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  79151. */
  79152. layerMask: number;
  79153. /**
  79154. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  79155. */
  79156. isPickable: boolean;
  79157. /**
  79158. * Specifies the rendering group id for this mesh (0 by default)
  79159. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  79160. */
  79161. renderingGroupId: number;
  79162. /**
  79163. * Defines the list of sprites managed by the manager.
  79164. */
  79165. sprites: Array<Sprite>;
  79166. /**
  79167. * Tests the intersection of a sprite with a specific ray.
  79168. * @param ray The ray we are sending to test the collision
  79169. * @param camera The camera space we are sending rays in
  79170. * @param predicate A predicate allowing excluding sprites from the list of object to test
  79171. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  79172. * @returns picking info or null.
  79173. */
  79174. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  79175. /**
  79176. * Renders the list of sprites on screen.
  79177. */
  79178. render(): void;
  79179. }
  79180. /**
  79181. * Class used to manage multiple sprites on the same spritesheet
  79182. * @see http://doc.babylonjs.com/babylon101/sprites
  79183. */
  79184. export class SpriteManager implements ISpriteManager {
  79185. /** defines the manager's name */
  79186. name: string;
  79187. /** Gets the list of sprites */
  79188. sprites: Sprite[];
  79189. /** Gets or sets the rendering group id (0 by default) */
  79190. renderingGroupId: number;
  79191. /** Gets or sets camera layer mask */
  79192. layerMask: number;
  79193. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  79194. fogEnabled: boolean;
  79195. /** Gets or sets a boolean indicating if the sprites are pickable */
  79196. isPickable: boolean;
  79197. /** Defines the default width of a cell in the spritesheet */
  79198. cellWidth: number;
  79199. /** Defines the default height of a cell in the spritesheet */
  79200. cellHeight: number;
  79201. /**
  79202. * An event triggered when the manager is disposed.
  79203. */
  79204. onDisposeObservable: Observable<SpriteManager>;
  79205. private _onDisposeObserver;
  79206. /**
  79207. * Callback called when the manager is disposed
  79208. */
  79209. onDispose: () => void;
  79210. private _capacity;
  79211. private _spriteTexture;
  79212. private _epsilon;
  79213. private _scene;
  79214. private _vertexData;
  79215. private _buffer;
  79216. private _vertexBuffers;
  79217. private _indexBuffer;
  79218. private _effectBase;
  79219. private _effectFog;
  79220. /**
  79221. * Gets or sets the spritesheet texture
  79222. */
  79223. texture: Texture;
  79224. /**
  79225. * Creates a new sprite manager
  79226. * @param name defines the manager's name
  79227. * @param imgUrl defines the sprite sheet url
  79228. * @param capacity defines the maximum allowed number of sprites
  79229. * @param cellSize defines the size of a sprite cell
  79230. * @param scene defines the hosting scene
  79231. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  79232. * @param samplingMode defines the smapling mode to use with spritesheet
  79233. */
  79234. constructor(
  79235. /** defines the manager's name */
  79236. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  79237. private _appendSpriteVertex;
  79238. /**
  79239. * Intersects the sprites with a ray
  79240. * @param ray defines the ray to intersect with
  79241. * @param camera defines the current active camera
  79242. * @param predicate defines a predicate used to select candidate sprites
  79243. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  79244. * @returns null if no hit or a PickingInfo
  79245. */
  79246. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  79247. /**
  79248. * Render all child sprites
  79249. */
  79250. render(): void;
  79251. /**
  79252. * Release associated resources
  79253. */
  79254. dispose(): void;
  79255. }
  79256. }
  79257. declare module BABYLON {
  79258. /**
  79259. * Class used to represent a sprite
  79260. * @see http://doc.babylonjs.com/babylon101/sprites
  79261. */
  79262. export class Sprite {
  79263. /** defines the name */
  79264. name: string;
  79265. /** Gets or sets the current world position */
  79266. position: Vector3;
  79267. /** Gets or sets the main color */
  79268. color: Color4;
  79269. /** Gets or sets the width */
  79270. width: number;
  79271. /** Gets or sets the height */
  79272. height: number;
  79273. /** Gets or sets rotation angle */
  79274. angle: number;
  79275. /** Gets or sets the cell index in the sprite sheet */
  79276. cellIndex: number;
  79277. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  79278. invertU: number;
  79279. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  79280. invertV: number;
  79281. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  79282. disposeWhenFinishedAnimating: boolean;
  79283. /** Gets the list of attached animations */
  79284. animations: Animation[];
  79285. /** Gets or sets a boolean indicating if the sprite can be picked */
  79286. isPickable: boolean;
  79287. /**
  79288. * Gets or sets the associated action manager
  79289. */
  79290. actionManager: Nullable<ActionManager>;
  79291. private _animationStarted;
  79292. private _loopAnimation;
  79293. private _fromIndex;
  79294. private _toIndex;
  79295. private _delay;
  79296. private _direction;
  79297. private _manager;
  79298. private _time;
  79299. private _onAnimationEnd;
  79300. /**
  79301. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  79302. */
  79303. isVisible: boolean;
  79304. /**
  79305. * Gets or sets the sprite size
  79306. */
  79307. size: number;
  79308. /**
  79309. * Creates a new Sprite
  79310. * @param name defines the name
  79311. * @param manager defines the manager
  79312. */
  79313. constructor(
  79314. /** defines the name */
  79315. name: string, manager: ISpriteManager);
  79316. /**
  79317. * Starts an animation
  79318. * @param from defines the initial key
  79319. * @param to defines the end key
  79320. * @param loop defines if the animation must loop
  79321. * @param delay defines the start delay (in ms)
  79322. * @param onAnimationEnd defines a callback to call when animation ends
  79323. */
  79324. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  79325. /** Stops current animation (if any) */
  79326. stopAnimation(): void;
  79327. /** @hidden */
  79328. _animate(deltaTime: number): void;
  79329. /** Release associated resources */
  79330. dispose(): void;
  79331. }
  79332. }
  79333. declare module BABYLON {
  79334. /**
  79335. * Information about the result of picking within a scene
  79336. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  79337. */
  79338. export class PickingInfo {
  79339. /** @hidden */
  79340. _pickingUnavailable: boolean;
  79341. /**
  79342. * If the pick collided with an object
  79343. */
  79344. hit: boolean;
  79345. /**
  79346. * Distance away where the pick collided
  79347. */
  79348. distance: number;
  79349. /**
  79350. * The location of pick collision
  79351. */
  79352. pickedPoint: Nullable<Vector3>;
  79353. /**
  79354. * The mesh corresponding the the pick collision
  79355. */
  79356. pickedMesh: Nullable<AbstractMesh>;
  79357. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  79358. bu: number;
  79359. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  79360. bv: number;
  79361. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  79362. faceId: number;
  79363. /** Id of the the submesh that was picked */
  79364. subMeshId: number;
  79365. /** If a sprite was picked, this will be the sprite the pick collided with */
  79366. pickedSprite: Nullable<Sprite>;
  79367. /**
  79368. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  79369. */
  79370. originMesh: Nullable<AbstractMesh>;
  79371. /**
  79372. * The ray that was used to perform the picking.
  79373. */
  79374. ray: Nullable<Ray>;
  79375. /**
  79376. * Gets the normal correspodning to the face the pick collided with
  79377. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  79378. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  79379. * @returns The normal correspodning to the face the pick collided with
  79380. */
  79381. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  79382. /**
  79383. * Gets the texture coordinates of where the pick occured
  79384. * @returns the vector containing the coordnates of the texture
  79385. */
  79386. getTextureCoordinates(): Nullable<Vector2>;
  79387. }
  79388. }
  79389. declare module BABYLON {
  79390. /**
  79391. * Gather the list of pointer event types as constants.
  79392. */
  79393. export class PointerEventTypes {
  79394. /**
  79395. * 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.
  79396. */
  79397. static readonly POINTERDOWN: number;
  79398. /**
  79399. * The pointerup event is fired when a pointer is no longer active.
  79400. */
  79401. static readonly POINTERUP: number;
  79402. /**
  79403. * The pointermove event is fired when a pointer changes coordinates.
  79404. */
  79405. static readonly POINTERMOVE: number;
  79406. /**
  79407. * The pointerwheel event is fired when a mouse wheel has been rotated.
  79408. */
  79409. static readonly POINTERWHEEL: number;
  79410. /**
  79411. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  79412. */
  79413. static readonly POINTERPICK: number;
  79414. /**
  79415. * The pointertap event is fired when a the object has been touched and released without drag.
  79416. */
  79417. static readonly POINTERTAP: number;
  79418. /**
  79419. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  79420. */
  79421. static readonly POINTERDOUBLETAP: number;
  79422. }
  79423. /**
  79424. * Base class of pointer info types.
  79425. */
  79426. export class PointerInfoBase {
  79427. /**
  79428. * Defines the type of event (PointerEventTypes)
  79429. */
  79430. type: number;
  79431. /**
  79432. * Defines the related dom event
  79433. */
  79434. event: PointerEvent | MouseWheelEvent;
  79435. /**
  79436. * Instantiates the base class of pointers info.
  79437. * @param type Defines the type of event (PointerEventTypes)
  79438. * @param event Defines the related dom event
  79439. */
  79440. constructor(
  79441. /**
  79442. * Defines the type of event (PointerEventTypes)
  79443. */
  79444. type: number,
  79445. /**
  79446. * Defines the related dom event
  79447. */
  79448. event: PointerEvent | MouseWheelEvent);
  79449. }
  79450. /**
  79451. * This class is used to store pointer related info for the onPrePointerObservable event.
  79452. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  79453. */
  79454. export class PointerInfoPre extends PointerInfoBase {
  79455. /**
  79456. * Ray from a pointer if availible (eg. 6dof controller)
  79457. */
  79458. ray: Nullable<Ray>;
  79459. /**
  79460. * Defines the local position of the pointer on the canvas.
  79461. */
  79462. localPosition: Vector2;
  79463. /**
  79464. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  79465. */
  79466. skipOnPointerObservable: boolean;
  79467. /**
  79468. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  79469. * @param type Defines the type of event (PointerEventTypes)
  79470. * @param event Defines the related dom event
  79471. * @param localX Defines the local x coordinates of the pointer when the event occured
  79472. * @param localY Defines the local y coordinates of the pointer when the event occured
  79473. */
  79474. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  79475. }
  79476. /**
  79477. * This type contains all the data related to a pointer event in Babylon.js.
  79478. * 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.
  79479. */
  79480. export class PointerInfo extends PointerInfoBase {
  79481. /**
  79482. * Defines the picking info associated to the info (if any)\
  79483. */
  79484. pickInfo: Nullable<PickingInfo>;
  79485. /**
  79486. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  79487. * @param type Defines the type of event (PointerEventTypes)
  79488. * @param event Defines the related dom event
  79489. * @param pickInfo Defines the picking info associated to the info (if any)\
  79490. */
  79491. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  79492. /**
  79493. * Defines the picking info associated to the info (if any)\
  79494. */
  79495. pickInfo: Nullable<PickingInfo>);
  79496. }
  79497. /**
  79498. * Data relating to a touch event on the screen.
  79499. */
  79500. export interface PointerTouch {
  79501. /**
  79502. * X coordinate of touch.
  79503. */
  79504. x: number;
  79505. /**
  79506. * Y coordinate of touch.
  79507. */
  79508. y: number;
  79509. /**
  79510. * Id of touch. Unique for each finger.
  79511. */
  79512. pointerId: number;
  79513. /**
  79514. * Event type passed from DOM.
  79515. */
  79516. type: any;
  79517. }
  79518. }
  79519. declare module BABYLON {
  79520. /**
  79521. * Manage the mouse inputs to control the movement of a free camera.
  79522. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79523. */
  79524. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  79525. /**
  79526. * Define if touch is enabled in the mouse input
  79527. */
  79528. touchEnabled: boolean;
  79529. /**
  79530. * Defines the camera the input is attached to.
  79531. */
  79532. camera: FreeCamera;
  79533. /**
  79534. * Defines the buttons associated with the input to handle camera move.
  79535. */
  79536. buttons: number[];
  79537. /**
  79538. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  79539. */
  79540. angularSensibility: number;
  79541. private _pointerInput;
  79542. private _onMouseMove;
  79543. private _observer;
  79544. private previousPosition;
  79545. /**
  79546. * Observable for when a pointer move event occurs containing the move offset
  79547. */
  79548. onPointerMovedObservable: Observable<{
  79549. offsetX: number;
  79550. offsetY: number;
  79551. }>;
  79552. /**
  79553. * @hidden
  79554. * If the camera should be rotated automatically based on pointer movement
  79555. */
  79556. _allowCameraRotation: boolean;
  79557. /**
  79558. * Manage the mouse inputs to control the movement of a free camera.
  79559. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79560. * @param touchEnabled Defines if touch is enabled or not
  79561. */
  79562. constructor(
  79563. /**
  79564. * Define if touch is enabled in the mouse input
  79565. */
  79566. touchEnabled?: boolean);
  79567. /**
  79568. * Attach the input controls to a specific dom element to get the input from.
  79569. * @param element Defines the element the controls should be listened from
  79570. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79571. */
  79572. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79573. /**
  79574. * Called on JS contextmenu event.
  79575. * Override this method to provide functionality.
  79576. */
  79577. protected onContextMenu(evt: PointerEvent): void;
  79578. /**
  79579. * Detach the current controls from the specified dom element.
  79580. * @param element Defines the element to stop listening the inputs from
  79581. */
  79582. detachControl(element: Nullable<HTMLElement>): void;
  79583. /**
  79584. * Gets the class name of the current intput.
  79585. * @returns the class name
  79586. */
  79587. getClassName(): string;
  79588. /**
  79589. * Get the friendly name associated with the input class.
  79590. * @returns the input friendly name
  79591. */
  79592. getSimpleName(): string;
  79593. }
  79594. }
  79595. declare module BABYLON {
  79596. /**
  79597. * Manage the touch inputs to control the movement of a free camera.
  79598. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79599. */
  79600. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  79601. /**
  79602. * Defines the camera the input is attached to.
  79603. */
  79604. camera: FreeCamera;
  79605. /**
  79606. * Defines the touch sensibility for rotation.
  79607. * The higher the faster.
  79608. */
  79609. touchAngularSensibility: number;
  79610. /**
  79611. * Defines the touch sensibility for move.
  79612. * The higher the faster.
  79613. */
  79614. touchMoveSensibility: number;
  79615. private _offsetX;
  79616. private _offsetY;
  79617. private _pointerPressed;
  79618. private _pointerInput;
  79619. private _observer;
  79620. private _onLostFocus;
  79621. /**
  79622. * Attach the input controls to a specific dom element to get the input from.
  79623. * @param element Defines the element the controls should be listened from
  79624. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79625. */
  79626. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79627. /**
  79628. * Detach the current controls from the specified dom element.
  79629. * @param element Defines the element to stop listening the inputs from
  79630. */
  79631. detachControl(element: Nullable<HTMLElement>): void;
  79632. /**
  79633. * Update the current camera state depending on the inputs that have been used this frame.
  79634. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  79635. */
  79636. checkInputs(): void;
  79637. /**
  79638. * Gets the class name of the current intput.
  79639. * @returns the class name
  79640. */
  79641. getClassName(): string;
  79642. /**
  79643. * Get the friendly name associated with the input class.
  79644. * @returns the input friendly name
  79645. */
  79646. getSimpleName(): string;
  79647. }
  79648. }
  79649. declare module BABYLON {
  79650. /**
  79651. * Default Inputs manager for the FreeCamera.
  79652. * It groups all the default supported inputs for ease of use.
  79653. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79654. */
  79655. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  79656. /**
  79657. * @hidden
  79658. */
  79659. _mouseInput: Nullable<FreeCameraMouseInput>;
  79660. /**
  79661. * Instantiates a new FreeCameraInputsManager.
  79662. * @param camera Defines the camera the inputs belong to
  79663. */
  79664. constructor(camera: FreeCamera);
  79665. /**
  79666. * Add keyboard input support to the input manager.
  79667. * @returns the current input manager
  79668. */
  79669. addKeyboard(): FreeCameraInputsManager;
  79670. /**
  79671. * Add mouse input support to the input manager.
  79672. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  79673. * @returns the current input manager
  79674. */
  79675. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  79676. /**
  79677. * Removes the mouse input support from the manager
  79678. * @returns the current input manager
  79679. */
  79680. removeMouse(): FreeCameraInputsManager;
  79681. /**
  79682. * Add touch input support to the input manager.
  79683. * @returns the current input manager
  79684. */
  79685. addTouch(): FreeCameraInputsManager;
  79686. /**
  79687. * Remove all attached input methods from a camera
  79688. */
  79689. clear(): void;
  79690. }
  79691. }
  79692. declare module BABYLON {
  79693. /**
  79694. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  79695. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  79696. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  79697. */
  79698. export class FreeCamera extends TargetCamera {
  79699. /**
  79700. * Define the collision ellipsoid of the camera.
  79701. * This is helpful to simulate a camera body like the player body around the camera
  79702. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  79703. */
  79704. ellipsoid: Vector3;
  79705. /**
  79706. * Define an offset for the position of the ellipsoid around the camera.
  79707. * This can be helpful to determine the center of the body near the gravity center of the body
  79708. * instead of its head.
  79709. */
  79710. ellipsoidOffset: Vector3;
  79711. /**
  79712. * Enable or disable collisions of the camera with the rest of the scene objects.
  79713. */
  79714. checkCollisions: boolean;
  79715. /**
  79716. * Enable or disable gravity on the camera.
  79717. */
  79718. applyGravity: boolean;
  79719. /**
  79720. * Define the input manager associated to the camera.
  79721. */
  79722. inputs: FreeCameraInputsManager;
  79723. /**
  79724. * Gets the input sensibility for a mouse input. (default is 2000.0)
  79725. * Higher values reduce sensitivity.
  79726. */
  79727. /**
  79728. * Sets the input sensibility for a mouse input. (default is 2000.0)
  79729. * Higher values reduce sensitivity.
  79730. */
  79731. angularSensibility: number;
  79732. /**
  79733. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  79734. */
  79735. keysUp: number[];
  79736. /**
  79737. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  79738. */
  79739. keysDown: number[];
  79740. /**
  79741. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  79742. */
  79743. keysLeft: number[];
  79744. /**
  79745. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  79746. */
  79747. keysRight: number[];
  79748. /**
  79749. * Event raised when the camera collide with a mesh in the scene.
  79750. */
  79751. onCollide: (collidedMesh: AbstractMesh) => void;
  79752. private _collider;
  79753. private _needMoveForGravity;
  79754. private _oldPosition;
  79755. private _diffPosition;
  79756. private _newPosition;
  79757. /** @hidden */
  79758. _localDirection: Vector3;
  79759. /** @hidden */
  79760. _transformedDirection: Vector3;
  79761. /**
  79762. * Instantiates a Free Camera.
  79763. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  79764. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  79765. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  79766. * @param name Define the name of the camera in the scene
  79767. * @param position Define the start position of the camera in the scene
  79768. * @param scene Define the scene the camera belongs to
  79769. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  79770. */
  79771. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  79772. /**
  79773. * Attached controls to the current camera.
  79774. * @param element Defines the element the controls should be listened from
  79775. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79776. */
  79777. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79778. /**
  79779. * Detach the current controls from the camera.
  79780. * The camera will stop reacting to inputs.
  79781. * @param element Defines the element to stop listening the inputs from
  79782. */
  79783. detachControl(element: HTMLElement): void;
  79784. private _collisionMask;
  79785. /**
  79786. * Define a collision mask to limit the list of object the camera can collide with
  79787. */
  79788. collisionMask: number;
  79789. /** @hidden */
  79790. _collideWithWorld(displacement: Vector3): void;
  79791. private _onCollisionPositionChange;
  79792. /** @hidden */
  79793. _checkInputs(): void;
  79794. /** @hidden */
  79795. _decideIfNeedsToMove(): boolean;
  79796. /** @hidden */
  79797. _updatePosition(): void;
  79798. /**
  79799. * Destroy the camera and release the current resources hold by it.
  79800. */
  79801. dispose(): void;
  79802. /**
  79803. * Gets the current object class name.
  79804. * @return the class name
  79805. */
  79806. getClassName(): string;
  79807. }
  79808. }
  79809. declare module BABYLON {
  79810. /**
  79811. * Represents a gamepad control stick position
  79812. */
  79813. export class StickValues {
  79814. /**
  79815. * The x component of the control stick
  79816. */
  79817. x: number;
  79818. /**
  79819. * The y component of the control stick
  79820. */
  79821. y: number;
  79822. /**
  79823. * Initializes the gamepad x and y control stick values
  79824. * @param x The x component of the gamepad control stick value
  79825. * @param y The y component of the gamepad control stick value
  79826. */
  79827. constructor(
  79828. /**
  79829. * The x component of the control stick
  79830. */
  79831. x: number,
  79832. /**
  79833. * The y component of the control stick
  79834. */
  79835. y: number);
  79836. }
  79837. /**
  79838. * An interface which manages callbacks for gamepad button changes
  79839. */
  79840. export interface GamepadButtonChanges {
  79841. /**
  79842. * Called when a gamepad has been changed
  79843. */
  79844. changed: boolean;
  79845. /**
  79846. * Called when a gamepad press event has been triggered
  79847. */
  79848. pressChanged: boolean;
  79849. /**
  79850. * Called when a touch event has been triggered
  79851. */
  79852. touchChanged: boolean;
  79853. /**
  79854. * Called when a value has changed
  79855. */
  79856. valueChanged: boolean;
  79857. }
  79858. /**
  79859. * Represents a gamepad
  79860. */
  79861. export class Gamepad {
  79862. /**
  79863. * The id of the gamepad
  79864. */
  79865. id: string;
  79866. /**
  79867. * The index of the gamepad
  79868. */
  79869. index: number;
  79870. /**
  79871. * The browser gamepad
  79872. */
  79873. browserGamepad: any;
  79874. /**
  79875. * Specifies what type of gamepad this represents
  79876. */
  79877. type: number;
  79878. private _leftStick;
  79879. private _rightStick;
  79880. /** @hidden */
  79881. _isConnected: boolean;
  79882. private _leftStickAxisX;
  79883. private _leftStickAxisY;
  79884. private _rightStickAxisX;
  79885. private _rightStickAxisY;
  79886. /**
  79887. * Triggered when the left control stick has been changed
  79888. */
  79889. private _onleftstickchanged;
  79890. /**
  79891. * Triggered when the right control stick has been changed
  79892. */
  79893. private _onrightstickchanged;
  79894. /**
  79895. * Represents a gamepad controller
  79896. */
  79897. static GAMEPAD: number;
  79898. /**
  79899. * Represents a generic controller
  79900. */
  79901. static GENERIC: number;
  79902. /**
  79903. * Represents an XBox controller
  79904. */
  79905. static XBOX: number;
  79906. /**
  79907. * Represents a pose-enabled controller
  79908. */
  79909. static POSE_ENABLED: number;
  79910. /**
  79911. * Specifies whether the left control stick should be Y-inverted
  79912. */
  79913. protected _invertLeftStickY: boolean;
  79914. /**
  79915. * Specifies if the gamepad has been connected
  79916. */
  79917. readonly isConnected: boolean;
  79918. /**
  79919. * Initializes the gamepad
  79920. * @param id The id of the gamepad
  79921. * @param index The index of the gamepad
  79922. * @param browserGamepad The browser gamepad
  79923. * @param leftStickX The x component of the left joystick
  79924. * @param leftStickY The y component of the left joystick
  79925. * @param rightStickX The x component of the right joystick
  79926. * @param rightStickY The y component of the right joystick
  79927. */
  79928. constructor(
  79929. /**
  79930. * The id of the gamepad
  79931. */
  79932. id: string,
  79933. /**
  79934. * The index of the gamepad
  79935. */
  79936. index: number,
  79937. /**
  79938. * The browser gamepad
  79939. */
  79940. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  79941. /**
  79942. * Callback triggered when the left joystick has changed
  79943. * @param callback
  79944. */
  79945. onleftstickchanged(callback: (values: StickValues) => void): void;
  79946. /**
  79947. * Callback triggered when the right joystick has changed
  79948. * @param callback
  79949. */
  79950. onrightstickchanged(callback: (values: StickValues) => void): void;
  79951. /**
  79952. * Gets the left joystick
  79953. */
  79954. /**
  79955. * Sets the left joystick values
  79956. */
  79957. leftStick: StickValues;
  79958. /**
  79959. * Gets the right joystick
  79960. */
  79961. /**
  79962. * Sets the right joystick value
  79963. */
  79964. rightStick: StickValues;
  79965. /**
  79966. * Updates the gamepad joystick positions
  79967. */
  79968. update(): void;
  79969. /**
  79970. * Disposes the gamepad
  79971. */
  79972. dispose(): void;
  79973. }
  79974. /**
  79975. * Represents a generic gamepad
  79976. */
  79977. export class GenericPad extends Gamepad {
  79978. private _buttons;
  79979. private _onbuttondown;
  79980. private _onbuttonup;
  79981. /**
  79982. * Observable triggered when a button has been pressed
  79983. */
  79984. onButtonDownObservable: Observable<number>;
  79985. /**
  79986. * Observable triggered when a button has been released
  79987. */
  79988. onButtonUpObservable: Observable<number>;
  79989. /**
  79990. * Callback triggered when a button has been pressed
  79991. * @param callback Called when a button has been pressed
  79992. */
  79993. onbuttondown(callback: (buttonPressed: number) => void): void;
  79994. /**
  79995. * Callback triggered when a button has been released
  79996. * @param callback Called when a button has been released
  79997. */
  79998. onbuttonup(callback: (buttonReleased: number) => void): void;
  79999. /**
  80000. * Initializes the generic gamepad
  80001. * @param id The id of the generic gamepad
  80002. * @param index The index of the generic gamepad
  80003. * @param browserGamepad The browser gamepad
  80004. */
  80005. constructor(id: string, index: number, browserGamepad: any);
  80006. private _setButtonValue;
  80007. /**
  80008. * Updates the generic gamepad
  80009. */
  80010. update(): void;
  80011. /**
  80012. * Disposes the generic gamepad
  80013. */
  80014. dispose(): void;
  80015. }
  80016. }
  80017. declare module BABYLON {
  80018. /**
  80019. * Defines the types of pose enabled controllers that are supported
  80020. */
  80021. export enum PoseEnabledControllerType {
  80022. /**
  80023. * HTC Vive
  80024. */
  80025. VIVE = 0,
  80026. /**
  80027. * Oculus Rift
  80028. */
  80029. OCULUS = 1,
  80030. /**
  80031. * Windows mixed reality
  80032. */
  80033. WINDOWS = 2,
  80034. /**
  80035. * Samsung gear VR
  80036. */
  80037. GEAR_VR = 3,
  80038. /**
  80039. * Google Daydream
  80040. */
  80041. DAYDREAM = 4,
  80042. /**
  80043. * Generic
  80044. */
  80045. GENERIC = 5
  80046. }
  80047. /**
  80048. * Defines the MutableGamepadButton interface for the state of a gamepad button
  80049. */
  80050. export interface MutableGamepadButton {
  80051. /**
  80052. * Value of the button/trigger
  80053. */
  80054. value: number;
  80055. /**
  80056. * If the button/trigger is currently touched
  80057. */
  80058. touched: boolean;
  80059. /**
  80060. * If the button/trigger is currently pressed
  80061. */
  80062. pressed: boolean;
  80063. }
  80064. /**
  80065. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  80066. * @hidden
  80067. */
  80068. export interface ExtendedGamepadButton extends GamepadButton {
  80069. /**
  80070. * If the button/trigger is currently pressed
  80071. */
  80072. readonly pressed: boolean;
  80073. /**
  80074. * If the button/trigger is currently touched
  80075. */
  80076. readonly touched: boolean;
  80077. /**
  80078. * Value of the button/trigger
  80079. */
  80080. readonly value: number;
  80081. }
  80082. /** @hidden */
  80083. export interface _GamePadFactory {
  80084. /**
  80085. * Returns wether or not the current gamepad can be created for this type of controller.
  80086. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  80087. * @returns true if it can be created, otherwise false
  80088. */
  80089. canCreate(gamepadInfo: any): boolean;
  80090. /**
  80091. * Creates a new instance of the Gamepad.
  80092. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  80093. * @returns the new gamepad instance
  80094. */
  80095. create(gamepadInfo: any): Gamepad;
  80096. }
  80097. /**
  80098. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  80099. */
  80100. export class PoseEnabledControllerHelper {
  80101. /** @hidden */
  80102. static _ControllerFactories: _GamePadFactory[];
  80103. /** @hidden */
  80104. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  80105. /**
  80106. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  80107. * @param vrGamepad the gamepad to initialized
  80108. * @returns a vr controller of the type the gamepad identified as
  80109. */
  80110. static InitiateController(vrGamepad: any): Gamepad;
  80111. }
  80112. /**
  80113. * Defines the PoseEnabledController object that contains state of a vr capable controller
  80114. */
  80115. export class PoseEnabledController extends Gamepad implements PoseControlled {
  80116. private _deviceRoomPosition;
  80117. private _deviceRoomRotationQuaternion;
  80118. /**
  80119. * The device position in babylon space
  80120. */
  80121. devicePosition: Vector3;
  80122. /**
  80123. * The device rotation in babylon space
  80124. */
  80125. deviceRotationQuaternion: Quaternion;
  80126. /**
  80127. * The scale factor of the device in babylon space
  80128. */
  80129. deviceScaleFactor: number;
  80130. /**
  80131. * (Likely devicePosition should be used instead) The device position in its room space
  80132. */
  80133. position: Vector3;
  80134. /**
  80135. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  80136. */
  80137. rotationQuaternion: Quaternion;
  80138. /**
  80139. * The type of controller (Eg. Windows mixed reality)
  80140. */
  80141. controllerType: PoseEnabledControllerType;
  80142. protected _calculatedPosition: Vector3;
  80143. private _calculatedRotation;
  80144. /**
  80145. * The raw pose from the device
  80146. */
  80147. rawPose: DevicePose;
  80148. private _trackPosition;
  80149. private _maxRotationDistFromHeadset;
  80150. private _draggedRoomRotation;
  80151. /**
  80152. * @hidden
  80153. */
  80154. _disableTrackPosition(fixedPosition: Vector3): void;
  80155. /**
  80156. * Internal, the mesh attached to the controller
  80157. * @hidden
  80158. */
  80159. _mesh: Nullable<AbstractMesh>;
  80160. private _poseControlledCamera;
  80161. private _leftHandSystemQuaternion;
  80162. /**
  80163. * Internal, matrix used to convert room space to babylon space
  80164. * @hidden
  80165. */
  80166. _deviceToWorld: Matrix;
  80167. /**
  80168. * Node to be used when casting a ray from the controller
  80169. * @hidden
  80170. */
  80171. _pointingPoseNode: Nullable<TransformNode>;
  80172. /**
  80173. * Name of the child mesh that can be used to cast a ray from the controller
  80174. */
  80175. static readonly POINTING_POSE: string;
  80176. /**
  80177. * Creates a new PoseEnabledController from a gamepad
  80178. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  80179. */
  80180. constructor(browserGamepad: any);
  80181. private _workingMatrix;
  80182. /**
  80183. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  80184. */
  80185. update(): void;
  80186. /**
  80187. * Updates only the pose device and mesh without doing any button event checking
  80188. */
  80189. protected _updatePoseAndMesh(): void;
  80190. /**
  80191. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  80192. * @param poseData raw pose fromthe device
  80193. */
  80194. updateFromDevice(poseData: DevicePose): void;
  80195. /**
  80196. * @hidden
  80197. */
  80198. _meshAttachedObservable: Observable<AbstractMesh>;
  80199. /**
  80200. * Attaches a mesh to the controller
  80201. * @param mesh the mesh to be attached
  80202. */
  80203. attachToMesh(mesh: AbstractMesh): void;
  80204. /**
  80205. * Attaches the controllers mesh to a camera
  80206. * @param camera the camera the mesh should be attached to
  80207. */
  80208. attachToPoseControlledCamera(camera: TargetCamera): void;
  80209. /**
  80210. * Disposes of the controller
  80211. */
  80212. dispose(): void;
  80213. /**
  80214. * The mesh that is attached to the controller
  80215. */
  80216. readonly mesh: Nullable<AbstractMesh>;
  80217. /**
  80218. * Gets the ray of the controller in the direction the controller is pointing
  80219. * @param length the length the resulting ray should be
  80220. * @returns a ray in the direction the controller is pointing
  80221. */
  80222. getForwardRay(length?: number): Ray;
  80223. }
  80224. }
  80225. declare module BABYLON {
  80226. /**
  80227. * Defines the WebVRController object that represents controllers tracked in 3D space
  80228. */
  80229. export abstract class WebVRController extends PoseEnabledController {
  80230. /**
  80231. * Internal, the default controller model for the controller
  80232. */
  80233. protected _defaultModel: AbstractMesh;
  80234. /**
  80235. * Fired when the trigger state has changed
  80236. */
  80237. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  80238. /**
  80239. * Fired when the main button state has changed
  80240. */
  80241. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  80242. /**
  80243. * Fired when the secondary button state has changed
  80244. */
  80245. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  80246. /**
  80247. * Fired when the pad state has changed
  80248. */
  80249. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  80250. /**
  80251. * Fired when controllers stick values have changed
  80252. */
  80253. onPadValuesChangedObservable: Observable<StickValues>;
  80254. /**
  80255. * Array of button availible on the controller
  80256. */
  80257. protected _buttons: Array<MutableGamepadButton>;
  80258. private _onButtonStateChange;
  80259. /**
  80260. * Fired when a controller button's state has changed
  80261. * @param callback the callback containing the button that was modified
  80262. */
  80263. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  80264. /**
  80265. * X and Y axis corresponding to the controllers joystick
  80266. */
  80267. pad: StickValues;
  80268. /**
  80269. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  80270. */
  80271. hand: string;
  80272. /**
  80273. * The default controller model for the controller
  80274. */
  80275. readonly defaultModel: AbstractMesh;
  80276. /**
  80277. * Creates a new WebVRController from a gamepad
  80278. * @param vrGamepad the gamepad that the WebVRController should be created from
  80279. */
  80280. constructor(vrGamepad: any);
  80281. /**
  80282. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  80283. */
  80284. update(): void;
  80285. /**
  80286. * Function to be called when a button is modified
  80287. */
  80288. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  80289. /**
  80290. * Loads a mesh and attaches it to the controller
  80291. * @param scene the scene the mesh should be added to
  80292. * @param meshLoaded callback for when the mesh has been loaded
  80293. */
  80294. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  80295. private _setButtonValue;
  80296. private _changes;
  80297. private _checkChanges;
  80298. /**
  80299. * Disposes of th webVRCOntroller
  80300. */
  80301. dispose(): void;
  80302. }
  80303. }
  80304. declare module BABYLON {
  80305. /**
  80306. * The HemisphericLight simulates the ambient environment light,
  80307. * so the passed direction is the light reflection direction, not the incoming direction.
  80308. */
  80309. export class HemisphericLight extends Light {
  80310. /**
  80311. * The groundColor is the light in the opposite direction to the one specified during creation.
  80312. * 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.
  80313. */
  80314. groundColor: Color3;
  80315. /**
  80316. * The light reflection direction, not the incoming direction.
  80317. */
  80318. direction: Vector3;
  80319. /**
  80320. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  80321. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  80322. * The HemisphericLight can't cast shadows.
  80323. * Documentation : https://doc.babylonjs.com/babylon101/lights
  80324. * @param name The friendly name of the light
  80325. * @param direction The direction of the light reflection
  80326. * @param scene The scene the light belongs to
  80327. */
  80328. constructor(name: string, direction: Vector3, scene: Scene);
  80329. protected _buildUniformLayout(): void;
  80330. /**
  80331. * Returns the string "HemisphericLight".
  80332. * @return The class name
  80333. */
  80334. getClassName(): string;
  80335. /**
  80336. * Sets the HemisphericLight direction towards the passed target (Vector3).
  80337. * Returns the updated direction.
  80338. * @param target The target the direction should point to
  80339. * @return The computed direction
  80340. */
  80341. setDirectionToTarget(target: Vector3): Vector3;
  80342. /**
  80343. * Returns the shadow generator associated to the light.
  80344. * @returns Always null for hemispheric lights because it does not support shadows.
  80345. */
  80346. getShadowGenerator(): Nullable<IShadowGenerator>;
  80347. /**
  80348. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  80349. * @param effect The effect to update
  80350. * @param lightIndex The index of the light in the effect to update
  80351. * @returns The hemispheric light
  80352. */
  80353. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  80354. /**
  80355. * Computes the world matrix of the node
  80356. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  80357. * @param useWasUpdatedFlag defines a reserved property
  80358. * @returns the world matrix
  80359. */
  80360. computeWorldMatrix(): Matrix;
  80361. /**
  80362. * Returns the integer 3.
  80363. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  80364. */
  80365. getTypeID(): number;
  80366. /**
  80367. * Prepares the list of defines specific to the light type.
  80368. * @param defines the list of defines
  80369. * @param lightIndex defines the index of the light for the effect
  80370. */
  80371. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  80372. }
  80373. }
  80374. declare module BABYLON {
  80375. /** @hidden */
  80376. export var vrMultiviewToSingleviewPixelShader: {
  80377. name: string;
  80378. shader: string;
  80379. };
  80380. }
  80381. declare module BABYLON {
  80382. /**
  80383. * Renders to multiple views with a single draw call
  80384. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  80385. */
  80386. export class MultiviewRenderTarget extends RenderTargetTexture {
  80387. /**
  80388. * Creates a multiview render target
  80389. * @param scene scene used with the render target
  80390. * @param size the size of the render target (used for each view)
  80391. */
  80392. constructor(scene: Scene, size?: number | {
  80393. width: number;
  80394. height: number;
  80395. } | {
  80396. ratio: number;
  80397. });
  80398. /**
  80399. * @hidden
  80400. * @param faceIndex the face index, if its a cube texture
  80401. */
  80402. _bindFrameBuffer(faceIndex?: number): void;
  80403. /**
  80404. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  80405. * @returns the view count
  80406. */
  80407. getViewCount(): number;
  80408. }
  80409. }
  80410. declare module BABYLON {
  80411. interface Engine {
  80412. /**
  80413. * Creates a new multiview render target
  80414. * @param width defines the width of the texture
  80415. * @param height defines the height of the texture
  80416. * @returns the created multiview texture
  80417. */
  80418. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  80419. /**
  80420. * Binds a multiview framebuffer to be drawn to
  80421. * @param multiviewTexture texture to bind
  80422. */
  80423. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  80424. }
  80425. interface Camera {
  80426. /**
  80427. * @hidden
  80428. * 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)
  80429. */
  80430. _useMultiviewToSingleView: boolean;
  80431. /**
  80432. * @hidden
  80433. * 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)
  80434. */
  80435. _multiviewTexture: Nullable<RenderTargetTexture>;
  80436. /**
  80437. * @hidden
  80438. * ensures the multiview texture of the camera exists and has the specified width/height
  80439. * @param width height to set on the multiview texture
  80440. * @param height width to set on the multiview texture
  80441. */
  80442. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  80443. }
  80444. interface Scene {
  80445. /** @hidden */
  80446. _transformMatrixR: Matrix;
  80447. /** @hidden */
  80448. _multiviewSceneUbo: Nullable<UniformBuffer>;
  80449. /** @hidden */
  80450. _createMultiviewUbo(): void;
  80451. /** @hidden */
  80452. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  80453. /** @hidden */
  80454. _renderMultiviewToSingleView(camera: Camera): void;
  80455. }
  80456. }
  80457. declare module BABYLON {
  80458. /**
  80459. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  80460. * This will not be used for webXR as it supports displaying texture arrays directly
  80461. */
  80462. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  80463. /**
  80464. * Initializes a VRMultiviewToSingleview
  80465. * @param name name of the post process
  80466. * @param camera camera to be applied to
  80467. * @param scaleFactor scaling factor to the size of the output texture
  80468. */
  80469. constructor(name: string, camera: Camera, scaleFactor: number);
  80470. }
  80471. }
  80472. declare module BABYLON {
  80473. interface Engine {
  80474. /** @hidden */
  80475. _vrDisplay: any;
  80476. /** @hidden */
  80477. _vrSupported: boolean;
  80478. /** @hidden */
  80479. _oldSize: Size;
  80480. /** @hidden */
  80481. _oldHardwareScaleFactor: number;
  80482. /** @hidden */
  80483. _vrExclusivePointerMode: boolean;
  80484. /** @hidden */
  80485. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  80486. /** @hidden */
  80487. _onVRDisplayPointerRestricted: () => void;
  80488. /** @hidden */
  80489. _onVRDisplayPointerUnrestricted: () => void;
  80490. /** @hidden */
  80491. _onVrDisplayConnect: Nullable<(display: any) => void>;
  80492. /** @hidden */
  80493. _onVrDisplayDisconnect: Nullable<() => void>;
  80494. /** @hidden */
  80495. _onVrDisplayPresentChange: Nullable<() => void>;
  80496. /**
  80497. * Observable signaled when VR display mode changes
  80498. */
  80499. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  80500. /**
  80501. * Observable signaled when VR request present is complete
  80502. */
  80503. onVRRequestPresentComplete: Observable<boolean>;
  80504. /**
  80505. * Observable signaled when VR request present starts
  80506. */
  80507. onVRRequestPresentStart: Observable<Engine>;
  80508. /**
  80509. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  80510. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  80511. */
  80512. isInVRExclusivePointerMode: boolean;
  80513. /**
  80514. * Gets a boolean indicating if a webVR device was detected
  80515. * @returns true if a webVR device was detected
  80516. */
  80517. isVRDevicePresent(): boolean;
  80518. /**
  80519. * Gets the current webVR device
  80520. * @returns the current webVR device (or null)
  80521. */
  80522. getVRDevice(): any;
  80523. /**
  80524. * Initializes a webVR display and starts listening to display change events
  80525. * The onVRDisplayChangedObservable will be notified upon these changes
  80526. * @returns A promise containing a VRDisplay and if vr is supported
  80527. */
  80528. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  80529. /** @hidden */
  80530. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  80531. /**
  80532. * Call this function to switch to webVR mode
  80533. * Will do nothing if webVR is not supported or if there is no webVR device
  80534. * @see http://doc.babylonjs.com/how_to/webvr_camera
  80535. */
  80536. enableVR(): void;
  80537. /** @hidden */
  80538. _onVRFullScreenTriggered(): void;
  80539. }
  80540. }
  80541. declare module BABYLON {
  80542. /**
  80543. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  80544. * IMPORTANT!! The data is right-hand data.
  80545. * @export
  80546. * @interface DevicePose
  80547. */
  80548. export interface DevicePose {
  80549. /**
  80550. * The position of the device, values in array are [x,y,z].
  80551. */
  80552. readonly position: Nullable<Float32Array>;
  80553. /**
  80554. * The linearVelocity of the device, values in array are [x,y,z].
  80555. */
  80556. readonly linearVelocity: Nullable<Float32Array>;
  80557. /**
  80558. * The linearAcceleration of the device, values in array are [x,y,z].
  80559. */
  80560. readonly linearAcceleration: Nullable<Float32Array>;
  80561. /**
  80562. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  80563. */
  80564. readonly orientation: Nullable<Float32Array>;
  80565. /**
  80566. * The angularVelocity of the device, values in array are [x,y,z].
  80567. */
  80568. readonly angularVelocity: Nullable<Float32Array>;
  80569. /**
  80570. * The angularAcceleration of the device, values in array are [x,y,z].
  80571. */
  80572. readonly angularAcceleration: Nullable<Float32Array>;
  80573. }
  80574. /**
  80575. * Interface representing a pose controlled object in Babylon.
  80576. * A pose controlled object has both regular pose values as well as pose values
  80577. * from an external device such as a VR head mounted display
  80578. */
  80579. export interface PoseControlled {
  80580. /**
  80581. * The position of the object in babylon space.
  80582. */
  80583. position: Vector3;
  80584. /**
  80585. * The rotation quaternion of the object in babylon space.
  80586. */
  80587. rotationQuaternion: Quaternion;
  80588. /**
  80589. * The position of the device in babylon space.
  80590. */
  80591. devicePosition?: Vector3;
  80592. /**
  80593. * The rotation quaternion of the device in babylon space.
  80594. */
  80595. deviceRotationQuaternion: Quaternion;
  80596. /**
  80597. * The raw pose coming from the device.
  80598. */
  80599. rawPose: Nullable<DevicePose>;
  80600. /**
  80601. * The scale of the device to be used when translating from device space to babylon space.
  80602. */
  80603. deviceScaleFactor: number;
  80604. /**
  80605. * Updates the poseControlled values based on the input device pose.
  80606. * @param poseData the pose data to update the object with
  80607. */
  80608. updateFromDevice(poseData: DevicePose): void;
  80609. }
  80610. /**
  80611. * Set of options to customize the webVRCamera
  80612. */
  80613. export interface WebVROptions {
  80614. /**
  80615. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  80616. */
  80617. trackPosition?: boolean;
  80618. /**
  80619. * Sets the scale of the vrDevice in babylon space. (default: 1)
  80620. */
  80621. positionScale?: number;
  80622. /**
  80623. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  80624. */
  80625. displayName?: string;
  80626. /**
  80627. * Should the native controller meshes be initialized. (default: true)
  80628. */
  80629. controllerMeshes?: boolean;
  80630. /**
  80631. * Creating a default HemiLight only on controllers. (default: true)
  80632. */
  80633. defaultLightingOnControllers?: boolean;
  80634. /**
  80635. * If you don't want to use the default VR button of the helper. (default: false)
  80636. */
  80637. useCustomVRButton?: boolean;
  80638. /**
  80639. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  80640. */
  80641. customVRButton?: HTMLButtonElement;
  80642. /**
  80643. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  80644. */
  80645. rayLength?: number;
  80646. /**
  80647. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  80648. */
  80649. defaultHeight?: number;
  80650. /**
  80651. * If multiview should be used if availible (default: false)
  80652. */
  80653. useMultiview?: boolean;
  80654. }
  80655. /**
  80656. * This represents a WebVR camera.
  80657. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  80658. * @example http://doc.babylonjs.com/how_to/webvr_camera
  80659. */
  80660. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  80661. private webVROptions;
  80662. /**
  80663. * @hidden
  80664. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  80665. */
  80666. _vrDevice: any;
  80667. /**
  80668. * The rawPose of the vrDevice.
  80669. */
  80670. rawPose: Nullable<DevicePose>;
  80671. private _onVREnabled;
  80672. private _specsVersion;
  80673. private _attached;
  80674. private _frameData;
  80675. protected _descendants: Array<Node>;
  80676. private _deviceRoomPosition;
  80677. /** @hidden */
  80678. _deviceRoomRotationQuaternion: Quaternion;
  80679. private _standingMatrix;
  80680. /**
  80681. * Represents device position in babylon space.
  80682. */
  80683. devicePosition: Vector3;
  80684. /**
  80685. * Represents device rotation in babylon space.
  80686. */
  80687. deviceRotationQuaternion: Quaternion;
  80688. /**
  80689. * The scale of the device to be used when translating from device space to babylon space.
  80690. */
  80691. deviceScaleFactor: number;
  80692. private _deviceToWorld;
  80693. private _worldToDevice;
  80694. /**
  80695. * References to the webVR controllers for the vrDevice.
  80696. */
  80697. controllers: Array<WebVRController>;
  80698. /**
  80699. * Emits an event when a controller is attached.
  80700. */
  80701. onControllersAttachedObservable: Observable<WebVRController[]>;
  80702. /**
  80703. * Emits an event when a controller's mesh has been loaded;
  80704. */
  80705. onControllerMeshLoadedObservable: Observable<WebVRController>;
  80706. /**
  80707. * Emits an event when the HMD's pose has been updated.
  80708. */
  80709. onPoseUpdatedFromDeviceObservable: Observable<any>;
  80710. private _poseSet;
  80711. /**
  80712. * If the rig cameras be used as parent instead of this camera.
  80713. */
  80714. rigParenting: boolean;
  80715. private _lightOnControllers;
  80716. private _defaultHeight?;
  80717. /**
  80718. * Instantiates a WebVRFreeCamera.
  80719. * @param name The name of the WebVRFreeCamera
  80720. * @param position The starting anchor position for the camera
  80721. * @param scene The scene the camera belongs to
  80722. * @param webVROptions a set of customizable options for the webVRCamera
  80723. */
  80724. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  80725. /**
  80726. * Gets the device distance from the ground in meters.
  80727. * @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.
  80728. */
  80729. deviceDistanceToRoomGround(): number;
  80730. /**
  80731. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  80732. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  80733. */
  80734. useStandingMatrix(callback?: (bool: boolean) => void): void;
  80735. /**
  80736. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  80737. * @returns A promise with a boolean set to if the standing matrix is supported.
  80738. */
  80739. useStandingMatrixAsync(): Promise<boolean>;
  80740. /**
  80741. * Disposes the camera
  80742. */
  80743. dispose(): void;
  80744. /**
  80745. * Gets a vrController by name.
  80746. * @param name The name of the controller to retreive
  80747. * @returns the controller matching the name specified or null if not found
  80748. */
  80749. getControllerByName(name: string): Nullable<WebVRController>;
  80750. private _leftController;
  80751. /**
  80752. * The controller corresponding to the users left hand.
  80753. */
  80754. readonly leftController: Nullable<WebVRController>;
  80755. private _rightController;
  80756. /**
  80757. * The controller corresponding to the users right hand.
  80758. */
  80759. readonly rightController: Nullable<WebVRController>;
  80760. /**
  80761. * Casts a ray forward from the vrCamera's gaze.
  80762. * @param length Length of the ray (default: 100)
  80763. * @returns the ray corresponding to the gaze
  80764. */
  80765. getForwardRay(length?: number): Ray;
  80766. /**
  80767. * @hidden
  80768. * Updates the camera based on device's frame data
  80769. */
  80770. _checkInputs(): void;
  80771. /**
  80772. * Updates the poseControlled values based on the input device pose.
  80773. * @param poseData Pose coming from the device
  80774. */
  80775. updateFromDevice(poseData: DevicePose): void;
  80776. private _htmlElementAttached;
  80777. private _detachIfAttached;
  80778. /**
  80779. * WebVR's attach control will start broadcasting frames to the device.
  80780. * Note that in certain browsers (chrome for example) this function must be called
  80781. * within a user-interaction callback. Example:
  80782. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  80783. *
  80784. * @param element html element to attach the vrDevice to
  80785. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  80786. */
  80787. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  80788. /**
  80789. * Detaches the camera from the html element and disables VR
  80790. *
  80791. * @param element html element to detach from
  80792. */
  80793. detachControl(element: HTMLElement): void;
  80794. /**
  80795. * @returns the name of this class
  80796. */
  80797. getClassName(): string;
  80798. /**
  80799. * Calls resetPose on the vrDisplay
  80800. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  80801. */
  80802. resetToCurrentRotation(): void;
  80803. /**
  80804. * @hidden
  80805. * Updates the rig cameras (left and right eye)
  80806. */
  80807. _updateRigCameras(): void;
  80808. private _workingVector;
  80809. private _oneVector;
  80810. private _workingMatrix;
  80811. private updateCacheCalled;
  80812. private _correctPositionIfNotTrackPosition;
  80813. /**
  80814. * @hidden
  80815. * Updates the cached values of the camera
  80816. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  80817. */
  80818. _updateCache(ignoreParentClass?: boolean): void;
  80819. /**
  80820. * @hidden
  80821. * Get current device position in babylon world
  80822. */
  80823. _computeDevicePosition(): void;
  80824. /**
  80825. * Updates the current device position and rotation in the babylon world
  80826. */
  80827. update(): void;
  80828. /**
  80829. * @hidden
  80830. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  80831. * @returns an identity matrix
  80832. */
  80833. _getViewMatrix(): Matrix;
  80834. private _tmpMatrix;
  80835. /**
  80836. * This function is called by the two RIG cameras.
  80837. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  80838. * @hidden
  80839. */
  80840. _getWebVRViewMatrix(): Matrix;
  80841. /** @hidden */
  80842. _getWebVRProjectionMatrix(): Matrix;
  80843. private _onGamepadConnectedObserver;
  80844. private _onGamepadDisconnectedObserver;
  80845. private _updateCacheWhenTrackingDisabledObserver;
  80846. /**
  80847. * Initializes the controllers and their meshes
  80848. */
  80849. initControllers(): void;
  80850. }
  80851. }
  80852. declare module BABYLON {
  80853. /**
  80854. * Size options for a post process
  80855. */
  80856. export type PostProcessOptions = {
  80857. width: number;
  80858. height: number;
  80859. };
  80860. /**
  80861. * PostProcess can be used to apply a shader to a texture after it has been rendered
  80862. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  80863. */
  80864. export class PostProcess {
  80865. /** Name of the PostProcess. */
  80866. name: string;
  80867. /**
  80868. * Gets or sets the unique id of the post process
  80869. */
  80870. uniqueId: number;
  80871. /**
  80872. * Width of the texture to apply the post process on
  80873. */
  80874. width: number;
  80875. /**
  80876. * Height of the texture to apply the post process on
  80877. */
  80878. height: number;
  80879. /**
  80880. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  80881. * @hidden
  80882. */
  80883. _outputTexture: Nullable<InternalTexture>;
  80884. /**
  80885. * Sampling mode used by the shader
  80886. * See https://doc.babylonjs.com/classes/3.1/texture
  80887. */
  80888. renderTargetSamplingMode: number;
  80889. /**
  80890. * Clear color to use when screen clearing
  80891. */
  80892. clearColor: Color4;
  80893. /**
  80894. * If the buffer needs to be cleared before applying the post process. (default: true)
  80895. * Should be set to false if shader will overwrite all previous pixels.
  80896. */
  80897. autoClear: boolean;
  80898. /**
  80899. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  80900. */
  80901. alphaMode: number;
  80902. /**
  80903. * Sets the setAlphaBlendConstants of the babylon engine
  80904. */
  80905. alphaConstants: Color4;
  80906. /**
  80907. * Animations to be used for the post processing
  80908. */
  80909. animations: Animation[];
  80910. /**
  80911. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  80912. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  80913. */
  80914. enablePixelPerfectMode: boolean;
  80915. /**
  80916. * Force the postprocess to be applied without taking in account viewport
  80917. */
  80918. forceFullscreenViewport: boolean;
  80919. /**
  80920. * List of inspectable custom properties (used by the Inspector)
  80921. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  80922. */
  80923. inspectableCustomProperties: IInspectable[];
  80924. /**
  80925. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  80926. *
  80927. * | Value | Type | Description |
  80928. * | ----- | ----------------------------------- | ----------- |
  80929. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  80930. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  80931. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  80932. *
  80933. */
  80934. scaleMode: number;
  80935. /**
  80936. * Force textures to be a power of two (default: false)
  80937. */
  80938. alwaysForcePOT: boolean;
  80939. private _samples;
  80940. /**
  80941. * Number of sample textures (default: 1)
  80942. */
  80943. samples: number;
  80944. /**
  80945. * Modify the scale of the post process to be the same as the viewport (default: false)
  80946. */
  80947. adaptScaleToCurrentViewport: boolean;
  80948. private _camera;
  80949. private _scene;
  80950. private _engine;
  80951. private _options;
  80952. private _reusable;
  80953. private _textureType;
  80954. /**
  80955. * Smart array of input and output textures for the post process.
  80956. * @hidden
  80957. */
  80958. _textures: SmartArray<InternalTexture>;
  80959. /**
  80960. * The index in _textures that corresponds to the output texture.
  80961. * @hidden
  80962. */
  80963. _currentRenderTextureInd: number;
  80964. private _effect;
  80965. private _samplers;
  80966. private _fragmentUrl;
  80967. private _vertexUrl;
  80968. private _parameters;
  80969. private _scaleRatio;
  80970. protected _indexParameters: any;
  80971. private _shareOutputWithPostProcess;
  80972. private _texelSize;
  80973. private _forcedOutputTexture;
  80974. /**
  80975. * Returns the fragment url or shader name used in the post process.
  80976. * @returns the fragment url or name in the shader store.
  80977. */
  80978. getEffectName(): string;
  80979. /**
  80980. * An event triggered when the postprocess is activated.
  80981. */
  80982. onActivateObservable: Observable<Camera>;
  80983. private _onActivateObserver;
  80984. /**
  80985. * A function that is added to the onActivateObservable
  80986. */
  80987. onActivate: Nullable<(camera: Camera) => void>;
  80988. /**
  80989. * An event triggered when the postprocess changes its size.
  80990. */
  80991. onSizeChangedObservable: Observable<PostProcess>;
  80992. private _onSizeChangedObserver;
  80993. /**
  80994. * A function that is added to the onSizeChangedObservable
  80995. */
  80996. onSizeChanged: (postProcess: PostProcess) => void;
  80997. /**
  80998. * An event triggered when the postprocess applies its effect.
  80999. */
  81000. onApplyObservable: Observable<Effect>;
  81001. private _onApplyObserver;
  81002. /**
  81003. * A function that is added to the onApplyObservable
  81004. */
  81005. onApply: (effect: Effect) => void;
  81006. /**
  81007. * An event triggered before rendering the postprocess
  81008. */
  81009. onBeforeRenderObservable: Observable<Effect>;
  81010. private _onBeforeRenderObserver;
  81011. /**
  81012. * A function that is added to the onBeforeRenderObservable
  81013. */
  81014. onBeforeRender: (effect: Effect) => void;
  81015. /**
  81016. * An event triggered after rendering the postprocess
  81017. */
  81018. onAfterRenderObservable: Observable<Effect>;
  81019. private _onAfterRenderObserver;
  81020. /**
  81021. * A function that is added to the onAfterRenderObservable
  81022. */
  81023. onAfterRender: (efect: Effect) => void;
  81024. /**
  81025. * 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
  81026. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  81027. */
  81028. inputTexture: InternalTexture;
  81029. /**
  81030. * Gets the camera which post process is applied to.
  81031. * @returns The camera the post process is applied to.
  81032. */
  81033. getCamera(): Camera;
  81034. /**
  81035. * Gets the texel size of the postprocess.
  81036. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  81037. */
  81038. readonly texelSize: Vector2;
  81039. /**
  81040. * Creates a new instance PostProcess
  81041. * @param name The name of the PostProcess.
  81042. * @param fragmentUrl The url of the fragment shader to be used.
  81043. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  81044. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  81045. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  81046. * @param camera The camera to apply the render pass to.
  81047. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  81048. * @param engine The engine which the post process will be applied. (default: current engine)
  81049. * @param reusable If the post process can be reused on the same frame. (default: false)
  81050. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  81051. * @param textureType Type of textures used when performing the post process. (default: 0)
  81052. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  81053. * @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
  81054. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  81055. */
  81056. constructor(
  81057. /** Name of the PostProcess. */
  81058. 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);
  81059. /**
  81060. * Gets a string idenfifying the name of the class
  81061. * @returns "PostProcess" string
  81062. */
  81063. getClassName(): string;
  81064. /**
  81065. * Gets the engine which this post process belongs to.
  81066. * @returns The engine the post process was enabled with.
  81067. */
  81068. getEngine(): Engine;
  81069. /**
  81070. * The effect that is created when initializing the post process.
  81071. * @returns The created effect corresponding the the postprocess.
  81072. */
  81073. getEffect(): Effect;
  81074. /**
  81075. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  81076. * @param postProcess The post process to share the output with.
  81077. * @returns This post process.
  81078. */
  81079. shareOutputWith(postProcess: PostProcess): PostProcess;
  81080. /**
  81081. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  81082. * This should be called if the post process that shares output with this post process is disabled/disposed.
  81083. */
  81084. useOwnOutput(): void;
  81085. /**
  81086. * Updates the effect with the current post process compile time values and recompiles the shader.
  81087. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  81088. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  81089. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  81090. * @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
  81091. * @param onCompiled Called when the shader has been compiled.
  81092. * @param onError Called if there is an error when compiling a shader.
  81093. */
  81094. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  81095. /**
  81096. * The post process is reusable if it can be used multiple times within one frame.
  81097. * @returns If the post process is reusable
  81098. */
  81099. isReusable(): boolean;
  81100. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  81101. markTextureDirty(): void;
  81102. /**
  81103. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  81104. * 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.
  81105. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  81106. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  81107. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  81108. * @returns The target texture that was bound to be written to.
  81109. */
  81110. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  81111. /**
  81112. * If the post process is supported.
  81113. */
  81114. readonly isSupported: boolean;
  81115. /**
  81116. * The aspect ratio of the output texture.
  81117. */
  81118. readonly aspectRatio: number;
  81119. /**
  81120. * Get a value indicating if the post-process is ready to be used
  81121. * @returns true if the post-process is ready (shader is compiled)
  81122. */
  81123. isReady(): boolean;
  81124. /**
  81125. * Binds all textures and uniforms to the shader, this will be run on every pass.
  81126. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  81127. */
  81128. apply(): Nullable<Effect>;
  81129. private _disposeTextures;
  81130. /**
  81131. * Disposes the post process.
  81132. * @param camera The camera to dispose the post process on.
  81133. */
  81134. dispose(camera?: Camera): void;
  81135. }
  81136. }
  81137. declare module BABYLON {
  81138. /** @hidden */
  81139. export var kernelBlurVaryingDeclaration: {
  81140. name: string;
  81141. shader: string;
  81142. };
  81143. }
  81144. declare module BABYLON {
  81145. /** @hidden */
  81146. export var kernelBlurFragment: {
  81147. name: string;
  81148. shader: string;
  81149. };
  81150. }
  81151. declare module BABYLON {
  81152. /** @hidden */
  81153. export var kernelBlurFragment2: {
  81154. name: string;
  81155. shader: string;
  81156. };
  81157. }
  81158. declare module BABYLON {
  81159. /** @hidden */
  81160. export var kernelBlurPixelShader: {
  81161. name: string;
  81162. shader: string;
  81163. };
  81164. }
  81165. declare module BABYLON {
  81166. /** @hidden */
  81167. export var kernelBlurVertex: {
  81168. name: string;
  81169. shader: string;
  81170. };
  81171. }
  81172. declare module BABYLON {
  81173. /** @hidden */
  81174. export var kernelBlurVertexShader: {
  81175. name: string;
  81176. shader: string;
  81177. };
  81178. }
  81179. declare module BABYLON {
  81180. /**
  81181. * The Blur Post Process which blurs an image based on a kernel and direction.
  81182. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  81183. */
  81184. export class BlurPostProcess extends PostProcess {
  81185. /** The direction in which to blur the image. */
  81186. direction: Vector2;
  81187. private blockCompilation;
  81188. protected _kernel: number;
  81189. protected _idealKernel: number;
  81190. protected _packedFloat: boolean;
  81191. private _staticDefines;
  81192. /**
  81193. * Sets the length in pixels of the blur sample region
  81194. */
  81195. /**
  81196. * Gets the length in pixels of the blur sample region
  81197. */
  81198. kernel: number;
  81199. /**
  81200. * Sets wether or not the blur needs to unpack/repack floats
  81201. */
  81202. /**
  81203. * Gets wether or not the blur is unpacking/repacking floats
  81204. */
  81205. packedFloat: boolean;
  81206. /**
  81207. * Creates a new instance BlurPostProcess
  81208. * @param name The name of the effect.
  81209. * @param direction The direction in which to blur the image.
  81210. * @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.
  81211. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  81212. * @param camera The camera to apply the render pass to.
  81213. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  81214. * @param engine The engine which the post process will be applied. (default: current engine)
  81215. * @param reusable If the post process can be reused on the same frame. (default: false)
  81216. * @param textureType Type of textures used when performing the post process. (default: 0)
  81217. * @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)
  81218. */
  81219. constructor(name: string,
  81220. /** The direction in which to blur the image. */
  81221. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  81222. /**
  81223. * Updates the effect with the current post process compile time values and recompiles the shader.
  81224. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  81225. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  81226. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  81227. * @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
  81228. * @param onCompiled Called when the shader has been compiled.
  81229. * @param onError Called if there is an error when compiling a shader.
  81230. */
  81231. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  81232. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  81233. /**
  81234. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  81235. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  81236. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  81237. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  81238. * The gaps between physical kernels are compensated for in the weighting of the samples
  81239. * @param idealKernel Ideal blur kernel.
  81240. * @return Nearest best kernel.
  81241. */
  81242. protected _nearestBestKernel(idealKernel: number): number;
  81243. /**
  81244. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  81245. * @param x The point on the Gaussian distribution to sample.
  81246. * @return the value of the Gaussian function at x.
  81247. */
  81248. protected _gaussianWeight(x: number): number;
  81249. /**
  81250. * Generates a string that can be used as a floating point number in GLSL.
  81251. * @param x Value to print.
  81252. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  81253. * @return GLSL float string.
  81254. */
  81255. protected _glslFloat(x: number, decimalFigures?: number): string;
  81256. }
  81257. }
  81258. declare module BABYLON {
  81259. /**
  81260. * Mirror texture can be used to simulate the view from a mirror in a scene.
  81261. * It will dynamically be rendered every frame to adapt to the camera point of view.
  81262. * You can then easily use it as a reflectionTexture on a flat surface.
  81263. * In case the surface is not a plane, please consider relying on reflection probes.
  81264. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  81265. */
  81266. export class MirrorTexture extends RenderTargetTexture {
  81267. private scene;
  81268. /**
  81269. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  81270. * 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.
  81271. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  81272. */
  81273. mirrorPlane: Plane;
  81274. /**
  81275. * Define the blur ratio used to blur the reflection if needed.
  81276. */
  81277. blurRatio: number;
  81278. /**
  81279. * Define the adaptive blur kernel used to blur the reflection if needed.
  81280. * This will autocompute the closest best match for the `blurKernel`
  81281. */
  81282. adaptiveBlurKernel: number;
  81283. /**
  81284. * Define the blur kernel used to blur the reflection if needed.
  81285. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  81286. */
  81287. blurKernel: number;
  81288. /**
  81289. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  81290. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  81291. */
  81292. blurKernelX: number;
  81293. /**
  81294. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  81295. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  81296. */
  81297. blurKernelY: number;
  81298. private _autoComputeBlurKernel;
  81299. protected _onRatioRescale(): void;
  81300. private _updateGammaSpace;
  81301. private _imageProcessingConfigChangeObserver;
  81302. private _transformMatrix;
  81303. private _mirrorMatrix;
  81304. private _savedViewMatrix;
  81305. private _blurX;
  81306. private _blurY;
  81307. private _adaptiveBlurKernel;
  81308. private _blurKernelX;
  81309. private _blurKernelY;
  81310. private _blurRatio;
  81311. /**
  81312. * Instantiates a Mirror Texture.
  81313. * Mirror texture can be used to simulate the view from a mirror in a scene.
  81314. * It will dynamically be rendered every frame to adapt to the camera point of view.
  81315. * You can then easily use it as a reflectionTexture on a flat surface.
  81316. * In case the surface is not a plane, please consider relying on reflection probes.
  81317. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  81318. * @param name
  81319. * @param size
  81320. * @param scene
  81321. * @param generateMipMaps
  81322. * @param type
  81323. * @param samplingMode
  81324. * @param generateDepthBuffer
  81325. */
  81326. constructor(name: string, size: number | {
  81327. width: number;
  81328. height: number;
  81329. } | {
  81330. ratio: number;
  81331. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  81332. private _preparePostProcesses;
  81333. /**
  81334. * Clone the mirror texture.
  81335. * @returns the cloned texture
  81336. */
  81337. clone(): MirrorTexture;
  81338. /**
  81339. * Serialize the texture to a JSON representation you could use in Parse later on
  81340. * @returns the serialized JSON representation
  81341. */
  81342. serialize(): any;
  81343. /**
  81344. * Dispose the texture and release its associated resources.
  81345. */
  81346. dispose(): void;
  81347. }
  81348. }
  81349. declare module BABYLON {
  81350. /**
  81351. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  81352. * @see http://doc.babylonjs.com/babylon101/materials#texture
  81353. */
  81354. export class Texture extends BaseTexture {
  81355. /** @hidden */
  81356. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  81357. /** @hidden */
  81358. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  81359. /** @hidden */
  81360. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  81361. /** nearest is mag = nearest and min = nearest and mip = linear */
  81362. static readonly NEAREST_SAMPLINGMODE: number;
  81363. /** nearest is mag = nearest and min = nearest and mip = linear */
  81364. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  81365. /** Bilinear is mag = linear and min = linear and mip = nearest */
  81366. static readonly BILINEAR_SAMPLINGMODE: number;
  81367. /** Bilinear is mag = linear and min = linear and mip = nearest */
  81368. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  81369. /** Trilinear is mag = linear and min = linear and mip = linear */
  81370. static readonly TRILINEAR_SAMPLINGMODE: number;
  81371. /** Trilinear is mag = linear and min = linear and mip = linear */
  81372. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  81373. /** mag = nearest and min = nearest and mip = nearest */
  81374. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  81375. /** mag = nearest and min = linear and mip = nearest */
  81376. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  81377. /** mag = nearest and min = linear and mip = linear */
  81378. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  81379. /** mag = nearest and min = linear and mip = none */
  81380. static readonly NEAREST_LINEAR: number;
  81381. /** mag = nearest and min = nearest and mip = none */
  81382. static readonly NEAREST_NEAREST: number;
  81383. /** mag = linear and min = nearest and mip = nearest */
  81384. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  81385. /** mag = linear and min = nearest and mip = linear */
  81386. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  81387. /** mag = linear and min = linear and mip = none */
  81388. static readonly LINEAR_LINEAR: number;
  81389. /** mag = linear and min = nearest and mip = none */
  81390. static readonly LINEAR_NEAREST: number;
  81391. /** Explicit coordinates mode */
  81392. static readonly EXPLICIT_MODE: number;
  81393. /** Spherical coordinates mode */
  81394. static readonly SPHERICAL_MODE: number;
  81395. /** Planar coordinates mode */
  81396. static readonly PLANAR_MODE: number;
  81397. /** Cubic coordinates mode */
  81398. static readonly CUBIC_MODE: number;
  81399. /** Projection coordinates mode */
  81400. static readonly PROJECTION_MODE: number;
  81401. /** Inverse Cubic coordinates mode */
  81402. static readonly SKYBOX_MODE: number;
  81403. /** Inverse Cubic coordinates mode */
  81404. static readonly INVCUBIC_MODE: number;
  81405. /** Equirectangular coordinates mode */
  81406. static readonly EQUIRECTANGULAR_MODE: number;
  81407. /** Equirectangular Fixed coordinates mode */
  81408. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  81409. /** Equirectangular Fixed Mirrored coordinates mode */
  81410. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  81411. /** Texture is not repeating outside of 0..1 UVs */
  81412. static readonly CLAMP_ADDRESSMODE: number;
  81413. /** Texture is repeating outside of 0..1 UVs */
  81414. static readonly WRAP_ADDRESSMODE: number;
  81415. /** Texture is repeating and mirrored */
  81416. static readonly MIRROR_ADDRESSMODE: number;
  81417. /**
  81418. * 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
  81419. */
  81420. static UseSerializedUrlIfAny: boolean;
  81421. /**
  81422. * Define the url of the texture.
  81423. */
  81424. url: Nullable<string>;
  81425. /**
  81426. * Define an offset on the texture to offset the u coordinates of the UVs
  81427. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  81428. */
  81429. uOffset: number;
  81430. /**
  81431. * Define an offset on the texture to offset the v coordinates of the UVs
  81432. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  81433. */
  81434. vOffset: number;
  81435. /**
  81436. * Define an offset on the texture to scale the u coordinates of the UVs
  81437. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  81438. */
  81439. uScale: number;
  81440. /**
  81441. * Define an offset on the texture to scale the v coordinates of the UVs
  81442. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  81443. */
  81444. vScale: number;
  81445. /**
  81446. * Define an offset on the texture to rotate around the u coordinates of the UVs
  81447. * @see http://doc.babylonjs.com/how_to/more_materials
  81448. */
  81449. uAng: number;
  81450. /**
  81451. * Define an offset on the texture to rotate around the v coordinates of the UVs
  81452. * @see http://doc.babylonjs.com/how_to/more_materials
  81453. */
  81454. vAng: number;
  81455. /**
  81456. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  81457. * @see http://doc.babylonjs.com/how_to/more_materials
  81458. */
  81459. wAng: number;
  81460. /**
  81461. * Defines the center of rotation (U)
  81462. */
  81463. uRotationCenter: number;
  81464. /**
  81465. * Defines the center of rotation (V)
  81466. */
  81467. vRotationCenter: number;
  81468. /**
  81469. * Defines the center of rotation (W)
  81470. */
  81471. wRotationCenter: number;
  81472. /**
  81473. * Are mip maps generated for this texture or not.
  81474. */
  81475. readonly noMipmap: boolean;
  81476. /**
  81477. * List of inspectable custom properties (used by the Inspector)
  81478. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81479. */
  81480. inspectableCustomProperties: Nullable<IInspectable[]>;
  81481. private _noMipmap;
  81482. /** @hidden */
  81483. _invertY: boolean;
  81484. private _rowGenerationMatrix;
  81485. private _cachedTextureMatrix;
  81486. private _projectionModeMatrix;
  81487. private _t0;
  81488. private _t1;
  81489. private _t2;
  81490. private _cachedUOffset;
  81491. private _cachedVOffset;
  81492. private _cachedUScale;
  81493. private _cachedVScale;
  81494. private _cachedUAng;
  81495. private _cachedVAng;
  81496. private _cachedWAng;
  81497. private _cachedProjectionMatrixId;
  81498. private _cachedCoordinatesMode;
  81499. /** @hidden */
  81500. protected _initialSamplingMode: number;
  81501. /** @hidden */
  81502. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  81503. private _deleteBuffer;
  81504. protected _format: Nullable<number>;
  81505. private _delayedOnLoad;
  81506. private _delayedOnError;
  81507. /**
  81508. * Observable triggered once the texture has been loaded.
  81509. */
  81510. onLoadObservable: Observable<Texture>;
  81511. protected _isBlocking: boolean;
  81512. /**
  81513. * Is the texture preventing material to render while loading.
  81514. * If false, a default texture will be used instead of the loading one during the preparation step.
  81515. */
  81516. isBlocking: boolean;
  81517. /**
  81518. * Get the current sampling mode associated with the texture.
  81519. */
  81520. readonly samplingMode: number;
  81521. /**
  81522. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  81523. */
  81524. readonly invertY: boolean;
  81525. /**
  81526. * Instantiates a new texture.
  81527. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  81528. * @see http://doc.babylonjs.com/babylon101/materials#texture
  81529. * @param url define the url of the picture to load as a texture
  81530. * @param scene define the scene the texture will belong to
  81531. * @param noMipmap define if the texture will require mip maps or not
  81532. * @param invertY define if the texture needs to be inverted on the y axis during loading
  81533. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  81534. * @param onLoad define a callback triggered when the texture has been loaded
  81535. * @param onError define a callback triggered when an error occurred during the loading session
  81536. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  81537. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  81538. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  81539. */
  81540. 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);
  81541. /**
  81542. * Update the url (and optional buffer) of this texture if url was null during construction.
  81543. * @param url the url of the texture
  81544. * @param buffer the buffer of the texture (defaults to null)
  81545. * @param onLoad callback called when the texture is loaded (defaults to null)
  81546. */
  81547. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  81548. /**
  81549. * Finish the loading sequence of a texture flagged as delayed load.
  81550. * @hidden
  81551. */
  81552. delayLoad(): void;
  81553. private _prepareRowForTextureGeneration;
  81554. /**
  81555. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  81556. * @returns the transform matrix of the texture.
  81557. */
  81558. getTextureMatrix(): Matrix;
  81559. /**
  81560. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  81561. * @returns The reflection texture transform
  81562. */
  81563. getReflectionTextureMatrix(): Matrix;
  81564. /**
  81565. * Clones the texture.
  81566. * @returns the cloned texture
  81567. */
  81568. clone(): Texture;
  81569. /**
  81570. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  81571. * @returns The JSON representation of the texture
  81572. */
  81573. serialize(): any;
  81574. /**
  81575. * Get the current class name of the texture useful for serialization or dynamic coding.
  81576. * @returns "Texture"
  81577. */
  81578. getClassName(): string;
  81579. /**
  81580. * Dispose the texture and release its associated resources.
  81581. */
  81582. dispose(): void;
  81583. /**
  81584. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  81585. * @param parsedTexture Define the JSON representation of the texture
  81586. * @param scene Define the scene the parsed texture should be instantiated in
  81587. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  81588. * @returns The parsed texture if successful
  81589. */
  81590. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  81591. /**
  81592. * Creates a texture from its base 64 representation.
  81593. * @param data Define the base64 payload without the data: prefix
  81594. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  81595. * @param scene Define the scene the texture should belong to
  81596. * @param noMipmap Forces the texture to not create mip map information if true
  81597. * @param invertY define if the texture needs to be inverted on the y axis during loading
  81598. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  81599. * @param onLoad define a callback triggered when the texture has been loaded
  81600. * @param onError define a callback triggered when an error occurred during the loading session
  81601. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  81602. * @returns the created texture
  81603. */
  81604. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  81605. /**
  81606. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  81607. * @param data Define the base64 payload without the data: prefix
  81608. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  81609. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  81610. * @param scene Define the scene the texture should belong to
  81611. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  81612. * @param noMipmap Forces the texture to not create mip map information if true
  81613. * @param invertY define if the texture needs to be inverted on the y axis during loading
  81614. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  81615. * @param onLoad define a callback triggered when the texture has been loaded
  81616. * @param onError define a callback triggered when an error occurred during the loading session
  81617. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  81618. * @returns the created texture
  81619. */
  81620. 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;
  81621. }
  81622. }
  81623. declare module BABYLON {
  81624. /**
  81625. * PostProcessManager is used to manage one or more post processes or post process pipelines
  81626. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  81627. */
  81628. export class PostProcessManager {
  81629. private _scene;
  81630. private _indexBuffer;
  81631. private _vertexBuffers;
  81632. /**
  81633. * Creates a new instance PostProcess
  81634. * @param scene The scene that the post process is associated with.
  81635. */
  81636. constructor(scene: Scene);
  81637. private _prepareBuffers;
  81638. private _buildIndexBuffer;
  81639. /**
  81640. * Rebuilds the vertex buffers of the manager.
  81641. * @hidden
  81642. */
  81643. _rebuild(): void;
  81644. /**
  81645. * Prepares a frame to be run through a post process.
  81646. * @param sourceTexture The input texture to the post procesess. (default: null)
  81647. * @param postProcesses An array of post processes to be run. (default: null)
  81648. * @returns True if the post processes were able to be run.
  81649. * @hidden
  81650. */
  81651. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  81652. /**
  81653. * Manually render a set of post processes to a texture.
  81654. * @param postProcesses An array of post processes to be run.
  81655. * @param targetTexture The target texture to render to.
  81656. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  81657. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  81658. * @param lodLevel defines which lod of the texture to render to
  81659. */
  81660. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  81661. /**
  81662. * Finalize the result of the output of the postprocesses.
  81663. * @param doNotPresent If true the result will not be displayed to the screen.
  81664. * @param targetTexture The target texture to render to.
  81665. * @param faceIndex The index of the face to bind the target texture to.
  81666. * @param postProcesses The array of post processes to render.
  81667. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  81668. * @hidden
  81669. */
  81670. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  81671. /**
  81672. * Disposes of the post process manager.
  81673. */
  81674. dispose(): void;
  81675. }
  81676. }
  81677. declare module BABYLON {
  81678. interface AbstractScene {
  81679. /**
  81680. * The list of procedural textures added to the scene
  81681. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  81682. */
  81683. proceduralTextures: Array<ProceduralTexture>;
  81684. }
  81685. /**
  81686. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  81687. * in a given scene.
  81688. */
  81689. export class ProceduralTextureSceneComponent implements ISceneComponent {
  81690. /**
  81691. * The component name helpfull to identify the component in the list of scene components.
  81692. */
  81693. readonly name: string;
  81694. /**
  81695. * The scene the component belongs to.
  81696. */
  81697. scene: Scene;
  81698. /**
  81699. * Creates a new instance of the component for the given scene
  81700. * @param scene Defines the scene to register the component in
  81701. */
  81702. constructor(scene: Scene);
  81703. /**
  81704. * Registers the component in a given scene
  81705. */
  81706. register(): void;
  81707. /**
  81708. * Rebuilds the elements related to this component in case of
  81709. * context lost for instance.
  81710. */
  81711. rebuild(): void;
  81712. /**
  81713. * Disposes the component and the associated ressources.
  81714. */
  81715. dispose(): void;
  81716. private _beforeClear;
  81717. }
  81718. }
  81719. declare module BABYLON {
  81720. interface Engine {
  81721. /**
  81722. * Creates a new render target cube texture
  81723. * @param size defines the size of the texture
  81724. * @param options defines the options used to create the texture
  81725. * @returns a new render target cube texture stored in an InternalTexture
  81726. */
  81727. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  81728. }
  81729. }
  81730. declare module BABYLON {
  81731. /** @hidden */
  81732. export var proceduralVertexShader: {
  81733. name: string;
  81734. shader: string;
  81735. };
  81736. }
  81737. declare module BABYLON {
  81738. /**
  81739. * 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.
  81740. * This is the base class of any Procedural texture and contains most of the shareable code.
  81741. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  81742. */
  81743. export class ProceduralTexture extends Texture {
  81744. isCube: boolean;
  81745. /**
  81746. * Define if the texture is enabled or not (disabled texture will not render)
  81747. */
  81748. isEnabled: boolean;
  81749. /**
  81750. * Define if the texture must be cleared before rendering (default is true)
  81751. */
  81752. autoClear: boolean;
  81753. /**
  81754. * Callback called when the texture is generated
  81755. */
  81756. onGenerated: () => void;
  81757. /**
  81758. * Event raised when the texture is generated
  81759. */
  81760. onGeneratedObservable: Observable<ProceduralTexture>;
  81761. /** @hidden */
  81762. _generateMipMaps: boolean;
  81763. /** @hidden **/
  81764. _effect: Effect;
  81765. /** @hidden */
  81766. _textures: {
  81767. [key: string]: Texture;
  81768. };
  81769. private _size;
  81770. private _currentRefreshId;
  81771. private _refreshRate;
  81772. private _vertexBuffers;
  81773. private _indexBuffer;
  81774. private _uniforms;
  81775. private _samplers;
  81776. private _fragment;
  81777. private _floats;
  81778. private _ints;
  81779. private _floatsArrays;
  81780. private _colors3;
  81781. private _colors4;
  81782. private _vectors2;
  81783. private _vectors3;
  81784. private _matrices;
  81785. private _fallbackTexture;
  81786. private _fallbackTextureUsed;
  81787. private _engine;
  81788. private _cachedDefines;
  81789. private _contentUpdateId;
  81790. private _contentData;
  81791. /**
  81792. * Instantiates a new procedural texture.
  81793. * 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.
  81794. * This is the base class of any Procedural texture and contains most of the shareable code.
  81795. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  81796. * @param name Define the name of the texture
  81797. * @param size Define the size of the texture to create
  81798. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  81799. * @param scene Define the scene the texture belongs to
  81800. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  81801. * @param generateMipMaps Define if the texture should creates mip maps or not
  81802. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  81803. */
  81804. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  81805. /**
  81806. * The effect that is created when initializing the post process.
  81807. * @returns The created effect corresponding the the postprocess.
  81808. */
  81809. getEffect(): Effect;
  81810. /**
  81811. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  81812. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  81813. */
  81814. getContent(): Nullable<ArrayBufferView>;
  81815. private _createIndexBuffer;
  81816. /** @hidden */
  81817. _rebuild(): void;
  81818. /**
  81819. * Resets the texture in order to recreate its associated resources.
  81820. * This can be called in case of context loss
  81821. */
  81822. reset(): void;
  81823. protected _getDefines(): string;
  81824. /**
  81825. * Is the texture ready to be used ? (rendered at least once)
  81826. * @returns true if ready, otherwise, false.
  81827. */
  81828. isReady(): boolean;
  81829. /**
  81830. * Resets the refresh counter of the texture and start bak from scratch.
  81831. * Could be useful to regenerate the texture if it is setup to render only once.
  81832. */
  81833. resetRefreshCounter(): void;
  81834. /**
  81835. * Set the fragment shader to use in order to render the texture.
  81836. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  81837. */
  81838. setFragment(fragment: any): void;
  81839. /**
  81840. * Define the refresh rate of the texture or the rendering frequency.
  81841. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  81842. */
  81843. refreshRate: number;
  81844. /** @hidden */
  81845. _shouldRender(): boolean;
  81846. /**
  81847. * Get the size the texture is rendering at.
  81848. * @returns the size (texture is always squared)
  81849. */
  81850. getRenderSize(): number;
  81851. /**
  81852. * Resize the texture to new value.
  81853. * @param size Define the new size the texture should have
  81854. * @param generateMipMaps Define whether the new texture should create mip maps
  81855. */
  81856. resize(size: number, generateMipMaps: boolean): void;
  81857. private _checkUniform;
  81858. /**
  81859. * Set a texture in the shader program used to render.
  81860. * @param name Define the name of the uniform samplers as defined in the shader
  81861. * @param texture Define the texture to bind to this sampler
  81862. * @return the texture itself allowing "fluent" like uniform updates
  81863. */
  81864. setTexture(name: string, texture: Texture): ProceduralTexture;
  81865. /**
  81866. * Set a float in the shader.
  81867. * @param name Define the name of the uniform as defined in the shader
  81868. * @param value Define the value to give to the uniform
  81869. * @return the texture itself allowing "fluent" like uniform updates
  81870. */
  81871. setFloat(name: string, value: number): ProceduralTexture;
  81872. /**
  81873. * Set a int in the shader.
  81874. * @param name Define the name of the uniform as defined in the shader
  81875. * @param value Define the value to give to the uniform
  81876. * @return the texture itself allowing "fluent" like uniform updates
  81877. */
  81878. setInt(name: string, value: number): ProceduralTexture;
  81879. /**
  81880. * Set an array of floats in the shader.
  81881. * @param name Define the name of the uniform as defined in the shader
  81882. * @param value Define the value to give to the uniform
  81883. * @return the texture itself allowing "fluent" like uniform updates
  81884. */
  81885. setFloats(name: string, value: number[]): ProceduralTexture;
  81886. /**
  81887. * Set a vec3 in the shader from a Color3.
  81888. * @param name Define the name of the uniform as defined in the shader
  81889. * @param value Define the value to give to the uniform
  81890. * @return the texture itself allowing "fluent" like uniform updates
  81891. */
  81892. setColor3(name: string, value: Color3): ProceduralTexture;
  81893. /**
  81894. * Set a vec4 in the shader from a Color4.
  81895. * @param name Define the name of the uniform as defined in the shader
  81896. * @param value Define the value to give to the uniform
  81897. * @return the texture itself allowing "fluent" like uniform updates
  81898. */
  81899. setColor4(name: string, value: Color4): ProceduralTexture;
  81900. /**
  81901. * Set a vec2 in the shader from a Vector2.
  81902. * @param name Define the name of the uniform as defined in the shader
  81903. * @param value Define the value to give to the uniform
  81904. * @return the texture itself allowing "fluent" like uniform updates
  81905. */
  81906. setVector2(name: string, value: Vector2): ProceduralTexture;
  81907. /**
  81908. * Set a vec3 in the shader from a Vector3.
  81909. * @param name Define the name of the uniform as defined in the shader
  81910. * @param value Define the value to give to the uniform
  81911. * @return the texture itself allowing "fluent" like uniform updates
  81912. */
  81913. setVector3(name: string, value: Vector3): ProceduralTexture;
  81914. /**
  81915. * Set a mat4 in the shader from a MAtrix.
  81916. * @param name Define the name of the uniform as defined in the shader
  81917. * @param value Define the value to give to the uniform
  81918. * @return the texture itself allowing "fluent" like uniform updates
  81919. */
  81920. setMatrix(name: string, value: Matrix): ProceduralTexture;
  81921. /**
  81922. * Render the texture to its associated render target.
  81923. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  81924. */
  81925. render(useCameraPostProcess?: boolean): void;
  81926. /**
  81927. * Clone the texture.
  81928. * @returns the cloned texture
  81929. */
  81930. clone(): ProceduralTexture;
  81931. /**
  81932. * Dispose the texture and release its asoociated resources.
  81933. */
  81934. dispose(): void;
  81935. }
  81936. }
  81937. declare module BABYLON {
  81938. /**
  81939. * This represents the base class for particle system in Babylon.
  81940. * 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.
  81941. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  81942. * @example https://doc.babylonjs.com/babylon101/particles
  81943. */
  81944. export class BaseParticleSystem {
  81945. /**
  81946. * Source color is added to the destination color without alpha affecting the result
  81947. */
  81948. static BLENDMODE_ONEONE: number;
  81949. /**
  81950. * Blend current color and particle color using particle’s alpha
  81951. */
  81952. static BLENDMODE_STANDARD: number;
  81953. /**
  81954. * Add current color and particle color multiplied by particle’s alpha
  81955. */
  81956. static BLENDMODE_ADD: number;
  81957. /**
  81958. * Multiply current color with particle color
  81959. */
  81960. static BLENDMODE_MULTIPLY: number;
  81961. /**
  81962. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  81963. */
  81964. static BLENDMODE_MULTIPLYADD: number;
  81965. /**
  81966. * List of animations used by the particle system.
  81967. */
  81968. animations: Animation[];
  81969. /**
  81970. * The id of the Particle system.
  81971. */
  81972. id: string;
  81973. /**
  81974. * The friendly name of the Particle system.
  81975. */
  81976. name: string;
  81977. /**
  81978. * The rendering group used by the Particle system to chose when to render.
  81979. */
  81980. renderingGroupId: number;
  81981. /**
  81982. * The emitter represents the Mesh or position we are attaching the particle system to.
  81983. */
  81984. emitter: Nullable<AbstractMesh | Vector3>;
  81985. /**
  81986. * The maximum number of particles to emit per frame
  81987. */
  81988. emitRate: number;
  81989. /**
  81990. * If you want to launch only a few particles at once, that can be done, as well.
  81991. */
  81992. manualEmitCount: number;
  81993. /**
  81994. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  81995. */
  81996. updateSpeed: number;
  81997. /**
  81998. * The amount of time the particle system is running (depends of the overall update speed).
  81999. */
  82000. targetStopDuration: number;
  82001. /**
  82002. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  82003. */
  82004. disposeOnStop: boolean;
  82005. /**
  82006. * Minimum power of emitting particles.
  82007. */
  82008. minEmitPower: number;
  82009. /**
  82010. * Maximum power of emitting particles.
  82011. */
  82012. maxEmitPower: number;
  82013. /**
  82014. * Minimum life time of emitting particles.
  82015. */
  82016. minLifeTime: number;
  82017. /**
  82018. * Maximum life time of emitting particles.
  82019. */
  82020. maxLifeTime: number;
  82021. /**
  82022. * Minimum Size of emitting particles.
  82023. */
  82024. minSize: number;
  82025. /**
  82026. * Maximum Size of emitting particles.
  82027. */
  82028. maxSize: number;
  82029. /**
  82030. * Minimum scale of emitting particles on X axis.
  82031. */
  82032. minScaleX: number;
  82033. /**
  82034. * Maximum scale of emitting particles on X axis.
  82035. */
  82036. maxScaleX: number;
  82037. /**
  82038. * Minimum scale of emitting particles on Y axis.
  82039. */
  82040. minScaleY: number;
  82041. /**
  82042. * Maximum scale of emitting particles on Y axis.
  82043. */
  82044. maxScaleY: number;
  82045. /**
  82046. * Gets or sets the minimal initial rotation in radians.
  82047. */
  82048. minInitialRotation: number;
  82049. /**
  82050. * Gets or sets the maximal initial rotation in radians.
  82051. */
  82052. maxInitialRotation: number;
  82053. /**
  82054. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  82055. */
  82056. minAngularSpeed: number;
  82057. /**
  82058. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  82059. */
  82060. maxAngularSpeed: number;
  82061. /**
  82062. * The texture used to render each particle. (this can be a spritesheet)
  82063. */
  82064. particleTexture: Nullable<Texture>;
  82065. /**
  82066. * The layer mask we are rendering the particles through.
  82067. */
  82068. layerMask: number;
  82069. /**
  82070. * This can help using your own shader to render the particle system.
  82071. * The according effect will be created
  82072. */
  82073. customShader: any;
  82074. /**
  82075. * By default particle system starts as soon as they are created. This prevents the
  82076. * automatic start to happen and let you decide when to start emitting particles.
  82077. */
  82078. preventAutoStart: boolean;
  82079. private _noiseTexture;
  82080. /**
  82081. * Gets or sets a texture used to add random noise to particle positions
  82082. */
  82083. noiseTexture: Nullable<ProceduralTexture>;
  82084. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  82085. noiseStrength: Vector3;
  82086. /**
  82087. * Callback triggered when the particle animation is ending.
  82088. */
  82089. onAnimationEnd: Nullable<() => void>;
  82090. /**
  82091. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  82092. */
  82093. blendMode: number;
  82094. /**
  82095. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  82096. * to override the particles.
  82097. */
  82098. forceDepthWrite: boolean;
  82099. /** 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 */
  82100. preWarmCycles: number;
  82101. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  82102. preWarmStepOffset: number;
  82103. /**
  82104. * 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)
  82105. */
  82106. spriteCellChangeSpeed: number;
  82107. /**
  82108. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  82109. */
  82110. startSpriteCellID: number;
  82111. /**
  82112. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  82113. */
  82114. endSpriteCellID: number;
  82115. /**
  82116. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  82117. */
  82118. spriteCellWidth: number;
  82119. /**
  82120. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  82121. */
  82122. spriteCellHeight: number;
  82123. /**
  82124. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  82125. */
  82126. spriteRandomStartCell: boolean;
  82127. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  82128. translationPivot: Vector2;
  82129. /** @hidden */
  82130. protected _isAnimationSheetEnabled: boolean;
  82131. /**
  82132. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  82133. */
  82134. beginAnimationOnStart: boolean;
  82135. /**
  82136. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  82137. */
  82138. beginAnimationFrom: number;
  82139. /**
  82140. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  82141. */
  82142. beginAnimationTo: number;
  82143. /**
  82144. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  82145. */
  82146. beginAnimationLoop: boolean;
  82147. /**
  82148. * Gets or sets a world offset applied to all particles
  82149. */
  82150. worldOffset: Vector3;
  82151. /**
  82152. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  82153. */
  82154. isAnimationSheetEnabled: boolean;
  82155. /**
  82156. * Get hosting scene
  82157. * @returns the scene
  82158. */
  82159. getScene(): Scene;
  82160. /**
  82161. * You can use gravity if you want to give an orientation to your particles.
  82162. */
  82163. gravity: Vector3;
  82164. protected _colorGradients: Nullable<Array<ColorGradient>>;
  82165. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  82166. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  82167. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  82168. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  82169. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  82170. protected _dragGradients: Nullable<Array<FactorGradient>>;
  82171. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  82172. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  82173. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  82174. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  82175. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  82176. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  82177. /**
  82178. * Defines the delay in milliseconds before starting the system (0 by default)
  82179. */
  82180. startDelay: number;
  82181. /**
  82182. * Gets the current list of drag gradients.
  82183. * You must use addDragGradient and removeDragGradient to udpate this list
  82184. * @returns the list of drag gradients
  82185. */
  82186. getDragGradients(): Nullable<Array<FactorGradient>>;
  82187. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  82188. limitVelocityDamping: number;
  82189. /**
  82190. * Gets the current list of limit velocity gradients.
  82191. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  82192. * @returns the list of limit velocity gradients
  82193. */
  82194. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  82195. /**
  82196. * Gets the current list of color gradients.
  82197. * You must use addColorGradient and removeColorGradient to udpate this list
  82198. * @returns the list of color gradients
  82199. */
  82200. getColorGradients(): Nullable<Array<ColorGradient>>;
  82201. /**
  82202. * Gets the current list of size gradients.
  82203. * You must use addSizeGradient and removeSizeGradient to udpate this list
  82204. * @returns the list of size gradients
  82205. */
  82206. getSizeGradients(): Nullable<Array<FactorGradient>>;
  82207. /**
  82208. * Gets the current list of color remap gradients.
  82209. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  82210. * @returns the list of color remap gradients
  82211. */
  82212. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  82213. /**
  82214. * Gets the current list of alpha remap gradients.
  82215. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  82216. * @returns the list of alpha remap gradients
  82217. */
  82218. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  82219. /**
  82220. * Gets the current list of life time gradients.
  82221. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  82222. * @returns the list of life time gradients
  82223. */
  82224. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  82225. /**
  82226. * Gets the current list of angular speed gradients.
  82227. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  82228. * @returns the list of angular speed gradients
  82229. */
  82230. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  82231. /**
  82232. * Gets the current list of velocity gradients.
  82233. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  82234. * @returns the list of velocity gradients
  82235. */
  82236. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  82237. /**
  82238. * Gets the current list of start size gradients.
  82239. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  82240. * @returns the list of start size gradients
  82241. */
  82242. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  82243. /**
  82244. * Gets the current list of emit rate gradients.
  82245. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  82246. * @returns the list of emit rate gradients
  82247. */
  82248. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  82249. /**
  82250. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  82251. * This only works when particleEmitterTyps is a BoxParticleEmitter
  82252. */
  82253. direction1: Vector3;
  82254. /**
  82255. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  82256. * This only works when particleEmitterTyps is a BoxParticleEmitter
  82257. */
  82258. direction2: Vector3;
  82259. /**
  82260. * 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.
  82261. * This only works when particleEmitterTyps is a BoxParticleEmitter
  82262. */
  82263. minEmitBox: Vector3;
  82264. /**
  82265. * 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.
  82266. * This only works when particleEmitterTyps is a BoxParticleEmitter
  82267. */
  82268. maxEmitBox: Vector3;
  82269. /**
  82270. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  82271. */
  82272. color1: Color4;
  82273. /**
  82274. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  82275. */
  82276. color2: Color4;
  82277. /**
  82278. * Color the particle will have at the end of its lifetime
  82279. */
  82280. colorDead: Color4;
  82281. /**
  82282. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  82283. */
  82284. textureMask: Color4;
  82285. /**
  82286. * The particle emitter type defines the emitter used by the particle system.
  82287. * It can be for example box, sphere, or cone...
  82288. */
  82289. particleEmitterType: IParticleEmitterType;
  82290. /** @hidden */
  82291. _isSubEmitter: boolean;
  82292. /**
  82293. * Gets or sets the billboard mode to use when isBillboardBased = true.
  82294. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  82295. */
  82296. billboardMode: number;
  82297. protected _isBillboardBased: boolean;
  82298. /**
  82299. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  82300. */
  82301. isBillboardBased: boolean;
  82302. /**
  82303. * The scene the particle system belongs to.
  82304. */
  82305. protected _scene: Scene;
  82306. /**
  82307. * Local cache of defines for image processing.
  82308. */
  82309. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  82310. /**
  82311. * Default configuration related to image processing available in the standard Material.
  82312. */
  82313. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  82314. /**
  82315. * Gets the image processing configuration used either in this material.
  82316. */
  82317. /**
  82318. * Sets the Default image processing configuration used either in the this material.
  82319. *
  82320. * If sets to null, the scene one is in use.
  82321. */
  82322. imageProcessingConfiguration: ImageProcessingConfiguration;
  82323. /**
  82324. * Attaches a new image processing configuration to the Standard Material.
  82325. * @param configuration
  82326. */
  82327. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  82328. /** @hidden */
  82329. protected _reset(): void;
  82330. /** @hidden */
  82331. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  82332. /**
  82333. * Instantiates a particle system.
  82334. * 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.
  82335. * @param name The name of the particle system
  82336. */
  82337. constructor(name: string);
  82338. /**
  82339. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  82340. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  82341. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  82342. * @returns the emitter
  82343. */
  82344. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  82345. /**
  82346. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  82347. * @param radius The radius of the hemisphere to emit from
  82348. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  82349. * @returns the emitter
  82350. */
  82351. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  82352. /**
  82353. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  82354. * @param radius The radius of the sphere to emit from
  82355. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  82356. * @returns the emitter
  82357. */
  82358. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  82359. /**
  82360. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  82361. * @param radius The radius of the sphere to emit from
  82362. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  82363. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  82364. * @returns the emitter
  82365. */
  82366. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  82367. /**
  82368. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  82369. * @param radius The radius of the emission cylinder
  82370. * @param height The height of the emission cylinder
  82371. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  82372. * @param directionRandomizer How much to randomize the particle direction [0-1]
  82373. * @returns the emitter
  82374. */
  82375. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  82376. /**
  82377. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  82378. * @param radius The radius of the cylinder to emit from
  82379. * @param height The height of the emission cylinder
  82380. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  82381. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  82382. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  82383. * @returns the emitter
  82384. */
  82385. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  82386. /**
  82387. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  82388. * @param radius The radius of the cone to emit from
  82389. * @param angle The base angle of the cone
  82390. * @returns the emitter
  82391. */
  82392. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  82393. /**
  82394. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  82395. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  82396. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  82397. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  82398. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  82399. * @returns the emitter
  82400. */
  82401. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  82402. }
  82403. }
  82404. declare module BABYLON {
  82405. /**
  82406. * Type of sub emitter
  82407. */
  82408. export enum SubEmitterType {
  82409. /**
  82410. * Attached to the particle over it's lifetime
  82411. */
  82412. ATTACHED = 0,
  82413. /**
  82414. * Created when the particle dies
  82415. */
  82416. END = 1
  82417. }
  82418. /**
  82419. * Sub emitter class used to emit particles from an existing particle
  82420. */
  82421. export class SubEmitter {
  82422. /**
  82423. * the particle system to be used by the sub emitter
  82424. */
  82425. particleSystem: ParticleSystem;
  82426. /**
  82427. * Type of the submitter (Default: END)
  82428. */
  82429. type: SubEmitterType;
  82430. /**
  82431. * 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)
  82432. * Note: This only is supported when using an emitter of type Mesh
  82433. */
  82434. inheritDirection: boolean;
  82435. /**
  82436. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  82437. */
  82438. inheritedVelocityAmount: number;
  82439. /**
  82440. * Creates a sub emitter
  82441. * @param particleSystem the particle system to be used by the sub emitter
  82442. */
  82443. constructor(
  82444. /**
  82445. * the particle system to be used by the sub emitter
  82446. */
  82447. particleSystem: ParticleSystem);
  82448. /**
  82449. * Clones the sub emitter
  82450. * @returns the cloned sub emitter
  82451. */
  82452. clone(): SubEmitter;
  82453. /**
  82454. * Serialize current object to a JSON object
  82455. * @returns the serialized object
  82456. */
  82457. serialize(): any;
  82458. /** @hidden */
  82459. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  82460. /**
  82461. * Creates a new SubEmitter from a serialized JSON version
  82462. * @param serializationObject defines the JSON object to read from
  82463. * @param scene defines the hosting scene
  82464. * @param rootUrl defines the rootUrl for data loading
  82465. * @returns a new SubEmitter
  82466. */
  82467. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  82468. /** Release associated resources */
  82469. dispose(): void;
  82470. }
  82471. }
  82472. declare module BABYLON {
  82473. /** @hidden */
  82474. export var imageProcessingDeclaration: {
  82475. name: string;
  82476. shader: string;
  82477. };
  82478. }
  82479. declare module BABYLON {
  82480. /** @hidden */
  82481. export var imageProcessingFunctions: {
  82482. name: string;
  82483. shader: string;
  82484. };
  82485. }
  82486. declare module BABYLON {
  82487. /** @hidden */
  82488. export var particlesPixelShader: {
  82489. name: string;
  82490. shader: string;
  82491. };
  82492. }
  82493. declare module BABYLON {
  82494. /** @hidden */
  82495. export var particlesVertexShader: {
  82496. name: string;
  82497. shader: string;
  82498. };
  82499. }
  82500. declare module BABYLON {
  82501. /**
  82502. * This represents a particle system in Babylon.
  82503. * 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.
  82504. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  82505. * @example https://doc.babylonjs.com/babylon101/particles
  82506. */
  82507. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  82508. /**
  82509. * Billboard mode will only apply to Y axis
  82510. */
  82511. static readonly BILLBOARDMODE_Y: number;
  82512. /**
  82513. * Billboard mode will apply to all axes
  82514. */
  82515. static readonly BILLBOARDMODE_ALL: number;
  82516. /**
  82517. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  82518. */
  82519. static readonly BILLBOARDMODE_STRETCHED: number;
  82520. /**
  82521. * This function can be defined to provide custom update for active particles.
  82522. * This function will be called instead of regular update (age, position, color, etc.).
  82523. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  82524. */
  82525. updateFunction: (particles: Particle[]) => void;
  82526. private _emitterWorldMatrix;
  82527. /**
  82528. * This function can be defined to specify initial direction for every new particle.
  82529. * It by default use the emitterType defined function
  82530. */
  82531. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  82532. /**
  82533. * This function can be defined to specify initial position for every new particle.
  82534. * It by default use the emitterType defined function
  82535. */
  82536. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  82537. /**
  82538. * @hidden
  82539. */
  82540. _inheritedVelocityOffset: Vector3;
  82541. /**
  82542. * An event triggered when the system is disposed
  82543. */
  82544. onDisposeObservable: Observable<ParticleSystem>;
  82545. private _onDisposeObserver;
  82546. /**
  82547. * Sets a callback that will be triggered when the system is disposed
  82548. */
  82549. onDispose: () => void;
  82550. private _particles;
  82551. private _epsilon;
  82552. private _capacity;
  82553. private _stockParticles;
  82554. private _newPartsExcess;
  82555. private _vertexData;
  82556. private _vertexBuffer;
  82557. private _vertexBuffers;
  82558. private _spriteBuffer;
  82559. private _indexBuffer;
  82560. private _effect;
  82561. private _customEffect;
  82562. private _cachedDefines;
  82563. private _scaledColorStep;
  82564. private _colorDiff;
  82565. private _scaledDirection;
  82566. private _scaledGravity;
  82567. private _currentRenderId;
  82568. private _alive;
  82569. private _useInstancing;
  82570. private _started;
  82571. private _stopped;
  82572. private _actualFrame;
  82573. private _scaledUpdateSpeed;
  82574. private _vertexBufferSize;
  82575. /** @hidden */
  82576. _currentEmitRateGradient: Nullable<FactorGradient>;
  82577. /** @hidden */
  82578. _currentEmitRate1: number;
  82579. /** @hidden */
  82580. _currentEmitRate2: number;
  82581. /** @hidden */
  82582. _currentStartSizeGradient: Nullable<FactorGradient>;
  82583. /** @hidden */
  82584. _currentStartSize1: number;
  82585. /** @hidden */
  82586. _currentStartSize2: number;
  82587. private readonly _rawTextureWidth;
  82588. private _rampGradientsTexture;
  82589. private _useRampGradients;
  82590. /** Gets or sets a boolean indicating that ramp gradients must be used
  82591. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  82592. */
  82593. useRampGradients: boolean;
  82594. /**
  82595. * 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.
  82596. * 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: [])
  82597. */
  82598. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  82599. private _subEmitters;
  82600. /**
  82601. * @hidden
  82602. * If the particle systems emitter should be disposed when the particle system is disposed
  82603. */
  82604. _disposeEmitterOnDispose: boolean;
  82605. /**
  82606. * The current active Sub-systems, this property is used by the root particle system only.
  82607. */
  82608. activeSubSystems: Array<ParticleSystem>;
  82609. private _rootParticleSystem;
  82610. /**
  82611. * Gets the current list of active particles
  82612. */
  82613. readonly particles: Particle[];
  82614. /**
  82615. * Returns the string "ParticleSystem"
  82616. * @returns a string containing the class name
  82617. */
  82618. getClassName(): string;
  82619. /**
  82620. * Instantiates a particle system.
  82621. * 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.
  82622. * @param name The name of the particle system
  82623. * @param capacity The max number of particles alive at the same time
  82624. * @param scene The scene the particle system belongs to
  82625. * @param customEffect a custom effect used to change the way particles are rendered by default
  82626. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  82627. * @param epsilon Offset used to render the particles
  82628. */
  82629. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  82630. private _addFactorGradient;
  82631. private _removeFactorGradient;
  82632. /**
  82633. * Adds a new life time gradient
  82634. * @param gradient defines the gradient to use (between 0 and 1)
  82635. * @param factor defines the life time factor to affect to the specified gradient
  82636. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82637. * @returns the current particle system
  82638. */
  82639. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82640. /**
  82641. * Remove a specific life time gradient
  82642. * @param gradient defines the gradient to remove
  82643. * @returns the current particle system
  82644. */
  82645. removeLifeTimeGradient(gradient: number): IParticleSystem;
  82646. /**
  82647. * Adds a new size gradient
  82648. * @param gradient defines the gradient to use (between 0 and 1)
  82649. * @param factor defines the size factor to affect to the specified gradient
  82650. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82651. * @returns the current particle system
  82652. */
  82653. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82654. /**
  82655. * Remove a specific size gradient
  82656. * @param gradient defines the gradient to remove
  82657. * @returns the current particle system
  82658. */
  82659. removeSizeGradient(gradient: number): IParticleSystem;
  82660. /**
  82661. * Adds a new color remap gradient
  82662. * @param gradient defines the gradient to use (between 0 and 1)
  82663. * @param min defines the color remap minimal range
  82664. * @param max defines the color remap maximal range
  82665. * @returns the current particle system
  82666. */
  82667. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  82668. /**
  82669. * Remove a specific color remap gradient
  82670. * @param gradient defines the gradient to remove
  82671. * @returns the current particle system
  82672. */
  82673. removeColorRemapGradient(gradient: number): IParticleSystem;
  82674. /**
  82675. * Adds a new alpha remap gradient
  82676. * @param gradient defines the gradient to use (between 0 and 1)
  82677. * @param min defines the alpha remap minimal range
  82678. * @param max defines the alpha remap maximal range
  82679. * @returns the current particle system
  82680. */
  82681. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  82682. /**
  82683. * Remove a specific alpha remap gradient
  82684. * @param gradient defines the gradient to remove
  82685. * @returns the current particle system
  82686. */
  82687. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  82688. /**
  82689. * Adds a new angular speed gradient
  82690. * @param gradient defines the gradient to use (between 0 and 1)
  82691. * @param factor defines the angular speed to affect to the specified gradient
  82692. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82693. * @returns the current particle system
  82694. */
  82695. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82696. /**
  82697. * Remove a specific angular speed gradient
  82698. * @param gradient defines the gradient to remove
  82699. * @returns the current particle system
  82700. */
  82701. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  82702. /**
  82703. * Adds a new velocity gradient
  82704. * @param gradient defines the gradient to use (between 0 and 1)
  82705. * @param factor defines the velocity to affect to the specified gradient
  82706. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82707. * @returns the current particle system
  82708. */
  82709. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82710. /**
  82711. * Remove a specific velocity gradient
  82712. * @param gradient defines the gradient to remove
  82713. * @returns the current particle system
  82714. */
  82715. removeVelocityGradient(gradient: number): IParticleSystem;
  82716. /**
  82717. * Adds a new limit velocity gradient
  82718. * @param gradient defines the gradient to use (between 0 and 1)
  82719. * @param factor defines the limit velocity value to affect to the specified gradient
  82720. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82721. * @returns the current particle system
  82722. */
  82723. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82724. /**
  82725. * Remove a specific limit velocity gradient
  82726. * @param gradient defines the gradient to remove
  82727. * @returns the current particle system
  82728. */
  82729. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  82730. /**
  82731. * Adds a new drag gradient
  82732. * @param gradient defines the gradient to use (between 0 and 1)
  82733. * @param factor defines the drag value to affect to the specified gradient
  82734. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82735. * @returns the current particle system
  82736. */
  82737. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82738. /**
  82739. * Remove a specific drag gradient
  82740. * @param gradient defines the gradient to remove
  82741. * @returns the current particle system
  82742. */
  82743. removeDragGradient(gradient: number): IParticleSystem;
  82744. /**
  82745. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  82746. * @param gradient defines the gradient to use (between 0 and 1)
  82747. * @param factor defines the emit rate value to affect to the specified gradient
  82748. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82749. * @returns the current particle system
  82750. */
  82751. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82752. /**
  82753. * Remove a specific emit rate gradient
  82754. * @param gradient defines the gradient to remove
  82755. * @returns the current particle system
  82756. */
  82757. removeEmitRateGradient(gradient: number): IParticleSystem;
  82758. /**
  82759. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  82760. * @param gradient defines the gradient to use (between 0 and 1)
  82761. * @param factor defines the start size value to affect to the specified gradient
  82762. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82763. * @returns the current particle system
  82764. */
  82765. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82766. /**
  82767. * Remove a specific start size gradient
  82768. * @param gradient defines the gradient to remove
  82769. * @returns the current particle system
  82770. */
  82771. removeStartSizeGradient(gradient: number): IParticleSystem;
  82772. private _createRampGradientTexture;
  82773. /**
  82774. * Gets the current list of ramp gradients.
  82775. * You must use addRampGradient and removeRampGradient to udpate this list
  82776. * @returns the list of ramp gradients
  82777. */
  82778. getRampGradients(): Nullable<Array<Color3Gradient>>;
  82779. /**
  82780. * Adds a new ramp gradient used to remap particle colors
  82781. * @param gradient defines the gradient to use (between 0 and 1)
  82782. * @param color defines the color to affect to the specified gradient
  82783. * @returns the current particle system
  82784. */
  82785. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  82786. /**
  82787. * Remove a specific ramp gradient
  82788. * @param gradient defines the gradient to remove
  82789. * @returns the current particle system
  82790. */
  82791. removeRampGradient(gradient: number): ParticleSystem;
  82792. /**
  82793. * Adds a new color gradient
  82794. * @param gradient defines the gradient to use (between 0 and 1)
  82795. * @param color1 defines the color to affect to the specified gradient
  82796. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  82797. * @returns this particle system
  82798. */
  82799. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  82800. /**
  82801. * Remove a specific color gradient
  82802. * @param gradient defines the gradient to remove
  82803. * @returns this particle system
  82804. */
  82805. removeColorGradient(gradient: number): IParticleSystem;
  82806. private _fetchR;
  82807. protected _reset(): void;
  82808. private _resetEffect;
  82809. private _createVertexBuffers;
  82810. private _createIndexBuffer;
  82811. /**
  82812. * Gets the maximum number of particles active at the same time.
  82813. * @returns The max number of active particles.
  82814. */
  82815. getCapacity(): number;
  82816. /**
  82817. * Gets whether there are still active particles in the system.
  82818. * @returns True if it is alive, otherwise false.
  82819. */
  82820. isAlive(): boolean;
  82821. /**
  82822. * Gets if the system has been started. (Note: this will still be true after stop is called)
  82823. * @returns True if it has been started, otherwise false.
  82824. */
  82825. isStarted(): boolean;
  82826. private _prepareSubEmitterInternalArray;
  82827. /**
  82828. * Starts the particle system and begins to emit
  82829. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  82830. */
  82831. start(delay?: number): void;
  82832. /**
  82833. * Stops the particle system.
  82834. * @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.
  82835. */
  82836. stop(stopSubEmitters?: boolean): void;
  82837. /**
  82838. * Remove all active particles
  82839. */
  82840. reset(): void;
  82841. /**
  82842. * @hidden (for internal use only)
  82843. */
  82844. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  82845. /**
  82846. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  82847. * Its lifetime will start back at 0.
  82848. */
  82849. recycleParticle: (particle: Particle) => void;
  82850. private _stopSubEmitters;
  82851. private _createParticle;
  82852. private _removeFromRoot;
  82853. private _emitFromParticle;
  82854. private _update;
  82855. /** @hidden */
  82856. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  82857. /** @hidden */
  82858. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  82859. /** @hidden */
  82860. private _getEffect;
  82861. /**
  82862. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  82863. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  82864. */
  82865. animate(preWarmOnly?: boolean): void;
  82866. private _appendParticleVertices;
  82867. /**
  82868. * Rebuilds the particle system.
  82869. */
  82870. rebuild(): void;
  82871. /**
  82872. * Is this system ready to be used/rendered
  82873. * @return true if the system is ready
  82874. */
  82875. isReady(): boolean;
  82876. private _render;
  82877. /**
  82878. * Renders the particle system in its current state.
  82879. * @returns the current number of particles
  82880. */
  82881. render(): number;
  82882. /**
  82883. * Disposes the particle system and free the associated resources
  82884. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  82885. */
  82886. dispose(disposeTexture?: boolean): void;
  82887. /**
  82888. * Clones the particle system.
  82889. * @param name The name of the cloned object
  82890. * @param newEmitter The new emitter to use
  82891. * @returns the cloned particle system
  82892. */
  82893. clone(name: string, newEmitter: any): ParticleSystem;
  82894. /**
  82895. * Serializes the particle system to a JSON object.
  82896. * @returns the JSON object
  82897. */
  82898. serialize(): any;
  82899. /** @hidden */
  82900. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  82901. /** @hidden */
  82902. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  82903. /**
  82904. * Parses a JSON object to create a particle system.
  82905. * @param parsedParticleSystem The JSON object to parse
  82906. * @param scene The scene to create the particle system in
  82907. * @param rootUrl The root url to use to load external dependencies like texture
  82908. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  82909. * @returns the Parsed particle system
  82910. */
  82911. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  82912. }
  82913. }
  82914. declare module BABYLON {
  82915. /**
  82916. * A particle represents one of the element emitted by a particle system.
  82917. * This is mainly define by its coordinates, direction, velocity and age.
  82918. */
  82919. export class Particle {
  82920. /**
  82921. * The particle system the particle belongs to.
  82922. */
  82923. particleSystem: ParticleSystem;
  82924. private static _Count;
  82925. /**
  82926. * Unique ID of the particle
  82927. */
  82928. id: number;
  82929. /**
  82930. * The world position of the particle in the scene.
  82931. */
  82932. position: Vector3;
  82933. /**
  82934. * The world direction of the particle in the scene.
  82935. */
  82936. direction: Vector3;
  82937. /**
  82938. * The color of the particle.
  82939. */
  82940. color: Color4;
  82941. /**
  82942. * The color change of the particle per step.
  82943. */
  82944. colorStep: Color4;
  82945. /**
  82946. * Defines how long will the life of the particle be.
  82947. */
  82948. lifeTime: number;
  82949. /**
  82950. * The current age of the particle.
  82951. */
  82952. age: number;
  82953. /**
  82954. * The current size of the particle.
  82955. */
  82956. size: number;
  82957. /**
  82958. * The current scale of the particle.
  82959. */
  82960. scale: Vector2;
  82961. /**
  82962. * The current angle of the particle.
  82963. */
  82964. angle: number;
  82965. /**
  82966. * Defines how fast is the angle changing.
  82967. */
  82968. angularSpeed: number;
  82969. /**
  82970. * Defines the cell index used by the particle to be rendered from a sprite.
  82971. */
  82972. cellIndex: number;
  82973. /**
  82974. * The information required to support color remapping
  82975. */
  82976. remapData: Vector4;
  82977. /** @hidden */
  82978. _randomCellOffset?: number;
  82979. /** @hidden */
  82980. _initialDirection: Nullable<Vector3>;
  82981. /** @hidden */
  82982. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  82983. /** @hidden */
  82984. _initialStartSpriteCellID: number;
  82985. /** @hidden */
  82986. _initialEndSpriteCellID: number;
  82987. /** @hidden */
  82988. _currentColorGradient: Nullable<ColorGradient>;
  82989. /** @hidden */
  82990. _currentColor1: Color4;
  82991. /** @hidden */
  82992. _currentColor2: Color4;
  82993. /** @hidden */
  82994. _currentSizeGradient: Nullable<FactorGradient>;
  82995. /** @hidden */
  82996. _currentSize1: number;
  82997. /** @hidden */
  82998. _currentSize2: number;
  82999. /** @hidden */
  83000. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  83001. /** @hidden */
  83002. _currentAngularSpeed1: number;
  83003. /** @hidden */
  83004. _currentAngularSpeed2: number;
  83005. /** @hidden */
  83006. _currentVelocityGradient: Nullable<FactorGradient>;
  83007. /** @hidden */
  83008. _currentVelocity1: number;
  83009. /** @hidden */
  83010. _currentVelocity2: number;
  83011. /** @hidden */
  83012. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  83013. /** @hidden */
  83014. _currentLimitVelocity1: number;
  83015. /** @hidden */
  83016. _currentLimitVelocity2: number;
  83017. /** @hidden */
  83018. _currentDragGradient: Nullable<FactorGradient>;
  83019. /** @hidden */
  83020. _currentDrag1: number;
  83021. /** @hidden */
  83022. _currentDrag2: number;
  83023. /** @hidden */
  83024. _randomNoiseCoordinates1: Vector3;
  83025. /** @hidden */
  83026. _randomNoiseCoordinates2: Vector3;
  83027. /**
  83028. * Creates a new instance Particle
  83029. * @param particleSystem the particle system the particle belongs to
  83030. */
  83031. constructor(
  83032. /**
  83033. * The particle system the particle belongs to.
  83034. */
  83035. particleSystem: ParticleSystem);
  83036. private updateCellInfoFromSystem;
  83037. /**
  83038. * Defines how the sprite cell index is updated for the particle
  83039. */
  83040. updateCellIndex(): void;
  83041. /** @hidden */
  83042. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  83043. /** @hidden */
  83044. _inheritParticleInfoToSubEmitters(): void;
  83045. /** @hidden */
  83046. _reset(): void;
  83047. /**
  83048. * Copy the properties of particle to another one.
  83049. * @param other the particle to copy the information to.
  83050. */
  83051. copyTo(other: Particle): void;
  83052. }
  83053. }
  83054. declare module BABYLON {
  83055. /**
  83056. * Particle emitter represents a volume emitting particles.
  83057. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  83058. */
  83059. export interface IParticleEmitterType {
  83060. /**
  83061. * Called by the particle System when the direction is computed for the created particle.
  83062. * @param worldMatrix is the world matrix of the particle system
  83063. * @param directionToUpdate is the direction vector to update with the result
  83064. * @param particle is the particle we are computed the direction for
  83065. */
  83066. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83067. /**
  83068. * Called by the particle System when the position is computed for the created particle.
  83069. * @param worldMatrix is the world matrix of the particle system
  83070. * @param positionToUpdate is the position vector to update with the result
  83071. * @param particle is the particle we are computed the position for
  83072. */
  83073. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83074. /**
  83075. * Clones the current emitter and returns a copy of it
  83076. * @returns the new emitter
  83077. */
  83078. clone(): IParticleEmitterType;
  83079. /**
  83080. * Called by the GPUParticleSystem to setup the update shader
  83081. * @param effect defines the update shader
  83082. */
  83083. applyToShader(effect: Effect): void;
  83084. /**
  83085. * Returns a string to use to update the GPU particles update shader
  83086. * @returns the effect defines string
  83087. */
  83088. getEffectDefines(): string;
  83089. /**
  83090. * Returns a string representing the class name
  83091. * @returns a string containing the class name
  83092. */
  83093. getClassName(): string;
  83094. /**
  83095. * Serializes the particle system to a JSON object.
  83096. * @returns the JSON object
  83097. */
  83098. serialize(): any;
  83099. /**
  83100. * Parse properties from a JSON object
  83101. * @param serializationObject defines the JSON object
  83102. */
  83103. parse(serializationObject: any): void;
  83104. }
  83105. }
  83106. declare module BABYLON {
  83107. /**
  83108. * Particle emitter emitting particles from the inside of a box.
  83109. * It emits the particles randomly between 2 given directions.
  83110. */
  83111. export class BoxParticleEmitter implements IParticleEmitterType {
  83112. /**
  83113. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83114. */
  83115. direction1: Vector3;
  83116. /**
  83117. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83118. */
  83119. direction2: Vector3;
  83120. /**
  83121. * 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.
  83122. */
  83123. minEmitBox: Vector3;
  83124. /**
  83125. * 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.
  83126. */
  83127. maxEmitBox: Vector3;
  83128. /**
  83129. * Creates a new instance BoxParticleEmitter
  83130. */
  83131. constructor();
  83132. /**
  83133. * Called by the particle System when the direction is computed for the created particle.
  83134. * @param worldMatrix is the world matrix of the particle system
  83135. * @param directionToUpdate is the direction vector to update with the result
  83136. * @param particle is the particle we are computed the direction for
  83137. */
  83138. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83139. /**
  83140. * Called by the particle System when the position is computed for the created particle.
  83141. * @param worldMatrix is the world matrix of the particle system
  83142. * @param positionToUpdate is the position vector to update with the result
  83143. * @param particle is the particle we are computed the position for
  83144. */
  83145. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83146. /**
  83147. * Clones the current emitter and returns a copy of it
  83148. * @returns the new emitter
  83149. */
  83150. clone(): BoxParticleEmitter;
  83151. /**
  83152. * Called by the GPUParticleSystem to setup the update shader
  83153. * @param effect defines the update shader
  83154. */
  83155. applyToShader(effect: Effect): void;
  83156. /**
  83157. * Returns a string to use to update the GPU particles update shader
  83158. * @returns a string containng the defines string
  83159. */
  83160. getEffectDefines(): string;
  83161. /**
  83162. * Returns the string "BoxParticleEmitter"
  83163. * @returns a string containing the class name
  83164. */
  83165. getClassName(): string;
  83166. /**
  83167. * Serializes the particle system to a JSON object.
  83168. * @returns the JSON object
  83169. */
  83170. serialize(): any;
  83171. /**
  83172. * Parse properties from a JSON object
  83173. * @param serializationObject defines the JSON object
  83174. */
  83175. parse(serializationObject: any): void;
  83176. }
  83177. }
  83178. declare module BABYLON {
  83179. /**
  83180. * Particle emitter emitting particles from the inside of a cone.
  83181. * It emits the particles alongside the cone volume from the base to the particle.
  83182. * The emission direction might be randomized.
  83183. */
  83184. export class ConeParticleEmitter implements IParticleEmitterType {
  83185. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  83186. directionRandomizer: number;
  83187. private _radius;
  83188. private _angle;
  83189. private _height;
  83190. /**
  83191. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  83192. */
  83193. radiusRange: number;
  83194. /**
  83195. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  83196. */
  83197. heightRange: number;
  83198. /**
  83199. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  83200. */
  83201. emitFromSpawnPointOnly: boolean;
  83202. /**
  83203. * Gets or sets the radius of the emission cone
  83204. */
  83205. radius: number;
  83206. /**
  83207. * Gets or sets the angle of the emission cone
  83208. */
  83209. angle: number;
  83210. private _buildHeight;
  83211. /**
  83212. * Creates a new instance ConeParticleEmitter
  83213. * @param radius the radius of the emission cone (1 by default)
  83214. * @param angle the cone base angle (PI by default)
  83215. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  83216. */
  83217. constructor(radius?: number, angle?: number,
  83218. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  83219. directionRandomizer?: number);
  83220. /**
  83221. * Called by the particle System when the direction is computed for the created particle.
  83222. * @param worldMatrix is the world matrix of the particle system
  83223. * @param directionToUpdate is the direction vector to update with the result
  83224. * @param particle is the particle we are computed the direction for
  83225. */
  83226. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83227. /**
  83228. * Called by the particle System when the position is computed for the created particle.
  83229. * @param worldMatrix is the world matrix of the particle system
  83230. * @param positionToUpdate is the position vector to update with the result
  83231. * @param particle is the particle we are computed the position for
  83232. */
  83233. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83234. /**
  83235. * Clones the current emitter and returns a copy of it
  83236. * @returns the new emitter
  83237. */
  83238. clone(): ConeParticleEmitter;
  83239. /**
  83240. * Called by the GPUParticleSystem to setup the update shader
  83241. * @param effect defines the update shader
  83242. */
  83243. applyToShader(effect: Effect): void;
  83244. /**
  83245. * Returns a string to use to update the GPU particles update shader
  83246. * @returns a string containng the defines string
  83247. */
  83248. getEffectDefines(): string;
  83249. /**
  83250. * Returns the string "ConeParticleEmitter"
  83251. * @returns a string containing the class name
  83252. */
  83253. getClassName(): string;
  83254. /**
  83255. * Serializes the particle system to a JSON object.
  83256. * @returns the JSON object
  83257. */
  83258. serialize(): any;
  83259. /**
  83260. * Parse properties from a JSON object
  83261. * @param serializationObject defines the JSON object
  83262. */
  83263. parse(serializationObject: any): void;
  83264. }
  83265. }
  83266. declare module BABYLON {
  83267. /**
  83268. * Particle emitter emitting particles from the inside of a cylinder.
  83269. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  83270. */
  83271. export class CylinderParticleEmitter implements IParticleEmitterType {
  83272. /**
  83273. * The radius of the emission cylinder.
  83274. */
  83275. radius: number;
  83276. /**
  83277. * The height of the emission cylinder.
  83278. */
  83279. height: number;
  83280. /**
  83281. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83282. */
  83283. radiusRange: number;
  83284. /**
  83285. * How much to randomize the particle direction [0-1].
  83286. */
  83287. directionRandomizer: number;
  83288. /**
  83289. * Creates a new instance CylinderParticleEmitter
  83290. * @param radius the radius of the emission cylinder (1 by default)
  83291. * @param height the height of the emission cylinder (1 by default)
  83292. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83293. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  83294. */
  83295. constructor(
  83296. /**
  83297. * The radius of the emission cylinder.
  83298. */
  83299. radius?: number,
  83300. /**
  83301. * The height of the emission cylinder.
  83302. */
  83303. height?: number,
  83304. /**
  83305. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83306. */
  83307. radiusRange?: number,
  83308. /**
  83309. * How much to randomize the particle direction [0-1].
  83310. */
  83311. directionRandomizer?: number);
  83312. /**
  83313. * Called by the particle System when the direction is computed for the created particle.
  83314. * @param worldMatrix is the world matrix of the particle system
  83315. * @param directionToUpdate is the direction vector to update with the result
  83316. * @param particle is the particle we are computed the direction for
  83317. */
  83318. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83319. /**
  83320. * Called by the particle System when the position is computed for the created particle.
  83321. * @param worldMatrix is the world matrix of the particle system
  83322. * @param positionToUpdate is the position vector to update with the result
  83323. * @param particle is the particle we are computed the position for
  83324. */
  83325. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83326. /**
  83327. * Clones the current emitter and returns a copy of it
  83328. * @returns the new emitter
  83329. */
  83330. clone(): CylinderParticleEmitter;
  83331. /**
  83332. * Called by the GPUParticleSystem to setup the update shader
  83333. * @param effect defines the update shader
  83334. */
  83335. applyToShader(effect: Effect): void;
  83336. /**
  83337. * Returns a string to use to update the GPU particles update shader
  83338. * @returns a string containng the defines string
  83339. */
  83340. getEffectDefines(): string;
  83341. /**
  83342. * Returns the string "CylinderParticleEmitter"
  83343. * @returns a string containing the class name
  83344. */
  83345. getClassName(): string;
  83346. /**
  83347. * Serializes the particle system to a JSON object.
  83348. * @returns the JSON object
  83349. */
  83350. serialize(): any;
  83351. /**
  83352. * Parse properties from a JSON object
  83353. * @param serializationObject defines the JSON object
  83354. */
  83355. parse(serializationObject: any): void;
  83356. }
  83357. /**
  83358. * Particle emitter emitting particles from the inside of a cylinder.
  83359. * It emits the particles randomly between two vectors.
  83360. */
  83361. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  83362. /**
  83363. * The min limit of the emission direction.
  83364. */
  83365. direction1: Vector3;
  83366. /**
  83367. * The max limit of the emission direction.
  83368. */
  83369. direction2: Vector3;
  83370. /**
  83371. * Creates a new instance CylinderDirectedParticleEmitter
  83372. * @param radius the radius of the emission cylinder (1 by default)
  83373. * @param height the height of the emission cylinder (1 by default)
  83374. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83375. * @param direction1 the min limit of the emission direction (up vector by default)
  83376. * @param direction2 the max limit of the emission direction (up vector by default)
  83377. */
  83378. constructor(radius?: number, height?: number, radiusRange?: number,
  83379. /**
  83380. * The min limit of the emission direction.
  83381. */
  83382. direction1?: Vector3,
  83383. /**
  83384. * The max limit of the emission direction.
  83385. */
  83386. direction2?: Vector3);
  83387. /**
  83388. * Called by the particle System when the direction is computed for the created particle.
  83389. * @param worldMatrix is the world matrix of the particle system
  83390. * @param directionToUpdate is the direction vector to update with the result
  83391. * @param particle is the particle we are computed the direction for
  83392. */
  83393. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83394. /**
  83395. * Clones the current emitter and returns a copy of it
  83396. * @returns the new emitter
  83397. */
  83398. clone(): CylinderDirectedParticleEmitter;
  83399. /**
  83400. * Called by the GPUParticleSystem to setup the update shader
  83401. * @param effect defines the update shader
  83402. */
  83403. applyToShader(effect: Effect): void;
  83404. /**
  83405. * Returns a string to use to update the GPU particles update shader
  83406. * @returns a string containng the defines string
  83407. */
  83408. getEffectDefines(): string;
  83409. /**
  83410. * Returns the string "CylinderDirectedParticleEmitter"
  83411. * @returns a string containing the class name
  83412. */
  83413. getClassName(): string;
  83414. /**
  83415. * Serializes the particle system to a JSON object.
  83416. * @returns the JSON object
  83417. */
  83418. serialize(): any;
  83419. /**
  83420. * Parse properties from a JSON object
  83421. * @param serializationObject defines the JSON object
  83422. */
  83423. parse(serializationObject: any): void;
  83424. }
  83425. }
  83426. declare module BABYLON {
  83427. /**
  83428. * Particle emitter emitting particles from the inside of a hemisphere.
  83429. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  83430. */
  83431. export class HemisphericParticleEmitter implements IParticleEmitterType {
  83432. /**
  83433. * The radius of the emission hemisphere.
  83434. */
  83435. radius: number;
  83436. /**
  83437. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83438. */
  83439. radiusRange: number;
  83440. /**
  83441. * How much to randomize the particle direction [0-1].
  83442. */
  83443. directionRandomizer: number;
  83444. /**
  83445. * Creates a new instance HemisphericParticleEmitter
  83446. * @param radius the radius of the emission hemisphere (1 by default)
  83447. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83448. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  83449. */
  83450. constructor(
  83451. /**
  83452. * The radius of the emission hemisphere.
  83453. */
  83454. radius?: number,
  83455. /**
  83456. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83457. */
  83458. radiusRange?: number,
  83459. /**
  83460. * How much to randomize the particle direction [0-1].
  83461. */
  83462. directionRandomizer?: number);
  83463. /**
  83464. * Called by the particle System when the direction is computed for the created particle.
  83465. * @param worldMatrix is the world matrix of the particle system
  83466. * @param directionToUpdate is the direction vector to update with the result
  83467. * @param particle is the particle we are computed the direction for
  83468. */
  83469. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83470. /**
  83471. * Called by the particle System when the position is computed for the created particle.
  83472. * @param worldMatrix is the world matrix of the particle system
  83473. * @param positionToUpdate is the position vector to update with the result
  83474. * @param particle is the particle we are computed the position for
  83475. */
  83476. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83477. /**
  83478. * Clones the current emitter and returns a copy of it
  83479. * @returns the new emitter
  83480. */
  83481. clone(): HemisphericParticleEmitter;
  83482. /**
  83483. * Called by the GPUParticleSystem to setup the update shader
  83484. * @param effect defines the update shader
  83485. */
  83486. applyToShader(effect: Effect): void;
  83487. /**
  83488. * Returns a string to use to update the GPU particles update shader
  83489. * @returns a string containng the defines string
  83490. */
  83491. getEffectDefines(): string;
  83492. /**
  83493. * Returns the string "HemisphericParticleEmitter"
  83494. * @returns a string containing the class name
  83495. */
  83496. getClassName(): string;
  83497. /**
  83498. * Serializes the particle system to a JSON object.
  83499. * @returns the JSON object
  83500. */
  83501. serialize(): any;
  83502. /**
  83503. * Parse properties from a JSON object
  83504. * @param serializationObject defines the JSON object
  83505. */
  83506. parse(serializationObject: any): void;
  83507. }
  83508. }
  83509. declare module BABYLON {
  83510. /**
  83511. * Particle emitter emitting particles from a point.
  83512. * It emits the particles randomly between 2 given directions.
  83513. */
  83514. export class PointParticleEmitter implements IParticleEmitterType {
  83515. /**
  83516. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83517. */
  83518. direction1: Vector3;
  83519. /**
  83520. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83521. */
  83522. direction2: Vector3;
  83523. /**
  83524. * Creates a new instance PointParticleEmitter
  83525. */
  83526. constructor();
  83527. /**
  83528. * Called by the particle System when the direction is computed for the created particle.
  83529. * @param worldMatrix is the world matrix of the particle system
  83530. * @param directionToUpdate is the direction vector to update with the result
  83531. * @param particle is the particle we are computed the direction for
  83532. */
  83533. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83534. /**
  83535. * Called by the particle System when the position is computed for the created particle.
  83536. * @param worldMatrix is the world matrix of the particle system
  83537. * @param positionToUpdate is the position vector to update with the result
  83538. * @param particle is the particle we are computed the position for
  83539. */
  83540. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83541. /**
  83542. * Clones the current emitter and returns a copy of it
  83543. * @returns the new emitter
  83544. */
  83545. clone(): PointParticleEmitter;
  83546. /**
  83547. * Called by the GPUParticleSystem to setup the update shader
  83548. * @param effect defines the update shader
  83549. */
  83550. applyToShader(effect: Effect): void;
  83551. /**
  83552. * Returns a string to use to update the GPU particles update shader
  83553. * @returns a string containng the defines string
  83554. */
  83555. getEffectDefines(): string;
  83556. /**
  83557. * Returns the string "PointParticleEmitter"
  83558. * @returns a string containing the class name
  83559. */
  83560. getClassName(): string;
  83561. /**
  83562. * Serializes the particle system to a JSON object.
  83563. * @returns the JSON object
  83564. */
  83565. serialize(): any;
  83566. /**
  83567. * Parse properties from a JSON object
  83568. * @param serializationObject defines the JSON object
  83569. */
  83570. parse(serializationObject: any): void;
  83571. }
  83572. }
  83573. declare module BABYLON {
  83574. /**
  83575. * Particle emitter emitting particles from the inside of a sphere.
  83576. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  83577. */
  83578. export class SphereParticleEmitter implements IParticleEmitterType {
  83579. /**
  83580. * The radius of the emission sphere.
  83581. */
  83582. radius: number;
  83583. /**
  83584. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83585. */
  83586. radiusRange: number;
  83587. /**
  83588. * How much to randomize the particle direction [0-1].
  83589. */
  83590. directionRandomizer: number;
  83591. /**
  83592. * Creates a new instance SphereParticleEmitter
  83593. * @param radius the radius of the emission sphere (1 by default)
  83594. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83595. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  83596. */
  83597. constructor(
  83598. /**
  83599. * The radius of the emission sphere.
  83600. */
  83601. radius?: number,
  83602. /**
  83603. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83604. */
  83605. radiusRange?: number,
  83606. /**
  83607. * How much to randomize the particle direction [0-1].
  83608. */
  83609. directionRandomizer?: number);
  83610. /**
  83611. * Called by the particle System when the direction is computed for the created particle.
  83612. * @param worldMatrix is the world matrix of the particle system
  83613. * @param directionToUpdate is the direction vector to update with the result
  83614. * @param particle is the particle we are computed the direction for
  83615. */
  83616. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83617. /**
  83618. * Called by the particle System when the position is computed for the created particle.
  83619. * @param worldMatrix is the world matrix of the particle system
  83620. * @param positionToUpdate is the position vector to update with the result
  83621. * @param particle is the particle we are computed the position for
  83622. */
  83623. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83624. /**
  83625. * Clones the current emitter and returns a copy of it
  83626. * @returns the new emitter
  83627. */
  83628. clone(): SphereParticleEmitter;
  83629. /**
  83630. * Called by the GPUParticleSystem to setup the update shader
  83631. * @param effect defines the update shader
  83632. */
  83633. applyToShader(effect: Effect): void;
  83634. /**
  83635. * Returns a string to use to update the GPU particles update shader
  83636. * @returns a string containng the defines string
  83637. */
  83638. getEffectDefines(): string;
  83639. /**
  83640. * Returns the string "SphereParticleEmitter"
  83641. * @returns a string containing the class name
  83642. */
  83643. getClassName(): string;
  83644. /**
  83645. * Serializes the particle system to a JSON object.
  83646. * @returns the JSON object
  83647. */
  83648. serialize(): any;
  83649. /**
  83650. * Parse properties from a JSON object
  83651. * @param serializationObject defines the JSON object
  83652. */
  83653. parse(serializationObject: any): void;
  83654. }
  83655. /**
  83656. * Particle emitter emitting particles from the inside of a sphere.
  83657. * It emits the particles randomly between two vectors.
  83658. */
  83659. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  83660. /**
  83661. * The min limit of the emission direction.
  83662. */
  83663. direction1: Vector3;
  83664. /**
  83665. * The max limit of the emission direction.
  83666. */
  83667. direction2: Vector3;
  83668. /**
  83669. * Creates a new instance SphereDirectedParticleEmitter
  83670. * @param radius the radius of the emission sphere (1 by default)
  83671. * @param direction1 the min limit of the emission direction (up vector by default)
  83672. * @param direction2 the max limit of the emission direction (up vector by default)
  83673. */
  83674. constructor(radius?: number,
  83675. /**
  83676. * The min limit of the emission direction.
  83677. */
  83678. direction1?: Vector3,
  83679. /**
  83680. * The max limit of the emission direction.
  83681. */
  83682. direction2?: Vector3);
  83683. /**
  83684. * Called by the particle System when the direction is computed for the created particle.
  83685. * @param worldMatrix is the world matrix of the particle system
  83686. * @param directionToUpdate is the direction vector to update with the result
  83687. * @param particle is the particle we are computed the direction for
  83688. */
  83689. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83690. /**
  83691. * Clones the current emitter and returns a copy of it
  83692. * @returns the new emitter
  83693. */
  83694. clone(): SphereDirectedParticleEmitter;
  83695. /**
  83696. * Called by the GPUParticleSystem to setup the update shader
  83697. * @param effect defines the update shader
  83698. */
  83699. applyToShader(effect: Effect): void;
  83700. /**
  83701. * Returns a string to use to update the GPU particles update shader
  83702. * @returns a string containng the defines string
  83703. */
  83704. getEffectDefines(): string;
  83705. /**
  83706. * Returns the string "SphereDirectedParticleEmitter"
  83707. * @returns a string containing the class name
  83708. */
  83709. getClassName(): string;
  83710. /**
  83711. * Serializes the particle system to a JSON object.
  83712. * @returns the JSON object
  83713. */
  83714. serialize(): any;
  83715. /**
  83716. * Parse properties from a JSON object
  83717. * @param serializationObject defines the JSON object
  83718. */
  83719. parse(serializationObject: any): void;
  83720. }
  83721. }
  83722. declare module BABYLON {
  83723. /**
  83724. * Interface representing a particle system in Babylon.js.
  83725. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  83726. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  83727. */
  83728. export interface IParticleSystem {
  83729. /**
  83730. * List of animations used by the particle system.
  83731. */
  83732. animations: Animation[];
  83733. /**
  83734. * The id of the Particle system.
  83735. */
  83736. id: string;
  83737. /**
  83738. * The name of the Particle system.
  83739. */
  83740. name: string;
  83741. /**
  83742. * The emitter represents the Mesh or position we are attaching the particle system to.
  83743. */
  83744. emitter: Nullable<AbstractMesh | Vector3>;
  83745. /**
  83746. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  83747. */
  83748. isBillboardBased: boolean;
  83749. /**
  83750. * The rendering group used by the Particle system to chose when to render.
  83751. */
  83752. renderingGroupId: number;
  83753. /**
  83754. * The layer mask we are rendering the particles through.
  83755. */
  83756. layerMask: number;
  83757. /**
  83758. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  83759. */
  83760. updateSpeed: number;
  83761. /**
  83762. * The amount of time the particle system is running (depends of the overall update speed).
  83763. */
  83764. targetStopDuration: number;
  83765. /**
  83766. * The texture used to render each particle. (this can be a spritesheet)
  83767. */
  83768. particleTexture: Nullable<Texture>;
  83769. /**
  83770. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  83771. */
  83772. blendMode: number;
  83773. /**
  83774. * Minimum life time of emitting particles.
  83775. */
  83776. minLifeTime: number;
  83777. /**
  83778. * Maximum life time of emitting particles.
  83779. */
  83780. maxLifeTime: number;
  83781. /**
  83782. * Minimum Size of emitting particles.
  83783. */
  83784. minSize: number;
  83785. /**
  83786. * Maximum Size of emitting particles.
  83787. */
  83788. maxSize: number;
  83789. /**
  83790. * Minimum scale of emitting particles on X axis.
  83791. */
  83792. minScaleX: number;
  83793. /**
  83794. * Maximum scale of emitting particles on X axis.
  83795. */
  83796. maxScaleX: number;
  83797. /**
  83798. * Minimum scale of emitting particles on Y axis.
  83799. */
  83800. minScaleY: number;
  83801. /**
  83802. * Maximum scale of emitting particles on Y axis.
  83803. */
  83804. maxScaleY: number;
  83805. /**
  83806. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  83807. */
  83808. color1: Color4;
  83809. /**
  83810. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  83811. */
  83812. color2: Color4;
  83813. /**
  83814. * Color the particle will have at the end of its lifetime.
  83815. */
  83816. colorDead: Color4;
  83817. /**
  83818. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  83819. */
  83820. emitRate: number;
  83821. /**
  83822. * You can use gravity if you want to give an orientation to your particles.
  83823. */
  83824. gravity: Vector3;
  83825. /**
  83826. * Minimum power of emitting particles.
  83827. */
  83828. minEmitPower: number;
  83829. /**
  83830. * Maximum power of emitting particles.
  83831. */
  83832. maxEmitPower: number;
  83833. /**
  83834. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  83835. */
  83836. minAngularSpeed: number;
  83837. /**
  83838. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  83839. */
  83840. maxAngularSpeed: number;
  83841. /**
  83842. * Gets or sets the minimal initial rotation in radians.
  83843. */
  83844. minInitialRotation: number;
  83845. /**
  83846. * Gets or sets the maximal initial rotation in radians.
  83847. */
  83848. maxInitialRotation: number;
  83849. /**
  83850. * The particle emitter type defines the emitter used by the particle system.
  83851. * It can be for example box, sphere, or cone...
  83852. */
  83853. particleEmitterType: Nullable<IParticleEmitterType>;
  83854. /**
  83855. * Defines the delay in milliseconds before starting the system (0 by default)
  83856. */
  83857. startDelay: number;
  83858. /**
  83859. * 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
  83860. */
  83861. preWarmCycles: number;
  83862. /**
  83863. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  83864. */
  83865. preWarmStepOffset: number;
  83866. /**
  83867. * 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)
  83868. */
  83869. spriteCellChangeSpeed: number;
  83870. /**
  83871. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  83872. */
  83873. startSpriteCellID: number;
  83874. /**
  83875. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  83876. */
  83877. endSpriteCellID: number;
  83878. /**
  83879. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  83880. */
  83881. spriteCellWidth: number;
  83882. /**
  83883. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  83884. */
  83885. spriteCellHeight: number;
  83886. /**
  83887. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  83888. */
  83889. spriteRandomStartCell: boolean;
  83890. /**
  83891. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  83892. */
  83893. isAnimationSheetEnabled: boolean;
  83894. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  83895. translationPivot: Vector2;
  83896. /**
  83897. * Gets or sets a texture used to add random noise to particle positions
  83898. */
  83899. noiseTexture: Nullable<BaseTexture>;
  83900. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  83901. noiseStrength: Vector3;
  83902. /**
  83903. * Gets or sets the billboard mode to use when isBillboardBased = true.
  83904. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  83905. */
  83906. billboardMode: number;
  83907. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  83908. limitVelocityDamping: number;
  83909. /**
  83910. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  83911. */
  83912. beginAnimationOnStart: boolean;
  83913. /**
  83914. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  83915. */
  83916. beginAnimationFrom: number;
  83917. /**
  83918. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  83919. */
  83920. beginAnimationTo: number;
  83921. /**
  83922. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  83923. */
  83924. beginAnimationLoop: boolean;
  83925. /**
  83926. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  83927. */
  83928. disposeOnStop: boolean;
  83929. /**
  83930. * Gets the maximum number of particles active at the same time.
  83931. * @returns The max number of active particles.
  83932. */
  83933. getCapacity(): number;
  83934. /**
  83935. * Gets if the system has been started. (Note: this will still be true after stop is called)
  83936. * @returns True if it has been started, otherwise false.
  83937. */
  83938. isStarted(): boolean;
  83939. /**
  83940. * Animates the particle system for this frame.
  83941. */
  83942. animate(): void;
  83943. /**
  83944. * Renders the particle system in its current state.
  83945. * @returns the current number of particles
  83946. */
  83947. render(): number;
  83948. /**
  83949. * Dispose the particle system and frees its associated resources.
  83950. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  83951. */
  83952. dispose(disposeTexture?: boolean): void;
  83953. /**
  83954. * Clones the particle system.
  83955. * @param name The name of the cloned object
  83956. * @param newEmitter The new emitter to use
  83957. * @returns the cloned particle system
  83958. */
  83959. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  83960. /**
  83961. * Serializes the particle system to a JSON object.
  83962. * @returns the JSON object
  83963. */
  83964. serialize(): any;
  83965. /**
  83966. * Rebuild the particle system
  83967. */
  83968. rebuild(): void;
  83969. /**
  83970. * Starts the particle system and begins to emit
  83971. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  83972. */
  83973. start(delay?: number): void;
  83974. /**
  83975. * Stops the particle system.
  83976. */
  83977. stop(): void;
  83978. /**
  83979. * Remove all active particles
  83980. */
  83981. reset(): void;
  83982. /**
  83983. * Is this system ready to be used/rendered
  83984. * @return true if the system is ready
  83985. */
  83986. isReady(): boolean;
  83987. /**
  83988. * Adds a new color gradient
  83989. * @param gradient defines the gradient to use (between 0 and 1)
  83990. * @param color1 defines the color to affect to the specified gradient
  83991. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  83992. * @returns the current particle system
  83993. */
  83994. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  83995. /**
  83996. * Remove a specific color gradient
  83997. * @param gradient defines the gradient to remove
  83998. * @returns the current particle system
  83999. */
  84000. removeColorGradient(gradient: number): IParticleSystem;
  84001. /**
  84002. * Adds a new size gradient
  84003. * @param gradient defines the gradient to use (between 0 and 1)
  84004. * @param factor defines the size factor to affect to the specified gradient
  84005. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84006. * @returns the current particle system
  84007. */
  84008. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84009. /**
  84010. * Remove a specific size gradient
  84011. * @param gradient defines the gradient to remove
  84012. * @returns the current particle system
  84013. */
  84014. removeSizeGradient(gradient: number): IParticleSystem;
  84015. /**
  84016. * Gets the current list of color gradients.
  84017. * You must use addColorGradient and removeColorGradient to udpate this list
  84018. * @returns the list of color gradients
  84019. */
  84020. getColorGradients(): Nullable<Array<ColorGradient>>;
  84021. /**
  84022. * Gets the current list of size gradients.
  84023. * You must use addSizeGradient and removeSizeGradient to udpate this list
  84024. * @returns the list of size gradients
  84025. */
  84026. getSizeGradients(): Nullable<Array<FactorGradient>>;
  84027. /**
  84028. * Gets the current list of angular speed gradients.
  84029. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  84030. * @returns the list of angular speed gradients
  84031. */
  84032. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  84033. /**
  84034. * Adds a new angular speed gradient
  84035. * @param gradient defines the gradient to use (between 0 and 1)
  84036. * @param factor defines the angular speed to affect to the specified gradient
  84037. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84038. * @returns the current particle system
  84039. */
  84040. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84041. /**
  84042. * Remove a specific angular speed gradient
  84043. * @param gradient defines the gradient to remove
  84044. * @returns the current particle system
  84045. */
  84046. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  84047. /**
  84048. * Gets the current list of velocity gradients.
  84049. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  84050. * @returns the list of velocity gradients
  84051. */
  84052. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  84053. /**
  84054. * Adds a new velocity gradient
  84055. * @param gradient defines the gradient to use (between 0 and 1)
  84056. * @param factor defines the velocity to affect to the specified gradient
  84057. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84058. * @returns the current particle system
  84059. */
  84060. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84061. /**
  84062. * Remove a specific velocity gradient
  84063. * @param gradient defines the gradient to remove
  84064. * @returns the current particle system
  84065. */
  84066. removeVelocityGradient(gradient: number): IParticleSystem;
  84067. /**
  84068. * Gets the current list of limit velocity gradients.
  84069. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  84070. * @returns the list of limit velocity gradients
  84071. */
  84072. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  84073. /**
  84074. * Adds a new limit velocity gradient
  84075. * @param gradient defines the gradient to use (between 0 and 1)
  84076. * @param factor defines the limit velocity to affect to the specified gradient
  84077. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84078. * @returns the current particle system
  84079. */
  84080. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84081. /**
  84082. * Remove a specific limit velocity gradient
  84083. * @param gradient defines the gradient to remove
  84084. * @returns the current particle system
  84085. */
  84086. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  84087. /**
  84088. * Adds a new drag gradient
  84089. * @param gradient defines the gradient to use (between 0 and 1)
  84090. * @param factor defines the drag to affect to the specified gradient
  84091. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84092. * @returns the current particle system
  84093. */
  84094. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84095. /**
  84096. * Remove a specific drag gradient
  84097. * @param gradient defines the gradient to remove
  84098. * @returns the current particle system
  84099. */
  84100. removeDragGradient(gradient: number): IParticleSystem;
  84101. /**
  84102. * Gets the current list of drag gradients.
  84103. * You must use addDragGradient and removeDragGradient to udpate this list
  84104. * @returns the list of drag gradients
  84105. */
  84106. getDragGradients(): Nullable<Array<FactorGradient>>;
  84107. /**
  84108. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  84109. * @param gradient defines the gradient to use (between 0 and 1)
  84110. * @param factor defines the emit rate to affect to the specified gradient
  84111. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84112. * @returns the current particle system
  84113. */
  84114. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84115. /**
  84116. * Remove a specific emit rate gradient
  84117. * @param gradient defines the gradient to remove
  84118. * @returns the current particle system
  84119. */
  84120. removeEmitRateGradient(gradient: number): IParticleSystem;
  84121. /**
  84122. * Gets the current list of emit rate gradients.
  84123. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  84124. * @returns the list of emit rate gradients
  84125. */
  84126. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  84127. /**
  84128. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  84129. * @param gradient defines the gradient to use (between 0 and 1)
  84130. * @param factor defines the start size to affect to the specified gradient
  84131. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84132. * @returns the current particle system
  84133. */
  84134. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84135. /**
  84136. * Remove a specific start size gradient
  84137. * @param gradient defines the gradient to remove
  84138. * @returns the current particle system
  84139. */
  84140. removeStartSizeGradient(gradient: number): IParticleSystem;
  84141. /**
  84142. * Gets the current list of start size gradients.
  84143. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  84144. * @returns the list of start size gradients
  84145. */
  84146. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  84147. /**
  84148. * Adds a new life time gradient
  84149. * @param gradient defines the gradient to use (between 0 and 1)
  84150. * @param factor defines the life time factor to affect to the specified gradient
  84151. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84152. * @returns the current particle system
  84153. */
  84154. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84155. /**
  84156. * Remove a specific life time gradient
  84157. * @param gradient defines the gradient to remove
  84158. * @returns the current particle system
  84159. */
  84160. removeLifeTimeGradient(gradient: number): IParticleSystem;
  84161. /**
  84162. * Gets the current list of life time gradients.
  84163. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  84164. * @returns the list of life time gradients
  84165. */
  84166. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  84167. /**
  84168. * Gets the current list of color gradients.
  84169. * You must use addColorGradient and removeColorGradient to udpate this list
  84170. * @returns the list of color gradients
  84171. */
  84172. getColorGradients(): Nullable<Array<ColorGradient>>;
  84173. /**
  84174. * Adds a new ramp gradient used to remap particle colors
  84175. * @param gradient defines the gradient to use (between 0 and 1)
  84176. * @param color defines the color to affect to the specified gradient
  84177. * @returns the current particle system
  84178. */
  84179. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  84180. /**
  84181. * Gets the current list of ramp gradients.
  84182. * You must use addRampGradient and removeRampGradient to udpate this list
  84183. * @returns the list of ramp gradients
  84184. */
  84185. getRampGradients(): Nullable<Array<Color3Gradient>>;
  84186. /** Gets or sets a boolean indicating that ramp gradients must be used
  84187. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  84188. */
  84189. useRampGradients: boolean;
  84190. /**
  84191. * Adds a new color remap gradient
  84192. * @param gradient defines the gradient to use (between 0 and 1)
  84193. * @param min defines the color remap minimal range
  84194. * @param max defines the color remap maximal range
  84195. * @returns the current particle system
  84196. */
  84197. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  84198. /**
  84199. * Gets the current list of color remap gradients.
  84200. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  84201. * @returns the list of color remap gradients
  84202. */
  84203. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  84204. /**
  84205. * Adds a new alpha remap gradient
  84206. * @param gradient defines the gradient to use (between 0 and 1)
  84207. * @param min defines the alpha remap minimal range
  84208. * @param max defines the alpha remap maximal range
  84209. * @returns the current particle system
  84210. */
  84211. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  84212. /**
  84213. * Gets the current list of alpha remap gradients.
  84214. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  84215. * @returns the list of alpha remap gradients
  84216. */
  84217. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  84218. /**
  84219. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  84220. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84221. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84222. * @returns the emitter
  84223. */
  84224. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  84225. /**
  84226. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  84227. * @param radius The radius of the hemisphere to emit from
  84228. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84229. * @returns the emitter
  84230. */
  84231. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  84232. /**
  84233. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  84234. * @param radius The radius of the sphere to emit from
  84235. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84236. * @returns the emitter
  84237. */
  84238. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  84239. /**
  84240. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  84241. * @param radius The radius of the sphere to emit from
  84242. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  84243. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  84244. * @returns the emitter
  84245. */
  84246. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  84247. /**
  84248. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  84249. * @param radius The radius of the emission cylinder
  84250. * @param height The height of the emission cylinder
  84251. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  84252. * @param directionRandomizer How much to randomize the particle direction [0-1]
  84253. * @returns the emitter
  84254. */
  84255. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  84256. /**
  84257. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  84258. * @param radius The radius of the cylinder to emit from
  84259. * @param height The height of the emission cylinder
  84260. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84261. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  84262. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  84263. * @returns the emitter
  84264. */
  84265. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  84266. /**
  84267. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  84268. * @param radius The radius of the cone to emit from
  84269. * @param angle The base angle of the cone
  84270. * @returns the emitter
  84271. */
  84272. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  84273. /**
  84274. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  84275. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84276. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84277. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84278. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84279. * @returns the emitter
  84280. */
  84281. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  84282. /**
  84283. * Get hosting scene
  84284. * @returns the scene
  84285. */
  84286. getScene(): Scene;
  84287. }
  84288. }
  84289. declare module BABYLON {
  84290. /** @hidden */
  84291. export var linePixelShader: {
  84292. name: string;
  84293. shader: string;
  84294. };
  84295. }
  84296. declare module BABYLON {
  84297. /** @hidden */
  84298. export var lineVertexShader: {
  84299. name: string;
  84300. shader: string;
  84301. };
  84302. }
  84303. declare module BABYLON {
  84304. interface AbstractMesh {
  84305. /**
  84306. * Gets the edgesRenderer associated with the mesh
  84307. */
  84308. edgesRenderer: Nullable<EdgesRenderer>;
  84309. }
  84310. interface LinesMesh {
  84311. /**
  84312. * Enables the edge rendering mode on the mesh.
  84313. * This mode makes the mesh edges visible
  84314. * @param epsilon defines the maximal distance between two angles to detect a face
  84315. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  84316. * @returns the currentAbstractMesh
  84317. * @see https://www.babylonjs-playground.com/#19O9TU#0
  84318. */
  84319. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  84320. }
  84321. interface InstancedLinesMesh {
  84322. /**
  84323. * Enables the edge rendering mode on the mesh.
  84324. * This mode makes the mesh edges visible
  84325. * @param epsilon defines the maximal distance between two angles to detect a face
  84326. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  84327. * @returns the current InstancedLinesMesh
  84328. * @see https://www.babylonjs-playground.com/#19O9TU#0
  84329. */
  84330. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  84331. }
  84332. /**
  84333. * Defines the minimum contract an Edges renderer should follow.
  84334. */
  84335. export interface IEdgesRenderer extends IDisposable {
  84336. /**
  84337. * Gets or sets a boolean indicating if the edgesRenderer is active
  84338. */
  84339. isEnabled: boolean;
  84340. /**
  84341. * Renders the edges of the attached mesh,
  84342. */
  84343. render(): void;
  84344. /**
  84345. * Checks wether or not the edges renderer is ready to render.
  84346. * @return true if ready, otherwise false.
  84347. */
  84348. isReady(): boolean;
  84349. }
  84350. /**
  84351. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  84352. */
  84353. export class EdgesRenderer implements IEdgesRenderer {
  84354. /**
  84355. * Define the size of the edges with an orthographic camera
  84356. */
  84357. edgesWidthScalerForOrthographic: number;
  84358. /**
  84359. * Define the size of the edges with a perspective camera
  84360. */
  84361. edgesWidthScalerForPerspective: number;
  84362. protected _source: AbstractMesh;
  84363. protected _linesPositions: number[];
  84364. protected _linesNormals: number[];
  84365. protected _linesIndices: number[];
  84366. protected _epsilon: number;
  84367. protected _indicesCount: number;
  84368. protected _lineShader: ShaderMaterial;
  84369. protected _ib: DataBuffer;
  84370. protected _buffers: {
  84371. [key: string]: Nullable<VertexBuffer>;
  84372. };
  84373. protected _checkVerticesInsteadOfIndices: boolean;
  84374. private _meshRebuildObserver;
  84375. private _meshDisposeObserver;
  84376. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  84377. isEnabled: boolean;
  84378. /**
  84379. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  84380. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  84381. * @param source Mesh used to create edges
  84382. * @param epsilon sum of angles in adjacency to check for edge
  84383. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  84384. * @param generateEdgesLines - should generate Lines or only prepare resources.
  84385. */
  84386. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  84387. protected _prepareRessources(): void;
  84388. /** @hidden */
  84389. _rebuild(): void;
  84390. /**
  84391. * Releases the required resources for the edges renderer
  84392. */
  84393. dispose(): void;
  84394. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  84395. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  84396. /**
  84397. * Checks if the pair of p0 and p1 is en edge
  84398. * @param faceIndex
  84399. * @param edge
  84400. * @param faceNormals
  84401. * @param p0
  84402. * @param p1
  84403. * @private
  84404. */
  84405. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  84406. /**
  84407. * push line into the position, normal and index buffer
  84408. * @protected
  84409. */
  84410. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  84411. /**
  84412. * Generates lines edges from adjacencjes
  84413. * @private
  84414. */
  84415. _generateEdgesLines(): void;
  84416. /**
  84417. * Checks wether or not the edges renderer is ready to render.
  84418. * @return true if ready, otherwise false.
  84419. */
  84420. isReady(): boolean;
  84421. /**
  84422. * Renders the edges of the attached mesh,
  84423. */
  84424. render(): void;
  84425. }
  84426. /**
  84427. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  84428. */
  84429. export class LineEdgesRenderer extends EdgesRenderer {
  84430. /**
  84431. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  84432. * @param source LineMesh used to generate edges
  84433. * @param epsilon not important (specified angle for edge detection)
  84434. * @param checkVerticesInsteadOfIndices not important for LineMesh
  84435. */
  84436. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  84437. /**
  84438. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  84439. */
  84440. _generateEdgesLines(): void;
  84441. }
  84442. }
  84443. declare module BABYLON {
  84444. /**
  84445. * This represents the object necessary to create a rendering group.
  84446. * This is exclusively used and created by the rendering manager.
  84447. * To modify the behavior, you use the available helpers in your scene or meshes.
  84448. * @hidden
  84449. */
  84450. export class RenderingGroup {
  84451. index: number;
  84452. private static _zeroVector;
  84453. private _scene;
  84454. private _opaqueSubMeshes;
  84455. private _transparentSubMeshes;
  84456. private _alphaTestSubMeshes;
  84457. private _depthOnlySubMeshes;
  84458. private _particleSystems;
  84459. private _spriteManagers;
  84460. private _opaqueSortCompareFn;
  84461. private _alphaTestSortCompareFn;
  84462. private _transparentSortCompareFn;
  84463. private _renderOpaque;
  84464. private _renderAlphaTest;
  84465. private _renderTransparent;
  84466. /** @hidden */
  84467. _edgesRenderers: SmartArray<IEdgesRenderer>;
  84468. onBeforeTransparentRendering: () => void;
  84469. /**
  84470. * Set the opaque sort comparison function.
  84471. * If null the sub meshes will be render in the order they were created
  84472. */
  84473. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  84474. /**
  84475. * Set the alpha test sort comparison function.
  84476. * If null the sub meshes will be render in the order they were created
  84477. */
  84478. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  84479. /**
  84480. * Set the transparent sort comparison function.
  84481. * If null the sub meshes will be render in the order they were created
  84482. */
  84483. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  84484. /**
  84485. * Creates a new rendering group.
  84486. * @param index The rendering group index
  84487. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  84488. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  84489. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  84490. */
  84491. 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>);
  84492. /**
  84493. * Render all the sub meshes contained in the group.
  84494. * @param customRenderFunction Used to override the default render behaviour of the group.
  84495. * @returns true if rendered some submeshes.
  84496. */
  84497. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  84498. /**
  84499. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  84500. * @param subMeshes The submeshes to render
  84501. */
  84502. private renderOpaqueSorted;
  84503. /**
  84504. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  84505. * @param subMeshes The submeshes to render
  84506. */
  84507. private renderAlphaTestSorted;
  84508. /**
  84509. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  84510. * @param subMeshes The submeshes to render
  84511. */
  84512. private renderTransparentSorted;
  84513. /**
  84514. * Renders the submeshes in a specified order.
  84515. * @param subMeshes The submeshes to sort before render
  84516. * @param sortCompareFn The comparison function use to sort
  84517. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  84518. * @param transparent Specifies to activate blending if true
  84519. */
  84520. private static renderSorted;
  84521. /**
  84522. * Renders the submeshes in the order they were dispatched (no sort applied).
  84523. * @param subMeshes The submeshes to render
  84524. */
  84525. private static renderUnsorted;
  84526. /**
  84527. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  84528. * are rendered back to front if in the same alpha index.
  84529. *
  84530. * @param a The first submesh
  84531. * @param b The second submesh
  84532. * @returns The result of the comparison
  84533. */
  84534. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  84535. /**
  84536. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  84537. * are rendered back to front.
  84538. *
  84539. * @param a The first submesh
  84540. * @param b The second submesh
  84541. * @returns The result of the comparison
  84542. */
  84543. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  84544. /**
  84545. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  84546. * are rendered front to back (prevent overdraw).
  84547. *
  84548. * @param a The first submesh
  84549. * @param b The second submesh
  84550. * @returns The result of the comparison
  84551. */
  84552. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  84553. /**
  84554. * Resets the different lists of submeshes to prepare a new frame.
  84555. */
  84556. prepare(): void;
  84557. dispose(): void;
  84558. /**
  84559. * Inserts the submesh in its correct queue depending on its material.
  84560. * @param subMesh The submesh to dispatch
  84561. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  84562. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  84563. */
  84564. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  84565. dispatchSprites(spriteManager: ISpriteManager): void;
  84566. dispatchParticles(particleSystem: IParticleSystem): void;
  84567. private _renderParticles;
  84568. private _renderSprites;
  84569. }
  84570. }
  84571. declare module BABYLON {
  84572. /**
  84573. * Interface describing the different options available in the rendering manager
  84574. * regarding Auto Clear between groups.
  84575. */
  84576. export interface IRenderingManagerAutoClearSetup {
  84577. /**
  84578. * Defines whether or not autoclear is enable.
  84579. */
  84580. autoClear: boolean;
  84581. /**
  84582. * Defines whether or not to autoclear the depth buffer.
  84583. */
  84584. depth: boolean;
  84585. /**
  84586. * Defines whether or not to autoclear the stencil buffer.
  84587. */
  84588. stencil: boolean;
  84589. }
  84590. /**
  84591. * This class is used by the onRenderingGroupObservable
  84592. */
  84593. export class RenderingGroupInfo {
  84594. /**
  84595. * The Scene that being rendered
  84596. */
  84597. scene: Scene;
  84598. /**
  84599. * The camera currently used for the rendering pass
  84600. */
  84601. camera: Nullable<Camera>;
  84602. /**
  84603. * The ID of the renderingGroup being processed
  84604. */
  84605. renderingGroupId: number;
  84606. }
  84607. /**
  84608. * This is the manager responsible of all the rendering for meshes sprites and particles.
  84609. * It is enable to manage the different groups as well as the different necessary sort functions.
  84610. * This should not be used directly aside of the few static configurations
  84611. */
  84612. export class RenderingManager {
  84613. /**
  84614. * The max id used for rendering groups (not included)
  84615. */
  84616. static MAX_RENDERINGGROUPS: number;
  84617. /**
  84618. * The min id used for rendering groups (included)
  84619. */
  84620. static MIN_RENDERINGGROUPS: number;
  84621. /**
  84622. * Used to globally prevent autoclearing scenes.
  84623. */
  84624. static AUTOCLEAR: boolean;
  84625. /**
  84626. * @hidden
  84627. */
  84628. _useSceneAutoClearSetup: boolean;
  84629. private _scene;
  84630. private _renderingGroups;
  84631. private _depthStencilBufferAlreadyCleaned;
  84632. private _autoClearDepthStencil;
  84633. private _customOpaqueSortCompareFn;
  84634. private _customAlphaTestSortCompareFn;
  84635. private _customTransparentSortCompareFn;
  84636. private _renderingGroupInfo;
  84637. /**
  84638. * Instantiates a new rendering group for a particular scene
  84639. * @param scene Defines the scene the groups belongs to
  84640. */
  84641. constructor(scene: Scene);
  84642. private _clearDepthStencilBuffer;
  84643. /**
  84644. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  84645. * @hidden
  84646. */
  84647. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  84648. /**
  84649. * Resets the different information of the group to prepare a new frame
  84650. * @hidden
  84651. */
  84652. reset(): void;
  84653. /**
  84654. * Dispose and release the group and its associated resources.
  84655. * @hidden
  84656. */
  84657. dispose(): void;
  84658. /**
  84659. * Clear the info related to rendering groups preventing retention points during dispose.
  84660. */
  84661. freeRenderingGroups(): void;
  84662. private _prepareRenderingGroup;
  84663. /**
  84664. * Add a sprite manager to the rendering manager in order to render it this frame.
  84665. * @param spriteManager Define the sprite manager to render
  84666. */
  84667. dispatchSprites(spriteManager: ISpriteManager): void;
  84668. /**
  84669. * Add a particle system to the rendering manager in order to render it this frame.
  84670. * @param particleSystem Define the particle system to render
  84671. */
  84672. dispatchParticles(particleSystem: IParticleSystem): void;
  84673. /**
  84674. * Add a submesh to the manager in order to render it this frame
  84675. * @param subMesh The submesh to dispatch
  84676. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  84677. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  84678. */
  84679. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  84680. /**
  84681. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  84682. * This allowed control for front to back rendering or reversly depending of the special needs.
  84683. *
  84684. * @param renderingGroupId The rendering group id corresponding to its index
  84685. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  84686. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  84687. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  84688. */
  84689. 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;
  84690. /**
  84691. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  84692. *
  84693. * @param renderingGroupId The rendering group id corresponding to its index
  84694. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  84695. * @param depth Automatically clears depth between groups if true and autoClear is true.
  84696. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  84697. */
  84698. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  84699. /**
  84700. * Gets the current auto clear configuration for one rendering group of the rendering
  84701. * manager.
  84702. * @param index the rendering group index to get the information for
  84703. * @returns The auto clear setup for the requested rendering group
  84704. */
  84705. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  84706. }
  84707. }
  84708. declare module BABYLON {
  84709. /**
  84710. * This Helps creating a texture that will be created from a camera in your scene.
  84711. * It is basically a dynamic texture that could be used to create special effects for instance.
  84712. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  84713. */
  84714. export class RenderTargetTexture extends Texture {
  84715. isCube: boolean;
  84716. /**
  84717. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  84718. */
  84719. static readonly REFRESHRATE_RENDER_ONCE: number;
  84720. /**
  84721. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  84722. */
  84723. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  84724. /**
  84725. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  84726. * the central point of your effect and can save a lot of performances.
  84727. */
  84728. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  84729. /**
  84730. * Use this predicate to dynamically define the list of mesh you want to render.
  84731. * If set, the renderList property will be overwritten.
  84732. */
  84733. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  84734. private _renderList;
  84735. /**
  84736. * Use this list to define the list of mesh you want to render.
  84737. */
  84738. renderList: Nullable<Array<AbstractMesh>>;
  84739. private _hookArray;
  84740. /**
  84741. * Define if particles should be rendered in your texture.
  84742. */
  84743. renderParticles: boolean;
  84744. /**
  84745. * Define if sprites should be rendered in your texture.
  84746. */
  84747. renderSprites: boolean;
  84748. /**
  84749. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  84750. */
  84751. coordinatesMode: number;
  84752. /**
  84753. * Define the camera used to render the texture.
  84754. */
  84755. activeCamera: Nullable<Camera>;
  84756. /**
  84757. * Override the render function of the texture with your own one.
  84758. */
  84759. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  84760. /**
  84761. * Define if camera post processes should be use while rendering the texture.
  84762. */
  84763. useCameraPostProcesses: boolean;
  84764. /**
  84765. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  84766. */
  84767. ignoreCameraViewport: boolean;
  84768. private _postProcessManager;
  84769. private _postProcesses;
  84770. private _resizeObserver;
  84771. /**
  84772. * An event triggered when the texture is unbind.
  84773. */
  84774. onBeforeBindObservable: Observable<RenderTargetTexture>;
  84775. /**
  84776. * An event triggered when the texture is unbind.
  84777. */
  84778. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  84779. private _onAfterUnbindObserver;
  84780. /**
  84781. * Set a after unbind callback in the texture.
  84782. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  84783. */
  84784. onAfterUnbind: () => void;
  84785. /**
  84786. * An event triggered before rendering the texture
  84787. */
  84788. onBeforeRenderObservable: Observable<number>;
  84789. private _onBeforeRenderObserver;
  84790. /**
  84791. * Set a before render callback in the texture.
  84792. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  84793. */
  84794. onBeforeRender: (faceIndex: number) => void;
  84795. /**
  84796. * An event triggered after rendering the texture
  84797. */
  84798. onAfterRenderObservable: Observable<number>;
  84799. private _onAfterRenderObserver;
  84800. /**
  84801. * Set a after render callback in the texture.
  84802. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  84803. */
  84804. onAfterRender: (faceIndex: number) => void;
  84805. /**
  84806. * An event triggered after the texture clear
  84807. */
  84808. onClearObservable: Observable<Engine>;
  84809. private _onClearObserver;
  84810. /**
  84811. * Set a clear callback in the texture.
  84812. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  84813. */
  84814. onClear: (Engine: Engine) => void;
  84815. /**
  84816. * Define the clear color of the Render Target if it should be different from the scene.
  84817. */
  84818. clearColor: Color4;
  84819. protected _size: number | {
  84820. width: number;
  84821. height: number;
  84822. };
  84823. protected _initialSizeParameter: number | {
  84824. width: number;
  84825. height: number;
  84826. } | {
  84827. ratio: number;
  84828. };
  84829. protected _sizeRatio: Nullable<number>;
  84830. /** @hidden */
  84831. _generateMipMaps: boolean;
  84832. protected _renderingManager: RenderingManager;
  84833. /** @hidden */
  84834. _waitingRenderList: string[];
  84835. protected _doNotChangeAspectRatio: boolean;
  84836. protected _currentRefreshId: number;
  84837. protected _refreshRate: number;
  84838. protected _textureMatrix: Matrix;
  84839. protected _samples: number;
  84840. protected _renderTargetOptions: RenderTargetCreationOptions;
  84841. /**
  84842. * Gets render target creation options that were used.
  84843. */
  84844. readonly renderTargetOptions: RenderTargetCreationOptions;
  84845. protected _engine: Engine;
  84846. protected _onRatioRescale(): void;
  84847. /**
  84848. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  84849. * It must define where the camera used to render the texture is set
  84850. */
  84851. boundingBoxPosition: Vector3;
  84852. private _boundingBoxSize;
  84853. /**
  84854. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  84855. * When defined, the cubemap will switch to local mode
  84856. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  84857. * @example https://www.babylonjs-playground.com/#RNASML
  84858. */
  84859. boundingBoxSize: Vector3;
  84860. /**
  84861. * In case the RTT has been created with a depth texture, get the associated
  84862. * depth texture.
  84863. * Otherwise, return null.
  84864. */
  84865. depthStencilTexture: Nullable<InternalTexture>;
  84866. /**
  84867. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  84868. * or used a shadow, depth texture...
  84869. * @param name The friendly name of the texture
  84870. * @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)
  84871. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  84872. * @param generateMipMaps True if mip maps need to be generated after render.
  84873. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  84874. * @param type The type of the buffer in the RTT (int, half float, float...)
  84875. * @param isCube True if a cube texture needs to be created
  84876. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  84877. * @param generateDepthBuffer True to generate a depth buffer
  84878. * @param generateStencilBuffer True to generate a stencil buffer
  84879. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  84880. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  84881. * @param delayAllocation if the texture allocation should be delayed (default: false)
  84882. */
  84883. constructor(name: string, size: number | {
  84884. width: number;
  84885. height: number;
  84886. } | {
  84887. ratio: number;
  84888. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  84889. /**
  84890. * Creates a depth stencil texture.
  84891. * This is only available in WebGL 2 or with the depth texture extension available.
  84892. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  84893. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  84894. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  84895. */
  84896. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  84897. private _processSizeParameter;
  84898. /**
  84899. * Define the number of samples to use in case of MSAA.
  84900. * It defaults to one meaning no MSAA has been enabled.
  84901. */
  84902. samples: number;
  84903. /**
  84904. * Resets the refresh counter of the texture and start bak from scratch.
  84905. * Could be useful to regenerate the texture if it is setup to render only once.
  84906. */
  84907. resetRefreshCounter(): void;
  84908. /**
  84909. * Define the refresh rate of the texture or the rendering frequency.
  84910. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  84911. */
  84912. refreshRate: number;
  84913. /**
  84914. * Adds a post process to the render target rendering passes.
  84915. * @param postProcess define the post process to add
  84916. */
  84917. addPostProcess(postProcess: PostProcess): void;
  84918. /**
  84919. * Clear all the post processes attached to the render target
  84920. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  84921. */
  84922. clearPostProcesses(dispose?: boolean): void;
  84923. /**
  84924. * Remove one of the post process from the list of attached post processes to the texture
  84925. * @param postProcess define the post process to remove from the list
  84926. */
  84927. removePostProcess(postProcess: PostProcess): void;
  84928. /** @hidden */
  84929. _shouldRender(): boolean;
  84930. /**
  84931. * Gets the actual render size of the texture.
  84932. * @returns the width of the render size
  84933. */
  84934. getRenderSize(): number;
  84935. /**
  84936. * Gets the actual render width of the texture.
  84937. * @returns the width of the render size
  84938. */
  84939. getRenderWidth(): number;
  84940. /**
  84941. * Gets the actual render height of the texture.
  84942. * @returns the height of the render size
  84943. */
  84944. getRenderHeight(): number;
  84945. /**
  84946. * Get if the texture can be rescaled or not.
  84947. */
  84948. readonly canRescale: boolean;
  84949. /**
  84950. * Resize the texture using a ratio.
  84951. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  84952. */
  84953. scale(ratio: number): void;
  84954. /**
  84955. * Get the texture reflection matrix used to rotate/transform the reflection.
  84956. * @returns the reflection matrix
  84957. */
  84958. getReflectionTextureMatrix(): Matrix;
  84959. /**
  84960. * Resize the texture to a new desired size.
  84961. * Be carrefull as it will recreate all the data in the new texture.
  84962. * @param size Define the new size. It can be:
  84963. * - a number for squared texture,
  84964. * - an object containing { width: number, height: number }
  84965. * - or an object containing a ratio { ratio: number }
  84966. */
  84967. resize(size: number | {
  84968. width: number;
  84969. height: number;
  84970. } | {
  84971. ratio: number;
  84972. }): void;
  84973. /**
  84974. * Renders all the objects from the render list into the texture.
  84975. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  84976. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  84977. */
  84978. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  84979. private _bestReflectionRenderTargetDimension;
  84980. /**
  84981. * @hidden
  84982. * @param faceIndex face index to bind to if this is a cubetexture
  84983. */
  84984. _bindFrameBuffer(faceIndex?: number): void;
  84985. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  84986. private renderToTarget;
  84987. /**
  84988. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  84989. * This allowed control for front to back rendering or reversly depending of the special needs.
  84990. *
  84991. * @param renderingGroupId The rendering group id corresponding to its index
  84992. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  84993. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  84994. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  84995. */
  84996. 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;
  84997. /**
  84998. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  84999. *
  85000. * @param renderingGroupId The rendering group id corresponding to its index
  85001. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  85002. */
  85003. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  85004. /**
  85005. * Clones the texture.
  85006. * @returns the cloned texture
  85007. */
  85008. clone(): RenderTargetTexture;
  85009. /**
  85010. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  85011. * @returns The JSON representation of the texture
  85012. */
  85013. serialize(): any;
  85014. /**
  85015. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  85016. */
  85017. disposeFramebufferObjects(): void;
  85018. /**
  85019. * Dispose the texture and release its associated resources.
  85020. */
  85021. dispose(): void;
  85022. /** @hidden */
  85023. _rebuild(): void;
  85024. /**
  85025. * Clear the info related to rendering groups preventing retention point in material dispose.
  85026. */
  85027. freeRenderingGroups(): void;
  85028. /**
  85029. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  85030. * @returns the view count
  85031. */
  85032. getViewCount(): number;
  85033. }
  85034. }
  85035. declare module BABYLON {
  85036. /**
  85037. * Base class for the main features of a material in Babylon.js
  85038. */
  85039. export class Material implements IAnimatable {
  85040. /**
  85041. * Returns the triangle fill mode
  85042. */
  85043. static readonly TriangleFillMode: number;
  85044. /**
  85045. * Returns the wireframe mode
  85046. */
  85047. static readonly WireFrameFillMode: number;
  85048. /**
  85049. * Returns the point fill mode
  85050. */
  85051. static readonly PointFillMode: number;
  85052. /**
  85053. * Returns the point list draw mode
  85054. */
  85055. static readonly PointListDrawMode: number;
  85056. /**
  85057. * Returns the line list draw mode
  85058. */
  85059. static readonly LineListDrawMode: number;
  85060. /**
  85061. * Returns the line loop draw mode
  85062. */
  85063. static readonly LineLoopDrawMode: number;
  85064. /**
  85065. * Returns the line strip draw mode
  85066. */
  85067. static readonly LineStripDrawMode: number;
  85068. /**
  85069. * Returns the triangle strip draw mode
  85070. */
  85071. static readonly TriangleStripDrawMode: number;
  85072. /**
  85073. * Returns the triangle fan draw mode
  85074. */
  85075. static readonly TriangleFanDrawMode: number;
  85076. /**
  85077. * Stores the clock-wise side orientation
  85078. */
  85079. static readonly ClockWiseSideOrientation: number;
  85080. /**
  85081. * Stores the counter clock-wise side orientation
  85082. */
  85083. static readonly CounterClockWiseSideOrientation: number;
  85084. /**
  85085. * The dirty texture flag value
  85086. */
  85087. static readonly TextureDirtyFlag: number;
  85088. /**
  85089. * The dirty light flag value
  85090. */
  85091. static readonly LightDirtyFlag: number;
  85092. /**
  85093. * The dirty fresnel flag value
  85094. */
  85095. static readonly FresnelDirtyFlag: number;
  85096. /**
  85097. * The dirty attribute flag value
  85098. */
  85099. static readonly AttributesDirtyFlag: number;
  85100. /**
  85101. * The dirty misc flag value
  85102. */
  85103. static readonly MiscDirtyFlag: number;
  85104. /**
  85105. * The all dirty flag value
  85106. */
  85107. static readonly AllDirtyFlag: number;
  85108. /**
  85109. * The ID of the material
  85110. */
  85111. id: string;
  85112. /**
  85113. * Gets or sets the unique id of the material
  85114. */
  85115. uniqueId: number;
  85116. /**
  85117. * The name of the material
  85118. */
  85119. name: string;
  85120. /**
  85121. * Gets or sets user defined metadata
  85122. */
  85123. metadata: any;
  85124. /**
  85125. * For internal use only. Please do not use.
  85126. */
  85127. reservedDataStore: any;
  85128. /**
  85129. * Specifies if the ready state should be checked on each call
  85130. */
  85131. checkReadyOnEveryCall: boolean;
  85132. /**
  85133. * Specifies if the ready state should be checked once
  85134. */
  85135. checkReadyOnlyOnce: boolean;
  85136. /**
  85137. * The state of the material
  85138. */
  85139. state: string;
  85140. /**
  85141. * The alpha value of the material
  85142. */
  85143. protected _alpha: number;
  85144. /**
  85145. * List of inspectable custom properties (used by the Inspector)
  85146. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  85147. */
  85148. inspectableCustomProperties: IInspectable[];
  85149. /**
  85150. * Sets the alpha value of the material
  85151. */
  85152. /**
  85153. * Gets the alpha value of the material
  85154. */
  85155. alpha: number;
  85156. /**
  85157. * Specifies if back face culling is enabled
  85158. */
  85159. protected _backFaceCulling: boolean;
  85160. /**
  85161. * Sets the back-face culling state
  85162. */
  85163. /**
  85164. * Gets the back-face culling state
  85165. */
  85166. backFaceCulling: boolean;
  85167. /**
  85168. * Stores the value for side orientation
  85169. */
  85170. sideOrientation: number;
  85171. /**
  85172. * Callback triggered when the material is compiled
  85173. */
  85174. onCompiled: Nullable<(effect: Effect) => void>;
  85175. /**
  85176. * Callback triggered when an error occurs
  85177. */
  85178. onError: Nullable<(effect: Effect, errors: string) => void>;
  85179. /**
  85180. * Callback triggered to get the render target textures
  85181. */
  85182. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  85183. /**
  85184. * Gets a boolean indicating that current material needs to register RTT
  85185. */
  85186. readonly hasRenderTargetTextures: boolean;
  85187. /**
  85188. * Specifies if the material should be serialized
  85189. */
  85190. doNotSerialize: boolean;
  85191. /**
  85192. * @hidden
  85193. */
  85194. _storeEffectOnSubMeshes: boolean;
  85195. /**
  85196. * Stores the animations for the material
  85197. */
  85198. animations: Nullable<Array<Animation>>;
  85199. /**
  85200. * An event triggered when the material is disposed
  85201. */
  85202. onDisposeObservable: Observable<Material>;
  85203. /**
  85204. * An observer which watches for dispose events
  85205. */
  85206. private _onDisposeObserver;
  85207. private _onUnBindObservable;
  85208. /**
  85209. * Called during a dispose event
  85210. */
  85211. onDispose: () => void;
  85212. private _onBindObservable;
  85213. /**
  85214. * An event triggered when the material is bound
  85215. */
  85216. readonly onBindObservable: Observable<AbstractMesh>;
  85217. /**
  85218. * An observer which watches for bind events
  85219. */
  85220. private _onBindObserver;
  85221. /**
  85222. * Called during a bind event
  85223. */
  85224. onBind: (Mesh: AbstractMesh) => void;
  85225. /**
  85226. * An event triggered when the material is unbound
  85227. */
  85228. readonly onUnBindObservable: Observable<Material>;
  85229. /**
  85230. * Stores the value of the alpha mode
  85231. */
  85232. private _alphaMode;
  85233. /**
  85234. * Sets the value of the alpha mode.
  85235. *
  85236. * | Value | Type | Description |
  85237. * | --- | --- | --- |
  85238. * | 0 | ALPHA_DISABLE | |
  85239. * | 1 | ALPHA_ADD | |
  85240. * | 2 | ALPHA_COMBINE | |
  85241. * | 3 | ALPHA_SUBTRACT | |
  85242. * | 4 | ALPHA_MULTIPLY | |
  85243. * | 5 | ALPHA_MAXIMIZED | |
  85244. * | 6 | ALPHA_ONEONE | |
  85245. * | 7 | ALPHA_PREMULTIPLIED | |
  85246. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  85247. * | 9 | ALPHA_INTERPOLATE | |
  85248. * | 10 | ALPHA_SCREENMODE | |
  85249. *
  85250. */
  85251. /**
  85252. * Gets the value of the alpha mode
  85253. */
  85254. alphaMode: number;
  85255. /**
  85256. * Stores the state of the need depth pre-pass value
  85257. */
  85258. private _needDepthPrePass;
  85259. /**
  85260. * Sets the need depth pre-pass value
  85261. */
  85262. /**
  85263. * Gets the depth pre-pass value
  85264. */
  85265. needDepthPrePass: boolean;
  85266. /**
  85267. * Specifies if depth writing should be disabled
  85268. */
  85269. disableDepthWrite: boolean;
  85270. /**
  85271. * Specifies if depth writing should be forced
  85272. */
  85273. forceDepthWrite: boolean;
  85274. /**
  85275. * Specifies if there should be a separate pass for culling
  85276. */
  85277. separateCullingPass: boolean;
  85278. /**
  85279. * Stores the state specifing if fog should be enabled
  85280. */
  85281. private _fogEnabled;
  85282. /**
  85283. * Sets the state for enabling fog
  85284. */
  85285. /**
  85286. * Gets the value of the fog enabled state
  85287. */
  85288. fogEnabled: boolean;
  85289. /**
  85290. * Stores the size of points
  85291. */
  85292. pointSize: number;
  85293. /**
  85294. * Stores the z offset value
  85295. */
  85296. zOffset: number;
  85297. /**
  85298. * Gets a value specifying if wireframe mode is enabled
  85299. */
  85300. /**
  85301. * Sets the state of wireframe mode
  85302. */
  85303. wireframe: boolean;
  85304. /**
  85305. * Gets the value specifying if point clouds are enabled
  85306. */
  85307. /**
  85308. * Sets the state of point cloud mode
  85309. */
  85310. pointsCloud: boolean;
  85311. /**
  85312. * Gets the material fill mode
  85313. */
  85314. /**
  85315. * Sets the material fill mode
  85316. */
  85317. fillMode: number;
  85318. /**
  85319. * @hidden
  85320. * Stores the effects for the material
  85321. */
  85322. _effect: Nullable<Effect>;
  85323. /**
  85324. * @hidden
  85325. * Specifies if the material was previously ready
  85326. */
  85327. _wasPreviouslyReady: boolean;
  85328. /**
  85329. * Specifies if uniform buffers should be used
  85330. */
  85331. private _useUBO;
  85332. /**
  85333. * Stores a reference to the scene
  85334. */
  85335. private _scene;
  85336. /**
  85337. * Stores the fill mode state
  85338. */
  85339. private _fillMode;
  85340. /**
  85341. * Specifies if the depth write state should be cached
  85342. */
  85343. private _cachedDepthWriteState;
  85344. /**
  85345. * Stores the uniform buffer
  85346. */
  85347. protected _uniformBuffer: UniformBuffer;
  85348. /** @hidden */
  85349. _indexInSceneMaterialArray: number;
  85350. /** @hidden */
  85351. meshMap: Nullable<{
  85352. [id: string]: AbstractMesh | undefined;
  85353. }>;
  85354. /**
  85355. * Creates a material instance
  85356. * @param name defines the name of the material
  85357. * @param scene defines the scene to reference
  85358. * @param doNotAdd specifies if the material should be added to the scene
  85359. */
  85360. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  85361. /**
  85362. * Returns a string representation of the current material
  85363. * @param fullDetails defines a boolean indicating which levels of logging is desired
  85364. * @returns a string with material information
  85365. */
  85366. toString(fullDetails?: boolean): string;
  85367. /**
  85368. * Gets the class name of the material
  85369. * @returns a string with the class name of the material
  85370. */
  85371. getClassName(): string;
  85372. /**
  85373. * Specifies if updates for the material been locked
  85374. */
  85375. readonly isFrozen: boolean;
  85376. /**
  85377. * Locks updates for the material
  85378. */
  85379. freeze(): void;
  85380. /**
  85381. * Unlocks updates for the material
  85382. */
  85383. unfreeze(): void;
  85384. /**
  85385. * Specifies if the material is ready to be used
  85386. * @param mesh defines the mesh to check
  85387. * @param useInstances specifies if instances should be used
  85388. * @returns a boolean indicating if the material is ready to be used
  85389. */
  85390. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  85391. /**
  85392. * Specifies that the submesh is ready to be used
  85393. * @param mesh defines the mesh to check
  85394. * @param subMesh defines which submesh to check
  85395. * @param useInstances specifies that instances should be used
  85396. * @returns a boolean indicating that the submesh is ready or not
  85397. */
  85398. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  85399. /**
  85400. * Returns the material effect
  85401. * @returns the effect associated with the material
  85402. */
  85403. getEffect(): Nullable<Effect>;
  85404. /**
  85405. * Returns the current scene
  85406. * @returns a Scene
  85407. */
  85408. getScene(): Scene;
  85409. /**
  85410. * Specifies if the material will require alpha blending
  85411. * @returns a boolean specifying if alpha blending is needed
  85412. */
  85413. needAlphaBlending(): boolean;
  85414. /**
  85415. * Specifies if the mesh will require alpha blending
  85416. * @param mesh defines the mesh to check
  85417. * @returns a boolean specifying if alpha blending is needed for the mesh
  85418. */
  85419. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  85420. /**
  85421. * Specifies if this material should be rendered in alpha test mode
  85422. * @returns a boolean specifying if an alpha test is needed.
  85423. */
  85424. needAlphaTesting(): boolean;
  85425. /**
  85426. * Gets the texture used for the alpha test
  85427. * @returns the texture to use for alpha testing
  85428. */
  85429. getAlphaTestTexture(): Nullable<BaseTexture>;
  85430. /**
  85431. * Marks the material to indicate that it needs to be re-calculated
  85432. */
  85433. markDirty(): void;
  85434. /** @hidden */
  85435. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  85436. /**
  85437. * Binds the material to the mesh
  85438. * @param world defines the world transformation matrix
  85439. * @param mesh defines the mesh to bind the material to
  85440. */
  85441. bind(world: Matrix, mesh?: Mesh): void;
  85442. /**
  85443. * Binds the submesh to the material
  85444. * @param world defines the world transformation matrix
  85445. * @param mesh defines the mesh containing the submesh
  85446. * @param subMesh defines the submesh to bind the material to
  85447. */
  85448. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  85449. /**
  85450. * Binds the world matrix to the material
  85451. * @param world defines the world transformation matrix
  85452. */
  85453. bindOnlyWorldMatrix(world: Matrix): void;
  85454. /**
  85455. * Binds the scene's uniform buffer to the effect.
  85456. * @param effect defines the effect to bind to the scene uniform buffer
  85457. * @param sceneUbo defines the uniform buffer storing scene data
  85458. */
  85459. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  85460. /**
  85461. * Binds the view matrix to the effect
  85462. * @param effect defines the effect to bind the view matrix to
  85463. */
  85464. bindView(effect: Effect): void;
  85465. /**
  85466. * Binds the view projection matrix to the effect
  85467. * @param effect defines the effect to bind the view projection matrix to
  85468. */
  85469. bindViewProjection(effect: Effect): void;
  85470. /**
  85471. * Specifies if material alpha testing should be turned on for the mesh
  85472. * @param mesh defines the mesh to check
  85473. */
  85474. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  85475. /**
  85476. * Processes to execute after binding the material to a mesh
  85477. * @param mesh defines the rendered mesh
  85478. */
  85479. protected _afterBind(mesh?: Mesh): void;
  85480. /**
  85481. * Unbinds the material from the mesh
  85482. */
  85483. unbind(): void;
  85484. /**
  85485. * Gets the active textures from the material
  85486. * @returns an array of textures
  85487. */
  85488. getActiveTextures(): BaseTexture[];
  85489. /**
  85490. * Specifies if the material uses a texture
  85491. * @param texture defines the texture to check against the material
  85492. * @returns a boolean specifying if the material uses the texture
  85493. */
  85494. hasTexture(texture: BaseTexture): boolean;
  85495. /**
  85496. * Makes a duplicate of the material, and gives it a new name
  85497. * @param name defines the new name for the duplicated material
  85498. * @returns the cloned material
  85499. */
  85500. clone(name: string): Nullable<Material>;
  85501. /**
  85502. * Gets the meshes bound to the material
  85503. * @returns an array of meshes bound to the material
  85504. */
  85505. getBindedMeshes(): AbstractMesh[];
  85506. /**
  85507. * Force shader compilation
  85508. * @param mesh defines the mesh associated with this material
  85509. * @param onCompiled defines a function to execute once the material is compiled
  85510. * @param options defines the options to configure the compilation
  85511. */
  85512. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  85513. clipPlane: boolean;
  85514. }>): void;
  85515. /**
  85516. * Force shader compilation
  85517. * @param mesh defines the mesh that will use this material
  85518. * @param options defines additional options for compiling the shaders
  85519. * @returns a promise that resolves when the compilation completes
  85520. */
  85521. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  85522. clipPlane: boolean;
  85523. }>): Promise<void>;
  85524. private static readonly _AllDirtyCallBack;
  85525. private static readonly _ImageProcessingDirtyCallBack;
  85526. private static readonly _TextureDirtyCallBack;
  85527. private static readonly _FresnelDirtyCallBack;
  85528. private static readonly _MiscDirtyCallBack;
  85529. private static readonly _LightsDirtyCallBack;
  85530. private static readonly _AttributeDirtyCallBack;
  85531. private static _FresnelAndMiscDirtyCallBack;
  85532. private static _TextureAndMiscDirtyCallBack;
  85533. private static readonly _DirtyCallbackArray;
  85534. private static readonly _RunDirtyCallBacks;
  85535. /**
  85536. * Marks a define in the material to indicate that it needs to be re-computed
  85537. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  85538. */
  85539. markAsDirty(flag: number): void;
  85540. /**
  85541. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  85542. * @param func defines a function which checks material defines against the submeshes
  85543. */
  85544. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  85545. /**
  85546. * Indicates that we need to re-calculated for all submeshes
  85547. */
  85548. protected _markAllSubMeshesAsAllDirty(): void;
  85549. /**
  85550. * Indicates that image processing needs to be re-calculated for all submeshes
  85551. */
  85552. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  85553. /**
  85554. * Indicates that textures need to be re-calculated for all submeshes
  85555. */
  85556. protected _markAllSubMeshesAsTexturesDirty(): void;
  85557. /**
  85558. * Indicates that fresnel needs to be re-calculated for all submeshes
  85559. */
  85560. protected _markAllSubMeshesAsFresnelDirty(): void;
  85561. /**
  85562. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  85563. */
  85564. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  85565. /**
  85566. * Indicates that lights need to be re-calculated for all submeshes
  85567. */
  85568. protected _markAllSubMeshesAsLightsDirty(): void;
  85569. /**
  85570. * Indicates that attributes need to be re-calculated for all submeshes
  85571. */
  85572. protected _markAllSubMeshesAsAttributesDirty(): void;
  85573. /**
  85574. * Indicates that misc needs to be re-calculated for all submeshes
  85575. */
  85576. protected _markAllSubMeshesAsMiscDirty(): void;
  85577. /**
  85578. * Indicates that textures and misc need to be re-calculated for all submeshes
  85579. */
  85580. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  85581. /**
  85582. * Disposes the material
  85583. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  85584. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  85585. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  85586. */
  85587. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  85588. /** @hidden */
  85589. private releaseVertexArrayObject;
  85590. /**
  85591. * Serializes this material
  85592. * @returns the serialized material object
  85593. */
  85594. serialize(): any;
  85595. /**
  85596. * Creates a material from parsed material data
  85597. * @param parsedMaterial defines parsed material data
  85598. * @param scene defines the hosting scene
  85599. * @param rootUrl defines the root URL to use to load textures
  85600. * @returns a new material
  85601. */
  85602. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  85603. }
  85604. }
  85605. declare module BABYLON {
  85606. /**
  85607. * Base class for submeshes
  85608. */
  85609. export class BaseSubMesh {
  85610. /** @hidden */
  85611. _materialDefines: Nullable<MaterialDefines>;
  85612. /** @hidden */
  85613. _materialEffect: Nullable<Effect>;
  85614. /**
  85615. * Gets associated effect
  85616. */
  85617. readonly effect: Nullable<Effect>;
  85618. /**
  85619. * Sets associated effect (effect used to render this submesh)
  85620. * @param effect defines the effect to associate with
  85621. * @param defines defines the set of defines used to compile this effect
  85622. */
  85623. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  85624. }
  85625. /**
  85626. * Defines a subdivision inside a mesh
  85627. */
  85628. export class SubMesh extends BaseSubMesh implements ICullable {
  85629. /** the material index to use */
  85630. materialIndex: number;
  85631. /** vertex index start */
  85632. verticesStart: number;
  85633. /** vertices count */
  85634. verticesCount: number;
  85635. /** index start */
  85636. indexStart: number;
  85637. /** indices count */
  85638. indexCount: number;
  85639. /** @hidden */
  85640. _linesIndexCount: number;
  85641. private _mesh;
  85642. private _renderingMesh;
  85643. private _boundingInfo;
  85644. private _linesIndexBuffer;
  85645. /** @hidden */
  85646. _lastColliderWorldVertices: Nullable<Vector3[]>;
  85647. /** @hidden */
  85648. _trianglePlanes: Plane[];
  85649. /** @hidden */
  85650. _lastColliderTransformMatrix: Nullable<Matrix>;
  85651. /** @hidden */
  85652. _renderId: number;
  85653. /** @hidden */
  85654. _alphaIndex: number;
  85655. /** @hidden */
  85656. _distanceToCamera: number;
  85657. /** @hidden */
  85658. _id: number;
  85659. private _currentMaterial;
  85660. /**
  85661. * Add a new submesh to a mesh
  85662. * @param materialIndex defines the material index to use
  85663. * @param verticesStart defines vertex index start
  85664. * @param verticesCount defines vertices count
  85665. * @param indexStart defines index start
  85666. * @param indexCount defines indices count
  85667. * @param mesh defines the parent mesh
  85668. * @param renderingMesh defines an optional rendering mesh
  85669. * @param createBoundingBox defines if bounding box should be created for this submesh
  85670. * @returns the new submesh
  85671. */
  85672. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  85673. /**
  85674. * Creates a new submesh
  85675. * @param materialIndex defines the material index to use
  85676. * @param verticesStart defines vertex index start
  85677. * @param verticesCount defines vertices count
  85678. * @param indexStart defines index start
  85679. * @param indexCount defines indices count
  85680. * @param mesh defines the parent mesh
  85681. * @param renderingMesh defines an optional rendering mesh
  85682. * @param createBoundingBox defines if bounding box should be created for this submesh
  85683. */
  85684. constructor(
  85685. /** the material index to use */
  85686. materialIndex: number,
  85687. /** vertex index start */
  85688. verticesStart: number,
  85689. /** vertices count */
  85690. verticesCount: number,
  85691. /** index start */
  85692. indexStart: number,
  85693. /** indices count */
  85694. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  85695. /**
  85696. * Returns true if this submesh covers the entire parent mesh
  85697. * @ignorenaming
  85698. */
  85699. readonly IsGlobal: boolean;
  85700. /**
  85701. * Returns the submesh BoudingInfo object
  85702. * @returns current bounding info (or mesh's one if the submesh is global)
  85703. */
  85704. getBoundingInfo(): BoundingInfo;
  85705. /**
  85706. * Sets the submesh BoundingInfo
  85707. * @param boundingInfo defines the new bounding info to use
  85708. * @returns the SubMesh
  85709. */
  85710. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  85711. /**
  85712. * Returns the mesh of the current submesh
  85713. * @return the parent mesh
  85714. */
  85715. getMesh(): AbstractMesh;
  85716. /**
  85717. * Returns the rendering mesh of the submesh
  85718. * @returns the rendering mesh (could be different from parent mesh)
  85719. */
  85720. getRenderingMesh(): Mesh;
  85721. /**
  85722. * Returns the submesh material
  85723. * @returns null or the current material
  85724. */
  85725. getMaterial(): Nullable<Material>;
  85726. /**
  85727. * Sets a new updated BoundingInfo object to the submesh
  85728. * @param data defines an optional position array to use to determine the bounding info
  85729. * @returns the SubMesh
  85730. */
  85731. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  85732. /** @hidden */
  85733. _checkCollision(collider: Collider): boolean;
  85734. /**
  85735. * Updates the submesh BoundingInfo
  85736. * @param world defines the world matrix to use to update the bounding info
  85737. * @returns the submesh
  85738. */
  85739. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  85740. /**
  85741. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  85742. * @param frustumPlanes defines the frustum planes
  85743. * @returns true if the submesh is intersecting with the frustum
  85744. */
  85745. isInFrustum(frustumPlanes: Plane[]): boolean;
  85746. /**
  85747. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  85748. * @param frustumPlanes defines the frustum planes
  85749. * @returns true if the submesh is inside the frustum
  85750. */
  85751. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  85752. /**
  85753. * Renders the submesh
  85754. * @param enableAlphaMode defines if alpha needs to be used
  85755. * @returns the submesh
  85756. */
  85757. render(enableAlphaMode: boolean): SubMesh;
  85758. /**
  85759. * @hidden
  85760. */
  85761. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  85762. /**
  85763. * Checks if the submesh intersects with a ray
  85764. * @param ray defines the ray to test
  85765. * @returns true is the passed ray intersects the submesh bounding box
  85766. */
  85767. canIntersects(ray: Ray): boolean;
  85768. /**
  85769. * Intersects current submesh with a ray
  85770. * @param ray defines the ray to test
  85771. * @param positions defines mesh's positions array
  85772. * @param indices defines mesh's indices array
  85773. * @param fastCheck defines if only bounding info should be used
  85774. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  85775. * @returns intersection info or null if no intersection
  85776. */
  85777. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  85778. /** @hidden */
  85779. private _intersectLines;
  85780. /** @hidden */
  85781. private _intersectUnIndexedLines;
  85782. /** @hidden */
  85783. private _intersectTriangles;
  85784. /** @hidden */
  85785. private _intersectUnIndexedTriangles;
  85786. /** @hidden */
  85787. _rebuild(): void;
  85788. /**
  85789. * Creates a new submesh from the passed mesh
  85790. * @param newMesh defines the new hosting mesh
  85791. * @param newRenderingMesh defines an optional rendering mesh
  85792. * @returns the new submesh
  85793. */
  85794. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  85795. /**
  85796. * Release associated resources
  85797. */
  85798. dispose(): void;
  85799. /**
  85800. * Gets the class name
  85801. * @returns the string "SubMesh".
  85802. */
  85803. getClassName(): string;
  85804. /**
  85805. * Creates a new submesh from indices data
  85806. * @param materialIndex the index of the main mesh material
  85807. * @param startIndex the index where to start the copy in the mesh indices array
  85808. * @param indexCount the number of indices to copy then from the startIndex
  85809. * @param mesh the main mesh to create the submesh from
  85810. * @param renderingMesh the optional rendering mesh
  85811. * @returns a new submesh
  85812. */
  85813. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  85814. }
  85815. }
  85816. declare module BABYLON {
  85817. /**
  85818. * Class used to store geometry data (vertex buffers + index buffer)
  85819. */
  85820. export class Geometry implements IGetSetVerticesData {
  85821. /**
  85822. * Gets or sets the ID of the geometry
  85823. */
  85824. id: string;
  85825. /**
  85826. * Gets or sets the unique ID of the geometry
  85827. */
  85828. uniqueId: number;
  85829. /**
  85830. * Gets the delay loading state of the geometry (none by default which means not delayed)
  85831. */
  85832. delayLoadState: number;
  85833. /**
  85834. * Gets the file containing the data to load when running in delay load state
  85835. */
  85836. delayLoadingFile: Nullable<string>;
  85837. /**
  85838. * Callback called when the geometry is updated
  85839. */
  85840. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  85841. private _scene;
  85842. private _engine;
  85843. private _meshes;
  85844. private _totalVertices;
  85845. /** @hidden */
  85846. _indices: IndicesArray;
  85847. /** @hidden */
  85848. _vertexBuffers: {
  85849. [key: string]: VertexBuffer;
  85850. };
  85851. private _isDisposed;
  85852. private _extend;
  85853. private _boundingBias;
  85854. /** @hidden */
  85855. _delayInfo: Array<string>;
  85856. private _indexBuffer;
  85857. private _indexBufferIsUpdatable;
  85858. /** @hidden */
  85859. _boundingInfo: Nullable<BoundingInfo>;
  85860. /** @hidden */
  85861. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  85862. /** @hidden */
  85863. _softwareSkinningFrameId: number;
  85864. private _vertexArrayObjects;
  85865. private _updatable;
  85866. /** @hidden */
  85867. _positions: Nullable<Vector3[]>;
  85868. /**
  85869. * 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
  85870. */
  85871. /**
  85872. * 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
  85873. */
  85874. boundingBias: Vector2;
  85875. /**
  85876. * Static function used to attach a new empty geometry to a mesh
  85877. * @param mesh defines the mesh to attach the geometry to
  85878. * @returns the new Geometry
  85879. */
  85880. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  85881. /**
  85882. * Creates a new geometry
  85883. * @param id defines the unique ID
  85884. * @param scene defines the hosting scene
  85885. * @param vertexData defines the VertexData used to get geometry data
  85886. * @param updatable defines if geometry must be updatable (false by default)
  85887. * @param mesh defines the mesh that will be associated with the geometry
  85888. */
  85889. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  85890. /**
  85891. * Gets the current extend of the geometry
  85892. */
  85893. readonly extend: {
  85894. minimum: Vector3;
  85895. maximum: Vector3;
  85896. };
  85897. /**
  85898. * Gets the hosting scene
  85899. * @returns the hosting Scene
  85900. */
  85901. getScene(): Scene;
  85902. /**
  85903. * Gets the hosting engine
  85904. * @returns the hosting Engine
  85905. */
  85906. getEngine(): Engine;
  85907. /**
  85908. * Defines if the geometry is ready to use
  85909. * @returns true if the geometry is ready to be used
  85910. */
  85911. isReady(): boolean;
  85912. /**
  85913. * Gets a value indicating that the geometry should not be serialized
  85914. */
  85915. readonly doNotSerialize: boolean;
  85916. /** @hidden */
  85917. _rebuild(): void;
  85918. /**
  85919. * Affects all geometry data in one call
  85920. * @param vertexData defines the geometry data
  85921. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  85922. */
  85923. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  85924. /**
  85925. * Set specific vertex data
  85926. * @param kind defines the data kind (Position, normal, etc...)
  85927. * @param data defines the vertex data to use
  85928. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  85929. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  85930. */
  85931. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  85932. /**
  85933. * Removes a specific vertex data
  85934. * @param kind defines the data kind (Position, normal, etc...)
  85935. */
  85936. removeVerticesData(kind: string): void;
  85937. /**
  85938. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  85939. * @param buffer defines the vertex buffer to use
  85940. * @param totalVertices defines the total number of vertices for position kind (could be null)
  85941. */
  85942. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  85943. /**
  85944. * Update a specific vertex buffer
  85945. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  85946. * It will do nothing if the buffer is not updatable
  85947. * @param kind defines the data kind (Position, normal, etc...)
  85948. * @param data defines the data to use
  85949. * @param offset defines the offset in the target buffer where to store the data
  85950. * @param useBytes set to true if the offset is in bytes
  85951. */
  85952. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  85953. /**
  85954. * Update a specific vertex buffer
  85955. * This function will create a new buffer if the current one is not updatable
  85956. * @param kind defines the data kind (Position, normal, etc...)
  85957. * @param data defines the data to use
  85958. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  85959. */
  85960. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  85961. private _updateBoundingInfo;
  85962. /** @hidden */
  85963. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  85964. /**
  85965. * Gets total number of vertices
  85966. * @returns the total number of vertices
  85967. */
  85968. getTotalVertices(): number;
  85969. /**
  85970. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  85971. * @param kind defines the data kind (Position, normal, etc...)
  85972. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  85973. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85974. * @returns a float array containing vertex data
  85975. */
  85976. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  85977. /**
  85978. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  85979. * @param kind defines the data kind (Position, normal, etc...)
  85980. * @returns true if the vertex buffer with the specified kind is updatable
  85981. */
  85982. isVertexBufferUpdatable(kind: string): boolean;
  85983. /**
  85984. * Gets a specific vertex buffer
  85985. * @param kind defines the data kind (Position, normal, etc...)
  85986. * @returns a VertexBuffer
  85987. */
  85988. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  85989. /**
  85990. * Returns all vertex buffers
  85991. * @return an object holding all vertex buffers indexed by kind
  85992. */
  85993. getVertexBuffers(): Nullable<{
  85994. [key: string]: VertexBuffer;
  85995. }>;
  85996. /**
  85997. * Gets a boolean indicating if specific vertex buffer is present
  85998. * @param kind defines the data kind (Position, normal, etc...)
  85999. * @returns true if data is present
  86000. */
  86001. isVerticesDataPresent(kind: string): boolean;
  86002. /**
  86003. * Gets a list of all attached data kinds (Position, normal, etc...)
  86004. * @returns a list of string containing all kinds
  86005. */
  86006. getVerticesDataKinds(): string[];
  86007. /**
  86008. * Update index buffer
  86009. * @param indices defines the indices to store in the index buffer
  86010. * @param offset defines the offset in the target buffer where to store the data
  86011. * @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)
  86012. */
  86013. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  86014. /**
  86015. * Creates a new index buffer
  86016. * @param indices defines the indices to store in the index buffer
  86017. * @param totalVertices defines the total number of vertices (could be null)
  86018. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  86019. */
  86020. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  86021. /**
  86022. * Return the total number of indices
  86023. * @returns the total number of indices
  86024. */
  86025. getTotalIndices(): number;
  86026. /**
  86027. * Gets the index buffer array
  86028. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  86029. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  86030. * @returns the index buffer array
  86031. */
  86032. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  86033. /**
  86034. * Gets the index buffer
  86035. * @return the index buffer
  86036. */
  86037. getIndexBuffer(): Nullable<DataBuffer>;
  86038. /** @hidden */
  86039. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  86040. /**
  86041. * Release the associated resources for a specific mesh
  86042. * @param mesh defines the source mesh
  86043. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  86044. */
  86045. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  86046. /**
  86047. * Apply current geometry to a given mesh
  86048. * @param mesh defines the mesh to apply geometry to
  86049. */
  86050. applyToMesh(mesh: Mesh): void;
  86051. private _updateExtend;
  86052. private _applyToMesh;
  86053. private notifyUpdate;
  86054. /**
  86055. * Load the geometry if it was flagged as delay loaded
  86056. * @param scene defines the hosting scene
  86057. * @param onLoaded defines a callback called when the geometry is loaded
  86058. */
  86059. load(scene: Scene, onLoaded?: () => void): void;
  86060. private _queueLoad;
  86061. /**
  86062. * Invert the geometry to move from a right handed system to a left handed one.
  86063. */
  86064. toLeftHanded(): void;
  86065. /** @hidden */
  86066. _resetPointsArrayCache(): void;
  86067. /** @hidden */
  86068. _generatePointsArray(): boolean;
  86069. /**
  86070. * Gets a value indicating if the geometry is disposed
  86071. * @returns true if the geometry was disposed
  86072. */
  86073. isDisposed(): boolean;
  86074. private _disposeVertexArrayObjects;
  86075. /**
  86076. * Free all associated resources
  86077. */
  86078. dispose(): void;
  86079. /**
  86080. * Clone the current geometry into a new geometry
  86081. * @param id defines the unique ID of the new geometry
  86082. * @returns a new geometry object
  86083. */
  86084. copy(id: string): Geometry;
  86085. /**
  86086. * Serialize the current geometry info (and not the vertices data) into a JSON object
  86087. * @return a JSON representation of the current geometry data (without the vertices data)
  86088. */
  86089. serialize(): any;
  86090. private toNumberArray;
  86091. /**
  86092. * Serialize all vertices data into a JSON oject
  86093. * @returns a JSON representation of the current geometry data
  86094. */
  86095. serializeVerticeData(): any;
  86096. /**
  86097. * Extracts a clone of a mesh geometry
  86098. * @param mesh defines the source mesh
  86099. * @param id defines the unique ID of the new geometry object
  86100. * @returns the new geometry object
  86101. */
  86102. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  86103. /**
  86104. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  86105. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  86106. * Be aware Math.random() could cause collisions, but:
  86107. * "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"
  86108. * @returns a string containing a new GUID
  86109. */
  86110. static RandomId(): string;
  86111. /** @hidden */
  86112. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  86113. private static _CleanMatricesWeights;
  86114. /**
  86115. * Create a new geometry from persisted data (Using .babylon file format)
  86116. * @param parsedVertexData defines the persisted data
  86117. * @param scene defines the hosting scene
  86118. * @param rootUrl defines the root url to use to load assets (like delayed data)
  86119. * @returns the new geometry object
  86120. */
  86121. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  86122. }
  86123. }
  86124. declare module BABYLON {
  86125. /**
  86126. * Define an interface for all classes that will get and set the data on vertices
  86127. */
  86128. export interface IGetSetVerticesData {
  86129. /**
  86130. * Gets a boolean indicating if specific vertex data is present
  86131. * @param kind defines the vertex data kind to use
  86132. * @returns true is data kind is present
  86133. */
  86134. isVerticesDataPresent(kind: string): boolean;
  86135. /**
  86136. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  86137. * @param kind defines the data kind (Position, normal, etc...)
  86138. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  86139. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  86140. * @returns a float array containing vertex data
  86141. */
  86142. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  86143. /**
  86144. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  86145. * @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.
  86146. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  86147. * @returns the indices array or an empty array if the mesh has no geometry
  86148. */
  86149. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  86150. /**
  86151. * Set specific vertex data
  86152. * @param kind defines the data kind (Position, normal, etc...)
  86153. * @param data defines the vertex data to use
  86154. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  86155. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  86156. */
  86157. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  86158. /**
  86159. * Update a specific associated vertex buffer
  86160. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  86161. * - VertexBuffer.PositionKind
  86162. * - VertexBuffer.UVKind
  86163. * - VertexBuffer.UV2Kind
  86164. * - VertexBuffer.UV3Kind
  86165. * - VertexBuffer.UV4Kind
  86166. * - VertexBuffer.UV5Kind
  86167. * - VertexBuffer.UV6Kind
  86168. * - VertexBuffer.ColorKind
  86169. * - VertexBuffer.MatricesIndicesKind
  86170. * - VertexBuffer.MatricesIndicesExtraKind
  86171. * - VertexBuffer.MatricesWeightsKind
  86172. * - VertexBuffer.MatricesWeightsExtraKind
  86173. * @param data defines the data source
  86174. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  86175. * @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)
  86176. */
  86177. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  86178. /**
  86179. * Creates a new index buffer
  86180. * @param indices defines the indices to store in the index buffer
  86181. * @param totalVertices defines the total number of vertices (could be null)
  86182. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  86183. */
  86184. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  86185. }
  86186. /**
  86187. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  86188. */
  86189. export class VertexData {
  86190. /**
  86191. * Mesh side orientation : usually the external or front surface
  86192. */
  86193. static readonly FRONTSIDE: number;
  86194. /**
  86195. * Mesh side orientation : usually the internal or back surface
  86196. */
  86197. static readonly BACKSIDE: number;
  86198. /**
  86199. * Mesh side orientation : both internal and external or front and back surfaces
  86200. */
  86201. static readonly DOUBLESIDE: number;
  86202. /**
  86203. * Mesh side orientation : by default, `FRONTSIDE`
  86204. */
  86205. static readonly DEFAULTSIDE: number;
  86206. /**
  86207. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  86208. */
  86209. positions: Nullable<FloatArray>;
  86210. /**
  86211. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  86212. */
  86213. normals: Nullable<FloatArray>;
  86214. /**
  86215. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  86216. */
  86217. tangents: Nullable<FloatArray>;
  86218. /**
  86219. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  86220. */
  86221. uvs: Nullable<FloatArray>;
  86222. /**
  86223. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  86224. */
  86225. uvs2: Nullable<FloatArray>;
  86226. /**
  86227. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  86228. */
  86229. uvs3: Nullable<FloatArray>;
  86230. /**
  86231. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  86232. */
  86233. uvs4: Nullable<FloatArray>;
  86234. /**
  86235. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  86236. */
  86237. uvs5: Nullable<FloatArray>;
  86238. /**
  86239. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  86240. */
  86241. uvs6: Nullable<FloatArray>;
  86242. /**
  86243. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  86244. */
  86245. colors: Nullable<FloatArray>;
  86246. /**
  86247. * 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).
  86248. */
  86249. matricesIndices: Nullable<FloatArray>;
  86250. /**
  86251. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  86252. */
  86253. matricesWeights: Nullable<FloatArray>;
  86254. /**
  86255. * An array extending the number of possible indices
  86256. */
  86257. matricesIndicesExtra: Nullable<FloatArray>;
  86258. /**
  86259. * An array extending the number of possible weights when the number of indices is extended
  86260. */
  86261. matricesWeightsExtra: Nullable<FloatArray>;
  86262. /**
  86263. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  86264. */
  86265. indices: Nullable<IndicesArray>;
  86266. /**
  86267. * Uses the passed data array to set the set the values for the specified kind of data
  86268. * @param data a linear array of floating numbers
  86269. * @param kind the type of data that is being set, eg positions, colors etc
  86270. */
  86271. set(data: FloatArray, kind: string): void;
  86272. /**
  86273. * Associates the vertexData to the passed Mesh.
  86274. * Sets it as updatable or not (default `false`)
  86275. * @param mesh the mesh the vertexData is applied to
  86276. * @param updatable when used and having the value true allows new data to update the vertexData
  86277. * @returns the VertexData
  86278. */
  86279. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  86280. /**
  86281. * Associates the vertexData to the passed Geometry.
  86282. * Sets it as updatable or not (default `false`)
  86283. * @param geometry the geometry the vertexData is applied to
  86284. * @param updatable when used and having the value true allows new data to update the vertexData
  86285. * @returns VertexData
  86286. */
  86287. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  86288. /**
  86289. * Updates the associated mesh
  86290. * @param mesh the mesh to be updated
  86291. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  86292. * @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
  86293. * @returns VertexData
  86294. */
  86295. updateMesh(mesh: Mesh): VertexData;
  86296. /**
  86297. * Updates the associated geometry
  86298. * @param geometry the geometry to be updated
  86299. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  86300. * @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
  86301. * @returns VertexData.
  86302. */
  86303. updateGeometry(geometry: Geometry): VertexData;
  86304. private _applyTo;
  86305. private _update;
  86306. /**
  86307. * Transforms each position and each normal of the vertexData according to the passed Matrix
  86308. * @param matrix the transforming matrix
  86309. * @returns the VertexData
  86310. */
  86311. transform(matrix: Matrix): VertexData;
  86312. /**
  86313. * Merges the passed VertexData into the current one
  86314. * @param other the VertexData to be merged into the current one
  86315. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  86316. * @returns the modified VertexData
  86317. */
  86318. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  86319. private _mergeElement;
  86320. private _validate;
  86321. /**
  86322. * Serializes the VertexData
  86323. * @returns a serialized object
  86324. */
  86325. serialize(): any;
  86326. /**
  86327. * Extracts the vertexData from a mesh
  86328. * @param mesh the mesh from which to extract the VertexData
  86329. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  86330. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  86331. * @returns the object VertexData associated to the passed mesh
  86332. */
  86333. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  86334. /**
  86335. * Extracts the vertexData from the geometry
  86336. * @param geometry the geometry from which to extract the VertexData
  86337. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  86338. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  86339. * @returns the object VertexData associated to the passed mesh
  86340. */
  86341. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  86342. private static _ExtractFrom;
  86343. /**
  86344. * Creates the VertexData for a Ribbon
  86345. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  86346. * * pathArray array of paths, each of which an array of successive Vector3
  86347. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  86348. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  86349. * * 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
  86350. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86351. * * 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)
  86352. * * 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)
  86353. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  86354. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  86355. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  86356. * @returns the VertexData of the ribbon
  86357. */
  86358. static CreateRibbon(options: {
  86359. pathArray: Vector3[][];
  86360. closeArray?: boolean;
  86361. closePath?: boolean;
  86362. offset?: number;
  86363. sideOrientation?: number;
  86364. frontUVs?: Vector4;
  86365. backUVs?: Vector4;
  86366. invertUV?: boolean;
  86367. uvs?: Vector2[];
  86368. colors?: Color4[];
  86369. }): VertexData;
  86370. /**
  86371. * Creates the VertexData for a box
  86372. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86373. * * size sets the width, height and depth of the box to the value of size, optional default 1
  86374. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  86375. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  86376. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  86377. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  86378. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  86379. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86380. * * 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)
  86381. * * 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)
  86382. * @returns the VertexData of the box
  86383. */
  86384. static CreateBox(options: {
  86385. size?: number;
  86386. width?: number;
  86387. height?: number;
  86388. depth?: number;
  86389. faceUV?: Vector4[];
  86390. faceColors?: Color4[];
  86391. sideOrientation?: number;
  86392. frontUVs?: Vector4;
  86393. backUVs?: Vector4;
  86394. }): VertexData;
  86395. /**
  86396. * Creates the VertexData for a tiled box
  86397. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86398. * * faceTiles sets the pattern, tile size and number of tiles for a face
  86399. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  86400. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  86401. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86402. * @returns the VertexData of the box
  86403. */
  86404. static CreateTiledBox(options: {
  86405. pattern?: number;
  86406. width?: number;
  86407. height?: number;
  86408. depth?: number;
  86409. tileSize?: number;
  86410. tileWidth?: number;
  86411. tileHeight?: number;
  86412. alignHorizontal?: number;
  86413. alignVertical?: number;
  86414. faceUV?: Vector4[];
  86415. faceColors?: Color4[];
  86416. sideOrientation?: number;
  86417. }): VertexData;
  86418. /**
  86419. * Creates the VertexData for a tiled plane
  86420. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86421. * * pattern a limited pattern arrangement depending on the number
  86422. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  86423. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  86424. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  86425. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86426. * * 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)
  86427. * * 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)
  86428. * @returns the VertexData of the tiled plane
  86429. */
  86430. static CreateTiledPlane(options: {
  86431. pattern?: number;
  86432. tileSize?: number;
  86433. tileWidth?: number;
  86434. tileHeight?: number;
  86435. size?: number;
  86436. width?: number;
  86437. height?: number;
  86438. alignHorizontal?: number;
  86439. alignVertical?: number;
  86440. sideOrientation?: number;
  86441. frontUVs?: Vector4;
  86442. backUVs?: Vector4;
  86443. }): VertexData;
  86444. /**
  86445. * Creates the VertexData for an ellipsoid, defaults to a sphere
  86446. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86447. * * segments sets the number of horizontal strips optional, default 32
  86448. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  86449. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  86450. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  86451. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  86452. * * 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
  86453. * * 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
  86454. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86455. * * 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)
  86456. * * 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)
  86457. * @returns the VertexData of the ellipsoid
  86458. */
  86459. static CreateSphere(options: {
  86460. segments?: number;
  86461. diameter?: number;
  86462. diameterX?: number;
  86463. diameterY?: number;
  86464. diameterZ?: number;
  86465. arc?: number;
  86466. slice?: number;
  86467. sideOrientation?: number;
  86468. frontUVs?: Vector4;
  86469. backUVs?: Vector4;
  86470. }): VertexData;
  86471. /**
  86472. * Creates the VertexData for a cylinder, cone or prism
  86473. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86474. * * height sets the height (y direction) of the cylinder, optional, default 2
  86475. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  86476. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  86477. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  86478. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  86479. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  86480. * * 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
  86481. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  86482. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  86483. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  86484. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  86485. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86486. * * 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)
  86487. * * 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)
  86488. * @returns the VertexData of the cylinder, cone or prism
  86489. */
  86490. static CreateCylinder(options: {
  86491. height?: number;
  86492. diameterTop?: number;
  86493. diameterBottom?: number;
  86494. diameter?: number;
  86495. tessellation?: number;
  86496. subdivisions?: number;
  86497. arc?: number;
  86498. faceColors?: Color4[];
  86499. faceUV?: Vector4[];
  86500. hasRings?: boolean;
  86501. enclose?: boolean;
  86502. sideOrientation?: number;
  86503. frontUVs?: Vector4;
  86504. backUVs?: Vector4;
  86505. }): VertexData;
  86506. /**
  86507. * Creates the VertexData for a torus
  86508. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86509. * * diameter the diameter of the torus, optional default 1
  86510. * * thickness the diameter of the tube forming the torus, optional default 0.5
  86511. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  86512. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86513. * * 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)
  86514. * * 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)
  86515. * @returns the VertexData of the torus
  86516. */
  86517. static CreateTorus(options: {
  86518. diameter?: number;
  86519. thickness?: number;
  86520. tessellation?: number;
  86521. sideOrientation?: number;
  86522. frontUVs?: Vector4;
  86523. backUVs?: Vector4;
  86524. }): VertexData;
  86525. /**
  86526. * Creates the VertexData of the LineSystem
  86527. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  86528. * - lines an array of lines, each line being an array of successive Vector3
  86529. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  86530. * @returns the VertexData of the LineSystem
  86531. */
  86532. static CreateLineSystem(options: {
  86533. lines: Vector3[][];
  86534. colors?: Nullable<Color4[][]>;
  86535. }): VertexData;
  86536. /**
  86537. * Create the VertexData for a DashedLines
  86538. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  86539. * - points an array successive Vector3
  86540. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  86541. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  86542. * - dashNb the intended total number of dashes, optional, default 200
  86543. * @returns the VertexData for the DashedLines
  86544. */
  86545. static CreateDashedLines(options: {
  86546. points: Vector3[];
  86547. dashSize?: number;
  86548. gapSize?: number;
  86549. dashNb?: number;
  86550. }): VertexData;
  86551. /**
  86552. * Creates the VertexData for a Ground
  86553. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  86554. * - width the width (x direction) of the ground, optional, default 1
  86555. * - height the height (z direction) of the ground, optional, default 1
  86556. * - subdivisions the number of subdivisions per side, optional, default 1
  86557. * @returns the VertexData of the Ground
  86558. */
  86559. static CreateGround(options: {
  86560. width?: number;
  86561. height?: number;
  86562. subdivisions?: number;
  86563. subdivisionsX?: number;
  86564. subdivisionsY?: number;
  86565. }): VertexData;
  86566. /**
  86567. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  86568. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  86569. * * xmin the ground minimum X coordinate, optional, default -1
  86570. * * zmin the ground minimum Z coordinate, optional, default -1
  86571. * * xmax the ground maximum X coordinate, optional, default 1
  86572. * * zmax the ground maximum Z coordinate, optional, default 1
  86573. * * 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}
  86574. * * 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}
  86575. * @returns the VertexData of the TiledGround
  86576. */
  86577. static CreateTiledGround(options: {
  86578. xmin: number;
  86579. zmin: number;
  86580. xmax: number;
  86581. zmax: number;
  86582. subdivisions?: {
  86583. w: number;
  86584. h: number;
  86585. };
  86586. precision?: {
  86587. w: number;
  86588. h: number;
  86589. };
  86590. }): VertexData;
  86591. /**
  86592. * Creates the VertexData of the Ground designed from a heightmap
  86593. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  86594. * * width the width (x direction) of the ground
  86595. * * height the height (z direction) of the ground
  86596. * * subdivisions the number of subdivisions per side
  86597. * * minHeight the minimum altitude on the ground, optional, default 0
  86598. * * maxHeight the maximum altitude on the ground, optional default 1
  86599. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  86600. * * buffer the array holding the image color data
  86601. * * bufferWidth the width of image
  86602. * * bufferHeight the height of image
  86603. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  86604. * @returns the VertexData of the Ground designed from a heightmap
  86605. */
  86606. static CreateGroundFromHeightMap(options: {
  86607. width: number;
  86608. height: number;
  86609. subdivisions: number;
  86610. minHeight: number;
  86611. maxHeight: number;
  86612. colorFilter: Color3;
  86613. buffer: Uint8Array;
  86614. bufferWidth: number;
  86615. bufferHeight: number;
  86616. alphaFilter: number;
  86617. }): VertexData;
  86618. /**
  86619. * Creates the VertexData for a Plane
  86620. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  86621. * * size sets the width and height of the plane to the value of size, optional default 1
  86622. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  86623. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  86624. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86625. * * 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)
  86626. * * 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)
  86627. * @returns the VertexData of the box
  86628. */
  86629. static CreatePlane(options: {
  86630. size?: number;
  86631. width?: number;
  86632. height?: number;
  86633. sideOrientation?: number;
  86634. frontUVs?: Vector4;
  86635. backUVs?: Vector4;
  86636. }): VertexData;
  86637. /**
  86638. * Creates the VertexData of the Disc or regular Polygon
  86639. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  86640. * * radius the radius of the disc, optional default 0.5
  86641. * * tessellation the number of polygon sides, optional, default 64
  86642. * * 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
  86643. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86644. * * 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)
  86645. * * 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)
  86646. * @returns the VertexData of the box
  86647. */
  86648. static CreateDisc(options: {
  86649. radius?: number;
  86650. tessellation?: number;
  86651. arc?: number;
  86652. sideOrientation?: number;
  86653. frontUVs?: Vector4;
  86654. backUVs?: Vector4;
  86655. }): VertexData;
  86656. /**
  86657. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  86658. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  86659. * @param polygon a mesh built from polygonTriangulation.build()
  86660. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86661. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  86662. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  86663. * @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)
  86664. * @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)
  86665. * @returns the VertexData of the Polygon
  86666. */
  86667. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  86668. /**
  86669. * Creates the VertexData of the IcoSphere
  86670. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  86671. * * radius the radius of the IcoSphere, optional default 1
  86672. * * radiusX allows stretching in the x direction, optional, default radius
  86673. * * radiusY allows stretching in the y direction, optional, default radius
  86674. * * radiusZ allows stretching in the z direction, optional, default radius
  86675. * * flat when true creates a flat shaded mesh, optional, default true
  86676. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  86677. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86678. * * 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)
  86679. * * 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)
  86680. * @returns the VertexData of the IcoSphere
  86681. */
  86682. static CreateIcoSphere(options: {
  86683. radius?: number;
  86684. radiusX?: number;
  86685. radiusY?: number;
  86686. radiusZ?: number;
  86687. flat?: boolean;
  86688. subdivisions?: number;
  86689. sideOrientation?: number;
  86690. frontUVs?: Vector4;
  86691. backUVs?: Vector4;
  86692. }): VertexData;
  86693. /**
  86694. * Creates the VertexData for a Polyhedron
  86695. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  86696. * * type provided types are:
  86697. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  86698. * * 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)
  86699. * * size the size of the IcoSphere, optional default 1
  86700. * * sizeX allows stretching in the x direction, optional, default size
  86701. * * sizeY allows stretching in the y direction, optional, default size
  86702. * * sizeZ allows stretching in the z direction, optional, default size
  86703. * * 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
  86704. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  86705. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  86706. * * flat when true creates a flat shaded mesh, optional, default true
  86707. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  86708. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86709. * * 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)
  86710. * * 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)
  86711. * @returns the VertexData of the Polyhedron
  86712. */
  86713. static CreatePolyhedron(options: {
  86714. type?: number;
  86715. size?: number;
  86716. sizeX?: number;
  86717. sizeY?: number;
  86718. sizeZ?: number;
  86719. custom?: any;
  86720. faceUV?: Vector4[];
  86721. faceColors?: Color4[];
  86722. flat?: boolean;
  86723. sideOrientation?: number;
  86724. frontUVs?: Vector4;
  86725. backUVs?: Vector4;
  86726. }): VertexData;
  86727. /**
  86728. * Creates the VertexData for a TorusKnot
  86729. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  86730. * * radius the radius of the torus knot, optional, default 2
  86731. * * tube the thickness of the tube, optional, default 0.5
  86732. * * radialSegments the number of sides on each tube segments, optional, default 32
  86733. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  86734. * * p the number of windings around the z axis, optional, default 2
  86735. * * q the number of windings around the x axis, optional, default 3
  86736. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86737. * * 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)
  86738. * * 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)
  86739. * @returns the VertexData of the Torus Knot
  86740. */
  86741. static CreateTorusKnot(options: {
  86742. radius?: number;
  86743. tube?: number;
  86744. radialSegments?: number;
  86745. tubularSegments?: number;
  86746. p?: number;
  86747. q?: number;
  86748. sideOrientation?: number;
  86749. frontUVs?: Vector4;
  86750. backUVs?: Vector4;
  86751. }): VertexData;
  86752. /**
  86753. * Compute normals for given positions and indices
  86754. * @param positions an array of vertex positions, [...., x, y, z, ......]
  86755. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  86756. * @param normals an array of vertex normals, [...., x, y, z, ......]
  86757. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  86758. * * facetNormals : optional array of facet normals (vector3)
  86759. * * facetPositions : optional array of facet positions (vector3)
  86760. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  86761. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  86762. * * bInfo : optional bounding info, required for facetPartitioning computation
  86763. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  86764. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  86765. * * useRightHandedSystem: optional boolean to for right handed system computation
  86766. * * depthSort : optional boolean to enable the facet depth sort computation
  86767. * * distanceTo : optional Vector3 to compute the facet depth from this location
  86768. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  86769. */
  86770. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  86771. facetNormals?: any;
  86772. facetPositions?: any;
  86773. facetPartitioning?: any;
  86774. ratio?: number;
  86775. bInfo?: any;
  86776. bbSize?: Vector3;
  86777. subDiv?: any;
  86778. useRightHandedSystem?: boolean;
  86779. depthSort?: boolean;
  86780. distanceTo?: Vector3;
  86781. depthSortedFacets?: any;
  86782. }): void;
  86783. /** @hidden */
  86784. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  86785. /**
  86786. * Applies VertexData created from the imported parameters to the geometry
  86787. * @param parsedVertexData the parsed data from an imported file
  86788. * @param geometry the geometry to apply the VertexData to
  86789. */
  86790. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  86791. }
  86792. }
  86793. declare module BABYLON {
  86794. /**
  86795. * Class containing static functions to help procedurally build meshes
  86796. */
  86797. export class DiscBuilder {
  86798. /**
  86799. * Creates a plane polygonal mesh. By default, this is a disc
  86800. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  86801. * * 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
  86802. * * 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
  86803. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  86804. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  86805. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  86806. * @param name defines the name of the mesh
  86807. * @param options defines the options used to create the mesh
  86808. * @param scene defines the hosting scene
  86809. * @returns the plane polygonal mesh
  86810. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  86811. */
  86812. static CreateDisc(name: string, options: {
  86813. radius?: number;
  86814. tessellation?: number;
  86815. arc?: number;
  86816. updatable?: boolean;
  86817. sideOrientation?: number;
  86818. frontUVs?: Vector4;
  86819. backUVs?: Vector4;
  86820. }, scene?: Nullable<Scene>): Mesh;
  86821. }
  86822. }
  86823. declare module BABYLON {
  86824. /**
  86825. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  86826. *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.
  86827. * The SPS is also a particle system. It provides some methods to manage the particles.
  86828. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  86829. *
  86830. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  86831. */
  86832. export class SolidParticleSystem implements IDisposable {
  86833. /**
  86834. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  86835. * Example : var p = SPS.particles[i];
  86836. */
  86837. particles: SolidParticle[];
  86838. /**
  86839. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  86840. */
  86841. nbParticles: number;
  86842. /**
  86843. * If the particles must ever face the camera (default false). Useful for planar particles.
  86844. */
  86845. billboard: boolean;
  86846. /**
  86847. * Recompute normals when adding a shape
  86848. */
  86849. recomputeNormals: boolean;
  86850. /**
  86851. * This a counter ofr your own usage. It's not set by any SPS functions.
  86852. */
  86853. counter: number;
  86854. /**
  86855. * The SPS name. This name is also given to the underlying mesh.
  86856. */
  86857. name: string;
  86858. /**
  86859. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  86860. */
  86861. mesh: Mesh;
  86862. /**
  86863. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  86864. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  86865. */
  86866. vars: any;
  86867. /**
  86868. * This array is populated when the SPS is set as 'pickable'.
  86869. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  86870. * Each element of this array is an object `{idx: int, faceId: int}`.
  86871. * `idx` is the picked particle index in the `SPS.particles` array
  86872. * `faceId` is the picked face index counted within this particle.
  86873. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  86874. */
  86875. pickedParticles: {
  86876. idx: number;
  86877. faceId: number;
  86878. }[];
  86879. /**
  86880. * This array is populated when `enableDepthSort` is set to true.
  86881. * Each element of this array is an instance of the class DepthSortedParticle.
  86882. */
  86883. depthSortedParticles: DepthSortedParticle[];
  86884. /**
  86885. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  86886. * @hidden
  86887. */
  86888. _bSphereOnly: boolean;
  86889. /**
  86890. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  86891. * @hidden
  86892. */
  86893. _bSphereRadiusFactor: number;
  86894. private _scene;
  86895. private _positions;
  86896. private _indices;
  86897. private _normals;
  86898. private _colors;
  86899. private _uvs;
  86900. private _indices32;
  86901. private _positions32;
  86902. private _normals32;
  86903. private _fixedNormal32;
  86904. private _colors32;
  86905. private _uvs32;
  86906. private _index;
  86907. private _updatable;
  86908. private _pickable;
  86909. private _isVisibilityBoxLocked;
  86910. private _alwaysVisible;
  86911. private _depthSort;
  86912. private _shapeCounter;
  86913. private _copy;
  86914. private _color;
  86915. private _computeParticleColor;
  86916. private _computeParticleTexture;
  86917. private _computeParticleRotation;
  86918. private _computeParticleVertex;
  86919. private _computeBoundingBox;
  86920. private _depthSortParticles;
  86921. private _camera;
  86922. private _mustUnrotateFixedNormals;
  86923. private _particlesIntersect;
  86924. private _needs32Bits;
  86925. /**
  86926. * Creates a SPS (Solid Particle System) object.
  86927. * @param name (String) is the SPS name, this will be the underlying mesh name.
  86928. * @param scene (Scene) is the scene in which the SPS is added.
  86929. * @param options defines the options of the sps e.g.
  86930. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  86931. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  86932. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  86933. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  86934. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  86935. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  86936. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  86937. */
  86938. constructor(name: string, scene: Scene, options?: {
  86939. updatable?: boolean;
  86940. isPickable?: boolean;
  86941. enableDepthSort?: boolean;
  86942. particleIntersection?: boolean;
  86943. boundingSphereOnly?: boolean;
  86944. bSphereRadiusFactor?: number;
  86945. });
  86946. /**
  86947. * Builds the SPS underlying mesh. Returns a standard Mesh.
  86948. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  86949. * @returns the created mesh
  86950. */
  86951. buildMesh(): Mesh;
  86952. /**
  86953. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  86954. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  86955. * Thus the particles generated from `digest()` have their property `position` set yet.
  86956. * @param mesh ( Mesh ) is the mesh to be digested
  86957. * @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
  86958. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  86959. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  86960. * @returns the current SPS
  86961. */
  86962. digest(mesh: Mesh, options?: {
  86963. facetNb?: number;
  86964. number?: number;
  86965. delta?: number;
  86966. }): SolidParticleSystem;
  86967. private _unrotateFixedNormals;
  86968. private _resetCopy;
  86969. private _meshBuilder;
  86970. private _posToShape;
  86971. private _uvsToShapeUV;
  86972. private _addParticle;
  86973. /**
  86974. * Adds some particles to the SPS from the model shape. Returns the shape id.
  86975. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  86976. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  86977. * @param nb (positive integer) the number of particles to be created from this model
  86978. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  86979. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  86980. * @returns the number of shapes in the system
  86981. */
  86982. addShape(mesh: Mesh, nb: number, options?: {
  86983. positionFunction?: any;
  86984. vertexFunction?: any;
  86985. }): number;
  86986. private _rebuildParticle;
  86987. /**
  86988. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  86989. * @returns the SPS.
  86990. */
  86991. rebuildMesh(): SolidParticleSystem;
  86992. /**
  86993. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  86994. * This method calls `updateParticle()` for each particle of the SPS.
  86995. * For an animated SPS, it is usually called within the render loop.
  86996. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  86997. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  86998. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  86999. * @returns the SPS.
  87000. */
  87001. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  87002. /**
  87003. * Disposes the SPS.
  87004. */
  87005. dispose(): void;
  87006. /**
  87007. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  87008. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  87009. * @returns the SPS.
  87010. */
  87011. refreshVisibleSize(): SolidParticleSystem;
  87012. /**
  87013. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  87014. * @param size the size (float) of the visibility box
  87015. * note : this doesn't lock the SPS mesh bounding box.
  87016. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  87017. */
  87018. setVisibilityBox(size: number): void;
  87019. /**
  87020. * Gets whether the SPS as always visible or not
  87021. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  87022. */
  87023. /**
  87024. * Sets the SPS as always visible or not
  87025. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  87026. */
  87027. isAlwaysVisible: boolean;
  87028. /**
  87029. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  87030. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  87031. */
  87032. /**
  87033. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  87034. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  87035. */
  87036. isVisibilityBoxLocked: boolean;
  87037. /**
  87038. * Tells to `setParticles()` to compute the particle rotations or not.
  87039. * Default value : true. The SPS is faster when it's set to false.
  87040. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  87041. */
  87042. /**
  87043. * Gets if `setParticles()` computes the particle rotations or not.
  87044. * Default value : true. The SPS is faster when it's set to false.
  87045. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  87046. */
  87047. computeParticleRotation: boolean;
  87048. /**
  87049. * Tells to `setParticles()` to compute the particle colors or not.
  87050. * Default value : true. The SPS is faster when it's set to false.
  87051. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  87052. */
  87053. /**
  87054. * Gets if `setParticles()` computes the particle colors or not.
  87055. * Default value : true. The SPS is faster when it's set to false.
  87056. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  87057. */
  87058. computeParticleColor: boolean;
  87059. /**
  87060. * Gets if `setParticles()` computes the particle textures or not.
  87061. * Default value : true. The SPS is faster when it's set to false.
  87062. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  87063. */
  87064. computeParticleTexture: boolean;
  87065. /**
  87066. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  87067. * Default value : false. The SPS is faster when it's set to false.
  87068. * Note : the particle custom vertex positions aren't stored values.
  87069. */
  87070. /**
  87071. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  87072. * Default value : false. The SPS is faster when it's set to false.
  87073. * Note : the particle custom vertex positions aren't stored values.
  87074. */
  87075. computeParticleVertex: boolean;
  87076. /**
  87077. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  87078. */
  87079. /**
  87080. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  87081. */
  87082. computeBoundingBox: boolean;
  87083. /**
  87084. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  87085. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  87086. * Default : `true`
  87087. */
  87088. /**
  87089. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  87090. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  87091. * Default : `true`
  87092. */
  87093. depthSortParticles: boolean;
  87094. /**
  87095. * This function does nothing. It may be overwritten to set all the particle first values.
  87096. * The SPS doesn't call this function, you may have to call it by your own.
  87097. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  87098. */
  87099. initParticles(): void;
  87100. /**
  87101. * This function does nothing. It may be overwritten to recycle a particle.
  87102. * The SPS doesn't call this function, you may have to call it by your own.
  87103. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  87104. * @param particle The particle to recycle
  87105. * @returns the recycled particle
  87106. */
  87107. recycleParticle(particle: SolidParticle): SolidParticle;
  87108. /**
  87109. * Updates a particle : this function should be overwritten by the user.
  87110. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  87111. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  87112. * @example : just set a particle position or velocity and recycle conditions
  87113. * @param particle The particle to update
  87114. * @returns the updated particle
  87115. */
  87116. updateParticle(particle: SolidParticle): SolidParticle;
  87117. /**
  87118. * Updates a vertex of a particle : it can be overwritten by the user.
  87119. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  87120. * @param particle the current particle
  87121. * @param vertex the current index of the current particle
  87122. * @param pt the index of the current vertex in the particle shape
  87123. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  87124. * @example : just set a vertex particle position
  87125. * @returns the updated vertex
  87126. */
  87127. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  87128. /**
  87129. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  87130. * This does nothing and may be overwritten by the user.
  87131. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  87132. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  87133. * @param update the boolean update value actually passed to setParticles()
  87134. */
  87135. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  87136. /**
  87137. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  87138. * This will be passed three parameters.
  87139. * This does nothing and may be overwritten by the user.
  87140. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  87141. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  87142. * @param update the boolean update value actually passed to setParticles()
  87143. */
  87144. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  87145. }
  87146. }
  87147. declare module BABYLON {
  87148. /**
  87149. * Represents one particle of a solid particle system.
  87150. */
  87151. export class SolidParticle {
  87152. /**
  87153. * particle global index
  87154. */
  87155. idx: number;
  87156. /**
  87157. * The color of the particle
  87158. */
  87159. color: Nullable<Color4>;
  87160. /**
  87161. * The world space position of the particle.
  87162. */
  87163. position: Vector3;
  87164. /**
  87165. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  87166. */
  87167. rotation: Vector3;
  87168. /**
  87169. * The world space rotation quaternion of the particle.
  87170. */
  87171. rotationQuaternion: Nullable<Quaternion>;
  87172. /**
  87173. * The scaling of the particle.
  87174. */
  87175. scaling: Vector3;
  87176. /**
  87177. * The uvs of the particle.
  87178. */
  87179. uvs: Vector4;
  87180. /**
  87181. * The current speed of the particle.
  87182. */
  87183. velocity: Vector3;
  87184. /**
  87185. * The pivot point in the particle local space.
  87186. */
  87187. pivot: Vector3;
  87188. /**
  87189. * Must the particle be translated from its pivot point in its local space ?
  87190. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  87191. * Default : false
  87192. */
  87193. translateFromPivot: boolean;
  87194. /**
  87195. * Is the particle active or not ?
  87196. */
  87197. alive: boolean;
  87198. /**
  87199. * Is the particle visible or not ?
  87200. */
  87201. isVisible: boolean;
  87202. /**
  87203. * Index of this particle in the global "positions" array (Internal use)
  87204. * @hidden
  87205. */
  87206. _pos: number;
  87207. /**
  87208. * @hidden Index of this particle in the global "indices" array (Internal use)
  87209. */
  87210. _ind: number;
  87211. /**
  87212. * @hidden ModelShape of this particle (Internal use)
  87213. */
  87214. _model: ModelShape;
  87215. /**
  87216. * ModelShape id of this particle
  87217. */
  87218. shapeId: number;
  87219. /**
  87220. * Index of the particle in its shape id (Internal use)
  87221. */
  87222. idxInShape: number;
  87223. /**
  87224. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  87225. */
  87226. _modelBoundingInfo: BoundingInfo;
  87227. /**
  87228. * @hidden Particle BoundingInfo object (Internal use)
  87229. */
  87230. _boundingInfo: BoundingInfo;
  87231. /**
  87232. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  87233. */
  87234. _sps: SolidParticleSystem;
  87235. /**
  87236. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  87237. */
  87238. _stillInvisible: boolean;
  87239. /**
  87240. * @hidden Last computed particle rotation matrix
  87241. */
  87242. _rotationMatrix: number[];
  87243. /**
  87244. * Parent particle Id, if any.
  87245. * Default null.
  87246. */
  87247. parentId: Nullable<number>;
  87248. /**
  87249. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  87250. * The possible values are :
  87251. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  87252. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  87253. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  87254. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  87255. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  87256. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  87257. * */
  87258. cullingStrategy: number;
  87259. /**
  87260. * @hidden Internal global position in the SPS.
  87261. */
  87262. _globalPosition: Vector3;
  87263. /**
  87264. * Creates a Solid Particle object.
  87265. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  87266. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  87267. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  87268. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  87269. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  87270. * @param shapeId (integer) is the model shape identifier in the SPS.
  87271. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  87272. * @param sps defines the sps it is associated to
  87273. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  87274. */
  87275. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  87276. /**
  87277. * Legacy support, changed scale to scaling
  87278. */
  87279. /**
  87280. * Legacy support, changed scale to scaling
  87281. */
  87282. scale: Vector3;
  87283. /**
  87284. * Legacy support, changed quaternion to rotationQuaternion
  87285. */
  87286. /**
  87287. * Legacy support, changed quaternion to rotationQuaternion
  87288. */
  87289. quaternion: Nullable<Quaternion>;
  87290. /**
  87291. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  87292. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  87293. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  87294. * @returns true if it intersects
  87295. */
  87296. intersectsMesh(target: Mesh | SolidParticle): boolean;
  87297. /**
  87298. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  87299. * A particle is in the frustum if its bounding box intersects the frustum
  87300. * @param frustumPlanes defines the frustum to test
  87301. * @returns true if the particle is in the frustum planes
  87302. */
  87303. isInFrustum(frustumPlanes: Plane[]): boolean;
  87304. /**
  87305. * get the rotation matrix of the particle
  87306. * @hidden
  87307. */
  87308. getRotationMatrix(m: Matrix): void;
  87309. }
  87310. /**
  87311. * Represents the shape of the model used by one particle of a solid particle system.
  87312. * SPS internal tool, don't use it manually.
  87313. */
  87314. export class ModelShape {
  87315. /**
  87316. * The shape id
  87317. * @hidden
  87318. */
  87319. shapeID: number;
  87320. /**
  87321. * flat array of model positions (internal use)
  87322. * @hidden
  87323. */
  87324. _shape: Vector3[];
  87325. /**
  87326. * flat array of model UVs (internal use)
  87327. * @hidden
  87328. */
  87329. _shapeUV: number[];
  87330. /**
  87331. * length of the shape in the model indices array (internal use)
  87332. * @hidden
  87333. */
  87334. _indicesLength: number;
  87335. /**
  87336. * Custom position function (internal use)
  87337. * @hidden
  87338. */
  87339. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  87340. /**
  87341. * Custom vertex function (internal use)
  87342. * @hidden
  87343. */
  87344. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  87345. /**
  87346. * 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.
  87347. * SPS internal tool, don't use it manually.
  87348. * @hidden
  87349. */
  87350. 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>);
  87351. }
  87352. /**
  87353. * Represents a Depth Sorted Particle in the solid particle system.
  87354. */
  87355. export class DepthSortedParticle {
  87356. /**
  87357. * Index of the particle in the "indices" array
  87358. */
  87359. ind: number;
  87360. /**
  87361. * Length of the particle shape in the "indices" array
  87362. */
  87363. indicesLength: number;
  87364. /**
  87365. * Squared distance from the particle to the camera
  87366. */
  87367. sqDistance: number;
  87368. }
  87369. }
  87370. declare module BABYLON {
  87371. /**
  87372. * @hidden
  87373. */
  87374. export class _MeshCollisionData {
  87375. _checkCollisions: boolean;
  87376. _collisionMask: number;
  87377. _collisionGroup: number;
  87378. _collider: Nullable<Collider>;
  87379. _oldPositionForCollisions: Vector3;
  87380. _diffPositionForCollisions: Vector3;
  87381. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  87382. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  87383. }
  87384. }
  87385. declare module BABYLON {
  87386. /** @hidden */
  87387. class _FacetDataStorage {
  87388. facetPositions: Vector3[];
  87389. facetNormals: Vector3[];
  87390. facetPartitioning: number[][];
  87391. facetNb: number;
  87392. partitioningSubdivisions: number;
  87393. partitioningBBoxRatio: number;
  87394. facetDataEnabled: boolean;
  87395. facetParameters: any;
  87396. bbSize: Vector3;
  87397. subDiv: {
  87398. max: number;
  87399. X: number;
  87400. Y: number;
  87401. Z: number;
  87402. };
  87403. facetDepthSort: boolean;
  87404. facetDepthSortEnabled: boolean;
  87405. depthSortedIndices: IndicesArray;
  87406. depthSortedFacets: {
  87407. ind: number;
  87408. sqDistance: number;
  87409. }[];
  87410. facetDepthSortFunction: (f1: {
  87411. ind: number;
  87412. sqDistance: number;
  87413. }, f2: {
  87414. ind: number;
  87415. sqDistance: number;
  87416. }) => number;
  87417. facetDepthSortFrom: Vector3;
  87418. facetDepthSortOrigin: Vector3;
  87419. invertedMatrix: Matrix;
  87420. }
  87421. /**
  87422. * @hidden
  87423. **/
  87424. class _InternalAbstractMeshDataInfo {
  87425. _hasVertexAlpha: boolean;
  87426. _useVertexColors: boolean;
  87427. _numBoneInfluencers: number;
  87428. _applyFog: boolean;
  87429. _receiveShadows: boolean;
  87430. _facetData: _FacetDataStorage;
  87431. _visibility: number;
  87432. _skeleton: Nullable<Skeleton>;
  87433. _layerMask: number;
  87434. _computeBonesUsingShaders: boolean;
  87435. _isActive: boolean;
  87436. _onlyForInstances: boolean;
  87437. _isActiveIntermediate: boolean;
  87438. _onlyForInstancesIntermediate: boolean;
  87439. }
  87440. /**
  87441. * Class used to store all common mesh properties
  87442. */
  87443. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  87444. /** No occlusion */
  87445. static OCCLUSION_TYPE_NONE: number;
  87446. /** Occlusion set to optimisitic */
  87447. static OCCLUSION_TYPE_OPTIMISTIC: number;
  87448. /** Occlusion set to strict */
  87449. static OCCLUSION_TYPE_STRICT: number;
  87450. /** Use an accurante occlusion algorithm */
  87451. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  87452. /** Use a conservative occlusion algorithm */
  87453. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  87454. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  87455. * Test order :
  87456. * Is the bounding sphere outside the frustum ?
  87457. * If not, are the bounding box vertices outside the frustum ?
  87458. * It not, then the cullable object is in the frustum.
  87459. */
  87460. static readonly CULLINGSTRATEGY_STANDARD: number;
  87461. /** Culling strategy : Bounding Sphere Only.
  87462. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  87463. * It's also less accurate than the standard because some not visible objects can still be selected.
  87464. * Test : is the bounding sphere outside the frustum ?
  87465. * If not, then the cullable object is in the frustum.
  87466. */
  87467. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  87468. /** Culling strategy : Optimistic Inclusion.
  87469. * This in an inclusion test first, then the standard exclusion test.
  87470. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  87471. * 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.
  87472. * Anyway, it's as accurate as the standard strategy.
  87473. * Test :
  87474. * Is the cullable object bounding sphere center in the frustum ?
  87475. * If not, apply the default culling strategy.
  87476. */
  87477. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  87478. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  87479. * This in an inclusion test first, then the bounding sphere only exclusion test.
  87480. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  87481. * 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.
  87482. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  87483. * Test :
  87484. * Is the cullable object bounding sphere center in the frustum ?
  87485. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  87486. */
  87487. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  87488. /**
  87489. * No billboard
  87490. */
  87491. static readonly BILLBOARDMODE_NONE: number;
  87492. /** Billboard on X axis */
  87493. static readonly BILLBOARDMODE_X: number;
  87494. /** Billboard on Y axis */
  87495. static readonly BILLBOARDMODE_Y: number;
  87496. /** Billboard on Z axis */
  87497. static readonly BILLBOARDMODE_Z: number;
  87498. /** Billboard on all axes */
  87499. static readonly BILLBOARDMODE_ALL: number;
  87500. /** @hidden */
  87501. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  87502. /**
  87503. * The culling strategy to use to check whether the mesh must be rendered or not.
  87504. * This value can be changed at any time and will be used on the next render mesh selection.
  87505. * The possible values are :
  87506. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  87507. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  87508. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  87509. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  87510. * Please read each static variable documentation to get details about the culling process.
  87511. * */
  87512. cullingStrategy: number;
  87513. /**
  87514. * Gets the number of facets in the mesh
  87515. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  87516. */
  87517. readonly facetNb: number;
  87518. /**
  87519. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  87520. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  87521. */
  87522. partitioningSubdivisions: number;
  87523. /**
  87524. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  87525. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  87526. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  87527. */
  87528. partitioningBBoxRatio: number;
  87529. /**
  87530. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  87531. * Works only for updatable meshes.
  87532. * Doesn't work with multi-materials
  87533. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  87534. */
  87535. mustDepthSortFacets: boolean;
  87536. /**
  87537. * The location (Vector3) where the facet depth sort must be computed from.
  87538. * By default, the active camera position.
  87539. * Used only when facet depth sort is enabled
  87540. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  87541. */
  87542. facetDepthSortFrom: Vector3;
  87543. /**
  87544. * gets a boolean indicating if facetData is enabled
  87545. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  87546. */
  87547. readonly isFacetDataEnabled: boolean;
  87548. /** @hidden */
  87549. _updateNonUniformScalingState(value: boolean): boolean;
  87550. /**
  87551. * An event triggered when this mesh collides with another one
  87552. */
  87553. onCollideObservable: Observable<AbstractMesh>;
  87554. /** Set a function to call when this mesh collides with another one */
  87555. onCollide: () => void;
  87556. /**
  87557. * An event triggered when the collision's position changes
  87558. */
  87559. onCollisionPositionChangeObservable: Observable<Vector3>;
  87560. /** Set a function to call when the collision's position changes */
  87561. onCollisionPositionChange: () => void;
  87562. /**
  87563. * An event triggered when material is changed
  87564. */
  87565. onMaterialChangedObservable: Observable<AbstractMesh>;
  87566. /**
  87567. * Gets or sets the orientation for POV movement & rotation
  87568. */
  87569. definedFacingForward: boolean;
  87570. /** @hidden */
  87571. _occlusionQuery: Nullable<WebGLQuery>;
  87572. /** @hidden */
  87573. _renderingGroup: Nullable<RenderingGroup>;
  87574. /**
  87575. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  87576. */
  87577. /**
  87578. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  87579. */
  87580. visibility: number;
  87581. /** Gets or sets the alpha index used to sort transparent meshes
  87582. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  87583. */
  87584. alphaIndex: number;
  87585. /**
  87586. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  87587. */
  87588. isVisible: boolean;
  87589. /**
  87590. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  87591. */
  87592. isPickable: boolean;
  87593. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  87594. showSubMeshesBoundingBox: boolean;
  87595. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  87596. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  87597. */
  87598. isBlocker: boolean;
  87599. /**
  87600. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  87601. */
  87602. enablePointerMoveEvents: boolean;
  87603. /**
  87604. * Specifies the rendering group id for this mesh (0 by default)
  87605. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  87606. */
  87607. renderingGroupId: number;
  87608. private _material;
  87609. /** Gets or sets current material */
  87610. material: Nullable<Material>;
  87611. /**
  87612. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  87613. * @see http://doc.babylonjs.com/babylon101/shadows
  87614. */
  87615. receiveShadows: boolean;
  87616. /** Defines color to use when rendering outline */
  87617. outlineColor: Color3;
  87618. /** Define width to use when rendering outline */
  87619. outlineWidth: number;
  87620. /** Defines color to use when rendering overlay */
  87621. overlayColor: Color3;
  87622. /** Defines alpha to use when rendering overlay */
  87623. overlayAlpha: number;
  87624. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  87625. hasVertexAlpha: boolean;
  87626. /** 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) */
  87627. useVertexColors: boolean;
  87628. /**
  87629. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  87630. */
  87631. computeBonesUsingShaders: boolean;
  87632. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  87633. numBoneInfluencers: number;
  87634. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  87635. applyFog: boolean;
  87636. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  87637. useOctreeForRenderingSelection: boolean;
  87638. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  87639. useOctreeForPicking: boolean;
  87640. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  87641. useOctreeForCollisions: boolean;
  87642. /**
  87643. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  87644. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  87645. */
  87646. layerMask: number;
  87647. /**
  87648. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  87649. */
  87650. alwaysSelectAsActiveMesh: boolean;
  87651. /**
  87652. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  87653. */
  87654. doNotSyncBoundingInfo: boolean;
  87655. /**
  87656. * Gets or sets the current action manager
  87657. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87658. */
  87659. actionManager: Nullable<AbstractActionManager>;
  87660. private _meshCollisionData;
  87661. /**
  87662. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  87663. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  87664. */
  87665. ellipsoid: Vector3;
  87666. /**
  87667. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  87668. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  87669. */
  87670. ellipsoidOffset: Vector3;
  87671. /**
  87672. * Gets or sets a collision mask used to mask collisions (default is -1).
  87673. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  87674. */
  87675. collisionMask: number;
  87676. /**
  87677. * Gets or sets the current collision group mask (-1 by default).
  87678. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  87679. */
  87680. collisionGroup: number;
  87681. /**
  87682. * Defines edge width used when edgesRenderer is enabled
  87683. * @see https://www.babylonjs-playground.com/#10OJSG#13
  87684. */
  87685. edgesWidth: number;
  87686. /**
  87687. * Defines edge color used when edgesRenderer is enabled
  87688. * @see https://www.babylonjs-playground.com/#10OJSG#13
  87689. */
  87690. edgesColor: Color4;
  87691. /** @hidden */
  87692. _edgesRenderer: Nullable<IEdgesRenderer>;
  87693. /** @hidden */
  87694. _masterMesh: Nullable<AbstractMesh>;
  87695. /** @hidden */
  87696. _boundingInfo: Nullable<BoundingInfo>;
  87697. /** @hidden */
  87698. _renderId: number;
  87699. /**
  87700. * Gets or sets the list of subMeshes
  87701. * @see http://doc.babylonjs.com/how_to/multi_materials
  87702. */
  87703. subMeshes: SubMesh[];
  87704. /** @hidden */
  87705. _intersectionsInProgress: AbstractMesh[];
  87706. /** @hidden */
  87707. _unIndexed: boolean;
  87708. /** @hidden */
  87709. _lightSources: Light[];
  87710. /** Gets the list of lights affecting that mesh */
  87711. readonly lightSources: Light[];
  87712. /** @hidden */
  87713. readonly _positions: Nullable<Vector3[]>;
  87714. /** @hidden */
  87715. _waitingData: {
  87716. lods: Nullable<any>;
  87717. actions: Nullable<any>;
  87718. freezeWorldMatrix: Nullable<boolean>;
  87719. };
  87720. /** @hidden */
  87721. _bonesTransformMatrices: Nullable<Float32Array>;
  87722. /**
  87723. * Gets or sets a skeleton to apply skining transformations
  87724. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  87725. */
  87726. skeleton: Nullable<Skeleton>;
  87727. /**
  87728. * An event triggered when the mesh is rebuilt.
  87729. */
  87730. onRebuildObservable: Observable<AbstractMesh>;
  87731. /**
  87732. * Creates a new AbstractMesh
  87733. * @param name defines the name of the mesh
  87734. * @param scene defines the hosting scene
  87735. */
  87736. constructor(name: string, scene?: Nullable<Scene>);
  87737. /**
  87738. * Returns the string "AbstractMesh"
  87739. * @returns "AbstractMesh"
  87740. */
  87741. getClassName(): string;
  87742. /**
  87743. * Gets a string representation of the current mesh
  87744. * @param fullDetails defines a boolean indicating if full details must be included
  87745. * @returns a string representation of the current mesh
  87746. */
  87747. toString(fullDetails?: boolean): string;
  87748. /**
  87749. * @hidden
  87750. */
  87751. protected _getEffectiveParent(): Nullable<Node>;
  87752. /** @hidden */
  87753. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  87754. /** @hidden */
  87755. _rebuild(): void;
  87756. /** @hidden */
  87757. _resyncLightSources(): void;
  87758. /** @hidden */
  87759. _resyncLighSource(light: Light): void;
  87760. /** @hidden */
  87761. _unBindEffect(): void;
  87762. /** @hidden */
  87763. _removeLightSource(light: Light): void;
  87764. private _markSubMeshesAsDirty;
  87765. /** @hidden */
  87766. _markSubMeshesAsLightDirty(): void;
  87767. /** @hidden */
  87768. _markSubMeshesAsAttributesDirty(): void;
  87769. /** @hidden */
  87770. _markSubMeshesAsMiscDirty(): void;
  87771. /**
  87772. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  87773. */
  87774. scaling: Vector3;
  87775. /**
  87776. * Returns true if the mesh is blocked. Implemented by child classes
  87777. */
  87778. readonly isBlocked: boolean;
  87779. /**
  87780. * Returns the mesh itself by default. Implemented by child classes
  87781. * @param camera defines the camera to use to pick the right LOD level
  87782. * @returns the currentAbstractMesh
  87783. */
  87784. getLOD(camera: Camera): Nullable<AbstractMesh>;
  87785. /**
  87786. * Returns 0 by default. Implemented by child classes
  87787. * @returns an integer
  87788. */
  87789. getTotalVertices(): number;
  87790. /**
  87791. * Returns a positive integer : the total number of indices in this mesh geometry.
  87792. * @returns the numner of indices or zero if the mesh has no geometry.
  87793. */
  87794. getTotalIndices(): number;
  87795. /**
  87796. * Returns null by default. Implemented by child classes
  87797. * @returns null
  87798. */
  87799. getIndices(): Nullable<IndicesArray>;
  87800. /**
  87801. * Returns the array of the requested vertex data kind. Implemented by child classes
  87802. * @param kind defines the vertex data kind to use
  87803. * @returns null
  87804. */
  87805. getVerticesData(kind: string): Nullable<FloatArray>;
  87806. /**
  87807. * Sets the vertex data of the mesh geometry for the requested `kind`.
  87808. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  87809. * Note that a new underlying VertexBuffer object is created each call.
  87810. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  87811. * @param kind defines vertex data kind:
  87812. * * VertexBuffer.PositionKind
  87813. * * VertexBuffer.UVKind
  87814. * * VertexBuffer.UV2Kind
  87815. * * VertexBuffer.UV3Kind
  87816. * * VertexBuffer.UV4Kind
  87817. * * VertexBuffer.UV5Kind
  87818. * * VertexBuffer.UV6Kind
  87819. * * VertexBuffer.ColorKind
  87820. * * VertexBuffer.MatricesIndicesKind
  87821. * * VertexBuffer.MatricesIndicesExtraKind
  87822. * * VertexBuffer.MatricesWeightsKind
  87823. * * VertexBuffer.MatricesWeightsExtraKind
  87824. * @param data defines the data source
  87825. * @param updatable defines if the data must be flagged as updatable (or static)
  87826. * @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
  87827. * @returns the current mesh
  87828. */
  87829. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  87830. /**
  87831. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  87832. * If the mesh has no geometry, it is simply returned as it is.
  87833. * @param kind defines vertex data kind:
  87834. * * VertexBuffer.PositionKind
  87835. * * VertexBuffer.UVKind
  87836. * * VertexBuffer.UV2Kind
  87837. * * VertexBuffer.UV3Kind
  87838. * * VertexBuffer.UV4Kind
  87839. * * VertexBuffer.UV5Kind
  87840. * * VertexBuffer.UV6Kind
  87841. * * VertexBuffer.ColorKind
  87842. * * VertexBuffer.MatricesIndicesKind
  87843. * * VertexBuffer.MatricesIndicesExtraKind
  87844. * * VertexBuffer.MatricesWeightsKind
  87845. * * VertexBuffer.MatricesWeightsExtraKind
  87846. * @param data defines the data source
  87847. * @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
  87848. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  87849. * @returns the current mesh
  87850. */
  87851. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  87852. /**
  87853. * Sets the mesh indices,
  87854. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  87855. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  87856. * @param totalVertices Defines the total number of vertices
  87857. * @returns the current mesh
  87858. */
  87859. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  87860. /**
  87861. * Gets a boolean indicating if specific vertex data is present
  87862. * @param kind defines the vertex data kind to use
  87863. * @returns true is data kind is present
  87864. */
  87865. isVerticesDataPresent(kind: string): boolean;
  87866. /**
  87867. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  87868. * @returns a BoundingInfo
  87869. */
  87870. getBoundingInfo(): BoundingInfo;
  87871. /**
  87872. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  87873. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  87874. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  87875. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  87876. * @returns the current mesh
  87877. */
  87878. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  87879. /**
  87880. * Overwrite the current bounding info
  87881. * @param boundingInfo defines the new bounding info
  87882. * @returns the current mesh
  87883. */
  87884. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  87885. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  87886. readonly useBones: boolean;
  87887. /** @hidden */
  87888. _preActivate(): void;
  87889. /** @hidden */
  87890. _preActivateForIntermediateRendering(renderId: number): void;
  87891. /** @hidden */
  87892. _activate(renderId: number, intermediateRendering: boolean): boolean;
  87893. /** @hidden */
  87894. _postActivate(): void;
  87895. /** @hidden */
  87896. _freeze(): void;
  87897. /** @hidden */
  87898. _unFreeze(): void;
  87899. /**
  87900. * Gets the current world matrix
  87901. * @returns a Matrix
  87902. */
  87903. getWorldMatrix(): Matrix;
  87904. /** @hidden */
  87905. _getWorldMatrixDeterminant(): number;
  87906. /**
  87907. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  87908. */
  87909. readonly isAnInstance: boolean;
  87910. /**
  87911. * Perform relative position change from the point of view of behind the front of the mesh.
  87912. * This is performed taking into account the meshes current rotation, so you do not have to care.
  87913. * Supports definition of mesh facing forward or backward
  87914. * @param amountRight defines the distance on the right axis
  87915. * @param amountUp defines the distance on the up axis
  87916. * @param amountForward defines the distance on the forward axis
  87917. * @returns the current mesh
  87918. */
  87919. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  87920. /**
  87921. * Calculate relative position change from the point of view of behind the front of the mesh.
  87922. * This is performed taking into account the meshes current rotation, so you do not have to care.
  87923. * Supports definition of mesh facing forward or backward
  87924. * @param amountRight defines the distance on the right axis
  87925. * @param amountUp defines the distance on the up axis
  87926. * @param amountForward defines the distance on the forward axis
  87927. * @returns the new displacement vector
  87928. */
  87929. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  87930. /**
  87931. * Perform relative rotation change from the point of view of behind the front of the mesh.
  87932. * Supports definition of mesh facing forward or backward
  87933. * @param flipBack defines the flip
  87934. * @param twirlClockwise defines the twirl
  87935. * @param tiltRight defines the tilt
  87936. * @returns the current mesh
  87937. */
  87938. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  87939. /**
  87940. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  87941. * Supports definition of mesh facing forward or backward.
  87942. * @param flipBack defines the flip
  87943. * @param twirlClockwise defines the twirl
  87944. * @param tiltRight defines the tilt
  87945. * @returns the new rotation vector
  87946. */
  87947. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  87948. /**
  87949. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  87950. * This means the mesh underlying bounding box and sphere are recomputed.
  87951. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  87952. * @returns the current mesh
  87953. */
  87954. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  87955. /** @hidden */
  87956. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  87957. /** @hidden */
  87958. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  87959. /** @hidden */
  87960. _updateBoundingInfo(): AbstractMesh;
  87961. /** @hidden */
  87962. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  87963. /** @hidden */
  87964. protected _afterComputeWorldMatrix(): void;
  87965. /** @hidden */
  87966. readonly _effectiveMesh: AbstractMesh;
  87967. /**
  87968. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  87969. * A mesh is in the frustum if its bounding box intersects the frustum
  87970. * @param frustumPlanes defines the frustum to test
  87971. * @returns true if the mesh is in the frustum planes
  87972. */
  87973. isInFrustum(frustumPlanes: Plane[]): boolean;
  87974. /**
  87975. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  87976. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  87977. * @param frustumPlanes defines the frustum to test
  87978. * @returns true if the mesh is completely in the frustum planes
  87979. */
  87980. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  87981. /**
  87982. * True if the mesh intersects another mesh or a SolidParticle object
  87983. * @param mesh defines a target mesh or SolidParticle to test
  87984. * @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)
  87985. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  87986. * @returns true if there is an intersection
  87987. */
  87988. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  87989. /**
  87990. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  87991. * @param point defines the point to test
  87992. * @returns true if there is an intersection
  87993. */
  87994. intersectsPoint(point: Vector3): boolean;
  87995. /**
  87996. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  87997. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  87998. */
  87999. checkCollisions: boolean;
  88000. /**
  88001. * Gets Collider object used to compute collisions (not physics)
  88002. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  88003. */
  88004. readonly collider: Nullable<Collider>;
  88005. /**
  88006. * Move the mesh using collision engine
  88007. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  88008. * @param displacement defines the requested displacement vector
  88009. * @returns the current mesh
  88010. */
  88011. moveWithCollisions(displacement: Vector3): AbstractMesh;
  88012. private _onCollisionPositionChange;
  88013. /** @hidden */
  88014. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  88015. /** @hidden */
  88016. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  88017. /** @hidden */
  88018. _checkCollision(collider: Collider): AbstractMesh;
  88019. /** @hidden */
  88020. _generatePointsArray(): boolean;
  88021. /**
  88022. * Checks if the passed Ray intersects with the mesh
  88023. * @param ray defines the ray to use
  88024. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  88025. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  88026. * @returns the picking info
  88027. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  88028. */
  88029. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  88030. /**
  88031. * Clones the current mesh
  88032. * @param name defines the mesh name
  88033. * @param newParent defines the new mesh parent
  88034. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  88035. * @returns the new mesh
  88036. */
  88037. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  88038. /**
  88039. * Disposes all the submeshes of the current meshnp
  88040. * @returns the current mesh
  88041. */
  88042. releaseSubMeshes(): AbstractMesh;
  88043. /**
  88044. * Releases resources associated with this abstract mesh.
  88045. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  88046. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  88047. */
  88048. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  88049. /**
  88050. * Adds the passed mesh as a child to the current mesh
  88051. * @param mesh defines the child mesh
  88052. * @returns the current mesh
  88053. */
  88054. addChild(mesh: AbstractMesh): AbstractMesh;
  88055. /**
  88056. * Removes the passed mesh from the current mesh children list
  88057. * @param mesh defines the child mesh
  88058. * @returns the current mesh
  88059. */
  88060. removeChild(mesh: AbstractMesh): AbstractMesh;
  88061. /** @hidden */
  88062. private _initFacetData;
  88063. /**
  88064. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  88065. * This method can be called within the render loop.
  88066. * 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
  88067. * @returns the current mesh
  88068. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  88069. */
  88070. updateFacetData(): AbstractMesh;
  88071. /**
  88072. * Returns the facetLocalNormals array.
  88073. * The normals are expressed in the mesh local spac
  88074. * @returns an array of Vector3
  88075. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  88076. */
  88077. getFacetLocalNormals(): Vector3[];
  88078. /**
  88079. * Returns the facetLocalPositions array.
  88080. * The facet positions are expressed in the mesh local space
  88081. * @returns an array of Vector3
  88082. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  88083. */
  88084. getFacetLocalPositions(): Vector3[];
  88085. /**
  88086. * Returns the facetLocalPartioning array
  88087. * @returns an array of array of numbers
  88088. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  88089. */
  88090. getFacetLocalPartitioning(): number[][];
  88091. /**
  88092. * Returns the i-th facet position in the world system.
  88093. * This method allocates a new Vector3 per call
  88094. * @param i defines the facet index
  88095. * @returns a new Vector3
  88096. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  88097. */
  88098. getFacetPosition(i: number): Vector3;
  88099. /**
  88100. * Sets the reference Vector3 with the i-th facet position in the world system
  88101. * @param i defines the facet index
  88102. * @param ref defines the target vector
  88103. * @returns the current mesh
  88104. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  88105. */
  88106. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  88107. /**
  88108. * Returns the i-th facet normal in the world system.
  88109. * This method allocates a new Vector3 per call
  88110. * @param i defines the facet index
  88111. * @returns a new Vector3
  88112. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  88113. */
  88114. getFacetNormal(i: number): Vector3;
  88115. /**
  88116. * Sets the reference Vector3 with the i-th facet normal in the world system
  88117. * @param i defines the facet index
  88118. * @param ref defines the target vector
  88119. * @returns the current mesh
  88120. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  88121. */
  88122. getFacetNormalToRef(i: number, ref: Vector3): this;
  88123. /**
  88124. * 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)
  88125. * @param x defines x coordinate
  88126. * @param y defines y coordinate
  88127. * @param z defines z coordinate
  88128. * @returns the array of facet indexes
  88129. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  88130. */
  88131. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  88132. /**
  88133. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  88134. * @param projected sets as the (x,y,z) world projection on the facet
  88135. * @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
  88136. * @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
  88137. * @param x defines x coordinate
  88138. * @param y defines y coordinate
  88139. * @param z defines z coordinate
  88140. * @returns the face index if found (or null instead)
  88141. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  88142. */
  88143. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  88144. /**
  88145. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  88146. * @param projected sets as the (x,y,z) local projection on the facet
  88147. * @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
  88148. * @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
  88149. * @param x defines x coordinate
  88150. * @param y defines y coordinate
  88151. * @param z defines z coordinate
  88152. * @returns the face index if found (or null instead)
  88153. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  88154. */
  88155. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  88156. /**
  88157. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  88158. * @returns the parameters
  88159. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  88160. */
  88161. getFacetDataParameters(): any;
  88162. /**
  88163. * Disables the feature FacetData and frees the related memory
  88164. * @returns the current mesh
  88165. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  88166. */
  88167. disableFacetData(): AbstractMesh;
  88168. /**
  88169. * Updates the AbstractMesh indices array
  88170. * @param indices defines the data source
  88171. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  88172. * @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)
  88173. * @returns the current mesh
  88174. */
  88175. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  88176. /**
  88177. * Creates new normals data for the mesh
  88178. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  88179. * @returns the current mesh
  88180. */
  88181. createNormals(updatable: boolean): AbstractMesh;
  88182. /**
  88183. * Align the mesh with a normal
  88184. * @param normal defines the normal to use
  88185. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  88186. * @returns the current mesh
  88187. */
  88188. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  88189. /** @hidden */
  88190. _checkOcclusionQuery(): boolean;
  88191. /**
  88192. * Disables the mesh edge rendering mode
  88193. * @returns the currentAbstractMesh
  88194. */
  88195. disableEdgesRendering(): AbstractMesh;
  88196. /**
  88197. * Enables the edge rendering mode on the mesh.
  88198. * This mode makes the mesh edges visible
  88199. * @param epsilon defines the maximal distance between two angles to detect a face
  88200. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  88201. * @returns the currentAbstractMesh
  88202. * @see https://www.babylonjs-playground.com/#19O9TU#0
  88203. */
  88204. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  88205. }
  88206. }
  88207. declare module BABYLON {
  88208. /**
  88209. * Interface used to define ActionEvent
  88210. */
  88211. export interface IActionEvent {
  88212. /** The mesh or sprite that triggered the action */
  88213. source: any;
  88214. /** The X mouse cursor position at the time of the event */
  88215. pointerX: number;
  88216. /** The Y mouse cursor position at the time of the event */
  88217. pointerY: number;
  88218. /** The mesh that is currently pointed at (can be null) */
  88219. meshUnderPointer: Nullable<AbstractMesh>;
  88220. /** the original (browser) event that triggered the ActionEvent */
  88221. sourceEvent?: any;
  88222. /** additional data for the event */
  88223. additionalData?: any;
  88224. }
  88225. /**
  88226. * ActionEvent is the event being sent when an action is triggered.
  88227. */
  88228. export class ActionEvent implements IActionEvent {
  88229. /** The mesh or sprite that triggered the action */
  88230. source: any;
  88231. /** The X mouse cursor position at the time of the event */
  88232. pointerX: number;
  88233. /** The Y mouse cursor position at the time of the event */
  88234. pointerY: number;
  88235. /** The mesh that is currently pointed at (can be null) */
  88236. meshUnderPointer: Nullable<AbstractMesh>;
  88237. /** the original (browser) event that triggered the ActionEvent */
  88238. sourceEvent?: any;
  88239. /** additional data for the event */
  88240. additionalData?: any;
  88241. /**
  88242. * Creates a new ActionEvent
  88243. * @param source The mesh or sprite that triggered the action
  88244. * @param pointerX The X mouse cursor position at the time of the event
  88245. * @param pointerY The Y mouse cursor position at the time of the event
  88246. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  88247. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  88248. * @param additionalData additional data for the event
  88249. */
  88250. constructor(
  88251. /** The mesh or sprite that triggered the action */
  88252. source: any,
  88253. /** The X mouse cursor position at the time of the event */
  88254. pointerX: number,
  88255. /** The Y mouse cursor position at the time of the event */
  88256. pointerY: number,
  88257. /** The mesh that is currently pointed at (can be null) */
  88258. meshUnderPointer: Nullable<AbstractMesh>,
  88259. /** the original (browser) event that triggered the ActionEvent */
  88260. sourceEvent?: any,
  88261. /** additional data for the event */
  88262. additionalData?: any);
  88263. /**
  88264. * Helper function to auto-create an ActionEvent from a source mesh.
  88265. * @param source The source mesh that triggered the event
  88266. * @param evt The original (browser) event
  88267. * @param additionalData additional data for the event
  88268. * @returns the new ActionEvent
  88269. */
  88270. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  88271. /**
  88272. * Helper function to auto-create an ActionEvent from a source sprite
  88273. * @param source The source sprite that triggered the event
  88274. * @param scene Scene associated with the sprite
  88275. * @param evt The original (browser) event
  88276. * @param additionalData additional data for the event
  88277. * @returns the new ActionEvent
  88278. */
  88279. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  88280. /**
  88281. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  88282. * @param scene the scene where the event occurred
  88283. * @param evt The original (browser) event
  88284. * @returns the new ActionEvent
  88285. */
  88286. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  88287. /**
  88288. * Helper function to auto-create an ActionEvent from a primitive
  88289. * @param prim defines the target primitive
  88290. * @param pointerPos defines the pointer position
  88291. * @param evt The original (browser) event
  88292. * @param additionalData additional data for the event
  88293. * @returns the new ActionEvent
  88294. */
  88295. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  88296. }
  88297. }
  88298. declare module BABYLON {
  88299. /**
  88300. * Abstract class used to decouple action Manager from scene and meshes.
  88301. * Do not instantiate.
  88302. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  88303. */
  88304. export abstract class AbstractActionManager implements IDisposable {
  88305. /** Gets the list of active triggers */
  88306. static Triggers: {
  88307. [key: string]: number;
  88308. };
  88309. /** Gets the cursor to use when hovering items */
  88310. hoverCursor: string;
  88311. /** Gets the list of actions */
  88312. actions: IAction[];
  88313. /**
  88314. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  88315. */
  88316. isRecursive: boolean;
  88317. /**
  88318. * Releases all associated resources
  88319. */
  88320. abstract dispose(): void;
  88321. /**
  88322. * Does this action manager has pointer triggers
  88323. */
  88324. abstract readonly hasPointerTriggers: boolean;
  88325. /**
  88326. * Does this action manager has pick triggers
  88327. */
  88328. abstract readonly hasPickTriggers: boolean;
  88329. /**
  88330. * Process a specific trigger
  88331. * @param trigger defines the trigger to process
  88332. * @param evt defines the event details to be processed
  88333. */
  88334. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  88335. /**
  88336. * Does this action manager handles actions of any of the given triggers
  88337. * @param triggers defines the triggers to be tested
  88338. * @return a boolean indicating whether one (or more) of the triggers is handled
  88339. */
  88340. abstract hasSpecificTriggers(triggers: number[]): boolean;
  88341. /**
  88342. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  88343. * speed.
  88344. * @param triggerA defines the trigger to be tested
  88345. * @param triggerB defines the trigger to be tested
  88346. * @return a boolean indicating whether one (or more) of the triggers is handled
  88347. */
  88348. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  88349. /**
  88350. * Does this action manager handles actions of a given trigger
  88351. * @param trigger defines the trigger to be tested
  88352. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  88353. * @return whether the trigger is handled
  88354. */
  88355. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  88356. /**
  88357. * Serialize this manager to a JSON object
  88358. * @param name defines the property name to store this manager
  88359. * @returns a JSON representation of this manager
  88360. */
  88361. abstract serialize(name: string): any;
  88362. /**
  88363. * Registers an action to this action manager
  88364. * @param action defines the action to be registered
  88365. * @return the action amended (prepared) after registration
  88366. */
  88367. abstract registerAction(action: IAction): Nullable<IAction>;
  88368. /**
  88369. * Unregisters an action to this action manager
  88370. * @param action defines the action to be unregistered
  88371. * @return a boolean indicating whether the action has been unregistered
  88372. */
  88373. abstract unregisterAction(action: IAction): Boolean;
  88374. /**
  88375. * Does exist one action manager with at least one trigger
  88376. **/
  88377. static readonly HasTriggers: boolean;
  88378. /**
  88379. * Does exist one action manager with at least one pick trigger
  88380. **/
  88381. static readonly HasPickTriggers: boolean;
  88382. /**
  88383. * Does exist one action manager that handles actions of a given trigger
  88384. * @param trigger defines the trigger to be tested
  88385. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  88386. **/
  88387. static HasSpecificTrigger(trigger: number): boolean;
  88388. }
  88389. }
  88390. declare module BABYLON {
  88391. /**
  88392. * Defines how a node can be built from a string name.
  88393. */
  88394. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  88395. /**
  88396. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  88397. */
  88398. export class Node implements IBehaviorAware<Node> {
  88399. /** @hidden */
  88400. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  88401. private static _NodeConstructors;
  88402. /**
  88403. * Add a new node constructor
  88404. * @param type defines the type name of the node to construct
  88405. * @param constructorFunc defines the constructor function
  88406. */
  88407. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  88408. /**
  88409. * Returns a node constructor based on type name
  88410. * @param type defines the type name
  88411. * @param name defines the new node name
  88412. * @param scene defines the hosting scene
  88413. * @param options defines optional options to transmit to constructors
  88414. * @returns the new constructor or null
  88415. */
  88416. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  88417. /**
  88418. * Gets or sets the name of the node
  88419. */
  88420. name: string;
  88421. /**
  88422. * Gets or sets the id of the node
  88423. */
  88424. id: string;
  88425. /**
  88426. * Gets or sets the unique id of the node
  88427. */
  88428. uniqueId: number;
  88429. /**
  88430. * Gets or sets a string used to store user defined state for the node
  88431. */
  88432. state: string;
  88433. /**
  88434. * Gets or sets an object used to store user defined information for the node
  88435. */
  88436. metadata: any;
  88437. /**
  88438. * For internal use only. Please do not use.
  88439. */
  88440. reservedDataStore: any;
  88441. /**
  88442. * List of inspectable custom properties (used by the Inspector)
  88443. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  88444. */
  88445. inspectableCustomProperties: IInspectable[];
  88446. /**
  88447. * Gets or sets a boolean used to define if the node must be serialized
  88448. */
  88449. doNotSerialize: boolean;
  88450. /** @hidden */
  88451. _isDisposed: boolean;
  88452. /**
  88453. * Gets a list of Animations associated with the node
  88454. */
  88455. animations: Animation[];
  88456. protected _ranges: {
  88457. [name: string]: Nullable<AnimationRange>;
  88458. };
  88459. /**
  88460. * Callback raised when the node is ready to be used
  88461. */
  88462. onReady: Nullable<(node: Node) => void>;
  88463. private _isEnabled;
  88464. private _isParentEnabled;
  88465. private _isReady;
  88466. /** @hidden */
  88467. _currentRenderId: number;
  88468. private _parentUpdateId;
  88469. /** @hidden */
  88470. _childUpdateId: number;
  88471. /** @hidden */
  88472. _waitingParentId: Nullable<string>;
  88473. /** @hidden */
  88474. _scene: Scene;
  88475. /** @hidden */
  88476. _cache: any;
  88477. private _parentNode;
  88478. private _children;
  88479. /** @hidden */
  88480. _worldMatrix: Matrix;
  88481. /** @hidden */
  88482. _worldMatrixDeterminant: number;
  88483. /** @hidden */
  88484. _worldMatrixDeterminantIsDirty: boolean;
  88485. /** @hidden */
  88486. private _sceneRootNodesIndex;
  88487. /**
  88488. * Gets a boolean indicating if the node has been disposed
  88489. * @returns true if the node was disposed
  88490. */
  88491. isDisposed(): boolean;
  88492. /**
  88493. * Gets or sets the parent of the node (without keeping the current position in the scene)
  88494. * @see https://doc.babylonjs.com/how_to/parenting
  88495. */
  88496. parent: Nullable<Node>;
  88497. private addToSceneRootNodes;
  88498. private removeFromSceneRootNodes;
  88499. private _animationPropertiesOverride;
  88500. /**
  88501. * Gets or sets the animation properties override
  88502. */
  88503. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  88504. /**
  88505. * Gets a string idenfifying the name of the class
  88506. * @returns "Node" string
  88507. */
  88508. getClassName(): string;
  88509. /** @hidden */
  88510. readonly _isNode: boolean;
  88511. /**
  88512. * An event triggered when the mesh is disposed
  88513. */
  88514. onDisposeObservable: Observable<Node>;
  88515. private _onDisposeObserver;
  88516. /**
  88517. * Sets a callback that will be raised when the node will be disposed
  88518. */
  88519. onDispose: () => void;
  88520. /**
  88521. * Creates a new Node
  88522. * @param name the name and id to be given to this node
  88523. * @param scene the scene this node will be added to
  88524. * @param addToRootNodes the node will be added to scene.rootNodes
  88525. */
  88526. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  88527. /**
  88528. * Gets the scene of the node
  88529. * @returns a scene
  88530. */
  88531. getScene(): Scene;
  88532. /**
  88533. * Gets the engine of the node
  88534. * @returns a Engine
  88535. */
  88536. getEngine(): Engine;
  88537. private _behaviors;
  88538. /**
  88539. * Attach a behavior to the node
  88540. * @see http://doc.babylonjs.com/features/behaviour
  88541. * @param behavior defines the behavior to attach
  88542. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  88543. * @returns the current Node
  88544. */
  88545. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  88546. /**
  88547. * Remove an attached behavior
  88548. * @see http://doc.babylonjs.com/features/behaviour
  88549. * @param behavior defines the behavior to attach
  88550. * @returns the current Node
  88551. */
  88552. removeBehavior(behavior: Behavior<Node>): Node;
  88553. /**
  88554. * Gets the list of attached behaviors
  88555. * @see http://doc.babylonjs.com/features/behaviour
  88556. */
  88557. readonly behaviors: Behavior<Node>[];
  88558. /**
  88559. * Gets an attached behavior by name
  88560. * @param name defines the name of the behavior to look for
  88561. * @see http://doc.babylonjs.com/features/behaviour
  88562. * @returns null if behavior was not found else the requested behavior
  88563. */
  88564. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  88565. /**
  88566. * Returns the latest update of the World matrix
  88567. * @returns a Matrix
  88568. */
  88569. getWorldMatrix(): Matrix;
  88570. /** @hidden */
  88571. _getWorldMatrixDeterminant(): number;
  88572. /**
  88573. * Returns directly the latest state of the mesh World matrix.
  88574. * A Matrix is returned.
  88575. */
  88576. readonly worldMatrixFromCache: Matrix;
  88577. /** @hidden */
  88578. _initCache(): void;
  88579. /** @hidden */
  88580. updateCache(force?: boolean): void;
  88581. /** @hidden */
  88582. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  88583. /** @hidden */
  88584. _updateCache(ignoreParentClass?: boolean): void;
  88585. /** @hidden */
  88586. _isSynchronized(): boolean;
  88587. /** @hidden */
  88588. _markSyncedWithParent(): void;
  88589. /** @hidden */
  88590. isSynchronizedWithParent(): boolean;
  88591. /** @hidden */
  88592. isSynchronized(): boolean;
  88593. /**
  88594. * Is this node ready to be used/rendered
  88595. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  88596. * @return true if the node is ready
  88597. */
  88598. isReady(completeCheck?: boolean): boolean;
  88599. /**
  88600. * Is this node enabled?
  88601. * 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
  88602. * @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
  88603. * @return whether this node (and its parent) is enabled
  88604. */
  88605. isEnabled(checkAncestors?: boolean): boolean;
  88606. /** @hidden */
  88607. protected _syncParentEnabledState(): void;
  88608. /**
  88609. * Set the enabled state of this node
  88610. * @param value defines the new enabled state
  88611. */
  88612. setEnabled(value: boolean): void;
  88613. /**
  88614. * Is this node a descendant of the given node?
  88615. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  88616. * @param ancestor defines the parent node to inspect
  88617. * @returns a boolean indicating if this node is a descendant of the given node
  88618. */
  88619. isDescendantOf(ancestor: Node): boolean;
  88620. /** @hidden */
  88621. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  88622. /**
  88623. * Will return all nodes that have this node as ascendant
  88624. * @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
  88625. * @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
  88626. * @return all children nodes of all types
  88627. */
  88628. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  88629. /**
  88630. * Get all child-meshes of this node
  88631. * @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)
  88632. * @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
  88633. * @returns an array of AbstractMesh
  88634. */
  88635. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  88636. /**
  88637. * Get all direct children of this node
  88638. * @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
  88639. * @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)
  88640. * @returns an array of Node
  88641. */
  88642. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  88643. /** @hidden */
  88644. _setReady(state: boolean): void;
  88645. /**
  88646. * Get an animation by name
  88647. * @param name defines the name of the animation to look for
  88648. * @returns null if not found else the requested animation
  88649. */
  88650. getAnimationByName(name: string): Nullable<Animation>;
  88651. /**
  88652. * Creates an animation range for this node
  88653. * @param name defines the name of the range
  88654. * @param from defines the starting key
  88655. * @param to defines the end key
  88656. */
  88657. createAnimationRange(name: string, from: number, to: number): void;
  88658. /**
  88659. * Delete a specific animation range
  88660. * @param name defines the name of the range to delete
  88661. * @param deleteFrames defines if animation frames from the range must be deleted as well
  88662. */
  88663. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  88664. /**
  88665. * Get an animation range by name
  88666. * @param name defines the name of the animation range to look for
  88667. * @returns null if not found else the requested animation range
  88668. */
  88669. getAnimationRange(name: string): Nullable<AnimationRange>;
  88670. /**
  88671. * Gets the list of all animation ranges defined on this node
  88672. * @returns an array
  88673. */
  88674. getAnimationRanges(): Nullable<AnimationRange>[];
  88675. /**
  88676. * Will start the animation sequence
  88677. * @param name defines the range frames for animation sequence
  88678. * @param loop defines if the animation should loop (false by default)
  88679. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  88680. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  88681. * @returns the object created for this animation. If range does not exist, it will return null
  88682. */
  88683. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  88684. /**
  88685. * Serialize animation ranges into a JSON compatible object
  88686. * @returns serialization object
  88687. */
  88688. serializeAnimationRanges(): any;
  88689. /**
  88690. * Computes the world matrix of the node
  88691. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  88692. * @returns the world matrix
  88693. */
  88694. computeWorldMatrix(force?: boolean): Matrix;
  88695. /**
  88696. * Releases resources associated with this node.
  88697. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  88698. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  88699. */
  88700. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  88701. /**
  88702. * Parse animation range data from a serialization object and store them into a given node
  88703. * @param node defines where to store the animation ranges
  88704. * @param parsedNode defines the serialization object to read data from
  88705. * @param scene defines the hosting scene
  88706. */
  88707. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  88708. /**
  88709. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  88710. * @param includeDescendants Include bounding info from descendants as well (true by default)
  88711. * @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
  88712. * @returns the new bounding vectors
  88713. */
  88714. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  88715. min: Vector3;
  88716. max: Vector3;
  88717. };
  88718. }
  88719. }
  88720. declare module BABYLON {
  88721. /**
  88722. * @hidden
  88723. */
  88724. export class _IAnimationState {
  88725. key: number;
  88726. repeatCount: number;
  88727. workValue?: any;
  88728. loopMode?: number;
  88729. offsetValue?: any;
  88730. highLimitValue?: any;
  88731. }
  88732. /**
  88733. * Class used to store any kind of animation
  88734. */
  88735. export class Animation {
  88736. /**Name of the animation */
  88737. name: string;
  88738. /**Property to animate */
  88739. targetProperty: string;
  88740. /**The frames per second of the animation */
  88741. framePerSecond: number;
  88742. /**The data type of the animation */
  88743. dataType: number;
  88744. /**The loop mode of the animation */
  88745. loopMode?: number | undefined;
  88746. /**Specifies if blending should be enabled */
  88747. enableBlending?: boolean | undefined;
  88748. /**
  88749. * Use matrix interpolation instead of using direct key value when animating matrices
  88750. */
  88751. static AllowMatricesInterpolation: boolean;
  88752. /**
  88753. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  88754. */
  88755. static AllowMatrixDecomposeForInterpolation: boolean;
  88756. /**
  88757. * Stores the key frames of the animation
  88758. */
  88759. private _keys;
  88760. /**
  88761. * Stores the easing function of the animation
  88762. */
  88763. private _easingFunction;
  88764. /**
  88765. * @hidden Internal use only
  88766. */
  88767. _runtimeAnimations: RuntimeAnimation[];
  88768. /**
  88769. * The set of event that will be linked to this animation
  88770. */
  88771. private _events;
  88772. /**
  88773. * Stores an array of target property paths
  88774. */
  88775. targetPropertyPath: string[];
  88776. /**
  88777. * Stores the blending speed of the animation
  88778. */
  88779. blendingSpeed: number;
  88780. /**
  88781. * Stores the animation ranges for the animation
  88782. */
  88783. private _ranges;
  88784. /**
  88785. * @hidden Internal use
  88786. */
  88787. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  88788. /**
  88789. * Sets up an animation
  88790. * @param property The property to animate
  88791. * @param animationType The animation type to apply
  88792. * @param framePerSecond The frames per second of the animation
  88793. * @param easingFunction The easing function used in the animation
  88794. * @returns The created animation
  88795. */
  88796. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  88797. /**
  88798. * Create and start an animation on a node
  88799. * @param name defines the name of the global animation that will be run on all nodes
  88800. * @param node defines the root node where the animation will take place
  88801. * @param targetProperty defines property to animate
  88802. * @param framePerSecond defines the number of frame per second yo use
  88803. * @param totalFrame defines the number of frames in total
  88804. * @param from defines the initial value
  88805. * @param to defines the final value
  88806. * @param loopMode defines which loop mode you want to use (off by default)
  88807. * @param easingFunction defines the easing function to use (linear by default)
  88808. * @param onAnimationEnd defines the callback to call when animation end
  88809. * @returns the animatable created for this animation
  88810. */
  88811. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  88812. /**
  88813. * Create and start an animation on a node and its descendants
  88814. * @param name defines the name of the global animation that will be run on all nodes
  88815. * @param node defines the root node where the animation will take place
  88816. * @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
  88817. * @param targetProperty defines property to animate
  88818. * @param framePerSecond defines the number of frame per second to use
  88819. * @param totalFrame defines the number of frames in total
  88820. * @param from defines the initial value
  88821. * @param to defines the final value
  88822. * @param loopMode defines which loop mode you want to use (off by default)
  88823. * @param easingFunction defines the easing function to use (linear by default)
  88824. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  88825. * @returns the list of animatables created for all nodes
  88826. * @example https://www.babylonjs-playground.com/#MH0VLI
  88827. */
  88828. 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[]>;
  88829. /**
  88830. * Creates a new animation, merges it with the existing animations and starts it
  88831. * @param name Name of the animation
  88832. * @param node Node which contains the scene that begins the animations
  88833. * @param targetProperty Specifies which property to animate
  88834. * @param framePerSecond The frames per second of the animation
  88835. * @param totalFrame The total number of frames
  88836. * @param from The frame at the beginning of the animation
  88837. * @param to The frame at the end of the animation
  88838. * @param loopMode Specifies the loop mode of the animation
  88839. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  88840. * @param onAnimationEnd Callback to run once the animation is complete
  88841. * @returns Nullable animation
  88842. */
  88843. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  88844. /**
  88845. * Transition property of an host to the target Value
  88846. * @param property The property to transition
  88847. * @param targetValue The target Value of the property
  88848. * @param host The object where the property to animate belongs
  88849. * @param scene Scene used to run the animation
  88850. * @param frameRate Framerate (in frame/s) to use
  88851. * @param transition The transition type we want to use
  88852. * @param duration The duration of the animation, in milliseconds
  88853. * @param onAnimationEnd Callback trigger at the end of the animation
  88854. * @returns Nullable animation
  88855. */
  88856. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  88857. /**
  88858. * Return the array of runtime animations currently using this animation
  88859. */
  88860. readonly runtimeAnimations: RuntimeAnimation[];
  88861. /**
  88862. * Specifies if any of the runtime animations are currently running
  88863. */
  88864. readonly hasRunningRuntimeAnimations: boolean;
  88865. /**
  88866. * Initializes the animation
  88867. * @param name Name of the animation
  88868. * @param targetProperty Property to animate
  88869. * @param framePerSecond The frames per second of the animation
  88870. * @param dataType The data type of the animation
  88871. * @param loopMode The loop mode of the animation
  88872. * @param enableBlending Specifies if blending should be enabled
  88873. */
  88874. constructor(
  88875. /**Name of the animation */
  88876. name: string,
  88877. /**Property to animate */
  88878. targetProperty: string,
  88879. /**The frames per second of the animation */
  88880. framePerSecond: number,
  88881. /**The data type of the animation */
  88882. dataType: number,
  88883. /**The loop mode of the animation */
  88884. loopMode?: number | undefined,
  88885. /**Specifies if blending should be enabled */
  88886. enableBlending?: boolean | undefined);
  88887. /**
  88888. * Converts the animation to a string
  88889. * @param fullDetails support for multiple levels of logging within scene loading
  88890. * @returns String form of the animation
  88891. */
  88892. toString(fullDetails?: boolean): string;
  88893. /**
  88894. * Add an event to this animation
  88895. * @param event Event to add
  88896. */
  88897. addEvent(event: AnimationEvent): void;
  88898. /**
  88899. * Remove all events found at the given frame
  88900. * @param frame The frame to remove events from
  88901. */
  88902. removeEvents(frame: number): void;
  88903. /**
  88904. * Retrieves all the events from the animation
  88905. * @returns Events from the animation
  88906. */
  88907. getEvents(): AnimationEvent[];
  88908. /**
  88909. * Creates an animation range
  88910. * @param name Name of the animation range
  88911. * @param from Starting frame of the animation range
  88912. * @param to Ending frame of the animation
  88913. */
  88914. createRange(name: string, from: number, to: number): void;
  88915. /**
  88916. * Deletes an animation range by name
  88917. * @param name Name of the animation range to delete
  88918. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  88919. */
  88920. deleteRange(name: string, deleteFrames?: boolean): void;
  88921. /**
  88922. * Gets the animation range by name, or null if not defined
  88923. * @param name Name of the animation range
  88924. * @returns Nullable animation range
  88925. */
  88926. getRange(name: string): Nullable<AnimationRange>;
  88927. /**
  88928. * Gets the key frames from the animation
  88929. * @returns The key frames of the animation
  88930. */
  88931. getKeys(): Array<IAnimationKey>;
  88932. /**
  88933. * Gets the highest frame rate of the animation
  88934. * @returns Highest frame rate of the animation
  88935. */
  88936. getHighestFrame(): number;
  88937. /**
  88938. * Gets the easing function of the animation
  88939. * @returns Easing function of the animation
  88940. */
  88941. getEasingFunction(): IEasingFunction;
  88942. /**
  88943. * Sets the easing function of the animation
  88944. * @param easingFunction A custom mathematical formula for animation
  88945. */
  88946. setEasingFunction(easingFunction: EasingFunction): void;
  88947. /**
  88948. * Interpolates a scalar linearly
  88949. * @param startValue Start value of the animation curve
  88950. * @param endValue End value of the animation curve
  88951. * @param gradient Scalar amount to interpolate
  88952. * @returns Interpolated scalar value
  88953. */
  88954. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  88955. /**
  88956. * Interpolates a scalar cubically
  88957. * @param startValue Start value of the animation curve
  88958. * @param outTangent End tangent of the animation
  88959. * @param endValue End value of the animation curve
  88960. * @param inTangent Start tangent of the animation curve
  88961. * @param gradient Scalar amount to interpolate
  88962. * @returns Interpolated scalar value
  88963. */
  88964. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  88965. /**
  88966. * Interpolates a quaternion using a spherical linear interpolation
  88967. * @param startValue Start value of the animation curve
  88968. * @param endValue End value of the animation curve
  88969. * @param gradient Scalar amount to interpolate
  88970. * @returns Interpolated quaternion value
  88971. */
  88972. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  88973. /**
  88974. * Interpolates a quaternion cubically
  88975. * @param startValue Start value of the animation curve
  88976. * @param outTangent End tangent of the animation curve
  88977. * @param endValue End value of the animation curve
  88978. * @param inTangent Start tangent of the animation curve
  88979. * @param gradient Scalar amount to interpolate
  88980. * @returns Interpolated quaternion value
  88981. */
  88982. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  88983. /**
  88984. * Interpolates a Vector3 linearl
  88985. * @param startValue Start value of the animation curve
  88986. * @param endValue End value of the animation curve
  88987. * @param gradient Scalar amount to interpolate
  88988. * @returns Interpolated scalar value
  88989. */
  88990. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  88991. /**
  88992. * Interpolates a Vector3 cubically
  88993. * @param startValue Start value of the animation curve
  88994. * @param outTangent End tangent of the animation
  88995. * @param endValue End value of the animation curve
  88996. * @param inTangent Start tangent of the animation curve
  88997. * @param gradient Scalar amount to interpolate
  88998. * @returns InterpolatedVector3 value
  88999. */
  89000. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  89001. /**
  89002. * Interpolates a Vector2 linearly
  89003. * @param startValue Start value of the animation curve
  89004. * @param endValue End value of the animation curve
  89005. * @param gradient Scalar amount to interpolate
  89006. * @returns Interpolated Vector2 value
  89007. */
  89008. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  89009. /**
  89010. * Interpolates a Vector2 cubically
  89011. * @param startValue Start value of the animation curve
  89012. * @param outTangent End tangent of the animation
  89013. * @param endValue End value of the animation curve
  89014. * @param inTangent Start tangent of the animation curve
  89015. * @param gradient Scalar amount to interpolate
  89016. * @returns Interpolated Vector2 value
  89017. */
  89018. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  89019. /**
  89020. * Interpolates a size linearly
  89021. * @param startValue Start value of the animation curve
  89022. * @param endValue End value of the animation curve
  89023. * @param gradient Scalar amount to interpolate
  89024. * @returns Interpolated Size value
  89025. */
  89026. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  89027. /**
  89028. * Interpolates a Color3 linearly
  89029. * @param startValue Start value of the animation curve
  89030. * @param endValue End value of the animation curve
  89031. * @param gradient Scalar amount to interpolate
  89032. * @returns Interpolated Color3 value
  89033. */
  89034. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  89035. /**
  89036. * @hidden Internal use only
  89037. */
  89038. _getKeyValue(value: any): any;
  89039. /**
  89040. * @hidden Internal use only
  89041. */
  89042. _interpolate(currentFrame: number, state: _IAnimationState): any;
  89043. /**
  89044. * Defines the function to use to interpolate matrices
  89045. * @param startValue defines the start matrix
  89046. * @param endValue defines the end matrix
  89047. * @param gradient defines the gradient between both matrices
  89048. * @param result defines an optional target matrix where to store the interpolation
  89049. * @returns the interpolated matrix
  89050. */
  89051. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  89052. /**
  89053. * Makes a copy of the animation
  89054. * @returns Cloned animation
  89055. */
  89056. clone(): Animation;
  89057. /**
  89058. * Sets the key frames of the animation
  89059. * @param values The animation key frames to set
  89060. */
  89061. setKeys(values: Array<IAnimationKey>): void;
  89062. /**
  89063. * Serializes the animation to an object
  89064. * @returns Serialized object
  89065. */
  89066. serialize(): any;
  89067. /**
  89068. * Float animation type
  89069. */
  89070. private static _ANIMATIONTYPE_FLOAT;
  89071. /**
  89072. * Vector3 animation type
  89073. */
  89074. private static _ANIMATIONTYPE_VECTOR3;
  89075. /**
  89076. * Quaternion animation type
  89077. */
  89078. private static _ANIMATIONTYPE_QUATERNION;
  89079. /**
  89080. * Matrix animation type
  89081. */
  89082. private static _ANIMATIONTYPE_MATRIX;
  89083. /**
  89084. * Color3 animation type
  89085. */
  89086. private static _ANIMATIONTYPE_COLOR3;
  89087. /**
  89088. * Vector2 animation type
  89089. */
  89090. private static _ANIMATIONTYPE_VECTOR2;
  89091. /**
  89092. * Size animation type
  89093. */
  89094. private static _ANIMATIONTYPE_SIZE;
  89095. /**
  89096. * Relative Loop Mode
  89097. */
  89098. private static _ANIMATIONLOOPMODE_RELATIVE;
  89099. /**
  89100. * Cycle Loop Mode
  89101. */
  89102. private static _ANIMATIONLOOPMODE_CYCLE;
  89103. /**
  89104. * Constant Loop Mode
  89105. */
  89106. private static _ANIMATIONLOOPMODE_CONSTANT;
  89107. /**
  89108. * Get the float animation type
  89109. */
  89110. static readonly ANIMATIONTYPE_FLOAT: number;
  89111. /**
  89112. * Get the Vector3 animation type
  89113. */
  89114. static readonly ANIMATIONTYPE_VECTOR3: number;
  89115. /**
  89116. * Get the Vector2 animation type
  89117. */
  89118. static readonly ANIMATIONTYPE_VECTOR2: number;
  89119. /**
  89120. * Get the Size animation type
  89121. */
  89122. static readonly ANIMATIONTYPE_SIZE: number;
  89123. /**
  89124. * Get the Quaternion animation type
  89125. */
  89126. static readonly ANIMATIONTYPE_QUATERNION: number;
  89127. /**
  89128. * Get the Matrix animation type
  89129. */
  89130. static readonly ANIMATIONTYPE_MATRIX: number;
  89131. /**
  89132. * Get the Color3 animation type
  89133. */
  89134. static readonly ANIMATIONTYPE_COLOR3: number;
  89135. /**
  89136. * Get the Relative Loop Mode
  89137. */
  89138. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  89139. /**
  89140. * Get the Cycle Loop Mode
  89141. */
  89142. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  89143. /**
  89144. * Get the Constant Loop Mode
  89145. */
  89146. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  89147. /** @hidden */
  89148. static _UniversalLerp(left: any, right: any, amount: number): any;
  89149. /**
  89150. * Parses an animation object and creates an animation
  89151. * @param parsedAnimation Parsed animation object
  89152. * @returns Animation object
  89153. */
  89154. static Parse(parsedAnimation: any): Animation;
  89155. /**
  89156. * Appends the serialized animations from the source animations
  89157. * @param source Source containing the animations
  89158. * @param destination Target to store the animations
  89159. */
  89160. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  89161. }
  89162. }
  89163. declare module BABYLON {
  89164. /**
  89165. * Base class of all the textures in babylon.
  89166. * It groups all the common properties the materials, post process, lights... might need
  89167. * in order to make a correct use of the texture.
  89168. */
  89169. export class BaseTexture implements IAnimatable {
  89170. /**
  89171. * Default anisotropic filtering level for the application.
  89172. * It is set to 4 as a good tradeoff between perf and quality.
  89173. */
  89174. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  89175. /**
  89176. * Gets or sets the unique id of the texture
  89177. */
  89178. uniqueId: number;
  89179. /**
  89180. * Define the name of the texture.
  89181. */
  89182. name: string;
  89183. /**
  89184. * Gets or sets an object used to store user defined information.
  89185. */
  89186. metadata: any;
  89187. /**
  89188. * For internal use only. Please do not use.
  89189. */
  89190. reservedDataStore: any;
  89191. private _hasAlpha;
  89192. /**
  89193. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  89194. */
  89195. hasAlpha: boolean;
  89196. /**
  89197. * Defines if the alpha value should be determined via the rgb values.
  89198. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  89199. */
  89200. getAlphaFromRGB: boolean;
  89201. /**
  89202. * Intensity or strength of the texture.
  89203. * It is commonly used by materials to fine tune the intensity of the texture
  89204. */
  89205. level: number;
  89206. /**
  89207. * Define the UV chanel to use starting from 0 and defaulting to 0.
  89208. * This is part of the texture as textures usually maps to one uv set.
  89209. */
  89210. coordinatesIndex: number;
  89211. private _coordinatesMode;
  89212. /**
  89213. * How a texture is mapped.
  89214. *
  89215. * | Value | Type | Description |
  89216. * | ----- | ----------------------------------- | ----------- |
  89217. * | 0 | EXPLICIT_MODE | |
  89218. * | 1 | SPHERICAL_MODE | |
  89219. * | 2 | PLANAR_MODE | |
  89220. * | 3 | CUBIC_MODE | |
  89221. * | 4 | PROJECTION_MODE | |
  89222. * | 5 | SKYBOX_MODE | |
  89223. * | 6 | INVCUBIC_MODE | |
  89224. * | 7 | EQUIRECTANGULAR_MODE | |
  89225. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  89226. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  89227. */
  89228. coordinatesMode: number;
  89229. /**
  89230. * | Value | Type | Description |
  89231. * | ----- | ------------------ | ----------- |
  89232. * | 0 | CLAMP_ADDRESSMODE | |
  89233. * | 1 | WRAP_ADDRESSMODE | |
  89234. * | 2 | MIRROR_ADDRESSMODE | |
  89235. */
  89236. wrapU: number;
  89237. /**
  89238. * | Value | Type | Description |
  89239. * | ----- | ------------------ | ----------- |
  89240. * | 0 | CLAMP_ADDRESSMODE | |
  89241. * | 1 | WRAP_ADDRESSMODE | |
  89242. * | 2 | MIRROR_ADDRESSMODE | |
  89243. */
  89244. wrapV: number;
  89245. /**
  89246. * | Value | Type | Description |
  89247. * | ----- | ------------------ | ----------- |
  89248. * | 0 | CLAMP_ADDRESSMODE | |
  89249. * | 1 | WRAP_ADDRESSMODE | |
  89250. * | 2 | MIRROR_ADDRESSMODE | |
  89251. */
  89252. wrapR: number;
  89253. /**
  89254. * With compliant hardware and browser (supporting anisotropic filtering)
  89255. * this defines the level of anisotropic filtering in the texture.
  89256. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  89257. */
  89258. anisotropicFilteringLevel: number;
  89259. /**
  89260. * Define if the texture is a cube texture or if false a 2d texture.
  89261. */
  89262. isCube: boolean;
  89263. /**
  89264. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  89265. */
  89266. is3D: boolean;
  89267. /**
  89268. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  89269. * HDR texture are usually stored in linear space.
  89270. * This only impacts the PBR and Background materials
  89271. */
  89272. gammaSpace: boolean;
  89273. /**
  89274. * Gets whether or not the texture contains RGBD data.
  89275. */
  89276. readonly isRGBD: boolean;
  89277. /**
  89278. * Is Z inverted in the texture (useful in a cube texture).
  89279. */
  89280. invertZ: boolean;
  89281. /**
  89282. * Are mip maps generated for this texture or not.
  89283. */
  89284. readonly noMipmap: boolean;
  89285. /**
  89286. * @hidden
  89287. */
  89288. lodLevelInAlpha: boolean;
  89289. /**
  89290. * With prefiltered texture, defined the offset used during the prefiltering steps.
  89291. */
  89292. lodGenerationOffset: number;
  89293. /**
  89294. * With prefiltered texture, defined the scale used during the prefiltering steps.
  89295. */
  89296. lodGenerationScale: number;
  89297. /**
  89298. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  89299. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  89300. * average roughness values.
  89301. */
  89302. linearSpecularLOD: boolean;
  89303. /**
  89304. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  89305. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  89306. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  89307. */
  89308. irradianceTexture: Nullable<BaseTexture>;
  89309. /**
  89310. * Define if the texture is a render target.
  89311. */
  89312. isRenderTarget: boolean;
  89313. /**
  89314. * Define the unique id of the texture in the scene.
  89315. */
  89316. readonly uid: string;
  89317. /**
  89318. * Return a string representation of the texture.
  89319. * @returns the texture as a string
  89320. */
  89321. toString(): string;
  89322. /**
  89323. * Get the class name of the texture.
  89324. * @returns "BaseTexture"
  89325. */
  89326. getClassName(): string;
  89327. /**
  89328. * Define the list of animation attached to the texture.
  89329. */
  89330. animations: Animation[];
  89331. /**
  89332. * An event triggered when the texture is disposed.
  89333. */
  89334. onDisposeObservable: Observable<BaseTexture>;
  89335. private _onDisposeObserver;
  89336. /**
  89337. * Callback triggered when the texture has been disposed.
  89338. * Kept for back compatibility, you can use the onDisposeObservable instead.
  89339. */
  89340. onDispose: () => void;
  89341. /**
  89342. * Define the current state of the loading sequence when in delayed load mode.
  89343. */
  89344. delayLoadState: number;
  89345. private _scene;
  89346. /** @hidden */
  89347. _texture: Nullable<InternalTexture>;
  89348. private _uid;
  89349. /**
  89350. * Define if the texture is preventinga material to render or not.
  89351. * If not and the texture is not ready, the engine will use a default black texture instead.
  89352. */
  89353. readonly isBlocking: boolean;
  89354. /**
  89355. * Instantiates a new BaseTexture.
  89356. * Base class of all the textures in babylon.
  89357. * It groups all the common properties the materials, post process, lights... might need
  89358. * in order to make a correct use of the texture.
  89359. * @param scene Define the scene the texture blongs to
  89360. */
  89361. constructor(scene: Nullable<Scene>);
  89362. /**
  89363. * Get the scene the texture belongs to.
  89364. * @returns the scene or null if undefined
  89365. */
  89366. getScene(): Nullable<Scene>;
  89367. /**
  89368. * Get the texture transform matrix used to offset tile the texture for istance.
  89369. * @returns the transformation matrix
  89370. */
  89371. getTextureMatrix(): Matrix;
  89372. /**
  89373. * Get the texture reflection matrix used to rotate/transform the reflection.
  89374. * @returns the reflection matrix
  89375. */
  89376. getReflectionTextureMatrix(): Matrix;
  89377. /**
  89378. * Get the underlying lower level texture from Babylon.
  89379. * @returns the insternal texture
  89380. */
  89381. getInternalTexture(): Nullable<InternalTexture>;
  89382. /**
  89383. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  89384. * @returns true if ready or not blocking
  89385. */
  89386. isReadyOrNotBlocking(): boolean;
  89387. /**
  89388. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  89389. * @returns true if fully ready
  89390. */
  89391. isReady(): boolean;
  89392. private _cachedSize;
  89393. /**
  89394. * Get the size of the texture.
  89395. * @returns the texture size.
  89396. */
  89397. getSize(): ISize;
  89398. /**
  89399. * Get the base size of the texture.
  89400. * It can be different from the size if the texture has been resized for POT for instance
  89401. * @returns the base size
  89402. */
  89403. getBaseSize(): ISize;
  89404. /**
  89405. * Update the sampling mode of the texture.
  89406. * Default is Trilinear mode.
  89407. *
  89408. * | Value | Type | Description |
  89409. * | ----- | ------------------ | ----------- |
  89410. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  89411. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  89412. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  89413. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  89414. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  89415. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  89416. * | 7 | NEAREST_LINEAR | |
  89417. * | 8 | NEAREST_NEAREST | |
  89418. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  89419. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  89420. * | 11 | LINEAR_LINEAR | |
  89421. * | 12 | LINEAR_NEAREST | |
  89422. *
  89423. * > _mag_: magnification filter (close to the viewer)
  89424. * > _min_: minification filter (far from the viewer)
  89425. * > _mip_: filter used between mip map levels
  89426. *@param samplingMode Define the new sampling mode of the texture
  89427. */
  89428. updateSamplingMode(samplingMode: number): void;
  89429. /**
  89430. * Scales the texture if is `canRescale()`
  89431. * @param ratio the resize factor we want to use to rescale
  89432. */
  89433. scale(ratio: number): void;
  89434. /**
  89435. * Get if the texture can rescale.
  89436. */
  89437. readonly canRescale: boolean;
  89438. /** @hidden */
  89439. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  89440. /** @hidden */
  89441. _rebuild(): void;
  89442. /**
  89443. * Triggers the load sequence in delayed load mode.
  89444. */
  89445. delayLoad(): void;
  89446. /**
  89447. * Clones the texture.
  89448. * @returns the cloned texture
  89449. */
  89450. clone(): Nullable<BaseTexture>;
  89451. /**
  89452. * Get the texture underlying type (INT, FLOAT...)
  89453. */
  89454. readonly textureType: number;
  89455. /**
  89456. * Get the texture underlying format (RGB, RGBA...)
  89457. */
  89458. readonly textureFormat: number;
  89459. /**
  89460. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  89461. * This will returns an RGBA array buffer containing either in values (0-255) or
  89462. * float values (0-1) depending of the underlying buffer type.
  89463. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  89464. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  89465. * @param buffer defines a user defined buffer to fill with data (can be null)
  89466. * @returns The Array buffer containing the pixels data.
  89467. */
  89468. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  89469. /**
  89470. * Release and destroy the underlying lower level texture aka internalTexture.
  89471. */
  89472. releaseInternalTexture(): void;
  89473. /**
  89474. * Get the polynomial representation of the texture data.
  89475. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  89476. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  89477. */
  89478. sphericalPolynomial: Nullable<SphericalPolynomial>;
  89479. /** @hidden */
  89480. readonly _lodTextureHigh: Nullable<BaseTexture>;
  89481. /** @hidden */
  89482. readonly _lodTextureMid: Nullable<BaseTexture>;
  89483. /** @hidden */
  89484. readonly _lodTextureLow: Nullable<BaseTexture>;
  89485. /**
  89486. * Dispose the texture and release its associated resources.
  89487. */
  89488. dispose(): void;
  89489. /**
  89490. * Serialize the texture into a JSON representation that can be parsed later on.
  89491. * @returns the JSON representation of the texture
  89492. */
  89493. serialize(): any;
  89494. /**
  89495. * Helper function to be called back once a list of texture contains only ready textures.
  89496. * @param textures Define the list of textures to wait for
  89497. * @param callback Define the callback triggered once the entire list will be ready
  89498. */
  89499. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  89500. }
  89501. }
  89502. declare module BABYLON {
  89503. /**
  89504. * Uniform buffer objects.
  89505. *
  89506. * Handles blocks of uniform on the GPU.
  89507. *
  89508. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  89509. *
  89510. * For more information, please refer to :
  89511. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  89512. */
  89513. export class UniformBuffer {
  89514. private _engine;
  89515. private _buffer;
  89516. private _data;
  89517. private _bufferData;
  89518. private _dynamic?;
  89519. private _uniformLocations;
  89520. private _uniformSizes;
  89521. private _uniformLocationPointer;
  89522. private _needSync;
  89523. private _noUBO;
  89524. private _currentEffect;
  89525. private static _MAX_UNIFORM_SIZE;
  89526. private static _tempBuffer;
  89527. /**
  89528. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  89529. * This is dynamic to allow compat with webgl 1 and 2.
  89530. * You will need to pass the name of the uniform as well as the value.
  89531. */
  89532. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  89533. /**
  89534. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  89535. * This is dynamic to allow compat with webgl 1 and 2.
  89536. * You will need to pass the name of the uniform as well as the value.
  89537. */
  89538. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  89539. /**
  89540. * Lambda to Update a single float in a uniform buffer.
  89541. * This is dynamic to allow compat with webgl 1 and 2.
  89542. * You will need to pass the name of the uniform as well as the value.
  89543. */
  89544. updateFloat: (name: string, x: number) => void;
  89545. /**
  89546. * Lambda to Update a vec2 of float in a uniform buffer.
  89547. * This is dynamic to allow compat with webgl 1 and 2.
  89548. * You will need to pass the name of the uniform as well as the value.
  89549. */
  89550. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  89551. /**
  89552. * Lambda to Update a vec3 of float in a uniform buffer.
  89553. * This is dynamic to allow compat with webgl 1 and 2.
  89554. * You will need to pass the name of the uniform as well as the value.
  89555. */
  89556. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  89557. /**
  89558. * Lambda to Update a vec4 of float in a uniform buffer.
  89559. * This is dynamic to allow compat with webgl 1 and 2.
  89560. * You will need to pass the name of the uniform as well as the value.
  89561. */
  89562. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  89563. /**
  89564. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  89565. * This is dynamic to allow compat with webgl 1 and 2.
  89566. * You will need to pass the name of the uniform as well as the value.
  89567. */
  89568. updateMatrix: (name: string, mat: Matrix) => void;
  89569. /**
  89570. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  89571. * This is dynamic to allow compat with webgl 1 and 2.
  89572. * You will need to pass the name of the uniform as well as the value.
  89573. */
  89574. updateVector3: (name: string, vector: Vector3) => void;
  89575. /**
  89576. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  89577. * This is dynamic to allow compat with webgl 1 and 2.
  89578. * You will need to pass the name of the uniform as well as the value.
  89579. */
  89580. updateVector4: (name: string, vector: Vector4) => void;
  89581. /**
  89582. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  89583. * This is dynamic to allow compat with webgl 1 and 2.
  89584. * You will need to pass the name of the uniform as well as the value.
  89585. */
  89586. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  89587. /**
  89588. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  89589. * This is dynamic to allow compat with webgl 1 and 2.
  89590. * You will need to pass the name of the uniform as well as the value.
  89591. */
  89592. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  89593. /**
  89594. * Instantiates a new Uniform buffer objects.
  89595. *
  89596. * Handles blocks of uniform on the GPU.
  89597. *
  89598. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  89599. *
  89600. * For more information, please refer to :
  89601. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  89602. * @param engine Define the engine the buffer is associated with
  89603. * @param data Define the data contained in the buffer
  89604. * @param dynamic Define if the buffer is updatable
  89605. */
  89606. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  89607. /**
  89608. * Indicates if the buffer is using the WebGL2 UBO implementation,
  89609. * or just falling back on setUniformXXX calls.
  89610. */
  89611. readonly useUbo: boolean;
  89612. /**
  89613. * Indicates if the WebGL underlying uniform buffer is in sync
  89614. * with the javascript cache data.
  89615. */
  89616. readonly isSync: boolean;
  89617. /**
  89618. * Indicates if the WebGL underlying uniform buffer is dynamic.
  89619. * Also, a dynamic UniformBuffer will disable cache verification and always
  89620. * update the underlying WebGL uniform buffer to the GPU.
  89621. * @returns if Dynamic, otherwise false
  89622. */
  89623. isDynamic(): boolean;
  89624. /**
  89625. * The data cache on JS side.
  89626. * @returns the underlying data as a float array
  89627. */
  89628. getData(): Float32Array;
  89629. /**
  89630. * The underlying WebGL Uniform buffer.
  89631. * @returns the webgl buffer
  89632. */
  89633. getBuffer(): Nullable<DataBuffer>;
  89634. /**
  89635. * std140 layout specifies how to align data within an UBO structure.
  89636. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  89637. * for specs.
  89638. */
  89639. private _fillAlignment;
  89640. /**
  89641. * Adds an uniform in the buffer.
  89642. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  89643. * for the layout to be correct !
  89644. * @param name Name of the uniform, as used in the uniform block in the shader.
  89645. * @param size Data size, or data directly.
  89646. */
  89647. addUniform(name: string, size: number | number[]): void;
  89648. /**
  89649. * Adds a Matrix 4x4 to the uniform buffer.
  89650. * @param name Name of the uniform, as used in the uniform block in the shader.
  89651. * @param mat A 4x4 matrix.
  89652. */
  89653. addMatrix(name: string, mat: Matrix): void;
  89654. /**
  89655. * Adds a vec2 to the uniform buffer.
  89656. * @param name Name of the uniform, as used in the uniform block in the shader.
  89657. * @param x Define the x component value of the vec2
  89658. * @param y Define the y component value of the vec2
  89659. */
  89660. addFloat2(name: string, x: number, y: number): void;
  89661. /**
  89662. * Adds a vec3 to the uniform buffer.
  89663. * @param name Name of the uniform, as used in the uniform block in the shader.
  89664. * @param x Define the x component value of the vec3
  89665. * @param y Define the y component value of the vec3
  89666. * @param z Define the z component value of the vec3
  89667. */
  89668. addFloat3(name: string, x: number, y: number, z: number): void;
  89669. /**
  89670. * Adds a vec3 to the uniform buffer.
  89671. * @param name Name of the uniform, as used in the uniform block in the shader.
  89672. * @param color Define the vec3 from a Color
  89673. */
  89674. addColor3(name: string, color: Color3): void;
  89675. /**
  89676. * Adds a vec4 to the uniform buffer.
  89677. * @param name Name of the uniform, as used in the uniform block in the shader.
  89678. * @param color Define the rgb components from a Color
  89679. * @param alpha Define the a component of the vec4
  89680. */
  89681. addColor4(name: string, color: Color3, alpha: number): void;
  89682. /**
  89683. * Adds a vec3 to the uniform buffer.
  89684. * @param name Name of the uniform, as used in the uniform block in the shader.
  89685. * @param vector Define the vec3 components from a Vector
  89686. */
  89687. addVector3(name: string, vector: Vector3): void;
  89688. /**
  89689. * Adds a Matrix 3x3 to the uniform buffer.
  89690. * @param name Name of the uniform, as used in the uniform block in the shader.
  89691. */
  89692. addMatrix3x3(name: string): void;
  89693. /**
  89694. * Adds a Matrix 2x2 to the uniform buffer.
  89695. * @param name Name of the uniform, as used in the uniform block in the shader.
  89696. */
  89697. addMatrix2x2(name: string): void;
  89698. /**
  89699. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  89700. */
  89701. create(): void;
  89702. /** @hidden */
  89703. _rebuild(): void;
  89704. /**
  89705. * Updates the WebGL Uniform Buffer on the GPU.
  89706. * If the `dynamic` flag is set to true, no cache comparison is done.
  89707. * Otherwise, the buffer will be updated only if the cache differs.
  89708. */
  89709. update(): void;
  89710. /**
  89711. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  89712. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  89713. * @param data Define the flattened data
  89714. * @param size Define the size of the data.
  89715. */
  89716. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  89717. private _updateMatrix3x3ForUniform;
  89718. private _updateMatrix3x3ForEffect;
  89719. private _updateMatrix2x2ForEffect;
  89720. private _updateMatrix2x2ForUniform;
  89721. private _updateFloatForEffect;
  89722. private _updateFloatForUniform;
  89723. private _updateFloat2ForEffect;
  89724. private _updateFloat2ForUniform;
  89725. private _updateFloat3ForEffect;
  89726. private _updateFloat3ForUniform;
  89727. private _updateFloat4ForEffect;
  89728. private _updateFloat4ForUniform;
  89729. private _updateMatrixForEffect;
  89730. private _updateMatrixForUniform;
  89731. private _updateVector3ForEffect;
  89732. private _updateVector3ForUniform;
  89733. private _updateVector4ForEffect;
  89734. private _updateVector4ForUniform;
  89735. private _updateColor3ForEffect;
  89736. private _updateColor3ForUniform;
  89737. private _updateColor4ForEffect;
  89738. private _updateColor4ForUniform;
  89739. /**
  89740. * Sets a sampler uniform on the effect.
  89741. * @param name Define the name of the sampler.
  89742. * @param texture Define the texture to set in the sampler
  89743. */
  89744. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  89745. /**
  89746. * Directly updates the value of the uniform in the cache AND on the GPU.
  89747. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  89748. * @param data Define the flattened data
  89749. */
  89750. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  89751. /**
  89752. * Binds this uniform buffer to an effect.
  89753. * @param effect Define the effect to bind the buffer to
  89754. * @param name Name of the uniform block in the shader.
  89755. */
  89756. bindToEffect(effect: Effect, name: string): void;
  89757. /**
  89758. * Disposes the uniform buffer.
  89759. */
  89760. dispose(): void;
  89761. }
  89762. }
  89763. declare module BABYLON {
  89764. /**
  89765. * Class used to work with sound analyzer using fast fourier transform (FFT)
  89766. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89767. */
  89768. export class Analyser {
  89769. /**
  89770. * Gets or sets the smoothing
  89771. * @ignorenaming
  89772. */
  89773. SMOOTHING: number;
  89774. /**
  89775. * Gets or sets the FFT table size
  89776. * @ignorenaming
  89777. */
  89778. FFT_SIZE: number;
  89779. /**
  89780. * Gets or sets the bar graph amplitude
  89781. * @ignorenaming
  89782. */
  89783. BARGRAPHAMPLITUDE: number;
  89784. /**
  89785. * Gets or sets the position of the debug canvas
  89786. * @ignorenaming
  89787. */
  89788. DEBUGCANVASPOS: {
  89789. x: number;
  89790. y: number;
  89791. };
  89792. /**
  89793. * Gets or sets the debug canvas size
  89794. * @ignorenaming
  89795. */
  89796. DEBUGCANVASSIZE: {
  89797. width: number;
  89798. height: number;
  89799. };
  89800. private _byteFreqs;
  89801. private _byteTime;
  89802. private _floatFreqs;
  89803. private _webAudioAnalyser;
  89804. private _debugCanvas;
  89805. private _debugCanvasContext;
  89806. private _scene;
  89807. private _registerFunc;
  89808. private _audioEngine;
  89809. /**
  89810. * Creates a new analyser
  89811. * @param scene defines hosting scene
  89812. */
  89813. constructor(scene: Scene);
  89814. /**
  89815. * Get the number of data values you will have to play with for the visualization
  89816. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  89817. * @returns a number
  89818. */
  89819. getFrequencyBinCount(): number;
  89820. /**
  89821. * Gets the current frequency data as a byte array
  89822. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  89823. * @returns a Uint8Array
  89824. */
  89825. getByteFrequencyData(): Uint8Array;
  89826. /**
  89827. * Gets the current waveform as a byte array
  89828. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  89829. * @returns a Uint8Array
  89830. */
  89831. getByteTimeDomainData(): Uint8Array;
  89832. /**
  89833. * Gets the current frequency data as a float array
  89834. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  89835. * @returns a Float32Array
  89836. */
  89837. getFloatFrequencyData(): Float32Array;
  89838. /**
  89839. * Renders the debug canvas
  89840. */
  89841. drawDebugCanvas(): void;
  89842. /**
  89843. * Stops rendering the debug canvas and removes it
  89844. */
  89845. stopDebugCanvas(): void;
  89846. /**
  89847. * Connects two audio nodes
  89848. * @param inputAudioNode defines first node to connect
  89849. * @param outputAudioNode defines second node to connect
  89850. */
  89851. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  89852. /**
  89853. * Releases all associated resources
  89854. */
  89855. dispose(): void;
  89856. }
  89857. }
  89858. declare module BABYLON {
  89859. /**
  89860. * This represents an audio engine and it is responsible
  89861. * to play, synchronize and analyse sounds throughout the application.
  89862. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89863. */
  89864. export interface IAudioEngine extends IDisposable {
  89865. /**
  89866. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  89867. */
  89868. readonly canUseWebAudio: boolean;
  89869. /**
  89870. * Gets the current AudioContext if available.
  89871. */
  89872. readonly audioContext: Nullable<AudioContext>;
  89873. /**
  89874. * The master gain node defines the global audio volume of your audio engine.
  89875. */
  89876. readonly masterGain: GainNode;
  89877. /**
  89878. * Gets whether or not mp3 are supported by your browser.
  89879. */
  89880. readonly isMP3supported: boolean;
  89881. /**
  89882. * Gets whether or not ogg are supported by your browser.
  89883. */
  89884. readonly isOGGsupported: boolean;
  89885. /**
  89886. * Defines if Babylon should emit a warning if WebAudio is not supported.
  89887. * @ignoreNaming
  89888. */
  89889. WarnedWebAudioUnsupported: boolean;
  89890. /**
  89891. * Defines if the audio engine relies on a custom unlocked button.
  89892. * In this case, the embedded button will not be displayed.
  89893. */
  89894. useCustomUnlockedButton: boolean;
  89895. /**
  89896. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  89897. */
  89898. readonly unlocked: boolean;
  89899. /**
  89900. * Event raised when audio has been unlocked on the browser.
  89901. */
  89902. onAudioUnlockedObservable: Observable<AudioEngine>;
  89903. /**
  89904. * Event raised when audio has been locked on the browser.
  89905. */
  89906. onAudioLockedObservable: Observable<AudioEngine>;
  89907. /**
  89908. * Flags the audio engine in Locked state.
  89909. * This happens due to new browser policies preventing audio to autoplay.
  89910. */
  89911. lock(): void;
  89912. /**
  89913. * Unlocks the audio engine once a user action has been done on the dom.
  89914. * This is helpful to resume play once browser policies have been satisfied.
  89915. */
  89916. unlock(): void;
  89917. }
  89918. /**
  89919. * This represents the default audio engine used in babylon.
  89920. * It is responsible to play, synchronize and analyse sounds throughout the application.
  89921. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89922. */
  89923. export class AudioEngine implements IAudioEngine {
  89924. private _audioContext;
  89925. private _audioContextInitialized;
  89926. private _muteButton;
  89927. private _hostElement;
  89928. /**
  89929. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  89930. */
  89931. canUseWebAudio: boolean;
  89932. /**
  89933. * The master gain node defines the global audio volume of your audio engine.
  89934. */
  89935. masterGain: GainNode;
  89936. /**
  89937. * Defines if Babylon should emit a warning if WebAudio is not supported.
  89938. * @ignoreNaming
  89939. */
  89940. WarnedWebAudioUnsupported: boolean;
  89941. /**
  89942. * Gets whether or not mp3 are supported by your browser.
  89943. */
  89944. isMP3supported: boolean;
  89945. /**
  89946. * Gets whether or not ogg are supported by your browser.
  89947. */
  89948. isOGGsupported: boolean;
  89949. /**
  89950. * Gets whether audio has been unlocked on the device.
  89951. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  89952. * a user interaction has happened.
  89953. */
  89954. unlocked: boolean;
  89955. /**
  89956. * Defines if the audio engine relies on a custom unlocked button.
  89957. * In this case, the embedded button will not be displayed.
  89958. */
  89959. useCustomUnlockedButton: boolean;
  89960. /**
  89961. * Event raised when audio has been unlocked on the browser.
  89962. */
  89963. onAudioUnlockedObservable: Observable<AudioEngine>;
  89964. /**
  89965. * Event raised when audio has been locked on the browser.
  89966. */
  89967. onAudioLockedObservable: Observable<AudioEngine>;
  89968. /**
  89969. * Gets the current AudioContext if available.
  89970. */
  89971. readonly audioContext: Nullable<AudioContext>;
  89972. private _connectedAnalyser;
  89973. /**
  89974. * Instantiates a new audio engine.
  89975. *
  89976. * There should be only one per page as some browsers restrict the number
  89977. * of audio contexts you can create.
  89978. * @param hostElement defines the host element where to display the mute icon if necessary
  89979. */
  89980. constructor(hostElement?: Nullable<HTMLElement>);
  89981. /**
  89982. * Flags the audio engine in Locked state.
  89983. * This happens due to new browser policies preventing audio to autoplay.
  89984. */
  89985. lock(): void;
  89986. /**
  89987. * Unlocks the audio engine once a user action has been done on the dom.
  89988. * This is helpful to resume play once browser policies have been satisfied.
  89989. */
  89990. unlock(): void;
  89991. private _resumeAudioContext;
  89992. private _initializeAudioContext;
  89993. private _tryToRun;
  89994. private _triggerRunningState;
  89995. private _triggerSuspendedState;
  89996. private _displayMuteButton;
  89997. private _moveButtonToTopLeft;
  89998. private _onResize;
  89999. private _hideMuteButton;
  90000. /**
  90001. * Destroy and release the resources associated with the audio ccontext.
  90002. */
  90003. dispose(): void;
  90004. /**
  90005. * Gets the global volume sets on the master gain.
  90006. * @returns the global volume if set or -1 otherwise
  90007. */
  90008. getGlobalVolume(): number;
  90009. /**
  90010. * Sets the global volume of your experience (sets on the master gain).
  90011. * @param newVolume Defines the new global volume of the application
  90012. */
  90013. setGlobalVolume(newVolume: number): void;
  90014. /**
  90015. * Connect the audio engine to an audio analyser allowing some amazing
  90016. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  90017. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  90018. * @param analyser The analyser to connect to the engine
  90019. */
  90020. connectToAnalyser(analyser: Analyser): void;
  90021. }
  90022. }
  90023. declare module BABYLON {
  90024. /**
  90025. * Interface used to present a loading screen while loading a scene
  90026. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  90027. */
  90028. export interface ILoadingScreen {
  90029. /**
  90030. * Function called to display the loading screen
  90031. */
  90032. displayLoadingUI: () => void;
  90033. /**
  90034. * Function called to hide the loading screen
  90035. */
  90036. hideLoadingUI: () => void;
  90037. /**
  90038. * Gets or sets the color to use for the background
  90039. */
  90040. loadingUIBackgroundColor: string;
  90041. /**
  90042. * Gets or sets the text to display while loading
  90043. */
  90044. loadingUIText: string;
  90045. }
  90046. /**
  90047. * Class used for the default loading screen
  90048. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  90049. */
  90050. export class DefaultLoadingScreen implements ILoadingScreen {
  90051. private _renderingCanvas;
  90052. private _loadingText;
  90053. private _loadingDivBackgroundColor;
  90054. private _loadingDiv;
  90055. private _loadingTextDiv;
  90056. /** Gets or sets the logo url to use for the default loading screen */
  90057. static DefaultLogoUrl: string;
  90058. /** Gets or sets the spinner url to use for the default loading screen */
  90059. static DefaultSpinnerUrl: string;
  90060. /**
  90061. * Creates a new default loading screen
  90062. * @param _renderingCanvas defines the canvas used to render the scene
  90063. * @param _loadingText defines the default text to display
  90064. * @param _loadingDivBackgroundColor defines the default background color
  90065. */
  90066. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  90067. /**
  90068. * Function called to display the loading screen
  90069. */
  90070. displayLoadingUI(): void;
  90071. /**
  90072. * Function called to hide the loading screen
  90073. */
  90074. hideLoadingUI(): void;
  90075. /**
  90076. * Gets or sets the text to display while loading
  90077. */
  90078. loadingUIText: string;
  90079. /**
  90080. * Gets or sets the color to use for the background
  90081. */
  90082. loadingUIBackgroundColor: string;
  90083. private _resizeLoadingUI;
  90084. }
  90085. }
  90086. declare module BABYLON {
  90087. /** @hidden */
  90088. export class WebGLPipelineContext implements IPipelineContext {
  90089. engine: Engine;
  90090. program: Nullable<WebGLProgram>;
  90091. context?: WebGLRenderingContext;
  90092. vertexShader?: WebGLShader;
  90093. fragmentShader?: WebGLShader;
  90094. isParallelCompiled: boolean;
  90095. onCompiled?: () => void;
  90096. transformFeedback?: WebGLTransformFeedback | null;
  90097. readonly isAsync: boolean;
  90098. readonly isReady: boolean;
  90099. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  90100. }
  90101. }
  90102. declare module BABYLON {
  90103. /** @hidden */
  90104. export class WebGLDataBuffer extends DataBuffer {
  90105. private _buffer;
  90106. constructor(resource: WebGLBuffer);
  90107. readonly underlyingResource: any;
  90108. }
  90109. }
  90110. declare module BABYLON {
  90111. /** @hidden */
  90112. export class WebGL2ShaderProcessor implements IShaderProcessor {
  90113. attributeProcessor(attribute: string): string;
  90114. varyingProcessor(varying: string, isFragment: boolean): string;
  90115. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  90116. }
  90117. }
  90118. declare module BABYLON {
  90119. /**
  90120. * Settings for finer control over video usage
  90121. */
  90122. export interface VideoTextureSettings {
  90123. /**
  90124. * Applies `autoplay` to video, if specified
  90125. */
  90126. autoPlay?: boolean;
  90127. /**
  90128. * Applies `loop` to video, if specified
  90129. */
  90130. loop?: boolean;
  90131. /**
  90132. * Automatically updates internal texture from video at every frame in the render loop
  90133. */
  90134. autoUpdateTexture: boolean;
  90135. /**
  90136. * Image src displayed during the video loading or until the user interacts with the video.
  90137. */
  90138. poster?: string;
  90139. }
  90140. /**
  90141. * If you want to display a video in your scene, this is the special texture for that.
  90142. * This special texture works similar to other textures, with the exception of a few parameters.
  90143. * @see https://doc.babylonjs.com/how_to/video_texture
  90144. */
  90145. export class VideoTexture extends Texture {
  90146. /**
  90147. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  90148. */
  90149. readonly autoUpdateTexture: boolean;
  90150. /**
  90151. * The video instance used by the texture internally
  90152. */
  90153. readonly video: HTMLVideoElement;
  90154. private _onUserActionRequestedObservable;
  90155. /**
  90156. * Event triggerd when a dom action is required by the user to play the video.
  90157. * This happens due to recent changes in browser policies preventing video to auto start.
  90158. */
  90159. readonly onUserActionRequestedObservable: Observable<Texture>;
  90160. private _generateMipMaps;
  90161. private _engine;
  90162. private _stillImageCaptured;
  90163. private _displayingPosterTexture;
  90164. private _settings;
  90165. private _createInternalTextureOnEvent;
  90166. /**
  90167. * Creates a video texture.
  90168. * If you want to display a video in your scene, this is the special texture for that.
  90169. * This special texture works similar to other textures, with the exception of a few parameters.
  90170. * @see https://doc.babylonjs.com/how_to/video_texture
  90171. * @param name optional name, will detect from video source, if not defined
  90172. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  90173. * @param scene is obviously the current scene.
  90174. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  90175. * @param invertY is false by default but can be used to invert video on Y axis
  90176. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  90177. * @param settings allows finer control over video usage
  90178. */
  90179. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  90180. private _getName;
  90181. private _getVideo;
  90182. private _createInternalTexture;
  90183. private reset;
  90184. /**
  90185. * @hidden Internal method to initiate `update`.
  90186. */
  90187. _rebuild(): void;
  90188. /**
  90189. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  90190. */
  90191. update(): void;
  90192. /**
  90193. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  90194. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  90195. */
  90196. updateTexture(isVisible: boolean): void;
  90197. protected _updateInternalTexture: () => void;
  90198. /**
  90199. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  90200. * @param url New url.
  90201. */
  90202. updateURL(url: string): void;
  90203. /**
  90204. * Dispose the texture and release its associated resources.
  90205. */
  90206. dispose(): void;
  90207. /**
  90208. * Creates a video texture straight from a stream.
  90209. * @param scene Define the scene the texture should be created in
  90210. * @param stream Define the stream the texture should be created from
  90211. * @returns The created video texture as a promise
  90212. */
  90213. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  90214. /**
  90215. * Creates a video texture straight from your WebCam video feed.
  90216. * @param scene Define the scene the texture should be created in
  90217. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  90218. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  90219. * @returns The created video texture as a promise
  90220. */
  90221. static CreateFromWebCamAsync(scene: Scene, constraints: {
  90222. minWidth: number;
  90223. maxWidth: number;
  90224. minHeight: number;
  90225. maxHeight: number;
  90226. deviceId: string;
  90227. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  90228. /**
  90229. * Creates a video texture straight from your WebCam video feed.
  90230. * @param scene Define the scene the texture should be created in
  90231. * @param onReady Define a callback to triggered once the texture will be ready
  90232. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  90233. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  90234. */
  90235. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  90236. minWidth: number;
  90237. maxWidth: number;
  90238. minHeight: number;
  90239. maxHeight: number;
  90240. deviceId: string;
  90241. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  90242. }
  90243. }
  90244. declare module BABYLON {
  90245. /**
  90246. * Interface for attribute information associated with buffer instanciation
  90247. */
  90248. export class InstancingAttributeInfo {
  90249. /**
  90250. * Index/offset of the attribute in the vertex shader
  90251. */
  90252. index: number;
  90253. /**
  90254. * size of the attribute, 1, 2, 3 or 4
  90255. */
  90256. attributeSize: number;
  90257. /**
  90258. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  90259. * default is FLOAT
  90260. */
  90261. attribyteType: number;
  90262. /**
  90263. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  90264. */
  90265. normalized: boolean;
  90266. /**
  90267. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  90268. */
  90269. offset: number;
  90270. /**
  90271. * Name of the GLSL attribute, for debugging purpose only
  90272. */
  90273. attributeName: string;
  90274. }
  90275. /**
  90276. * Define options used to create a depth texture
  90277. */
  90278. export class DepthTextureCreationOptions {
  90279. /** Specifies whether or not a stencil should be allocated in the texture */
  90280. generateStencil?: boolean;
  90281. /** Specifies whether or not bilinear filtering is enable on the texture */
  90282. bilinearFiltering?: boolean;
  90283. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  90284. comparisonFunction?: number;
  90285. /** Specifies if the created texture is a cube texture */
  90286. isCube?: boolean;
  90287. }
  90288. /**
  90289. * Class used to describe the capabilities of the engine relatively to the current browser
  90290. */
  90291. export class EngineCapabilities {
  90292. /** Maximum textures units per fragment shader */
  90293. maxTexturesImageUnits: number;
  90294. /** Maximum texture units per vertex shader */
  90295. maxVertexTextureImageUnits: number;
  90296. /** Maximum textures units in the entire pipeline */
  90297. maxCombinedTexturesImageUnits: number;
  90298. /** Maximum texture size */
  90299. maxTextureSize: number;
  90300. /** Maximum cube texture size */
  90301. maxCubemapTextureSize: number;
  90302. /** Maximum render texture size */
  90303. maxRenderTextureSize: number;
  90304. /** Maximum number of vertex attributes */
  90305. maxVertexAttribs: number;
  90306. /** Maximum number of varyings */
  90307. maxVaryingVectors: number;
  90308. /** Maximum number of uniforms per vertex shader */
  90309. maxVertexUniformVectors: number;
  90310. /** Maximum number of uniforms per fragment shader */
  90311. maxFragmentUniformVectors: number;
  90312. /** Defines if standard derivates (dx/dy) are supported */
  90313. standardDerivatives: boolean;
  90314. /** Defines if s3tc texture compression is supported */
  90315. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  90316. /** Defines if pvrtc texture compression is supported */
  90317. pvrtc: any;
  90318. /** Defines if etc1 texture compression is supported */
  90319. etc1: any;
  90320. /** Defines if etc2 texture compression is supported */
  90321. etc2: any;
  90322. /** Defines if astc texture compression is supported */
  90323. astc: any;
  90324. /** Defines if float textures are supported */
  90325. textureFloat: boolean;
  90326. /** Defines if vertex array objects are supported */
  90327. vertexArrayObject: boolean;
  90328. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  90329. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  90330. /** Gets the maximum level of anisotropy supported */
  90331. maxAnisotropy: number;
  90332. /** Defines if instancing is supported */
  90333. instancedArrays: boolean;
  90334. /** Defines if 32 bits indices are supported */
  90335. uintIndices: boolean;
  90336. /** Defines if high precision shaders are supported */
  90337. highPrecisionShaderSupported: boolean;
  90338. /** Defines if depth reading in the fragment shader is supported */
  90339. fragmentDepthSupported: boolean;
  90340. /** Defines if float texture linear filtering is supported*/
  90341. textureFloatLinearFiltering: boolean;
  90342. /** Defines if rendering to float textures is supported */
  90343. textureFloatRender: boolean;
  90344. /** Defines if half float textures are supported*/
  90345. textureHalfFloat: boolean;
  90346. /** Defines if half float texture linear filtering is supported*/
  90347. textureHalfFloatLinearFiltering: boolean;
  90348. /** Defines if rendering to half float textures is supported */
  90349. textureHalfFloatRender: boolean;
  90350. /** Defines if textureLOD shader command is supported */
  90351. textureLOD: boolean;
  90352. /** Defines if draw buffers extension is supported */
  90353. drawBuffersExtension: boolean;
  90354. /** Defines if depth textures are supported */
  90355. depthTextureExtension: boolean;
  90356. /** Defines if float color buffer are supported */
  90357. colorBufferFloat: boolean;
  90358. /** Gets disjoint timer query extension (null if not supported) */
  90359. timerQuery: EXT_disjoint_timer_query;
  90360. /** Defines if timestamp can be used with timer query */
  90361. canUseTimestampForTimerQuery: boolean;
  90362. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  90363. multiview: any;
  90364. /** Function used to let the system compiles shaders in background */
  90365. parallelShaderCompile: {
  90366. COMPLETION_STATUS_KHR: number;
  90367. };
  90368. }
  90369. /** Interface defining initialization parameters for Engine class */
  90370. export interface EngineOptions extends WebGLContextAttributes {
  90371. /**
  90372. * Defines if the engine should no exceed a specified device ratio
  90373. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  90374. */
  90375. limitDeviceRatio?: number;
  90376. /**
  90377. * Defines if webvr should be enabled automatically
  90378. * @see http://doc.babylonjs.com/how_to/webvr_camera
  90379. */
  90380. autoEnableWebVR?: boolean;
  90381. /**
  90382. * Defines if webgl2 should be turned off even if supported
  90383. * @see http://doc.babylonjs.com/features/webgl2
  90384. */
  90385. disableWebGL2Support?: boolean;
  90386. /**
  90387. * Defines if webaudio should be initialized as well
  90388. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  90389. */
  90390. audioEngine?: boolean;
  90391. /**
  90392. * Defines if animations should run using a deterministic lock step
  90393. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  90394. */
  90395. deterministicLockstep?: boolean;
  90396. /** Defines the maximum steps to use with deterministic lock step mode */
  90397. lockstepMaxSteps?: number;
  90398. /**
  90399. * Defines that engine should ignore context lost events
  90400. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  90401. */
  90402. doNotHandleContextLost?: boolean;
  90403. /**
  90404. * Defines that engine should ignore modifying touch action attribute and style
  90405. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  90406. */
  90407. doNotHandleTouchAction?: boolean;
  90408. /**
  90409. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  90410. */
  90411. useHighPrecisionFloats?: boolean;
  90412. }
  90413. /**
  90414. * Defines the interface used by display changed events
  90415. */
  90416. export interface IDisplayChangedEventArgs {
  90417. /** Gets the vrDisplay object (if any) */
  90418. vrDisplay: Nullable<any>;
  90419. /** Gets a boolean indicating if webVR is supported */
  90420. vrSupported: boolean;
  90421. }
  90422. /**
  90423. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  90424. */
  90425. export class Engine {
  90426. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  90427. static ExceptionList: ({
  90428. key: string;
  90429. capture: string;
  90430. captureConstraint: number;
  90431. targets: string[];
  90432. } | {
  90433. key: string;
  90434. capture: null;
  90435. captureConstraint: null;
  90436. targets: string[];
  90437. })[];
  90438. /** Gets the list of created engines */
  90439. static readonly Instances: Engine[];
  90440. /**
  90441. * Gets the latest created engine
  90442. */
  90443. static readonly LastCreatedEngine: Nullable<Engine>;
  90444. /**
  90445. * Gets the latest created scene
  90446. */
  90447. static readonly LastCreatedScene: Nullable<Scene>;
  90448. /**
  90449. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  90450. * @param flag defines which part of the materials must be marked as dirty
  90451. * @param predicate defines a predicate used to filter which materials should be affected
  90452. */
  90453. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  90454. /** @hidden */
  90455. static _TextureLoaders: IInternalTextureLoader[];
  90456. /** Defines that alpha blending is disabled */
  90457. static readonly ALPHA_DISABLE: number;
  90458. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  90459. static readonly ALPHA_ADD: number;
  90460. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  90461. static readonly ALPHA_COMBINE: number;
  90462. /** Defines that alpha blending to DEST - SRC * DEST */
  90463. static readonly ALPHA_SUBTRACT: number;
  90464. /** Defines that alpha blending to SRC * DEST */
  90465. static readonly ALPHA_MULTIPLY: number;
  90466. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  90467. static readonly ALPHA_MAXIMIZED: number;
  90468. /** Defines that alpha blending to SRC + DEST */
  90469. static readonly ALPHA_ONEONE: number;
  90470. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  90471. static readonly ALPHA_PREMULTIPLIED: number;
  90472. /**
  90473. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  90474. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  90475. */
  90476. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  90477. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  90478. static readonly ALPHA_INTERPOLATE: number;
  90479. /**
  90480. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  90481. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  90482. */
  90483. static readonly ALPHA_SCREENMODE: number;
  90484. /** Defines that the ressource is not delayed*/
  90485. static readonly DELAYLOADSTATE_NONE: number;
  90486. /** Defines that the ressource was successfully delay loaded */
  90487. static readonly DELAYLOADSTATE_LOADED: number;
  90488. /** Defines that the ressource is currently delay loading */
  90489. static readonly DELAYLOADSTATE_LOADING: number;
  90490. /** Defines that the ressource is delayed and has not started loading */
  90491. static readonly DELAYLOADSTATE_NOTLOADED: number;
  90492. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  90493. static readonly NEVER: number;
  90494. /** 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 */
  90495. static readonly ALWAYS: number;
  90496. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  90497. static readonly LESS: number;
  90498. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  90499. static readonly EQUAL: number;
  90500. /** 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 */
  90501. static readonly LEQUAL: number;
  90502. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  90503. static readonly GREATER: number;
  90504. /** 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 */
  90505. static readonly GEQUAL: number;
  90506. /** 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 */
  90507. static readonly NOTEQUAL: number;
  90508. /** Passed to stencilOperation to specify that stencil value must be kept */
  90509. static readonly KEEP: number;
  90510. /** Passed to stencilOperation to specify that stencil value must be replaced */
  90511. static readonly REPLACE: number;
  90512. /** Passed to stencilOperation to specify that stencil value must be incremented */
  90513. static readonly INCR: number;
  90514. /** Passed to stencilOperation to specify that stencil value must be decremented */
  90515. static readonly DECR: number;
  90516. /** Passed to stencilOperation to specify that stencil value must be inverted */
  90517. static readonly INVERT: number;
  90518. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  90519. static readonly INCR_WRAP: number;
  90520. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  90521. static readonly DECR_WRAP: number;
  90522. /** Texture is not repeating outside of 0..1 UVs */
  90523. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  90524. /** Texture is repeating outside of 0..1 UVs */
  90525. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  90526. /** Texture is repeating and mirrored */
  90527. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  90528. /** ALPHA */
  90529. static readonly TEXTUREFORMAT_ALPHA: number;
  90530. /** LUMINANCE */
  90531. static readonly TEXTUREFORMAT_LUMINANCE: number;
  90532. /** LUMINANCE_ALPHA */
  90533. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  90534. /** RGB */
  90535. static readonly TEXTUREFORMAT_RGB: number;
  90536. /** RGBA */
  90537. static readonly TEXTUREFORMAT_RGBA: number;
  90538. /** RED */
  90539. static readonly TEXTUREFORMAT_RED: number;
  90540. /** RED (2nd reference) */
  90541. static readonly TEXTUREFORMAT_R: number;
  90542. /** RG */
  90543. static readonly TEXTUREFORMAT_RG: number;
  90544. /** RED_INTEGER */
  90545. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  90546. /** RED_INTEGER (2nd reference) */
  90547. static readonly TEXTUREFORMAT_R_INTEGER: number;
  90548. /** RG_INTEGER */
  90549. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  90550. /** RGB_INTEGER */
  90551. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  90552. /** RGBA_INTEGER */
  90553. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  90554. /** UNSIGNED_BYTE */
  90555. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  90556. /** UNSIGNED_BYTE (2nd reference) */
  90557. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  90558. /** FLOAT */
  90559. static readonly TEXTURETYPE_FLOAT: number;
  90560. /** HALF_FLOAT */
  90561. static readonly TEXTURETYPE_HALF_FLOAT: number;
  90562. /** BYTE */
  90563. static readonly TEXTURETYPE_BYTE: number;
  90564. /** SHORT */
  90565. static readonly TEXTURETYPE_SHORT: number;
  90566. /** UNSIGNED_SHORT */
  90567. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  90568. /** INT */
  90569. static readonly TEXTURETYPE_INT: number;
  90570. /** UNSIGNED_INT */
  90571. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  90572. /** UNSIGNED_SHORT_4_4_4_4 */
  90573. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  90574. /** UNSIGNED_SHORT_5_5_5_1 */
  90575. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  90576. /** UNSIGNED_SHORT_5_6_5 */
  90577. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  90578. /** UNSIGNED_INT_2_10_10_10_REV */
  90579. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  90580. /** UNSIGNED_INT_24_8 */
  90581. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  90582. /** UNSIGNED_INT_10F_11F_11F_REV */
  90583. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  90584. /** UNSIGNED_INT_5_9_9_9_REV */
  90585. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  90586. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  90587. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  90588. /** nearest is mag = nearest and min = nearest and mip = linear */
  90589. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  90590. /** Bilinear is mag = linear and min = linear and mip = nearest */
  90591. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  90592. /** Trilinear is mag = linear and min = linear and mip = linear */
  90593. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  90594. /** nearest is mag = nearest and min = nearest and mip = linear */
  90595. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  90596. /** Bilinear is mag = linear and min = linear and mip = nearest */
  90597. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  90598. /** Trilinear is mag = linear and min = linear and mip = linear */
  90599. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  90600. /** mag = nearest and min = nearest and mip = nearest */
  90601. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  90602. /** mag = nearest and min = linear and mip = nearest */
  90603. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  90604. /** mag = nearest and min = linear and mip = linear */
  90605. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  90606. /** mag = nearest and min = linear and mip = none */
  90607. static readonly TEXTURE_NEAREST_LINEAR: number;
  90608. /** mag = nearest and min = nearest and mip = none */
  90609. static readonly TEXTURE_NEAREST_NEAREST: number;
  90610. /** mag = linear and min = nearest and mip = nearest */
  90611. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  90612. /** mag = linear and min = nearest and mip = linear */
  90613. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  90614. /** mag = linear and min = linear and mip = none */
  90615. static readonly TEXTURE_LINEAR_LINEAR: number;
  90616. /** mag = linear and min = nearest and mip = none */
  90617. static readonly TEXTURE_LINEAR_NEAREST: number;
  90618. /** Explicit coordinates mode */
  90619. static readonly TEXTURE_EXPLICIT_MODE: number;
  90620. /** Spherical coordinates mode */
  90621. static readonly TEXTURE_SPHERICAL_MODE: number;
  90622. /** Planar coordinates mode */
  90623. static readonly TEXTURE_PLANAR_MODE: number;
  90624. /** Cubic coordinates mode */
  90625. static readonly TEXTURE_CUBIC_MODE: number;
  90626. /** Projection coordinates mode */
  90627. static readonly TEXTURE_PROJECTION_MODE: number;
  90628. /** Skybox coordinates mode */
  90629. static readonly TEXTURE_SKYBOX_MODE: number;
  90630. /** Inverse Cubic coordinates mode */
  90631. static readonly TEXTURE_INVCUBIC_MODE: number;
  90632. /** Equirectangular coordinates mode */
  90633. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  90634. /** Equirectangular Fixed coordinates mode */
  90635. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  90636. /** Equirectangular Fixed Mirrored coordinates mode */
  90637. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  90638. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  90639. static readonly SCALEMODE_FLOOR: number;
  90640. /** Defines that texture rescaling will look for the nearest power of 2 size */
  90641. static readonly SCALEMODE_NEAREST: number;
  90642. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  90643. static readonly SCALEMODE_CEILING: number;
  90644. /**
  90645. * Returns the current npm package of the sdk
  90646. */
  90647. static readonly NpmPackage: string;
  90648. /**
  90649. * Returns the current version of the framework
  90650. */
  90651. static readonly Version: string;
  90652. /**
  90653. * Returns a string describing the current engine
  90654. */
  90655. readonly description: string;
  90656. /**
  90657. * Gets or sets the epsilon value used by collision engine
  90658. */
  90659. static CollisionsEpsilon: number;
  90660. /**
  90661. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  90662. */
  90663. static ShadersRepository: string;
  90664. /**
  90665. * Method called to create the default loading screen.
  90666. * This can be overriden in your own app.
  90667. * @param canvas The rendering canvas element
  90668. * @returns The loading screen
  90669. */
  90670. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  90671. /**
  90672. * Method called to create the default rescale post process on each engine.
  90673. */
  90674. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  90675. /** @hidden */
  90676. _shaderProcessor: IShaderProcessor;
  90677. /**
  90678. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  90679. */
  90680. forcePOTTextures: boolean;
  90681. /**
  90682. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  90683. */
  90684. isFullscreen: boolean;
  90685. /**
  90686. * Gets a boolean indicating if the pointer is currently locked
  90687. */
  90688. isPointerLock: boolean;
  90689. /**
  90690. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  90691. */
  90692. cullBackFaces: boolean;
  90693. /**
  90694. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  90695. */
  90696. renderEvenInBackground: boolean;
  90697. /**
  90698. * Gets or sets a boolean indicating that cache can be kept between frames
  90699. */
  90700. preventCacheWipeBetweenFrames: boolean;
  90701. /**
  90702. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  90703. **/
  90704. enableOfflineSupport: boolean;
  90705. /**
  90706. * 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)
  90707. **/
  90708. disableManifestCheck: boolean;
  90709. /**
  90710. * Gets the list of created scenes
  90711. */
  90712. scenes: Scene[];
  90713. /**
  90714. * Event raised when a new scene is created
  90715. */
  90716. onNewSceneAddedObservable: Observable<Scene>;
  90717. /**
  90718. * Gets the list of created postprocesses
  90719. */
  90720. postProcesses: PostProcess[];
  90721. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  90722. validateShaderPrograms: boolean;
  90723. /**
  90724. * Observable event triggered each time the rendering canvas is resized
  90725. */
  90726. onResizeObservable: Observable<Engine>;
  90727. /**
  90728. * Observable event triggered each time the canvas loses focus
  90729. */
  90730. onCanvasBlurObservable: Observable<Engine>;
  90731. /**
  90732. * Observable event triggered each time the canvas gains focus
  90733. */
  90734. onCanvasFocusObservable: Observable<Engine>;
  90735. /**
  90736. * Observable event triggered each time the canvas receives pointerout event
  90737. */
  90738. onCanvasPointerOutObservable: Observable<PointerEvent>;
  90739. /**
  90740. * Observable event triggered before each texture is initialized
  90741. */
  90742. onBeforeTextureInitObservable: Observable<Texture>;
  90743. /**
  90744. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  90745. */
  90746. disableUniformBuffers: boolean;
  90747. /** @hidden */
  90748. _uniformBuffers: UniformBuffer[];
  90749. /**
  90750. * Gets a boolean indicating that the engine supports uniform buffers
  90751. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  90752. */
  90753. readonly supportsUniformBuffers: boolean;
  90754. /**
  90755. * Observable raised when the engine begins a new frame
  90756. */
  90757. onBeginFrameObservable: Observable<Engine>;
  90758. /**
  90759. * If set, will be used to request the next animation frame for the render loop
  90760. */
  90761. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  90762. /**
  90763. * Observable raised when the engine ends the current frame
  90764. */
  90765. onEndFrameObservable: Observable<Engine>;
  90766. /**
  90767. * Observable raised when the engine is about to compile a shader
  90768. */
  90769. onBeforeShaderCompilationObservable: Observable<Engine>;
  90770. /**
  90771. * Observable raised when the engine has jsut compiled a shader
  90772. */
  90773. onAfterShaderCompilationObservable: Observable<Engine>;
  90774. /** @hidden */
  90775. _gl: WebGLRenderingContext;
  90776. private _renderingCanvas;
  90777. private _windowIsBackground;
  90778. private _webGLVersion;
  90779. protected _highPrecisionShadersAllowed: boolean;
  90780. /** @hidden */
  90781. readonly _shouldUseHighPrecisionShader: boolean;
  90782. /**
  90783. * Gets a boolean indicating that only power of 2 textures are supported
  90784. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  90785. */
  90786. readonly needPOTTextures: boolean;
  90787. /** @hidden */
  90788. _badOS: boolean;
  90789. /** @hidden */
  90790. _badDesktopOS: boolean;
  90791. /**
  90792. * Gets the audio engine
  90793. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  90794. * @ignorenaming
  90795. */
  90796. static audioEngine: IAudioEngine;
  90797. /**
  90798. * Default AudioEngine factory responsible of creating the Audio Engine.
  90799. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  90800. */
  90801. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  90802. /**
  90803. * Default offline support factory responsible of creating a tool used to store data locally.
  90804. * By default, this will create a Database object if the workload has been embedded.
  90805. */
  90806. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  90807. private _onFocus;
  90808. private _onBlur;
  90809. private _onCanvasPointerOut;
  90810. private _onCanvasBlur;
  90811. private _onCanvasFocus;
  90812. private _onFullscreenChange;
  90813. private _onPointerLockChange;
  90814. private _hardwareScalingLevel;
  90815. /** @hidden */
  90816. _caps: EngineCapabilities;
  90817. private _pointerLockRequested;
  90818. private _isStencilEnable;
  90819. private _colorWrite;
  90820. private _loadingScreen;
  90821. /** @hidden */
  90822. _drawCalls: PerfCounter;
  90823. private _glVersion;
  90824. private _glRenderer;
  90825. private _glVendor;
  90826. private _videoTextureSupported;
  90827. private _renderingQueueLaunched;
  90828. private _activeRenderLoops;
  90829. private _deterministicLockstep;
  90830. private _lockstepMaxSteps;
  90831. /**
  90832. * Observable signaled when a context lost event is raised
  90833. */
  90834. onContextLostObservable: Observable<Engine>;
  90835. /**
  90836. * Observable signaled when a context restored event is raised
  90837. */
  90838. onContextRestoredObservable: Observable<Engine>;
  90839. private _onContextLost;
  90840. private _onContextRestored;
  90841. private _contextWasLost;
  90842. /** @hidden */
  90843. _doNotHandleContextLost: boolean;
  90844. /**
  90845. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  90846. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  90847. */
  90848. doNotHandleContextLost: boolean;
  90849. private _performanceMonitor;
  90850. private _fps;
  90851. private _deltaTime;
  90852. /**
  90853. * Turn this value on if you want to pause FPS computation when in background
  90854. */
  90855. disablePerformanceMonitorInBackground: boolean;
  90856. /**
  90857. * Gets the performance monitor attached to this engine
  90858. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  90859. */
  90860. readonly performanceMonitor: PerformanceMonitor;
  90861. /**
  90862. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  90863. */
  90864. disableVertexArrayObjects: boolean;
  90865. /** @hidden */
  90866. protected _depthCullingState: _DepthCullingState;
  90867. /** @hidden */
  90868. protected _stencilState: _StencilState;
  90869. /** @hidden */
  90870. protected _alphaState: _AlphaState;
  90871. /** @hidden */
  90872. protected _alphaMode: number;
  90873. /** @hidden */
  90874. _internalTexturesCache: InternalTexture[];
  90875. /** @hidden */
  90876. protected _activeChannel: number;
  90877. private _currentTextureChannel;
  90878. /** @hidden */
  90879. protected _boundTexturesCache: {
  90880. [key: string]: Nullable<InternalTexture>;
  90881. };
  90882. /** @hidden */
  90883. protected _currentEffect: Nullable<Effect>;
  90884. /** @hidden */
  90885. protected _currentProgram: Nullable<WebGLProgram>;
  90886. private _compiledEffects;
  90887. private _vertexAttribArraysEnabled;
  90888. /** @hidden */
  90889. protected _cachedViewport: Nullable<Viewport>;
  90890. private _cachedVertexArrayObject;
  90891. /** @hidden */
  90892. protected _cachedVertexBuffers: any;
  90893. /** @hidden */
  90894. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  90895. /** @hidden */
  90896. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  90897. /** @hidden */
  90898. _currentRenderTarget: Nullable<InternalTexture>;
  90899. private _uintIndicesCurrentlySet;
  90900. private _currentBoundBuffer;
  90901. /** @hidden */
  90902. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  90903. private _currentBufferPointers;
  90904. private _currentInstanceLocations;
  90905. private _currentInstanceBuffers;
  90906. private _textureUnits;
  90907. /** @hidden */
  90908. _workingCanvas: Nullable<HTMLCanvasElement>;
  90909. /** @hidden */
  90910. _workingContext: Nullable<CanvasRenderingContext2D>;
  90911. private _rescalePostProcess;
  90912. private _dummyFramebuffer;
  90913. private _externalData;
  90914. /** @hidden */
  90915. _bindedRenderFunction: any;
  90916. private _vaoRecordInProgress;
  90917. private _mustWipeVertexAttributes;
  90918. private _emptyTexture;
  90919. private _emptyCubeTexture;
  90920. private _emptyTexture3D;
  90921. /** @hidden */
  90922. _frameHandler: number;
  90923. private _nextFreeTextureSlots;
  90924. private _maxSimultaneousTextures;
  90925. private _activeRequests;
  90926. private _texturesSupported;
  90927. /** @hidden */
  90928. _textureFormatInUse: Nullable<string>;
  90929. /**
  90930. * Gets the list of texture formats supported
  90931. */
  90932. readonly texturesSupported: Array<string>;
  90933. /**
  90934. * Gets the list of texture formats in use
  90935. */
  90936. readonly textureFormatInUse: Nullable<string>;
  90937. /**
  90938. * Gets the current viewport
  90939. */
  90940. readonly currentViewport: Nullable<Viewport>;
  90941. /**
  90942. * Gets the default empty texture
  90943. */
  90944. readonly emptyTexture: InternalTexture;
  90945. /**
  90946. * Gets the default empty 3D texture
  90947. */
  90948. readonly emptyTexture3D: InternalTexture;
  90949. /**
  90950. * Gets the default empty cube texture
  90951. */
  90952. readonly emptyCubeTexture: InternalTexture;
  90953. /**
  90954. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  90955. */
  90956. readonly premultipliedAlpha: boolean;
  90957. /**
  90958. * Creates a new engine
  90959. * @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
  90960. * @param antialias defines enable antialiasing (default: false)
  90961. * @param options defines further options to be sent to the getContext() function
  90962. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  90963. */
  90964. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  90965. /**
  90966. * Initializes a webVR display and starts listening to display change events
  90967. * The onVRDisplayChangedObservable will be notified upon these changes
  90968. * @returns The onVRDisplayChangedObservable
  90969. */
  90970. initWebVR(): Observable<IDisplayChangedEventArgs>;
  90971. /** @hidden */
  90972. _prepareVRComponent(): void;
  90973. /** @hidden */
  90974. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  90975. /** @hidden */
  90976. _submitVRFrame(): void;
  90977. /**
  90978. * Call this function to leave webVR mode
  90979. * Will do nothing if webVR is not supported or if there is no webVR device
  90980. * @see http://doc.babylonjs.com/how_to/webvr_camera
  90981. */
  90982. disableVR(): void;
  90983. /**
  90984. * Gets a boolean indicating that the system is in VR mode and is presenting
  90985. * @returns true if VR mode is engaged
  90986. */
  90987. isVRPresenting(): boolean;
  90988. /** @hidden */
  90989. _requestVRFrame(): void;
  90990. private _disableTouchAction;
  90991. private _rebuildInternalTextures;
  90992. private _rebuildEffects;
  90993. /**
  90994. * Gets a boolean indicating if all created effects are ready
  90995. * @returns true if all effects are ready
  90996. */
  90997. areAllEffectsReady(): boolean;
  90998. private _rebuildBuffers;
  90999. private _initGLContext;
  91000. /**
  91001. * Gets version of the current webGL context
  91002. */
  91003. readonly webGLVersion: number;
  91004. /**
  91005. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  91006. */
  91007. readonly isStencilEnable: boolean;
  91008. /** @hidden */
  91009. _prepareWorkingCanvas(): void;
  91010. /**
  91011. * Reset the texture cache to empty state
  91012. */
  91013. resetTextureCache(): void;
  91014. /**
  91015. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  91016. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  91017. * @returns true if engine is in deterministic lock step mode
  91018. */
  91019. isDeterministicLockStep(): boolean;
  91020. /**
  91021. * Gets the max steps when engine is running in deterministic lock step
  91022. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  91023. * @returns the max steps
  91024. */
  91025. getLockstepMaxSteps(): number;
  91026. /**
  91027. * Gets an object containing information about the current webGL context
  91028. * @returns an object containing the vender, the renderer and the version of the current webGL context
  91029. */
  91030. getGlInfo(): {
  91031. vendor: string;
  91032. renderer: string;
  91033. version: string;
  91034. };
  91035. /**
  91036. * Gets current aspect ratio
  91037. * @param camera defines the camera to use to get the aspect ratio
  91038. * @param useScreen defines if screen size must be used (or the current render target if any)
  91039. * @returns a number defining the aspect ratio
  91040. */
  91041. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  91042. /**
  91043. * Gets current screen aspect ratio
  91044. * @returns a number defining the aspect ratio
  91045. */
  91046. getScreenAspectRatio(): number;
  91047. /**
  91048. * Gets the current render width
  91049. * @param useScreen defines if screen size must be used (or the current render target if any)
  91050. * @returns a number defining the current render width
  91051. */
  91052. getRenderWidth(useScreen?: boolean): number;
  91053. /**
  91054. * Gets the current render height
  91055. * @param useScreen defines if screen size must be used (or the current render target if any)
  91056. * @returns a number defining the current render height
  91057. */
  91058. getRenderHeight(useScreen?: boolean): number;
  91059. /**
  91060. * Gets the HTML canvas attached with the current webGL context
  91061. * @returns a HTML canvas
  91062. */
  91063. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  91064. /**
  91065. * Gets the client rect of the HTML canvas attached with the current webGL context
  91066. * @returns a client rectanglee
  91067. */
  91068. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  91069. /**
  91070. * Defines the hardware scaling level.
  91071. * By default the hardware scaling level is computed from the window device ratio.
  91072. * 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.
  91073. * @param level defines the level to use
  91074. */
  91075. setHardwareScalingLevel(level: number): void;
  91076. /**
  91077. * Gets the current hardware scaling level.
  91078. * By default the hardware scaling level is computed from the window device ratio.
  91079. * 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.
  91080. * @returns a number indicating the current hardware scaling level
  91081. */
  91082. getHardwareScalingLevel(): number;
  91083. /**
  91084. * Gets the list of loaded textures
  91085. * @returns an array containing all loaded textures
  91086. */
  91087. getLoadedTexturesCache(): InternalTexture[];
  91088. /**
  91089. * Gets the object containing all engine capabilities
  91090. * @returns the EngineCapabilities object
  91091. */
  91092. getCaps(): EngineCapabilities;
  91093. /**
  91094. * Gets the current depth function
  91095. * @returns a number defining the depth function
  91096. */
  91097. getDepthFunction(): Nullable<number>;
  91098. /**
  91099. * Sets the current depth function
  91100. * @param depthFunc defines the function to use
  91101. */
  91102. setDepthFunction(depthFunc: number): void;
  91103. /**
  91104. * Sets the current depth function to GREATER
  91105. */
  91106. setDepthFunctionToGreater(): void;
  91107. /**
  91108. * Sets the current depth function to GEQUAL
  91109. */
  91110. setDepthFunctionToGreaterOrEqual(): void;
  91111. /**
  91112. * Sets the current depth function to LESS
  91113. */
  91114. setDepthFunctionToLess(): void;
  91115. private _cachedStencilBuffer;
  91116. private _cachedStencilFunction;
  91117. private _cachedStencilMask;
  91118. private _cachedStencilOperationPass;
  91119. private _cachedStencilOperationFail;
  91120. private _cachedStencilOperationDepthFail;
  91121. private _cachedStencilReference;
  91122. /**
  91123. * Caches the the state of the stencil buffer
  91124. */
  91125. cacheStencilState(): void;
  91126. /**
  91127. * Restores the state of the stencil buffer
  91128. */
  91129. restoreStencilState(): void;
  91130. /**
  91131. * Sets the current depth function to LEQUAL
  91132. */
  91133. setDepthFunctionToLessOrEqual(): void;
  91134. /**
  91135. * Gets a boolean indicating if stencil buffer is enabled
  91136. * @returns the current stencil buffer state
  91137. */
  91138. getStencilBuffer(): boolean;
  91139. /**
  91140. * Enable or disable the stencil buffer
  91141. * @param enable defines if the stencil buffer must be enabled or disabled
  91142. */
  91143. setStencilBuffer(enable: boolean): void;
  91144. /**
  91145. * Gets the current stencil mask
  91146. * @returns a number defining the new stencil mask to use
  91147. */
  91148. getStencilMask(): number;
  91149. /**
  91150. * Sets the current stencil mask
  91151. * @param mask defines the new stencil mask to use
  91152. */
  91153. setStencilMask(mask: number): void;
  91154. /**
  91155. * Gets the current stencil function
  91156. * @returns a number defining the stencil function to use
  91157. */
  91158. getStencilFunction(): number;
  91159. /**
  91160. * Gets the current stencil reference value
  91161. * @returns a number defining the stencil reference value to use
  91162. */
  91163. getStencilFunctionReference(): number;
  91164. /**
  91165. * Gets the current stencil mask
  91166. * @returns a number defining the stencil mask to use
  91167. */
  91168. getStencilFunctionMask(): number;
  91169. /**
  91170. * Sets the current stencil function
  91171. * @param stencilFunc defines the new stencil function to use
  91172. */
  91173. setStencilFunction(stencilFunc: number): void;
  91174. /**
  91175. * Sets the current stencil reference
  91176. * @param reference defines the new stencil reference to use
  91177. */
  91178. setStencilFunctionReference(reference: number): void;
  91179. /**
  91180. * Sets the current stencil mask
  91181. * @param mask defines the new stencil mask to use
  91182. */
  91183. setStencilFunctionMask(mask: number): void;
  91184. /**
  91185. * Gets the current stencil operation when stencil fails
  91186. * @returns a number defining stencil operation to use when stencil fails
  91187. */
  91188. getStencilOperationFail(): number;
  91189. /**
  91190. * Gets the current stencil operation when depth fails
  91191. * @returns a number defining stencil operation to use when depth fails
  91192. */
  91193. getStencilOperationDepthFail(): number;
  91194. /**
  91195. * Gets the current stencil operation when stencil passes
  91196. * @returns a number defining stencil operation to use when stencil passes
  91197. */
  91198. getStencilOperationPass(): number;
  91199. /**
  91200. * Sets the stencil operation to use when stencil fails
  91201. * @param operation defines the stencil operation to use when stencil fails
  91202. */
  91203. setStencilOperationFail(operation: number): void;
  91204. /**
  91205. * Sets the stencil operation to use when depth fails
  91206. * @param operation defines the stencil operation to use when depth fails
  91207. */
  91208. setStencilOperationDepthFail(operation: number): void;
  91209. /**
  91210. * Sets the stencil operation to use when stencil passes
  91211. * @param operation defines the stencil operation to use when stencil passes
  91212. */
  91213. setStencilOperationPass(operation: number): void;
  91214. /**
  91215. * Sets a boolean indicating if the dithering state is enabled or disabled
  91216. * @param value defines the dithering state
  91217. */
  91218. setDitheringState(value: boolean): void;
  91219. /**
  91220. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  91221. * @param value defines the rasterizer state
  91222. */
  91223. setRasterizerState(value: boolean): void;
  91224. /**
  91225. * stop executing a render loop function and remove it from the execution array
  91226. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  91227. */
  91228. stopRenderLoop(renderFunction?: () => void): void;
  91229. /** @hidden */
  91230. _renderLoop(): void;
  91231. /**
  91232. * Register and execute a render loop. The engine can have more than one render function
  91233. * @param renderFunction defines the function to continuously execute
  91234. */
  91235. runRenderLoop(renderFunction: () => void): void;
  91236. /**
  91237. * Toggle full screen mode
  91238. * @param requestPointerLock defines if a pointer lock should be requested from the user
  91239. */
  91240. switchFullscreen(requestPointerLock: boolean): void;
  91241. /**
  91242. * Enters full screen mode
  91243. * @param requestPointerLock defines if a pointer lock should be requested from the user
  91244. */
  91245. enterFullscreen(requestPointerLock: boolean): void;
  91246. /**
  91247. * Exits full screen mode
  91248. */
  91249. exitFullscreen(): void;
  91250. /**
  91251. * Enters Pointerlock mode
  91252. */
  91253. enterPointerlock(): void;
  91254. /**
  91255. * Exits Pointerlock mode
  91256. */
  91257. exitPointerlock(): void;
  91258. /**
  91259. * Clear the current render buffer or the current render target (if any is set up)
  91260. * @param color defines the color to use
  91261. * @param backBuffer defines if the back buffer must be cleared
  91262. * @param depth defines if the depth buffer must be cleared
  91263. * @param stencil defines if the stencil buffer must be cleared
  91264. */
  91265. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  91266. /**
  91267. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  91268. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  91269. * @param y defines the y-coordinate of the corner of the clear rectangle
  91270. * @param width defines the width of the clear rectangle
  91271. * @param height defines the height of the clear rectangle
  91272. * @param clearColor defines the clear color
  91273. */
  91274. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  91275. /**
  91276. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  91277. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  91278. * @param y defines the y-coordinate of the corner of the clear rectangle
  91279. * @param width defines the width of the clear rectangle
  91280. * @param height defines the height of the clear rectangle
  91281. */
  91282. enableScissor(x: number, y: number, width: number, height: number): void;
  91283. /**
  91284. * Disable previously set scissor test rectangle
  91285. */
  91286. disableScissor(): void;
  91287. private _viewportCached;
  91288. /** @hidden */
  91289. _viewport(x: number, y: number, width: number, height: number): void;
  91290. /**
  91291. * Set the WebGL's viewport
  91292. * @param viewport defines the viewport element to be used
  91293. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  91294. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  91295. */
  91296. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  91297. /**
  91298. * Directly set the WebGL Viewport
  91299. * @param x defines the x coordinate of the viewport (in screen space)
  91300. * @param y defines the y coordinate of the viewport (in screen space)
  91301. * @param width defines the width of the viewport (in screen space)
  91302. * @param height defines the height of the viewport (in screen space)
  91303. * @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
  91304. */
  91305. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  91306. /**
  91307. * Begin a new frame
  91308. */
  91309. beginFrame(): void;
  91310. /**
  91311. * Enf the current frame
  91312. */
  91313. endFrame(): void;
  91314. /**
  91315. * Resize the view according to the canvas' size
  91316. */
  91317. resize(): void;
  91318. /**
  91319. * Force a specific size of the canvas
  91320. * @param width defines the new canvas' width
  91321. * @param height defines the new canvas' height
  91322. */
  91323. setSize(width: number, height: number): void;
  91324. /**
  91325. * Binds the frame buffer to the specified texture.
  91326. * @param texture The texture to render to or null for the default canvas
  91327. * @param faceIndex The face of the texture to render to in case of cube texture
  91328. * @param requiredWidth The width of the target to render to
  91329. * @param requiredHeight The height of the target to render to
  91330. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  91331. * @param depthStencilTexture The depth stencil texture to use to render
  91332. * @param lodLevel defines le lod level to bind to the frame buffer
  91333. */
  91334. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  91335. /** @hidden */
  91336. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  91337. /**
  91338. * Unbind the current render target texture from the webGL context
  91339. * @param texture defines the render target texture to unbind
  91340. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  91341. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  91342. */
  91343. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  91344. /**
  91345. * Force the mipmap generation for the given render target texture
  91346. * @param texture defines the render target texture to use
  91347. */
  91348. generateMipMapsForCubemap(texture: InternalTexture): void;
  91349. /**
  91350. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  91351. */
  91352. flushFramebuffer(): void;
  91353. /**
  91354. * Unbind the current render target and bind the default framebuffer
  91355. */
  91356. restoreDefaultFramebuffer(): void;
  91357. /**
  91358. * Create an uniform buffer
  91359. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  91360. * @param elements defines the content of the uniform buffer
  91361. * @returns the webGL uniform buffer
  91362. */
  91363. createUniformBuffer(elements: FloatArray): DataBuffer;
  91364. /**
  91365. * Create a dynamic uniform buffer
  91366. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  91367. * @param elements defines the content of the uniform buffer
  91368. * @returns the webGL uniform buffer
  91369. */
  91370. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  91371. /**
  91372. * Update an existing uniform buffer
  91373. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  91374. * @param uniformBuffer defines the target uniform buffer
  91375. * @param elements defines the content to update
  91376. * @param offset defines the offset in the uniform buffer where update should start
  91377. * @param count defines the size of the data to update
  91378. */
  91379. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  91380. private _resetVertexBufferBinding;
  91381. /**
  91382. * Creates a vertex buffer
  91383. * @param data the data for the vertex buffer
  91384. * @returns the new WebGL static buffer
  91385. */
  91386. createVertexBuffer(data: DataArray): DataBuffer;
  91387. /**
  91388. * Creates a dynamic vertex buffer
  91389. * @param data the data for the dynamic vertex buffer
  91390. * @returns the new WebGL dynamic buffer
  91391. */
  91392. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  91393. /**
  91394. * Update a dynamic index buffer
  91395. * @param indexBuffer defines the target index buffer
  91396. * @param indices defines the data to update
  91397. * @param offset defines the offset in the target index buffer where update should start
  91398. */
  91399. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  91400. /**
  91401. * Updates a dynamic vertex buffer.
  91402. * @param vertexBuffer the vertex buffer to update
  91403. * @param data the data used to update the vertex buffer
  91404. * @param byteOffset the byte offset of the data
  91405. * @param byteLength the byte length of the data
  91406. */
  91407. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  91408. private _resetIndexBufferBinding;
  91409. /**
  91410. * Creates a new index buffer
  91411. * @param indices defines the content of the index buffer
  91412. * @param updatable defines if the index buffer must be updatable
  91413. * @returns a new webGL buffer
  91414. */
  91415. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  91416. /**
  91417. * Bind a webGL buffer to the webGL context
  91418. * @param buffer defines the buffer to bind
  91419. */
  91420. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  91421. /**
  91422. * Bind an uniform buffer to the current webGL context
  91423. * @param buffer defines the buffer to bind
  91424. */
  91425. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  91426. /**
  91427. * Bind a buffer to the current webGL context at a given location
  91428. * @param buffer defines the buffer to bind
  91429. * @param location defines the index where to bind the buffer
  91430. */
  91431. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  91432. /**
  91433. * Bind a specific block at a given index in a specific shader program
  91434. * @param pipelineContext defines the pipeline context to use
  91435. * @param blockName defines the block name
  91436. * @param index defines the index where to bind the block
  91437. */
  91438. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  91439. private bindIndexBuffer;
  91440. private bindBuffer;
  91441. /**
  91442. * update the bound buffer with the given data
  91443. * @param data defines the data to update
  91444. */
  91445. updateArrayBuffer(data: Float32Array): void;
  91446. private _vertexAttribPointer;
  91447. private _bindIndexBufferWithCache;
  91448. private _bindVertexBuffersAttributes;
  91449. /**
  91450. * Records a vertex array object
  91451. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  91452. * @param vertexBuffers defines the list of vertex buffers to store
  91453. * @param indexBuffer defines the index buffer to store
  91454. * @param effect defines the effect to store
  91455. * @returns the new vertex array object
  91456. */
  91457. recordVertexArrayObject(vertexBuffers: {
  91458. [key: string]: VertexBuffer;
  91459. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  91460. /**
  91461. * Bind a specific vertex array object
  91462. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  91463. * @param vertexArrayObject defines the vertex array object to bind
  91464. * @param indexBuffer defines the index buffer to bind
  91465. */
  91466. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  91467. /**
  91468. * Bind webGl buffers directly to the webGL context
  91469. * @param vertexBuffer defines the vertex buffer to bind
  91470. * @param indexBuffer defines the index buffer to bind
  91471. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  91472. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  91473. * @param effect defines the effect associated with the vertex buffer
  91474. */
  91475. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  91476. private _unbindVertexArrayObject;
  91477. /**
  91478. * Bind a list of vertex buffers to the webGL context
  91479. * @param vertexBuffers defines the list of vertex buffers to bind
  91480. * @param indexBuffer defines the index buffer to bind
  91481. * @param effect defines the effect associated with the vertex buffers
  91482. */
  91483. bindBuffers(vertexBuffers: {
  91484. [key: string]: Nullable<VertexBuffer>;
  91485. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  91486. /**
  91487. * Unbind all instance attributes
  91488. */
  91489. unbindInstanceAttributes(): void;
  91490. /**
  91491. * Release and free the memory of a vertex array object
  91492. * @param vao defines the vertex array object to delete
  91493. */
  91494. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  91495. /** @hidden */
  91496. _releaseBuffer(buffer: DataBuffer): boolean;
  91497. /**
  91498. * Creates a webGL buffer to use with instanciation
  91499. * @param capacity defines the size of the buffer
  91500. * @returns the webGL buffer
  91501. */
  91502. createInstancesBuffer(capacity: number): DataBuffer;
  91503. /**
  91504. * Delete a webGL buffer used with instanciation
  91505. * @param buffer defines the webGL buffer to delete
  91506. */
  91507. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  91508. /**
  91509. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  91510. * @param instancesBuffer defines the webGL buffer to update and bind
  91511. * @param data defines the data to store in the buffer
  91512. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  91513. */
  91514. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  91515. /**
  91516. * Apply all cached states (depth, culling, stencil and alpha)
  91517. */
  91518. applyStates(): void;
  91519. /**
  91520. * Send a draw order
  91521. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  91522. * @param indexStart defines the starting index
  91523. * @param indexCount defines the number of index to draw
  91524. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  91525. */
  91526. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  91527. /**
  91528. * Draw a list of points
  91529. * @param verticesStart defines the index of first vertex to draw
  91530. * @param verticesCount defines the count of vertices to draw
  91531. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  91532. */
  91533. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  91534. /**
  91535. * Draw a list of unindexed primitives
  91536. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  91537. * @param verticesStart defines the index of first vertex to draw
  91538. * @param verticesCount defines the count of vertices to draw
  91539. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  91540. */
  91541. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  91542. /**
  91543. * Draw a list of indexed primitives
  91544. * @param fillMode defines the primitive to use
  91545. * @param indexStart defines the starting index
  91546. * @param indexCount defines the number of index to draw
  91547. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  91548. */
  91549. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  91550. /**
  91551. * Draw a list of unindexed primitives
  91552. * @param fillMode defines the primitive to use
  91553. * @param verticesStart defines the index of first vertex to draw
  91554. * @param verticesCount defines the count of vertices to draw
  91555. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  91556. */
  91557. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  91558. private _drawMode;
  91559. /** @hidden */
  91560. _releaseEffect(effect: Effect): void;
  91561. /** @hidden */
  91562. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  91563. /**
  91564. * Create a new effect (used to store vertex/fragment shaders)
  91565. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  91566. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  91567. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  91568. * @param samplers defines an array of string used to represent textures
  91569. * @param defines defines the string containing the defines to use to compile the shaders
  91570. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  91571. * @param onCompiled defines a function to call when the effect creation is successful
  91572. * @param onError defines a function to call when the effect creation has failed
  91573. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  91574. * @returns the new Effect
  91575. */
  91576. 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;
  91577. private _compileShader;
  91578. private _compileRawShader;
  91579. /**
  91580. * Directly creates a webGL program
  91581. * @param pipelineContext defines the pipeline context to attach to
  91582. * @param vertexCode defines the vertex shader code to use
  91583. * @param fragmentCode defines the fragment shader code to use
  91584. * @param context defines the webGL context to use (if not set, the current one will be used)
  91585. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  91586. * @returns the new webGL program
  91587. */
  91588. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  91589. /**
  91590. * Creates a webGL program
  91591. * @param pipelineContext defines the pipeline context to attach to
  91592. * @param vertexCode defines the vertex shader code to use
  91593. * @param fragmentCode defines the fragment shader code to use
  91594. * @param defines defines the string containing the defines to use to compile the shaders
  91595. * @param context defines the webGL context to use (if not set, the current one will be used)
  91596. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  91597. * @returns the new webGL program
  91598. */
  91599. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  91600. /**
  91601. * Creates a new pipeline context
  91602. * @returns the new pipeline
  91603. */
  91604. createPipelineContext(): WebGLPipelineContext;
  91605. private _createShaderProgram;
  91606. private _finalizePipelineContext;
  91607. /** @hidden */
  91608. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  91609. /** @hidden */
  91610. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  91611. /** @hidden */
  91612. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  91613. /**
  91614. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  91615. * @param pipelineContext defines the pipeline context to use
  91616. * @param uniformsNames defines the list of uniform names
  91617. * @returns an array of webGL uniform locations
  91618. */
  91619. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  91620. /**
  91621. * Gets the lsit of active attributes for a given webGL program
  91622. * @param pipelineContext defines the pipeline context to use
  91623. * @param attributesNames defines the list of attribute names to get
  91624. * @returns an array of indices indicating the offset of each attribute
  91625. */
  91626. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  91627. /**
  91628. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  91629. * @param effect defines the effect to activate
  91630. */
  91631. enableEffect(effect: Nullable<Effect>): void;
  91632. /**
  91633. * Set the value of an uniform to an array of int32
  91634. * @param uniform defines the webGL uniform location where to store the value
  91635. * @param array defines the array of int32 to store
  91636. */
  91637. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  91638. /**
  91639. * Set the value of an uniform to an array of int32 (stored as vec2)
  91640. * @param uniform defines the webGL uniform location where to store the value
  91641. * @param array defines the array of int32 to store
  91642. */
  91643. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  91644. /**
  91645. * Set the value of an uniform to an array of int32 (stored as vec3)
  91646. * @param uniform defines the webGL uniform location where to store the value
  91647. * @param array defines the array of int32 to store
  91648. */
  91649. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  91650. /**
  91651. * Set the value of an uniform to an array of int32 (stored as vec4)
  91652. * @param uniform defines the webGL uniform location where to store the value
  91653. * @param array defines the array of int32 to store
  91654. */
  91655. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  91656. /**
  91657. * Set the value of an uniform to an array of float32
  91658. * @param uniform defines the webGL uniform location where to store the value
  91659. * @param array defines the array of float32 to store
  91660. */
  91661. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  91662. /**
  91663. * Set the value of an uniform to an array of float32 (stored as vec2)
  91664. * @param uniform defines the webGL uniform location where to store the value
  91665. * @param array defines the array of float32 to store
  91666. */
  91667. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  91668. /**
  91669. * Set the value of an uniform to an array of float32 (stored as vec3)
  91670. * @param uniform defines the webGL uniform location where to store the value
  91671. * @param array defines the array of float32 to store
  91672. */
  91673. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  91674. /**
  91675. * Set the value of an uniform to an array of float32 (stored as vec4)
  91676. * @param uniform defines the webGL uniform location where to store the value
  91677. * @param array defines the array of float32 to store
  91678. */
  91679. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  91680. /**
  91681. * Set the value of an uniform to an array of number
  91682. * @param uniform defines the webGL uniform location where to store the value
  91683. * @param array defines the array of number to store
  91684. */
  91685. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  91686. /**
  91687. * Set the value of an uniform to an array of number (stored as vec2)
  91688. * @param uniform defines the webGL uniform location where to store the value
  91689. * @param array defines the array of number to store
  91690. */
  91691. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  91692. /**
  91693. * Set the value of an uniform to an array of number (stored as vec3)
  91694. * @param uniform defines the webGL uniform location where to store the value
  91695. * @param array defines the array of number to store
  91696. */
  91697. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  91698. /**
  91699. * Set the value of an uniform to an array of number (stored as vec4)
  91700. * @param uniform defines the webGL uniform location where to store the value
  91701. * @param array defines the array of number to store
  91702. */
  91703. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  91704. /**
  91705. * Set the value of an uniform to an array of float32 (stored as matrices)
  91706. * @param uniform defines the webGL uniform location where to store the value
  91707. * @param matrices defines the array of float32 to store
  91708. */
  91709. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  91710. /**
  91711. * Set the value of an uniform to a matrix
  91712. * @param uniform defines the webGL uniform location where to store the value
  91713. * @param matrix defines the matrix to store
  91714. */
  91715. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  91716. /**
  91717. * Set the value of an uniform to a matrix (3x3)
  91718. * @param uniform defines the webGL uniform location where to store the value
  91719. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  91720. */
  91721. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  91722. /**
  91723. * Set the value of an uniform to a matrix (2x2)
  91724. * @param uniform defines the webGL uniform location where to store the value
  91725. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  91726. */
  91727. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  91728. /**
  91729. * Set the value of an uniform to a number (int)
  91730. * @param uniform defines the webGL uniform location where to store the value
  91731. * @param value defines the int number to store
  91732. */
  91733. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  91734. /**
  91735. * Set the value of an uniform to a number (float)
  91736. * @param uniform defines the webGL uniform location where to store the value
  91737. * @param value defines the float number to store
  91738. */
  91739. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  91740. /**
  91741. * Set the value of an uniform to a vec2
  91742. * @param uniform defines the webGL uniform location where to store the value
  91743. * @param x defines the 1st component of the value
  91744. * @param y defines the 2nd component of the value
  91745. */
  91746. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  91747. /**
  91748. * Set the value of an uniform to a vec3
  91749. * @param uniform defines the webGL uniform location where to store the value
  91750. * @param x defines the 1st component of the value
  91751. * @param y defines the 2nd component of the value
  91752. * @param z defines the 3rd component of the value
  91753. */
  91754. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  91755. /**
  91756. * Set the value of an uniform to a boolean
  91757. * @param uniform defines the webGL uniform location where to store the value
  91758. * @param bool defines the boolean to store
  91759. */
  91760. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  91761. /**
  91762. * Set the value of an uniform to a vec4
  91763. * @param uniform defines the webGL uniform location where to store the value
  91764. * @param x defines the 1st component of the value
  91765. * @param y defines the 2nd component of the value
  91766. * @param z defines the 3rd component of the value
  91767. * @param w defines the 4th component of the value
  91768. */
  91769. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  91770. /**
  91771. * Set the value of an uniform to a Color3
  91772. * @param uniform defines the webGL uniform location where to store the value
  91773. * @param color3 defines the color to store
  91774. */
  91775. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  91776. /**
  91777. * Set the value of an uniform to a Color3 and an alpha value
  91778. * @param uniform defines the webGL uniform location where to store the value
  91779. * @param color3 defines the color to store
  91780. * @param alpha defines the alpha component to store
  91781. */
  91782. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  91783. /**
  91784. * Sets a Color4 on a uniform variable
  91785. * @param uniform defines the uniform location
  91786. * @param color4 defines the value to be set
  91787. */
  91788. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  91789. /**
  91790. * Set various states to the webGL context
  91791. * @param culling defines backface culling state
  91792. * @param zOffset defines the value to apply to zOffset (0 by default)
  91793. * @param force defines if states must be applied even if cache is up to date
  91794. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  91795. */
  91796. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  91797. /**
  91798. * Set the z offset to apply to current rendering
  91799. * @param value defines the offset to apply
  91800. */
  91801. setZOffset(value: number): void;
  91802. /**
  91803. * Gets the current value of the zOffset
  91804. * @returns the current zOffset state
  91805. */
  91806. getZOffset(): number;
  91807. /**
  91808. * Enable or disable depth buffering
  91809. * @param enable defines the state to set
  91810. */
  91811. setDepthBuffer(enable: boolean): void;
  91812. /**
  91813. * Gets a boolean indicating if depth writing is enabled
  91814. * @returns the current depth writing state
  91815. */
  91816. getDepthWrite(): boolean;
  91817. /**
  91818. * Enable or disable depth writing
  91819. * @param enable defines the state to set
  91820. */
  91821. setDepthWrite(enable: boolean): void;
  91822. /**
  91823. * Enable or disable color writing
  91824. * @param enable defines the state to set
  91825. */
  91826. setColorWrite(enable: boolean): void;
  91827. /**
  91828. * Gets a boolean indicating if color writing is enabled
  91829. * @returns the current color writing state
  91830. */
  91831. getColorWrite(): boolean;
  91832. /**
  91833. * Sets alpha constants used by some alpha blending modes
  91834. * @param r defines the red component
  91835. * @param g defines the green component
  91836. * @param b defines the blue component
  91837. * @param a defines the alpha component
  91838. */
  91839. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  91840. /**
  91841. * Sets the current alpha mode
  91842. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  91843. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  91844. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  91845. */
  91846. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  91847. /**
  91848. * Gets the current alpha mode
  91849. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  91850. * @returns the current alpha mode
  91851. */
  91852. getAlphaMode(): number;
  91853. /**
  91854. * Clears the list of texture accessible through engine.
  91855. * This can help preventing texture load conflict due to name collision.
  91856. */
  91857. clearInternalTexturesCache(): void;
  91858. /**
  91859. * Force the entire cache to be cleared
  91860. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  91861. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  91862. */
  91863. wipeCaches(bruteForce?: boolean): void;
  91864. /**
  91865. * Set the compressed texture format to use, based on the formats you have, and the formats
  91866. * supported by the hardware / browser.
  91867. *
  91868. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  91869. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  91870. * to API arguments needed to compressed textures. This puts the burden on the container
  91871. * generator to house the arcane code for determining these for current & future formats.
  91872. *
  91873. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  91874. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  91875. *
  91876. * Note: The result of this call is not taken into account when a texture is base64.
  91877. *
  91878. * @param formatsAvailable defines the list of those format families you have created
  91879. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  91880. *
  91881. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  91882. * @returns The extension selected.
  91883. */
  91884. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  91885. /** @hidden */
  91886. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  91887. min: number;
  91888. mag: number;
  91889. };
  91890. /** @hidden */
  91891. _createTexture(): WebGLTexture;
  91892. /**
  91893. * Usually called from Texture.ts.
  91894. * Passed information to create a WebGLTexture
  91895. * @param urlArg defines a value which contains one of the following:
  91896. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  91897. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  91898. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  91899. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  91900. * @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)
  91901. * @param scene needed for loading to the correct scene
  91902. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  91903. * @param onLoad optional callback to be called upon successful completion
  91904. * @param onError optional callback to be called upon failure
  91905. * @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
  91906. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  91907. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  91908. * @param forcedExtension defines the extension to use to pick the right loader
  91909. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  91910. * @returns a InternalTexture for assignment back into BABYLON.Texture
  91911. */
  91912. 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;
  91913. /**
  91914. * @hidden
  91915. * Rescales a texture
  91916. * @param source input texutre
  91917. * @param destination destination texture
  91918. * @param scene scene to use to render the resize
  91919. * @param internalFormat format to use when resizing
  91920. * @param onComplete callback to be called when resize has completed
  91921. */
  91922. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  91923. private _unpackFlipYCached;
  91924. /**
  91925. * In case you are sharing the context with other applications, it might
  91926. * be interested to not cache the unpack flip y state to ensure a consistent
  91927. * value would be set.
  91928. */
  91929. enableUnpackFlipYCached: boolean;
  91930. /** @hidden */
  91931. _unpackFlipY(value: boolean): void;
  91932. /** @hidden */
  91933. _getUnpackAlignement(): number;
  91934. /**
  91935. * Creates a dynamic texture
  91936. * @param width defines the width of the texture
  91937. * @param height defines the height of the texture
  91938. * @param generateMipMaps defines if the engine should generate the mip levels
  91939. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  91940. * @returns the dynamic texture inside an InternalTexture
  91941. */
  91942. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  91943. /**
  91944. * Update the sampling mode of a given texture
  91945. * @param samplingMode defines the required sampling mode
  91946. * @param texture defines the texture to update
  91947. */
  91948. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  91949. /**
  91950. * Update the content of a dynamic texture
  91951. * @param texture defines the texture to update
  91952. * @param canvas defines the canvas containing the source
  91953. * @param invertY defines if data must be stored with Y axis inverted
  91954. * @param premulAlpha defines if alpha is stored as premultiplied
  91955. * @param format defines the format of the data
  91956. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  91957. */
  91958. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  91959. /**
  91960. * Update a video texture
  91961. * @param texture defines the texture to update
  91962. * @param video defines the video element to use
  91963. * @param invertY defines if data must be stored with Y axis inverted
  91964. */
  91965. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  91966. /**
  91967. * Updates a depth texture Comparison Mode and Function.
  91968. * If the comparison Function is equal to 0, the mode will be set to none.
  91969. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  91970. * @param texture The texture to set the comparison function for
  91971. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  91972. */
  91973. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  91974. /** @hidden */
  91975. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  91976. width: number;
  91977. height: number;
  91978. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  91979. /**
  91980. * Creates a depth stencil texture.
  91981. * This is only available in WebGL 2 or with the depth texture extension available.
  91982. * @param size The size of face edge in the texture.
  91983. * @param options The options defining the texture.
  91984. * @returns The texture
  91985. */
  91986. createDepthStencilTexture(size: number | {
  91987. width: number;
  91988. height: number;
  91989. }, options: DepthTextureCreationOptions): InternalTexture;
  91990. /**
  91991. * Creates a depth stencil texture.
  91992. * This is only available in WebGL 2 or with the depth texture extension available.
  91993. * @param size The size of face edge in the texture.
  91994. * @param options The options defining the texture.
  91995. * @returns The texture
  91996. */
  91997. private _createDepthStencilTexture;
  91998. /**
  91999. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  92000. * @param renderTarget The render target to set the frame buffer for
  92001. */
  92002. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  92003. /**
  92004. * Creates a new render target texture
  92005. * @param size defines the size of the texture
  92006. * @param options defines the options used to create the texture
  92007. * @returns a new render target texture stored in an InternalTexture
  92008. */
  92009. createRenderTargetTexture(size: number | {
  92010. width: number;
  92011. height: number;
  92012. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  92013. /** @hidden */
  92014. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  92015. /**
  92016. * Updates the sample count of a render target texture
  92017. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  92018. * @param texture defines the texture to update
  92019. * @param samples defines the sample count to set
  92020. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  92021. */
  92022. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  92023. /** @hidden */
  92024. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  92025. /** @hidden */
  92026. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  92027. /** @hidden */
  92028. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  92029. /** @hidden */
  92030. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  92031. /**
  92032. * @hidden
  92033. */
  92034. _setCubeMapTextureParams(loadMipmap: boolean): void;
  92035. private _prepareWebGLTextureContinuation;
  92036. private _prepareWebGLTexture;
  92037. /** @hidden */
  92038. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  92039. /** @hidden */
  92040. _releaseFramebufferObjects(texture: InternalTexture): void;
  92041. /** @hidden */
  92042. _releaseTexture(texture: InternalTexture): void;
  92043. private setProgram;
  92044. private _boundUniforms;
  92045. /**
  92046. * Binds an effect to the webGL context
  92047. * @param effect defines the effect to bind
  92048. */
  92049. bindSamplers(effect: Effect): void;
  92050. private _activateCurrentTexture;
  92051. /** @hidden */
  92052. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  92053. /** @hidden */
  92054. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  92055. /**
  92056. * Sets a texture to the webGL context from a postprocess
  92057. * @param channel defines the channel to use
  92058. * @param postProcess defines the source postprocess
  92059. */
  92060. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  92061. /**
  92062. * Binds the output of the passed in post process to the texture channel specified
  92063. * @param channel The channel the texture should be bound to
  92064. * @param postProcess The post process which's output should be bound
  92065. */
  92066. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  92067. /**
  92068. * Unbind all textures from the webGL context
  92069. */
  92070. unbindAllTextures(): void;
  92071. /**
  92072. * Sets a texture to the according uniform.
  92073. * @param channel The texture channel
  92074. * @param uniform The uniform to set
  92075. * @param texture The texture to apply
  92076. */
  92077. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  92078. /**
  92079. * Sets a depth stencil texture from a render target to the according uniform.
  92080. * @param channel The texture channel
  92081. * @param uniform The uniform to set
  92082. * @param texture The render target texture containing the depth stencil texture to apply
  92083. */
  92084. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  92085. private _bindSamplerUniformToChannel;
  92086. private _getTextureWrapMode;
  92087. private _setTexture;
  92088. /**
  92089. * Sets an array of texture to the webGL context
  92090. * @param channel defines the channel where the texture array must be set
  92091. * @param uniform defines the associated uniform location
  92092. * @param textures defines the array of textures to bind
  92093. */
  92094. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  92095. /** @hidden */
  92096. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  92097. private _setTextureParameterFloat;
  92098. private _setTextureParameterInteger;
  92099. /**
  92100. * Reads pixels from the current frame buffer. Please note that this function can be slow
  92101. * @param x defines the x coordinate of the rectangle where pixels must be read
  92102. * @param y defines the y coordinate of the rectangle where pixels must be read
  92103. * @param width defines the width of the rectangle where pixels must be read
  92104. * @param height defines the height of the rectangle where pixels must be read
  92105. * @returns a Uint8Array containing RGBA colors
  92106. */
  92107. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  92108. /**
  92109. * Add an externaly attached data from its key.
  92110. * This method call will fail and return false, if such key already exists.
  92111. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  92112. * @param key the unique key that identifies the data
  92113. * @param data the data object to associate to the key for this Engine instance
  92114. * @return true if no such key were already present and the data was added successfully, false otherwise
  92115. */
  92116. addExternalData<T>(key: string, data: T): boolean;
  92117. /**
  92118. * Get an externaly attached data from its key
  92119. * @param key the unique key that identifies the data
  92120. * @return the associated data, if present (can be null), or undefined if not present
  92121. */
  92122. getExternalData<T>(key: string): T;
  92123. /**
  92124. * Get an externaly attached data from its key, create it using a factory if it's not already present
  92125. * @param key the unique key that identifies the data
  92126. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  92127. * @return the associated data, can be null if the factory returned null.
  92128. */
  92129. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  92130. /**
  92131. * Remove an externaly attached data from the Engine instance
  92132. * @param key the unique key that identifies the data
  92133. * @return true if the data was successfully removed, false if it doesn't exist
  92134. */
  92135. removeExternalData(key: string): boolean;
  92136. /**
  92137. * Unbind all vertex attributes from the webGL context
  92138. */
  92139. unbindAllAttributes(): void;
  92140. /**
  92141. * 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
  92142. */
  92143. releaseEffects(): void;
  92144. /**
  92145. * Dispose and release all associated resources
  92146. */
  92147. dispose(): void;
  92148. /**
  92149. * Display the loading screen
  92150. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  92151. */
  92152. displayLoadingUI(): void;
  92153. /**
  92154. * Hide the loading screen
  92155. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  92156. */
  92157. hideLoadingUI(): void;
  92158. /**
  92159. * Gets the current loading screen object
  92160. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  92161. */
  92162. /**
  92163. * Sets the current loading screen object
  92164. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  92165. */
  92166. loadingScreen: ILoadingScreen;
  92167. /**
  92168. * Sets the current loading screen text
  92169. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  92170. */
  92171. loadingUIText: string;
  92172. /**
  92173. * Sets the current loading screen background color
  92174. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  92175. */
  92176. loadingUIBackgroundColor: string;
  92177. /**
  92178. * Attach a new callback raised when context lost event is fired
  92179. * @param callback defines the callback to call
  92180. */
  92181. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  92182. /**
  92183. * Attach a new callback raised when context restored event is fired
  92184. * @param callback defines the callback to call
  92185. */
  92186. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  92187. /**
  92188. * Gets the source code of the vertex shader associated with a specific webGL program
  92189. * @param program defines the program to use
  92190. * @returns a string containing the source code of the vertex shader associated with the program
  92191. */
  92192. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  92193. /**
  92194. * Gets the source code of the fragment shader associated with a specific webGL program
  92195. * @param program defines the program to use
  92196. * @returns a string containing the source code of the fragment shader associated with the program
  92197. */
  92198. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  92199. /**
  92200. * Get the current error code of the webGL context
  92201. * @returns the error code
  92202. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  92203. */
  92204. getError(): number;
  92205. /**
  92206. * Gets the current framerate
  92207. * @returns a number representing the framerate
  92208. */
  92209. getFps(): number;
  92210. /**
  92211. * Gets the time spent between current and previous frame
  92212. * @returns a number representing the delta time in ms
  92213. */
  92214. getDeltaTime(): number;
  92215. private _measureFps;
  92216. /** @hidden */
  92217. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  92218. private _canRenderToFloatFramebuffer;
  92219. private _canRenderToHalfFloatFramebuffer;
  92220. private _canRenderToFramebuffer;
  92221. /** @hidden */
  92222. _getWebGLTextureType(type: number): number;
  92223. /** @hidden */
  92224. _getInternalFormat(format: number): number;
  92225. /** @hidden */
  92226. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  92227. /** @hidden */
  92228. _getRGBAMultiSampleBufferFormat(type: number): number;
  92229. /** @hidden */
  92230. _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;
  92231. /** @hidden */
  92232. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  92233. /**
  92234. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  92235. * @returns true if the engine can be created
  92236. * @ignorenaming
  92237. */
  92238. static isSupported(): boolean;
  92239. }
  92240. }
  92241. declare module BABYLON {
  92242. /**
  92243. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  92244. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  92245. */
  92246. export class EffectFallbacks {
  92247. private _defines;
  92248. private _currentRank;
  92249. private _maxRank;
  92250. private _mesh;
  92251. /**
  92252. * Removes the fallback from the bound mesh.
  92253. */
  92254. unBindMesh(): void;
  92255. /**
  92256. * Adds a fallback on the specified property.
  92257. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  92258. * @param define The name of the define in the shader
  92259. */
  92260. addFallback(rank: number, define: string): void;
  92261. /**
  92262. * Sets the mesh to use CPU skinning when needing to fallback.
  92263. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  92264. * @param mesh The mesh to use the fallbacks.
  92265. */
  92266. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  92267. /**
  92268. * Checks to see if more fallbacks are still availible.
  92269. */
  92270. readonly isMoreFallbacks: boolean;
  92271. /**
  92272. * Removes the defines that should be removed when falling back.
  92273. * @param currentDefines defines the current define statements for the shader.
  92274. * @param effect defines the current effect we try to compile
  92275. * @returns The resulting defines with defines of the current rank removed.
  92276. */
  92277. reduce(currentDefines: string, effect: Effect): string;
  92278. }
  92279. /**
  92280. * Options to be used when creating an effect.
  92281. */
  92282. export class EffectCreationOptions {
  92283. /**
  92284. * Atrributes that will be used in the shader.
  92285. */
  92286. attributes: string[];
  92287. /**
  92288. * Uniform varible names that will be set in the shader.
  92289. */
  92290. uniformsNames: string[];
  92291. /**
  92292. * Uniform buffer varible names that will be set in the shader.
  92293. */
  92294. uniformBuffersNames: string[];
  92295. /**
  92296. * Sampler texture variable names that will be set in the shader.
  92297. */
  92298. samplers: string[];
  92299. /**
  92300. * Define statements that will be set in the shader.
  92301. */
  92302. defines: any;
  92303. /**
  92304. * Possible fallbacks for this effect to improve performance when needed.
  92305. */
  92306. fallbacks: Nullable<EffectFallbacks>;
  92307. /**
  92308. * Callback that will be called when the shader is compiled.
  92309. */
  92310. onCompiled: Nullable<(effect: Effect) => void>;
  92311. /**
  92312. * Callback that will be called if an error occurs during shader compilation.
  92313. */
  92314. onError: Nullable<(effect: Effect, errors: string) => void>;
  92315. /**
  92316. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  92317. */
  92318. indexParameters: any;
  92319. /**
  92320. * Max number of lights that can be used in the shader.
  92321. */
  92322. maxSimultaneousLights: number;
  92323. /**
  92324. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  92325. */
  92326. transformFeedbackVaryings: Nullable<string[]>;
  92327. }
  92328. /**
  92329. * Effect containing vertex and fragment shader that can be executed on an object.
  92330. */
  92331. export class Effect implements IDisposable {
  92332. /**
  92333. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  92334. */
  92335. static ShadersRepository: string;
  92336. /**
  92337. * Name of the effect.
  92338. */
  92339. name: any;
  92340. /**
  92341. * String container all the define statements that should be set on the shader.
  92342. */
  92343. defines: string;
  92344. /**
  92345. * Callback that will be called when the shader is compiled.
  92346. */
  92347. onCompiled: Nullable<(effect: Effect) => void>;
  92348. /**
  92349. * Callback that will be called if an error occurs during shader compilation.
  92350. */
  92351. onError: Nullable<(effect: Effect, errors: string) => void>;
  92352. /**
  92353. * Callback that will be called when effect is bound.
  92354. */
  92355. onBind: Nullable<(effect: Effect) => void>;
  92356. /**
  92357. * Unique ID of the effect.
  92358. */
  92359. uniqueId: number;
  92360. /**
  92361. * Observable that will be called when the shader is compiled.
  92362. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  92363. */
  92364. onCompileObservable: Observable<Effect>;
  92365. /**
  92366. * Observable that will be called if an error occurs during shader compilation.
  92367. */
  92368. onErrorObservable: Observable<Effect>;
  92369. /** @hidden */
  92370. _onBindObservable: Nullable<Observable<Effect>>;
  92371. /**
  92372. * Observable that will be called when effect is bound.
  92373. */
  92374. readonly onBindObservable: Observable<Effect>;
  92375. /** @hidden */
  92376. _bonesComputationForcedToCPU: boolean;
  92377. private static _uniqueIdSeed;
  92378. private _engine;
  92379. private _uniformBuffersNames;
  92380. private _uniformsNames;
  92381. private _samplerList;
  92382. private _samplers;
  92383. private _isReady;
  92384. private _compilationError;
  92385. private _attributesNames;
  92386. private _attributes;
  92387. private _uniforms;
  92388. /**
  92389. * Key for the effect.
  92390. * @hidden
  92391. */
  92392. _key: string;
  92393. private _indexParameters;
  92394. private _fallbacks;
  92395. private _vertexSourceCode;
  92396. private _fragmentSourceCode;
  92397. private _vertexSourceCodeOverride;
  92398. private _fragmentSourceCodeOverride;
  92399. private _transformFeedbackVaryings;
  92400. /**
  92401. * Compiled shader to webGL program.
  92402. * @hidden
  92403. */
  92404. _pipelineContext: Nullable<IPipelineContext>;
  92405. private _valueCache;
  92406. private static _baseCache;
  92407. /**
  92408. * Instantiates an effect.
  92409. * An effect can be used to create/manage/execute vertex and fragment shaders.
  92410. * @param baseName Name of the effect.
  92411. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  92412. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  92413. * @param samplers List of sampler variables that will be passed to the shader.
  92414. * @param engine Engine to be used to render the effect
  92415. * @param defines Define statements to be added to the shader.
  92416. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  92417. * @param onCompiled Callback that will be called when the shader is compiled.
  92418. * @param onError Callback that will be called if an error occurs during shader compilation.
  92419. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  92420. */
  92421. 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);
  92422. private _useFinalCode;
  92423. /**
  92424. * Unique key for this effect
  92425. */
  92426. readonly key: string;
  92427. /**
  92428. * If the effect has been compiled and prepared.
  92429. * @returns if the effect is compiled and prepared.
  92430. */
  92431. isReady(): boolean;
  92432. /**
  92433. * The engine the effect was initialized with.
  92434. * @returns the engine.
  92435. */
  92436. getEngine(): Engine;
  92437. /**
  92438. * The pipeline context for this effect
  92439. * @returns the associated pipeline context
  92440. */
  92441. getPipelineContext(): Nullable<IPipelineContext>;
  92442. /**
  92443. * The set of names of attribute variables for the shader.
  92444. * @returns An array of attribute names.
  92445. */
  92446. getAttributesNames(): string[];
  92447. /**
  92448. * Returns the attribute at the given index.
  92449. * @param index The index of the attribute.
  92450. * @returns The location of the attribute.
  92451. */
  92452. getAttributeLocation(index: number): number;
  92453. /**
  92454. * Returns the attribute based on the name of the variable.
  92455. * @param name of the attribute to look up.
  92456. * @returns the attribute location.
  92457. */
  92458. getAttributeLocationByName(name: string): number;
  92459. /**
  92460. * The number of attributes.
  92461. * @returns the numnber of attributes.
  92462. */
  92463. getAttributesCount(): number;
  92464. /**
  92465. * Gets the index of a uniform variable.
  92466. * @param uniformName of the uniform to look up.
  92467. * @returns the index.
  92468. */
  92469. getUniformIndex(uniformName: string): number;
  92470. /**
  92471. * Returns the attribute based on the name of the variable.
  92472. * @param uniformName of the uniform to look up.
  92473. * @returns the location of the uniform.
  92474. */
  92475. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  92476. /**
  92477. * Returns an array of sampler variable names
  92478. * @returns The array of sampler variable neames.
  92479. */
  92480. getSamplers(): string[];
  92481. /**
  92482. * The error from the last compilation.
  92483. * @returns the error string.
  92484. */
  92485. getCompilationError(): string;
  92486. /**
  92487. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  92488. * @param func The callback to be used.
  92489. */
  92490. executeWhenCompiled(func: (effect: Effect) => void): void;
  92491. private _checkIsReady;
  92492. /** @hidden */
  92493. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  92494. /** @hidden */
  92495. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  92496. /** @hidden */
  92497. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  92498. /**
  92499. * Recompiles the webGL program
  92500. * @param vertexSourceCode The source code for the vertex shader.
  92501. * @param fragmentSourceCode The source code for the fragment shader.
  92502. * @param onCompiled Callback called when completed.
  92503. * @param onError Callback called on error.
  92504. * @hidden
  92505. */
  92506. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  92507. /**
  92508. * Prepares the effect
  92509. * @hidden
  92510. */
  92511. _prepareEffect(): void;
  92512. /**
  92513. * Checks if the effect is supported. (Must be called after compilation)
  92514. */
  92515. readonly isSupported: boolean;
  92516. /**
  92517. * Binds a texture to the engine to be used as output of the shader.
  92518. * @param channel Name of the output variable.
  92519. * @param texture Texture to bind.
  92520. * @hidden
  92521. */
  92522. _bindTexture(channel: string, texture: InternalTexture): void;
  92523. /**
  92524. * Sets a texture on the engine to be used in the shader.
  92525. * @param channel Name of the sampler variable.
  92526. * @param texture Texture to set.
  92527. */
  92528. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  92529. /**
  92530. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  92531. * @param channel Name of the sampler variable.
  92532. * @param texture Texture to set.
  92533. */
  92534. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  92535. /**
  92536. * Sets an array of textures on the engine to be used in the shader.
  92537. * @param channel Name of the variable.
  92538. * @param textures Textures to set.
  92539. */
  92540. setTextureArray(channel: string, textures: BaseTexture[]): void;
  92541. /**
  92542. * 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)
  92543. * @param channel Name of the sampler variable.
  92544. * @param postProcess Post process to get the input texture from.
  92545. */
  92546. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  92547. /**
  92548. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  92549. * 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)
  92550. * @param channel Name of the sampler variable.
  92551. * @param postProcess Post process to get the output texture from.
  92552. */
  92553. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  92554. /** @hidden */
  92555. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  92556. /** @hidden */
  92557. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  92558. /** @hidden */
  92559. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  92560. /** @hidden */
  92561. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  92562. /**
  92563. * Binds a buffer to a uniform.
  92564. * @param buffer Buffer to bind.
  92565. * @param name Name of the uniform variable to bind to.
  92566. */
  92567. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  92568. /**
  92569. * Binds block to a uniform.
  92570. * @param blockName Name of the block to bind.
  92571. * @param index Index to bind.
  92572. */
  92573. bindUniformBlock(blockName: string, index: number): void;
  92574. /**
  92575. * Sets an interger value on a uniform variable.
  92576. * @param uniformName Name of the variable.
  92577. * @param value Value to be set.
  92578. * @returns this effect.
  92579. */
  92580. setInt(uniformName: string, value: number): Effect;
  92581. /**
  92582. * Sets an int array on a uniform variable.
  92583. * @param uniformName Name of the variable.
  92584. * @param array array to be set.
  92585. * @returns this effect.
  92586. */
  92587. setIntArray(uniformName: string, array: Int32Array): Effect;
  92588. /**
  92589. * 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)
  92590. * @param uniformName Name of the variable.
  92591. * @param array array to be set.
  92592. * @returns this effect.
  92593. */
  92594. setIntArray2(uniformName: string, array: Int32Array): Effect;
  92595. /**
  92596. * 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)
  92597. * @param uniformName Name of the variable.
  92598. * @param array array to be set.
  92599. * @returns this effect.
  92600. */
  92601. setIntArray3(uniformName: string, array: Int32Array): Effect;
  92602. /**
  92603. * 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)
  92604. * @param uniformName Name of the variable.
  92605. * @param array array to be set.
  92606. * @returns this effect.
  92607. */
  92608. setIntArray4(uniformName: string, array: Int32Array): Effect;
  92609. /**
  92610. * Sets an float array on a uniform variable.
  92611. * @param uniformName Name of the variable.
  92612. * @param array array to be set.
  92613. * @returns this effect.
  92614. */
  92615. setFloatArray(uniformName: string, array: Float32Array): Effect;
  92616. /**
  92617. * 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)
  92618. * @param uniformName Name of the variable.
  92619. * @param array array to be set.
  92620. * @returns this effect.
  92621. */
  92622. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  92623. /**
  92624. * 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)
  92625. * @param uniformName Name of the variable.
  92626. * @param array array to be set.
  92627. * @returns this effect.
  92628. */
  92629. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  92630. /**
  92631. * 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)
  92632. * @param uniformName Name of the variable.
  92633. * @param array array to be set.
  92634. * @returns this effect.
  92635. */
  92636. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  92637. /**
  92638. * Sets an array on a uniform variable.
  92639. * @param uniformName Name of the variable.
  92640. * @param array array to be set.
  92641. * @returns this effect.
  92642. */
  92643. setArray(uniformName: string, array: number[]): Effect;
  92644. /**
  92645. * 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)
  92646. * @param uniformName Name of the variable.
  92647. * @param array array to be set.
  92648. * @returns this effect.
  92649. */
  92650. setArray2(uniformName: string, array: number[]): Effect;
  92651. /**
  92652. * 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)
  92653. * @param uniformName Name of the variable.
  92654. * @param array array to be set.
  92655. * @returns this effect.
  92656. */
  92657. setArray3(uniformName: string, array: number[]): Effect;
  92658. /**
  92659. * 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)
  92660. * @param uniformName Name of the variable.
  92661. * @param array array to be set.
  92662. * @returns this effect.
  92663. */
  92664. setArray4(uniformName: string, array: number[]): Effect;
  92665. /**
  92666. * Sets matrices on a uniform variable.
  92667. * @param uniformName Name of the variable.
  92668. * @param matrices matrices to be set.
  92669. * @returns this effect.
  92670. */
  92671. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  92672. /**
  92673. * Sets matrix on a uniform variable.
  92674. * @param uniformName Name of the variable.
  92675. * @param matrix matrix to be set.
  92676. * @returns this effect.
  92677. */
  92678. setMatrix(uniformName: string, matrix: Matrix): Effect;
  92679. /**
  92680. * 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)
  92681. * @param uniformName Name of the variable.
  92682. * @param matrix matrix to be set.
  92683. * @returns this effect.
  92684. */
  92685. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  92686. /**
  92687. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  92688. * @param uniformName Name of the variable.
  92689. * @param matrix matrix to be set.
  92690. * @returns this effect.
  92691. */
  92692. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  92693. /**
  92694. * Sets a float on a uniform variable.
  92695. * @param uniformName Name of the variable.
  92696. * @param value value to be set.
  92697. * @returns this effect.
  92698. */
  92699. setFloat(uniformName: string, value: number): Effect;
  92700. /**
  92701. * Sets a boolean on a uniform variable.
  92702. * @param uniformName Name of the variable.
  92703. * @param bool value to be set.
  92704. * @returns this effect.
  92705. */
  92706. setBool(uniformName: string, bool: boolean): Effect;
  92707. /**
  92708. * Sets a Vector2 on a uniform variable.
  92709. * @param uniformName Name of the variable.
  92710. * @param vector2 vector2 to be set.
  92711. * @returns this effect.
  92712. */
  92713. setVector2(uniformName: string, vector2: Vector2): Effect;
  92714. /**
  92715. * Sets a float2 on a uniform variable.
  92716. * @param uniformName Name of the variable.
  92717. * @param x First float in float2.
  92718. * @param y Second float in float2.
  92719. * @returns this effect.
  92720. */
  92721. setFloat2(uniformName: string, x: number, y: number): Effect;
  92722. /**
  92723. * Sets a Vector3 on a uniform variable.
  92724. * @param uniformName Name of the variable.
  92725. * @param vector3 Value to be set.
  92726. * @returns this effect.
  92727. */
  92728. setVector3(uniformName: string, vector3: Vector3): Effect;
  92729. /**
  92730. * Sets a float3 on a uniform variable.
  92731. * @param uniformName Name of the variable.
  92732. * @param x First float in float3.
  92733. * @param y Second float in float3.
  92734. * @param z Third float in float3.
  92735. * @returns this effect.
  92736. */
  92737. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  92738. /**
  92739. * Sets a Vector4 on a uniform variable.
  92740. * @param uniformName Name of the variable.
  92741. * @param vector4 Value to be set.
  92742. * @returns this effect.
  92743. */
  92744. setVector4(uniformName: string, vector4: Vector4): Effect;
  92745. /**
  92746. * Sets a float4 on a uniform variable.
  92747. * @param uniformName Name of the variable.
  92748. * @param x First float in float4.
  92749. * @param y Second float in float4.
  92750. * @param z Third float in float4.
  92751. * @param w Fourth float in float4.
  92752. * @returns this effect.
  92753. */
  92754. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  92755. /**
  92756. * Sets a Color3 on a uniform variable.
  92757. * @param uniformName Name of the variable.
  92758. * @param color3 Value to be set.
  92759. * @returns this effect.
  92760. */
  92761. setColor3(uniformName: string, color3: Color3): Effect;
  92762. /**
  92763. * Sets a Color4 on a uniform variable.
  92764. * @param uniformName Name of the variable.
  92765. * @param color3 Value to be set.
  92766. * @param alpha Alpha value to be set.
  92767. * @returns this effect.
  92768. */
  92769. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  92770. /**
  92771. * Sets a Color4 on a uniform variable
  92772. * @param uniformName defines the name of the variable
  92773. * @param color4 defines the value to be set
  92774. * @returns this effect.
  92775. */
  92776. setDirectColor4(uniformName: string, color4: Color4): Effect;
  92777. /** Release all associated resources */
  92778. dispose(): void;
  92779. /**
  92780. * This function will add a new shader to the shader store
  92781. * @param name the name of the shader
  92782. * @param pixelShader optional pixel shader content
  92783. * @param vertexShader optional vertex shader content
  92784. */
  92785. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  92786. /**
  92787. * Store of each shader (The can be looked up using effect.key)
  92788. */
  92789. static ShadersStore: {
  92790. [key: string]: string;
  92791. };
  92792. /**
  92793. * Store of each included file for a shader (The can be looked up using effect.key)
  92794. */
  92795. static IncludesShadersStore: {
  92796. [key: string]: string;
  92797. };
  92798. /**
  92799. * Resets the cache of effects.
  92800. */
  92801. static ResetCache(): void;
  92802. }
  92803. }
  92804. declare module BABYLON {
  92805. /**
  92806. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  92807. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  92808. * 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;
  92809. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  92810. */
  92811. export class ColorCurves {
  92812. private _dirty;
  92813. private _tempColor;
  92814. private _globalCurve;
  92815. private _highlightsCurve;
  92816. private _midtonesCurve;
  92817. private _shadowsCurve;
  92818. private _positiveCurve;
  92819. private _negativeCurve;
  92820. private _globalHue;
  92821. private _globalDensity;
  92822. private _globalSaturation;
  92823. private _globalExposure;
  92824. /**
  92825. * Gets the global Hue value.
  92826. * 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).
  92827. */
  92828. /**
  92829. * Sets the global Hue value.
  92830. * 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).
  92831. */
  92832. globalHue: number;
  92833. /**
  92834. * Gets the global Density value.
  92835. * 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.
  92836. * Values less than zero provide a filter of opposite hue.
  92837. */
  92838. /**
  92839. * Sets the global Density value.
  92840. * 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.
  92841. * Values less than zero provide a filter of opposite hue.
  92842. */
  92843. globalDensity: number;
  92844. /**
  92845. * Gets the global Saturation value.
  92846. * 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.
  92847. */
  92848. /**
  92849. * Sets the global Saturation value.
  92850. * 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.
  92851. */
  92852. globalSaturation: number;
  92853. /**
  92854. * Gets the global Exposure value.
  92855. * 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.
  92856. */
  92857. /**
  92858. * Sets the global Exposure value.
  92859. * 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.
  92860. */
  92861. globalExposure: number;
  92862. private _highlightsHue;
  92863. private _highlightsDensity;
  92864. private _highlightsSaturation;
  92865. private _highlightsExposure;
  92866. /**
  92867. * Gets the highlights Hue value.
  92868. * 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).
  92869. */
  92870. /**
  92871. * Sets the highlights Hue value.
  92872. * 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).
  92873. */
  92874. highlightsHue: number;
  92875. /**
  92876. * Gets the highlights Density value.
  92877. * 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.
  92878. * Values less than zero provide a filter of opposite hue.
  92879. */
  92880. /**
  92881. * Sets the highlights Density value.
  92882. * 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.
  92883. * Values less than zero provide a filter of opposite hue.
  92884. */
  92885. highlightsDensity: number;
  92886. /**
  92887. * Gets the highlights Saturation value.
  92888. * 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.
  92889. */
  92890. /**
  92891. * Sets the highlights Saturation value.
  92892. * 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.
  92893. */
  92894. highlightsSaturation: number;
  92895. /**
  92896. * Gets the highlights Exposure value.
  92897. * 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.
  92898. */
  92899. /**
  92900. * Sets the highlights Exposure value.
  92901. * 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.
  92902. */
  92903. highlightsExposure: number;
  92904. private _midtonesHue;
  92905. private _midtonesDensity;
  92906. private _midtonesSaturation;
  92907. private _midtonesExposure;
  92908. /**
  92909. * Gets the midtones Hue value.
  92910. * 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).
  92911. */
  92912. /**
  92913. * Sets the midtones Hue value.
  92914. * 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).
  92915. */
  92916. midtonesHue: number;
  92917. /**
  92918. * Gets the midtones Density value.
  92919. * 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.
  92920. * Values less than zero provide a filter of opposite hue.
  92921. */
  92922. /**
  92923. * Sets the midtones Density value.
  92924. * 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.
  92925. * Values less than zero provide a filter of opposite hue.
  92926. */
  92927. midtonesDensity: number;
  92928. /**
  92929. * Gets the midtones Saturation value.
  92930. * 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.
  92931. */
  92932. /**
  92933. * Sets the midtones Saturation value.
  92934. * 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.
  92935. */
  92936. midtonesSaturation: number;
  92937. /**
  92938. * Gets the midtones Exposure value.
  92939. * 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.
  92940. */
  92941. /**
  92942. * Sets the midtones Exposure value.
  92943. * 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.
  92944. */
  92945. midtonesExposure: number;
  92946. private _shadowsHue;
  92947. private _shadowsDensity;
  92948. private _shadowsSaturation;
  92949. private _shadowsExposure;
  92950. /**
  92951. * Gets the shadows Hue value.
  92952. * 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).
  92953. */
  92954. /**
  92955. * Sets the shadows Hue value.
  92956. * 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).
  92957. */
  92958. shadowsHue: number;
  92959. /**
  92960. * Gets the shadows Density value.
  92961. * 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.
  92962. * Values less than zero provide a filter of opposite hue.
  92963. */
  92964. /**
  92965. * Sets the shadows Density value.
  92966. * 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.
  92967. * Values less than zero provide a filter of opposite hue.
  92968. */
  92969. shadowsDensity: number;
  92970. /**
  92971. * Gets the shadows Saturation value.
  92972. * 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.
  92973. */
  92974. /**
  92975. * Sets the shadows Saturation value.
  92976. * 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.
  92977. */
  92978. shadowsSaturation: number;
  92979. /**
  92980. * Gets the shadows Exposure value.
  92981. * 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.
  92982. */
  92983. /**
  92984. * Sets the shadows Exposure value.
  92985. * 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.
  92986. */
  92987. shadowsExposure: number;
  92988. /**
  92989. * Returns the class name
  92990. * @returns The class name
  92991. */
  92992. getClassName(): string;
  92993. /**
  92994. * Binds the color curves to the shader.
  92995. * @param colorCurves The color curve to bind
  92996. * @param effect The effect to bind to
  92997. * @param positiveUniform The positive uniform shader parameter
  92998. * @param neutralUniform The neutral uniform shader parameter
  92999. * @param negativeUniform The negative uniform shader parameter
  93000. */
  93001. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  93002. /**
  93003. * Prepare the list of uniforms associated with the ColorCurves effects.
  93004. * @param uniformsList The list of uniforms used in the effect
  93005. */
  93006. static PrepareUniforms(uniformsList: string[]): void;
  93007. /**
  93008. * Returns color grading data based on a hue, density, saturation and exposure value.
  93009. * @param filterHue The hue of the color filter.
  93010. * @param filterDensity The density of the color filter.
  93011. * @param saturation The saturation.
  93012. * @param exposure The exposure.
  93013. * @param result The result data container.
  93014. */
  93015. private getColorGradingDataToRef;
  93016. /**
  93017. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  93018. * @param value The input slider value in range [-100,100].
  93019. * @returns Adjusted value.
  93020. */
  93021. private static applyColorGradingSliderNonlinear;
  93022. /**
  93023. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  93024. * @param hue The hue (H) input.
  93025. * @param saturation The saturation (S) input.
  93026. * @param brightness The brightness (B) input.
  93027. * @result An RGBA color represented as Vector4.
  93028. */
  93029. private static fromHSBToRef;
  93030. /**
  93031. * Returns a value clamped between min and max
  93032. * @param value The value to clamp
  93033. * @param min The minimum of value
  93034. * @param max The maximum of value
  93035. * @returns The clamped value.
  93036. */
  93037. private static clamp;
  93038. /**
  93039. * Clones the current color curve instance.
  93040. * @return The cloned curves
  93041. */
  93042. clone(): ColorCurves;
  93043. /**
  93044. * Serializes the current color curve instance to a json representation.
  93045. * @return a JSON representation
  93046. */
  93047. serialize(): any;
  93048. /**
  93049. * Parses the color curve from a json representation.
  93050. * @param source the JSON source to parse
  93051. * @return The parsed curves
  93052. */
  93053. static Parse(source: any): ColorCurves;
  93054. }
  93055. }
  93056. declare module BABYLON {
  93057. /**
  93058. * Interface to follow in your material defines to integrate easily the
  93059. * Image proccessing functions.
  93060. * @hidden
  93061. */
  93062. export interface IImageProcessingConfigurationDefines {
  93063. IMAGEPROCESSING: boolean;
  93064. VIGNETTE: boolean;
  93065. VIGNETTEBLENDMODEMULTIPLY: boolean;
  93066. VIGNETTEBLENDMODEOPAQUE: boolean;
  93067. TONEMAPPING: boolean;
  93068. TONEMAPPING_ACES: boolean;
  93069. CONTRAST: boolean;
  93070. EXPOSURE: boolean;
  93071. COLORCURVES: boolean;
  93072. COLORGRADING: boolean;
  93073. COLORGRADING3D: boolean;
  93074. SAMPLER3DGREENDEPTH: boolean;
  93075. SAMPLER3DBGRMAP: boolean;
  93076. IMAGEPROCESSINGPOSTPROCESS: boolean;
  93077. }
  93078. /**
  93079. * @hidden
  93080. */
  93081. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  93082. IMAGEPROCESSING: boolean;
  93083. VIGNETTE: boolean;
  93084. VIGNETTEBLENDMODEMULTIPLY: boolean;
  93085. VIGNETTEBLENDMODEOPAQUE: boolean;
  93086. TONEMAPPING: boolean;
  93087. TONEMAPPING_ACES: boolean;
  93088. CONTRAST: boolean;
  93089. COLORCURVES: boolean;
  93090. COLORGRADING: boolean;
  93091. COLORGRADING3D: boolean;
  93092. SAMPLER3DGREENDEPTH: boolean;
  93093. SAMPLER3DBGRMAP: boolean;
  93094. IMAGEPROCESSINGPOSTPROCESS: boolean;
  93095. EXPOSURE: boolean;
  93096. constructor();
  93097. }
  93098. /**
  93099. * This groups together the common properties used for image processing either in direct forward pass
  93100. * or through post processing effect depending on the use of the image processing pipeline in your scene
  93101. * or not.
  93102. */
  93103. export class ImageProcessingConfiguration {
  93104. /**
  93105. * Default tone mapping applied in BabylonJS.
  93106. */
  93107. static readonly TONEMAPPING_STANDARD: number;
  93108. /**
  93109. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  93110. * to other engines rendering to increase portability.
  93111. */
  93112. static readonly TONEMAPPING_ACES: number;
  93113. /**
  93114. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  93115. */
  93116. colorCurves: Nullable<ColorCurves>;
  93117. private _colorCurvesEnabled;
  93118. /**
  93119. * Gets wether the color curves effect is enabled.
  93120. */
  93121. /**
  93122. * Sets wether the color curves effect is enabled.
  93123. */
  93124. colorCurvesEnabled: boolean;
  93125. private _colorGradingTexture;
  93126. /**
  93127. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  93128. */
  93129. /**
  93130. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  93131. */
  93132. colorGradingTexture: Nullable<BaseTexture>;
  93133. private _colorGradingEnabled;
  93134. /**
  93135. * Gets wether the color grading effect is enabled.
  93136. */
  93137. /**
  93138. * Sets wether the color grading effect is enabled.
  93139. */
  93140. colorGradingEnabled: boolean;
  93141. private _colorGradingWithGreenDepth;
  93142. /**
  93143. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  93144. */
  93145. /**
  93146. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  93147. */
  93148. colorGradingWithGreenDepth: boolean;
  93149. private _colorGradingBGR;
  93150. /**
  93151. * Gets wether the color grading texture contains BGR values.
  93152. */
  93153. /**
  93154. * Sets wether the color grading texture contains BGR values.
  93155. */
  93156. colorGradingBGR: boolean;
  93157. /** @hidden */
  93158. _exposure: number;
  93159. /**
  93160. * Gets the Exposure used in the effect.
  93161. */
  93162. /**
  93163. * Sets the Exposure used in the effect.
  93164. */
  93165. exposure: number;
  93166. private _toneMappingEnabled;
  93167. /**
  93168. * Gets wether the tone mapping effect is enabled.
  93169. */
  93170. /**
  93171. * Sets wether the tone mapping effect is enabled.
  93172. */
  93173. toneMappingEnabled: boolean;
  93174. private _toneMappingType;
  93175. /**
  93176. * Gets the type of tone mapping effect.
  93177. */
  93178. /**
  93179. * Sets the type of tone mapping effect used in BabylonJS.
  93180. */
  93181. toneMappingType: number;
  93182. protected _contrast: number;
  93183. /**
  93184. * Gets the contrast used in the effect.
  93185. */
  93186. /**
  93187. * Sets the contrast used in the effect.
  93188. */
  93189. contrast: number;
  93190. /**
  93191. * Vignette stretch size.
  93192. */
  93193. vignetteStretch: number;
  93194. /**
  93195. * Vignette centre X Offset.
  93196. */
  93197. vignetteCentreX: number;
  93198. /**
  93199. * Vignette centre Y Offset.
  93200. */
  93201. vignetteCentreY: number;
  93202. /**
  93203. * Vignette weight or intensity of the vignette effect.
  93204. */
  93205. vignetteWeight: number;
  93206. /**
  93207. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  93208. * if vignetteEnabled is set to true.
  93209. */
  93210. vignetteColor: Color4;
  93211. /**
  93212. * Camera field of view used by the Vignette effect.
  93213. */
  93214. vignetteCameraFov: number;
  93215. private _vignetteBlendMode;
  93216. /**
  93217. * Gets the vignette blend mode allowing different kind of effect.
  93218. */
  93219. /**
  93220. * Sets the vignette blend mode allowing different kind of effect.
  93221. */
  93222. vignetteBlendMode: number;
  93223. private _vignetteEnabled;
  93224. /**
  93225. * Gets wether the vignette effect is enabled.
  93226. */
  93227. /**
  93228. * Sets wether the vignette effect is enabled.
  93229. */
  93230. vignetteEnabled: boolean;
  93231. private _applyByPostProcess;
  93232. /**
  93233. * Gets wether the image processing is applied through a post process or not.
  93234. */
  93235. /**
  93236. * Sets wether the image processing is applied through a post process or not.
  93237. */
  93238. applyByPostProcess: boolean;
  93239. private _isEnabled;
  93240. /**
  93241. * Gets wether the image processing is enabled or not.
  93242. */
  93243. /**
  93244. * Sets wether the image processing is enabled or not.
  93245. */
  93246. isEnabled: boolean;
  93247. /**
  93248. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  93249. */
  93250. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  93251. /**
  93252. * Method called each time the image processing information changes requires to recompile the effect.
  93253. */
  93254. protected _updateParameters(): void;
  93255. /**
  93256. * Gets the current class name.
  93257. * @return "ImageProcessingConfiguration"
  93258. */
  93259. getClassName(): string;
  93260. /**
  93261. * Prepare the list of uniforms associated with the Image Processing effects.
  93262. * @param uniforms The list of uniforms used in the effect
  93263. * @param defines the list of defines currently in use
  93264. */
  93265. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  93266. /**
  93267. * Prepare the list of samplers associated with the Image Processing effects.
  93268. * @param samplersList The list of uniforms used in the effect
  93269. * @param defines the list of defines currently in use
  93270. */
  93271. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  93272. /**
  93273. * Prepare the list of defines associated to the shader.
  93274. * @param defines the list of defines to complete
  93275. * @param forPostProcess Define if we are currently in post process mode or not
  93276. */
  93277. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  93278. /**
  93279. * Returns true if all the image processing information are ready.
  93280. * @returns True if ready, otherwise, false
  93281. */
  93282. isReady(): boolean;
  93283. /**
  93284. * Binds the image processing to the shader.
  93285. * @param effect The effect to bind to
  93286. * @param aspectRatio Define the current aspect ratio of the effect
  93287. */
  93288. bind(effect: Effect, aspectRatio?: number): void;
  93289. /**
  93290. * Clones the current image processing instance.
  93291. * @return The cloned image processing
  93292. */
  93293. clone(): ImageProcessingConfiguration;
  93294. /**
  93295. * Serializes the current image processing instance to a json representation.
  93296. * @return a JSON representation
  93297. */
  93298. serialize(): any;
  93299. /**
  93300. * Parses the image processing from a json representation.
  93301. * @param source the JSON source to parse
  93302. * @return The parsed image processing
  93303. */
  93304. static Parse(source: any): ImageProcessingConfiguration;
  93305. private static _VIGNETTEMODE_MULTIPLY;
  93306. private static _VIGNETTEMODE_OPAQUE;
  93307. /**
  93308. * Used to apply the vignette as a mix with the pixel color.
  93309. */
  93310. static readonly VIGNETTEMODE_MULTIPLY: number;
  93311. /**
  93312. * Used to apply the vignette as a replacement of the pixel color.
  93313. */
  93314. static readonly VIGNETTEMODE_OPAQUE: number;
  93315. }
  93316. }
  93317. declare module BABYLON {
  93318. /**
  93319. * This represents all the required information to add a fresnel effect on a material:
  93320. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  93321. */
  93322. export class FresnelParameters {
  93323. private _isEnabled;
  93324. /**
  93325. * Define if the fresnel effect is enable or not.
  93326. */
  93327. isEnabled: boolean;
  93328. /**
  93329. * Define the color used on edges (grazing angle)
  93330. */
  93331. leftColor: Color3;
  93332. /**
  93333. * Define the color used on center
  93334. */
  93335. rightColor: Color3;
  93336. /**
  93337. * Define bias applied to computed fresnel term
  93338. */
  93339. bias: number;
  93340. /**
  93341. * Defined the power exponent applied to fresnel term
  93342. */
  93343. power: number;
  93344. /**
  93345. * Clones the current fresnel and its valuues
  93346. * @returns a clone fresnel configuration
  93347. */
  93348. clone(): FresnelParameters;
  93349. /**
  93350. * Serializes the current fresnel parameters to a JSON representation.
  93351. * @return the JSON serialization
  93352. */
  93353. serialize(): any;
  93354. /**
  93355. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  93356. * @param parsedFresnelParameters Define the JSON representation
  93357. * @returns the parsed parameters
  93358. */
  93359. static Parse(parsedFresnelParameters: any): FresnelParameters;
  93360. }
  93361. }
  93362. declare module BABYLON {
  93363. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  93364. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93365. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93366. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93367. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93368. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93369. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93370. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93371. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93372. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93373. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93374. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93375. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93376. /**
  93377. * Decorator used to define property that can be serialized as reference to a camera
  93378. * @param sourceName defines the name of the property to decorate
  93379. */
  93380. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93381. /**
  93382. * Class used to help serialization objects
  93383. */
  93384. export class SerializationHelper {
  93385. /** @hidden */
  93386. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  93387. /** @hidden */
  93388. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  93389. /** @hidden */
  93390. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  93391. /** @hidden */
  93392. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  93393. /**
  93394. * Appends the serialized animations from the source animations
  93395. * @param source Source containing the animations
  93396. * @param destination Target to store the animations
  93397. */
  93398. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  93399. /**
  93400. * Static function used to serialized a specific entity
  93401. * @param entity defines the entity to serialize
  93402. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  93403. * @returns a JSON compatible object representing the serialization of the entity
  93404. */
  93405. static Serialize<T>(entity: T, serializationObject?: any): any;
  93406. /**
  93407. * Creates a new entity from a serialization data object
  93408. * @param creationFunction defines a function used to instanciated the new entity
  93409. * @param source defines the source serialization data
  93410. * @param scene defines the hosting scene
  93411. * @param rootUrl defines the root url for resources
  93412. * @returns a new entity
  93413. */
  93414. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  93415. /**
  93416. * Clones an object
  93417. * @param creationFunction defines the function used to instanciate the new object
  93418. * @param source defines the source object
  93419. * @returns the cloned object
  93420. */
  93421. static Clone<T>(creationFunction: () => T, source: T): T;
  93422. /**
  93423. * Instanciates a new object based on a source one (some data will be shared between both object)
  93424. * @param creationFunction defines the function used to instanciate the new object
  93425. * @param source defines the source object
  93426. * @returns the new object
  93427. */
  93428. static Instanciate<T>(creationFunction: () => T, source: T): T;
  93429. }
  93430. }
  93431. declare module BABYLON {
  93432. /**
  93433. * This is the base class of all the camera used in the application.
  93434. * @see http://doc.babylonjs.com/features/cameras
  93435. */
  93436. export class Camera extends Node {
  93437. /** @hidden */
  93438. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  93439. /**
  93440. * This is the default projection mode used by the cameras.
  93441. * It helps recreating a feeling of perspective and better appreciate depth.
  93442. * This is the best way to simulate real life cameras.
  93443. */
  93444. static readonly PERSPECTIVE_CAMERA: number;
  93445. /**
  93446. * This helps creating camera with an orthographic mode.
  93447. * 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.
  93448. */
  93449. static readonly ORTHOGRAPHIC_CAMERA: number;
  93450. /**
  93451. * This is the default FOV mode for perspective cameras.
  93452. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  93453. */
  93454. static readonly FOVMODE_VERTICAL_FIXED: number;
  93455. /**
  93456. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  93457. */
  93458. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  93459. /**
  93460. * This specifies ther is no need for a camera rig.
  93461. * Basically only one eye is rendered corresponding to the camera.
  93462. */
  93463. static readonly RIG_MODE_NONE: number;
  93464. /**
  93465. * Simulates a camera Rig with one blue eye and one red eye.
  93466. * This can be use with 3d blue and red glasses.
  93467. */
  93468. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  93469. /**
  93470. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  93471. */
  93472. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  93473. /**
  93474. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  93475. */
  93476. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  93477. /**
  93478. * Defines that both eyes of the camera will be rendered over under each other.
  93479. */
  93480. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  93481. /**
  93482. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  93483. */
  93484. static readonly RIG_MODE_VR: number;
  93485. /**
  93486. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  93487. */
  93488. static readonly RIG_MODE_WEBVR: number;
  93489. /**
  93490. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  93491. */
  93492. static readonly RIG_MODE_CUSTOM: number;
  93493. /**
  93494. * Defines if by default attaching controls should prevent the default javascript event to continue.
  93495. */
  93496. static ForceAttachControlToAlwaysPreventDefault: boolean;
  93497. /**
  93498. * Define the input manager associated with the camera.
  93499. */
  93500. inputs: CameraInputsManager<Camera>;
  93501. /** @hidden */
  93502. _position: Vector3;
  93503. /**
  93504. * Define the current local position of the camera in the scene
  93505. */
  93506. position: Vector3;
  93507. /**
  93508. * The vector the camera should consider as up.
  93509. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  93510. */
  93511. upVector: Vector3;
  93512. /**
  93513. * Define the current limit on the left side for an orthographic camera
  93514. * In scene unit
  93515. */
  93516. orthoLeft: Nullable<number>;
  93517. /**
  93518. * Define the current limit on the right side for an orthographic camera
  93519. * In scene unit
  93520. */
  93521. orthoRight: Nullable<number>;
  93522. /**
  93523. * Define the current limit on the bottom side for an orthographic camera
  93524. * In scene unit
  93525. */
  93526. orthoBottom: Nullable<number>;
  93527. /**
  93528. * Define the current limit on the top side for an orthographic camera
  93529. * In scene unit
  93530. */
  93531. orthoTop: Nullable<number>;
  93532. /**
  93533. * Field Of View is set in Radians. (default is 0.8)
  93534. */
  93535. fov: number;
  93536. /**
  93537. * Define the minimum distance the camera can see from.
  93538. * This is important to note that the depth buffer are not infinite and the closer it starts
  93539. * the more your scene might encounter depth fighting issue.
  93540. */
  93541. minZ: number;
  93542. /**
  93543. * Define the maximum distance the camera can see to.
  93544. * This is important to note that the depth buffer are not infinite and the further it end
  93545. * the more your scene might encounter depth fighting issue.
  93546. */
  93547. maxZ: number;
  93548. /**
  93549. * Define the default inertia of the camera.
  93550. * This helps giving a smooth feeling to the camera movement.
  93551. */
  93552. inertia: number;
  93553. /**
  93554. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  93555. */
  93556. mode: number;
  93557. /**
  93558. * Define wether the camera is intermediate.
  93559. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  93560. */
  93561. isIntermediate: boolean;
  93562. /**
  93563. * Define the viewport of the camera.
  93564. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  93565. */
  93566. viewport: Viewport;
  93567. /**
  93568. * Restricts the camera to viewing objects with the same layerMask.
  93569. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  93570. */
  93571. layerMask: number;
  93572. /**
  93573. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  93574. */
  93575. fovMode: number;
  93576. /**
  93577. * Rig mode of the camera.
  93578. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  93579. * This is normally controlled byt the camera themselves as internal use.
  93580. */
  93581. cameraRigMode: number;
  93582. /**
  93583. * Defines the distance between both "eyes" in case of a RIG
  93584. */
  93585. interaxialDistance: number;
  93586. /**
  93587. * Defines if stereoscopic rendering is done side by side or over under.
  93588. */
  93589. isStereoscopicSideBySide: boolean;
  93590. /**
  93591. * 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
  93592. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  93593. * else in the scene.
  93594. */
  93595. customRenderTargets: RenderTargetTexture[];
  93596. /**
  93597. * When set, the camera will render to this render target instead of the default canvas
  93598. */
  93599. outputRenderTarget: Nullable<RenderTargetTexture>;
  93600. /**
  93601. * Observable triggered when the camera view matrix has changed.
  93602. */
  93603. onViewMatrixChangedObservable: Observable<Camera>;
  93604. /**
  93605. * Observable triggered when the camera Projection matrix has changed.
  93606. */
  93607. onProjectionMatrixChangedObservable: Observable<Camera>;
  93608. /**
  93609. * Observable triggered when the inputs have been processed.
  93610. */
  93611. onAfterCheckInputsObservable: Observable<Camera>;
  93612. /**
  93613. * Observable triggered when reset has been called and applied to the camera.
  93614. */
  93615. onRestoreStateObservable: Observable<Camera>;
  93616. /** @hidden */
  93617. _cameraRigParams: any;
  93618. /** @hidden */
  93619. _rigCameras: Camera[];
  93620. /** @hidden */
  93621. _rigPostProcess: Nullable<PostProcess>;
  93622. protected _webvrViewMatrix: Matrix;
  93623. /** @hidden */
  93624. _skipRendering: boolean;
  93625. /** @hidden */
  93626. _projectionMatrix: Matrix;
  93627. /** @hidden */
  93628. _postProcesses: Nullable<PostProcess>[];
  93629. /** @hidden */
  93630. _activeMeshes: SmartArray<AbstractMesh>;
  93631. protected _globalPosition: Vector3;
  93632. /** @hidden */
  93633. _computedViewMatrix: Matrix;
  93634. private _doNotComputeProjectionMatrix;
  93635. private _transformMatrix;
  93636. private _frustumPlanes;
  93637. private _refreshFrustumPlanes;
  93638. private _storedFov;
  93639. private _stateStored;
  93640. /**
  93641. * Instantiates a new camera object.
  93642. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  93643. * @see http://doc.babylonjs.com/features/cameras
  93644. * @param name Defines the name of the camera in the scene
  93645. * @param position Defines the position of the camera
  93646. * @param scene Defines the scene the camera belongs too
  93647. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  93648. */
  93649. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  93650. /**
  93651. * Store current camera state (fov, position, etc..)
  93652. * @returns the camera
  93653. */
  93654. storeState(): Camera;
  93655. /**
  93656. * Restores the camera state values if it has been stored. You must call storeState() first
  93657. */
  93658. protected _restoreStateValues(): boolean;
  93659. /**
  93660. * Restored camera state. You must call storeState() first.
  93661. * @returns true if restored and false otherwise
  93662. */
  93663. restoreState(): boolean;
  93664. /**
  93665. * Gets the class name of the camera.
  93666. * @returns the class name
  93667. */
  93668. getClassName(): string;
  93669. /** @hidden */
  93670. readonly _isCamera: boolean;
  93671. /**
  93672. * Gets a string representation of the camera useful for debug purpose.
  93673. * @param fullDetails Defines that a more verboe level of logging is required
  93674. * @returns the string representation
  93675. */
  93676. toString(fullDetails?: boolean): string;
  93677. /**
  93678. * Gets the current world space position of the camera.
  93679. */
  93680. readonly globalPosition: Vector3;
  93681. /**
  93682. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  93683. * @returns the active meshe list
  93684. */
  93685. getActiveMeshes(): SmartArray<AbstractMesh>;
  93686. /**
  93687. * Check wether a mesh is part of the current active mesh list of the camera
  93688. * @param mesh Defines the mesh to check
  93689. * @returns true if active, false otherwise
  93690. */
  93691. isActiveMesh(mesh: Mesh): boolean;
  93692. /**
  93693. * Is this camera ready to be used/rendered
  93694. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  93695. * @return true if the camera is ready
  93696. */
  93697. isReady(completeCheck?: boolean): boolean;
  93698. /** @hidden */
  93699. _initCache(): void;
  93700. /** @hidden */
  93701. _updateCache(ignoreParentClass?: boolean): void;
  93702. /** @hidden */
  93703. _isSynchronized(): boolean;
  93704. /** @hidden */
  93705. _isSynchronizedViewMatrix(): boolean;
  93706. /** @hidden */
  93707. _isSynchronizedProjectionMatrix(): boolean;
  93708. /**
  93709. * Attach the input controls to a specific dom element to get the input from.
  93710. * @param element Defines the element the controls should be listened from
  93711. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93712. */
  93713. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93714. /**
  93715. * Detach the current controls from the specified dom element.
  93716. * @param element Defines the element to stop listening the inputs from
  93717. */
  93718. detachControl(element: HTMLElement): void;
  93719. /**
  93720. * Update the camera state according to the different inputs gathered during the frame.
  93721. */
  93722. update(): void;
  93723. /** @hidden */
  93724. _checkInputs(): void;
  93725. /** @hidden */
  93726. readonly rigCameras: Camera[];
  93727. /**
  93728. * Gets the post process used by the rig cameras
  93729. */
  93730. readonly rigPostProcess: Nullable<PostProcess>;
  93731. /**
  93732. * Internal, gets the first post proces.
  93733. * @returns the first post process to be run on this camera.
  93734. */
  93735. _getFirstPostProcess(): Nullable<PostProcess>;
  93736. private _cascadePostProcessesToRigCams;
  93737. /**
  93738. * Attach a post process to the camera.
  93739. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  93740. * @param postProcess The post process to attach to the camera
  93741. * @param insertAt The position of the post process in case several of them are in use in the scene
  93742. * @returns the position the post process has been inserted at
  93743. */
  93744. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  93745. /**
  93746. * Detach a post process to the camera.
  93747. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  93748. * @param postProcess The post process to detach from the camera
  93749. */
  93750. detachPostProcess(postProcess: PostProcess): void;
  93751. /**
  93752. * Gets the current world matrix of the camera
  93753. */
  93754. getWorldMatrix(): Matrix;
  93755. /** @hidden */
  93756. _getViewMatrix(): Matrix;
  93757. /**
  93758. * Gets the current view matrix of the camera.
  93759. * @param force forces the camera to recompute the matrix without looking at the cached state
  93760. * @returns the view matrix
  93761. */
  93762. getViewMatrix(force?: boolean): Matrix;
  93763. /**
  93764. * Freeze the projection matrix.
  93765. * It will prevent the cache check of the camera projection compute and can speed up perf
  93766. * if no parameter of the camera are meant to change
  93767. * @param projection Defines manually a projection if necessary
  93768. */
  93769. freezeProjectionMatrix(projection?: Matrix): void;
  93770. /**
  93771. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  93772. */
  93773. unfreezeProjectionMatrix(): void;
  93774. /**
  93775. * Gets the current projection matrix of the camera.
  93776. * @param force forces the camera to recompute the matrix without looking at the cached state
  93777. * @returns the projection matrix
  93778. */
  93779. getProjectionMatrix(force?: boolean): Matrix;
  93780. /**
  93781. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  93782. * @returns a Matrix
  93783. */
  93784. getTransformationMatrix(): Matrix;
  93785. private _updateFrustumPlanes;
  93786. /**
  93787. * Checks if a cullable object (mesh...) is in the camera frustum
  93788. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  93789. * @param target The object to check
  93790. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  93791. * @returns true if the object is in frustum otherwise false
  93792. */
  93793. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  93794. /**
  93795. * Checks if a cullable object (mesh...) is in the camera frustum
  93796. * Unlike isInFrustum this cheks the full bounding box
  93797. * @param target The object to check
  93798. * @returns true if the object is in frustum otherwise false
  93799. */
  93800. isCompletelyInFrustum(target: ICullable): boolean;
  93801. /**
  93802. * Gets a ray in the forward direction from the camera.
  93803. * @param length Defines the length of the ray to create
  93804. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  93805. * @param origin Defines the start point of the ray which defaults to the camera position
  93806. * @returns the forward ray
  93807. */
  93808. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  93809. /**
  93810. * Releases resources associated with this node.
  93811. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93812. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93813. */
  93814. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93815. /** @hidden */
  93816. _isLeftCamera: boolean;
  93817. /**
  93818. * Gets the left camera of a rig setup in case of Rigged Camera
  93819. */
  93820. readonly isLeftCamera: boolean;
  93821. /** @hidden */
  93822. _isRightCamera: boolean;
  93823. /**
  93824. * Gets the right camera of a rig setup in case of Rigged Camera
  93825. */
  93826. readonly isRightCamera: boolean;
  93827. /**
  93828. * Gets the left camera of a rig setup in case of Rigged Camera
  93829. */
  93830. readonly leftCamera: Nullable<FreeCamera>;
  93831. /**
  93832. * Gets the right camera of a rig setup in case of Rigged Camera
  93833. */
  93834. readonly rightCamera: Nullable<FreeCamera>;
  93835. /**
  93836. * Gets the left camera target of a rig setup in case of Rigged Camera
  93837. * @returns the target position
  93838. */
  93839. getLeftTarget(): Nullable<Vector3>;
  93840. /**
  93841. * Gets the right camera target of a rig setup in case of Rigged Camera
  93842. * @returns the target position
  93843. */
  93844. getRightTarget(): Nullable<Vector3>;
  93845. /**
  93846. * @hidden
  93847. */
  93848. setCameraRigMode(mode: number, rigParams: any): void;
  93849. /** @hidden */
  93850. static _setStereoscopicRigMode(camera: Camera): void;
  93851. /** @hidden */
  93852. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  93853. /** @hidden */
  93854. static _setVRRigMode(camera: Camera, rigParams: any): void;
  93855. /** @hidden */
  93856. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  93857. /** @hidden */
  93858. _getVRProjectionMatrix(): Matrix;
  93859. protected _updateCameraRotationMatrix(): void;
  93860. protected _updateWebVRCameraRotationMatrix(): void;
  93861. /**
  93862. * This function MUST be overwritten by the different WebVR cameras available.
  93863. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  93864. * @hidden
  93865. */
  93866. _getWebVRProjectionMatrix(): Matrix;
  93867. /**
  93868. * This function MUST be overwritten by the different WebVR cameras available.
  93869. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  93870. * @hidden
  93871. */
  93872. _getWebVRViewMatrix(): Matrix;
  93873. /** @hidden */
  93874. setCameraRigParameter(name: string, value: any): void;
  93875. /**
  93876. * needs to be overridden by children so sub has required properties to be copied
  93877. * @hidden
  93878. */
  93879. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  93880. /**
  93881. * May need to be overridden by children
  93882. * @hidden
  93883. */
  93884. _updateRigCameras(): void;
  93885. /** @hidden */
  93886. _setupInputs(): void;
  93887. /**
  93888. * Serialiaze the camera setup to a json represention
  93889. * @returns the JSON representation
  93890. */
  93891. serialize(): any;
  93892. /**
  93893. * Clones the current camera.
  93894. * @param name The cloned camera name
  93895. * @returns the cloned camera
  93896. */
  93897. clone(name: string): Camera;
  93898. /**
  93899. * Gets the direction of the camera relative to a given local axis.
  93900. * @param localAxis Defines the reference axis to provide a relative direction.
  93901. * @return the direction
  93902. */
  93903. getDirection(localAxis: Vector3): Vector3;
  93904. /**
  93905. * Gets the direction of the camera relative to a given local axis into a passed vector.
  93906. * @param localAxis Defines the reference axis to provide a relative direction.
  93907. * @param result Defines the vector to store the result in
  93908. */
  93909. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  93910. /**
  93911. * Gets a camera constructor for a given camera type
  93912. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  93913. * @param name The name of the camera the result will be able to instantiate
  93914. * @param scene The scene the result will construct the camera in
  93915. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  93916. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  93917. * @returns a factory method to construc the camera
  93918. */
  93919. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  93920. /**
  93921. * Compute the world matrix of the camera.
  93922. * @returns the camera workd matrix
  93923. */
  93924. computeWorldMatrix(): Matrix;
  93925. /**
  93926. * Parse a JSON and creates the camera from the parsed information
  93927. * @param parsedCamera The JSON to parse
  93928. * @param scene The scene to instantiate the camera in
  93929. * @returns the newly constructed camera
  93930. */
  93931. static Parse(parsedCamera: any, scene: Scene): Camera;
  93932. }
  93933. }
  93934. declare module BABYLON {
  93935. /**
  93936. * Interface for any object that can request an animation frame
  93937. */
  93938. export interface ICustomAnimationFrameRequester {
  93939. /**
  93940. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  93941. */
  93942. renderFunction?: Function;
  93943. /**
  93944. * Called to request the next frame to render to
  93945. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  93946. */
  93947. requestAnimationFrame: Function;
  93948. /**
  93949. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  93950. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  93951. */
  93952. requestID?: number;
  93953. }
  93954. /**
  93955. * Interface containing an array of animations
  93956. */
  93957. export interface IAnimatable {
  93958. /**
  93959. * Array of animations
  93960. */
  93961. animations: Nullable<Array<Animation>>;
  93962. }
  93963. /** Interface used by value gradients (color, factor, ...) */
  93964. export interface IValueGradient {
  93965. /**
  93966. * Gets or sets the gradient value (between 0 and 1)
  93967. */
  93968. gradient: number;
  93969. }
  93970. /** Class used to store color4 gradient */
  93971. export class ColorGradient implements IValueGradient {
  93972. /**
  93973. * Gets or sets the gradient value (between 0 and 1)
  93974. */
  93975. gradient: number;
  93976. /**
  93977. * Gets or sets first associated color
  93978. */
  93979. color1: Color4;
  93980. /**
  93981. * Gets or sets second associated color
  93982. */
  93983. color2?: Color4;
  93984. /**
  93985. * Will get a color picked randomly between color1 and color2.
  93986. * If color2 is undefined then color1 will be used
  93987. * @param result defines the target Color4 to store the result in
  93988. */
  93989. getColorToRef(result: Color4): void;
  93990. }
  93991. /** Class used to store color 3 gradient */
  93992. export class Color3Gradient implements IValueGradient {
  93993. /**
  93994. * Gets or sets the gradient value (between 0 and 1)
  93995. */
  93996. gradient: number;
  93997. /**
  93998. * Gets or sets the associated color
  93999. */
  94000. color: Color3;
  94001. }
  94002. /** Class used to store factor gradient */
  94003. export class FactorGradient implements IValueGradient {
  94004. /**
  94005. * Gets or sets the gradient value (between 0 and 1)
  94006. */
  94007. gradient: number;
  94008. /**
  94009. * Gets or sets first associated factor
  94010. */
  94011. factor1: number;
  94012. /**
  94013. * Gets or sets second associated factor
  94014. */
  94015. factor2?: number;
  94016. /**
  94017. * Will get a number picked randomly between factor1 and factor2.
  94018. * If factor2 is undefined then factor1 will be used
  94019. * @returns the picked number
  94020. */
  94021. getFactor(): number;
  94022. }
  94023. /**
  94024. * @ignore
  94025. * Application error to support additional information when loading a file
  94026. */
  94027. export class LoadFileError extends Error {
  94028. /** defines the optional web request */
  94029. request?: WebRequest | undefined;
  94030. private static _setPrototypeOf;
  94031. /**
  94032. * Creates a new LoadFileError
  94033. * @param message defines the message of the error
  94034. * @param request defines the optional web request
  94035. */
  94036. constructor(message: string,
  94037. /** defines the optional web request */
  94038. request?: WebRequest | undefined);
  94039. }
  94040. /**
  94041. * Class used to define a retry strategy when error happens while loading assets
  94042. */
  94043. export class RetryStrategy {
  94044. /**
  94045. * Function used to defines an exponential back off strategy
  94046. * @param maxRetries defines the maximum number of retries (3 by default)
  94047. * @param baseInterval defines the interval between retries
  94048. * @returns the strategy function to use
  94049. */
  94050. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  94051. }
  94052. /**
  94053. * File request interface
  94054. */
  94055. export interface IFileRequest {
  94056. /**
  94057. * Raised when the request is complete (success or error).
  94058. */
  94059. onCompleteObservable: Observable<IFileRequest>;
  94060. /**
  94061. * Aborts the request for a file.
  94062. */
  94063. abort: () => void;
  94064. }
  94065. /**
  94066. * Class containing a set of static utilities functions
  94067. */
  94068. export class Tools {
  94069. /**
  94070. * Gets or sets the base URL to use to load assets
  94071. */
  94072. static BaseUrl: string;
  94073. /**
  94074. * Enable/Disable Custom HTTP Request Headers globally.
  94075. * default = false
  94076. * @see CustomRequestHeaders
  94077. */
  94078. static UseCustomRequestHeaders: boolean;
  94079. /**
  94080. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  94081. * i.e. when loading files, where the server/service expects an Authorization header
  94082. */
  94083. static CustomRequestHeaders: {
  94084. [key: string]: string;
  94085. };
  94086. /**
  94087. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  94088. */
  94089. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  94090. /**
  94091. * Default behaviour for cors in the application.
  94092. * It can be a string if the expected behavior is identical in the entire app.
  94093. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  94094. */
  94095. static CorsBehavior: string | ((url: string | string[]) => string);
  94096. /**
  94097. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  94098. * @ignorenaming
  94099. */
  94100. static UseFallbackTexture: boolean;
  94101. /**
  94102. * Use this object to register external classes like custom textures or material
  94103. * to allow the laoders to instantiate them
  94104. */
  94105. static RegisteredExternalClasses: {
  94106. [key: string]: Object;
  94107. };
  94108. /**
  94109. * Texture content used if a texture cannot loaded
  94110. * @ignorenaming
  94111. */
  94112. static fallbackTexture: string;
  94113. /**
  94114. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  94115. * @param u defines the coordinate on X axis
  94116. * @param v defines the coordinate on Y axis
  94117. * @param width defines the width of the source data
  94118. * @param height defines the height of the source data
  94119. * @param pixels defines the source byte array
  94120. * @param color defines the output color
  94121. */
  94122. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  94123. /**
  94124. * Interpolates between a and b via alpha
  94125. * @param a The lower value (returned when alpha = 0)
  94126. * @param b The upper value (returned when alpha = 1)
  94127. * @param alpha The interpolation-factor
  94128. * @return The mixed value
  94129. */
  94130. static Mix(a: number, b: number, alpha: number): number;
  94131. /**
  94132. * Tries to instantiate a new object from a given class name
  94133. * @param className defines the class name to instantiate
  94134. * @returns the new object or null if the system was not able to do the instantiation
  94135. */
  94136. static Instantiate(className: string): any;
  94137. /**
  94138. * Provides a slice function that will work even on IE
  94139. * @param data defines the array to slice
  94140. * @param start defines the start of the data (optional)
  94141. * @param end defines the end of the data (optional)
  94142. * @returns the new sliced array
  94143. */
  94144. static Slice<T>(data: T, start?: number, end?: number): T;
  94145. /**
  94146. * Polyfill for setImmediate
  94147. * @param action defines the action to execute after the current execution block
  94148. */
  94149. static SetImmediate(action: () => void): void;
  94150. /**
  94151. * Function indicating if a number is an exponent of 2
  94152. * @param value defines the value to test
  94153. * @returns true if the value is an exponent of 2
  94154. */
  94155. static IsExponentOfTwo(value: number): boolean;
  94156. private static _tmpFloatArray;
  94157. /**
  94158. * Returns the nearest 32-bit single precision float representation of a Number
  94159. * @param value A Number. If the parameter is of a different type, it will get converted
  94160. * to a number or to NaN if it cannot be converted
  94161. * @returns number
  94162. */
  94163. static FloatRound(value: number): number;
  94164. /**
  94165. * Find the next highest power of two.
  94166. * @param x Number to start search from.
  94167. * @return Next highest power of two.
  94168. */
  94169. static CeilingPOT(x: number): number;
  94170. /**
  94171. * Find the next lowest power of two.
  94172. * @param x Number to start search from.
  94173. * @return Next lowest power of two.
  94174. */
  94175. static FloorPOT(x: number): number;
  94176. /**
  94177. * Find the nearest power of two.
  94178. * @param x Number to start search from.
  94179. * @return Next nearest power of two.
  94180. */
  94181. static NearestPOT(x: number): number;
  94182. /**
  94183. * Get the closest exponent of two
  94184. * @param value defines the value to approximate
  94185. * @param max defines the maximum value to return
  94186. * @param mode defines how to define the closest value
  94187. * @returns closest exponent of two of the given value
  94188. */
  94189. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  94190. /**
  94191. * Extracts the filename from a path
  94192. * @param path defines the path to use
  94193. * @returns the filename
  94194. */
  94195. static GetFilename(path: string): string;
  94196. /**
  94197. * Extracts the "folder" part of a path (everything before the filename).
  94198. * @param uri The URI to extract the info from
  94199. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  94200. * @returns The "folder" part of the path
  94201. */
  94202. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  94203. /**
  94204. * Extracts text content from a DOM element hierarchy
  94205. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  94206. */
  94207. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  94208. /**
  94209. * Convert an angle in radians to degrees
  94210. * @param angle defines the angle to convert
  94211. * @returns the angle in degrees
  94212. */
  94213. static ToDegrees(angle: number): number;
  94214. /**
  94215. * Convert an angle in degrees to radians
  94216. * @param angle defines the angle to convert
  94217. * @returns the angle in radians
  94218. */
  94219. static ToRadians(angle: number): number;
  94220. /**
  94221. * Encode a buffer to a base64 string
  94222. * @param buffer defines the buffer to encode
  94223. * @returns the encoded string
  94224. */
  94225. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  94226. /**
  94227. * Extracts minimum and maximum values from a list of indexed positions
  94228. * @param positions defines the positions to use
  94229. * @param indices defines the indices to the positions
  94230. * @param indexStart defines the start index
  94231. * @param indexCount defines the end index
  94232. * @param bias defines bias value to add to the result
  94233. * @return minimum and maximum values
  94234. */
  94235. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  94236. minimum: Vector3;
  94237. maximum: Vector3;
  94238. };
  94239. /**
  94240. * Extracts minimum and maximum values from a list of positions
  94241. * @param positions defines the positions to use
  94242. * @param start defines the start index in the positions array
  94243. * @param count defines the number of positions to handle
  94244. * @param bias defines bias value to add to the result
  94245. * @param stride defines the stride size to use (distance between two positions in the positions array)
  94246. * @return minimum and maximum values
  94247. */
  94248. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  94249. minimum: Vector3;
  94250. maximum: Vector3;
  94251. };
  94252. /**
  94253. * Returns an array if obj is not an array
  94254. * @param obj defines the object to evaluate as an array
  94255. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  94256. * @returns either obj directly if obj is an array or a new array containing obj
  94257. */
  94258. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  94259. /**
  94260. * Gets the pointer prefix to use
  94261. * @returns "pointer" if touch is enabled. Else returns "mouse"
  94262. */
  94263. static GetPointerPrefix(): string;
  94264. /**
  94265. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  94266. * @param func - the function to be called
  94267. * @param requester - the object that will request the next frame. Falls back to window.
  94268. * @returns frame number
  94269. */
  94270. static QueueNewFrame(func: () => void, requester?: any): number;
  94271. /**
  94272. * Ask the browser to promote the current element to fullscreen rendering mode
  94273. * @param element defines the DOM element to promote
  94274. */
  94275. static RequestFullscreen(element: HTMLElement): void;
  94276. /**
  94277. * Asks the browser to exit fullscreen mode
  94278. */
  94279. static ExitFullscreen(): void;
  94280. /**
  94281. * Ask the browser to promote the current element to pointerlock mode
  94282. * @param element defines the DOM element to promote
  94283. */
  94284. static RequestPointerlock(element: HTMLElement): void;
  94285. /**
  94286. * Asks the browser to exit pointerlock mode
  94287. */
  94288. static ExitPointerlock(): void;
  94289. /**
  94290. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  94291. * @param url define the url we are trying
  94292. * @param element define the dom element where to configure the cors policy
  94293. */
  94294. static SetCorsBehavior(url: string | string[], element: {
  94295. crossOrigin: string | null;
  94296. }): void;
  94297. /**
  94298. * Removes unwanted characters from an url
  94299. * @param url defines the url to clean
  94300. * @returns the cleaned url
  94301. */
  94302. static CleanUrl(url: string): string;
  94303. /**
  94304. * Gets or sets a function used to pre-process url before using them to load assets
  94305. */
  94306. static PreprocessUrl: (url: string) => string;
  94307. /**
  94308. * Loads an image as an HTMLImageElement.
  94309. * @param input url string, ArrayBuffer, or Blob to load
  94310. * @param onLoad callback called when the image successfully loads
  94311. * @param onError callback called when the image fails to load
  94312. * @param offlineProvider offline provider for caching
  94313. * @returns the HTMLImageElement of the loaded image
  94314. */
  94315. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  94316. /**
  94317. * Loads a file
  94318. * @param url url string, ArrayBuffer, or Blob to load
  94319. * @param onSuccess callback called when the file successfully loads
  94320. * @param onProgress callback called while file is loading (if the server supports this mode)
  94321. * @param offlineProvider defines the offline provider for caching
  94322. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  94323. * @param onError callback called when the file fails to load
  94324. * @returns a file request object
  94325. */
  94326. 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;
  94327. /**
  94328. * Loads a file from a url
  94329. * @param url the file url to load
  94330. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  94331. */
  94332. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  94333. /**
  94334. * Load a script (identified by an url). When the url returns, the
  94335. * content of this file is added into a new script element, attached to the DOM (body element)
  94336. * @param scriptUrl defines the url of the script to laod
  94337. * @param onSuccess defines the callback called when the script is loaded
  94338. * @param onError defines the callback to call if an error occurs
  94339. * @param scriptId defines the id of the script element
  94340. */
  94341. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  94342. /**
  94343. * Load an asynchronous script (identified by an url). When the url returns, the
  94344. * content of this file is added into a new script element, attached to the DOM (body element)
  94345. * @param scriptUrl defines the url of the script to laod
  94346. * @param scriptId defines the id of the script element
  94347. * @returns a promise request object
  94348. */
  94349. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  94350. /**
  94351. * Loads a file from a blob
  94352. * @param fileToLoad defines the blob to use
  94353. * @param callback defines the callback to call when data is loaded
  94354. * @param progressCallback defines the callback to call during loading process
  94355. * @returns a file request object
  94356. */
  94357. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  94358. /**
  94359. * Loads a file
  94360. * @param fileToLoad defines the file to load
  94361. * @param callback defines the callback to call when data is loaded
  94362. * @param progressCallBack defines the callback to call during loading process
  94363. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  94364. * @returns a file request object
  94365. */
  94366. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  94367. /**
  94368. * Creates a data url from a given string content
  94369. * @param content defines the content to convert
  94370. * @returns the new data url link
  94371. */
  94372. static FileAsURL(content: string): string;
  94373. /**
  94374. * Format the given number to a specific decimal format
  94375. * @param value defines the number to format
  94376. * @param decimals defines the number of decimals to use
  94377. * @returns the formatted string
  94378. */
  94379. static Format(value: number, decimals?: number): string;
  94380. /**
  94381. * Checks if a given vector is inside a specific range
  94382. * @param v defines the vector to test
  94383. * @param min defines the minimum range
  94384. * @param max defines the maximum range
  94385. */
  94386. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  94387. /**
  94388. * Tries to copy an object by duplicating every property
  94389. * @param source defines the source object
  94390. * @param destination defines the target object
  94391. * @param doNotCopyList defines a list of properties to avoid
  94392. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  94393. */
  94394. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  94395. /**
  94396. * Gets a boolean indicating if the given object has no own property
  94397. * @param obj defines the object to test
  94398. * @returns true if object has no own property
  94399. */
  94400. static IsEmpty(obj: any): boolean;
  94401. /**
  94402. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  94403. * @param str Source string
  94404. * @param suffix Suffix to search for in the source string
  94405. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  94406. */
  94407. static EndsWith(str: string, suffix: string): boolean;
  94408. /**
  94409. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  94410. * @param str Source string
  94411. * @param suffix Suffix to search for in the source string
  94412. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  94413. */
  94414. static StartsWith(str: string, suffix: string): boolean;
  94415. /**
  94416. * Function used to register events at window level
  94417. * @param events defines the events to register
  94418. */
  94419. static RegisterTopRootEvents(events: {
  94420. name: string;
  94421. handler: Nullable<(e: FocusEvent) => any>;
  94422. }[]): void;
  94423. /**
  94424. * Function used to unregister events from window level
  94425. * @param events defines the events to unregister
  94426. */
  94427. static UnregisterTopRootEvents(events: {
  94428. name: string;
  94429. handler: Nullable<(e: FocusEvent) => any>;
  94430. }[]): void;
  94431. /**
  94432. * @ignore
  94433. */
  94434. static _ScreenshotCanvas: HTMLCanvasElement;
  94435. /**
  94436. * Dumps the current bound framebuffer
  94437. * @param width defines the rendering width
  94438. * @param height defines the rendering height
  94439. * @param engine defines the hosting engine
  94440. * @param successCallback defines the callback triggered once the data are available
  94441. * @param mimeType defines the mime type of the result
  94442. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  94443. */
  94444. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  94445. /**
  94446. * Converts the canvas data to blob.
  94447. * This acts as a polyfill for browsers not supporting the to blob function.
  94448. * @param canvas Defines the canvas to extract the data from
  94449. * @param successCallback Defines the callback triggered once the data are available
  94450. * @param mimeType Defines the mime type of the result
  94451. */
  94452. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  94453. /**
  94454. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  94455. * @param successCallback defines the callback triggered once the data are available
  94456. * @param mimeType defines the mime type of the result
  94457. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  94458. */
  94459. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  94460. /**
  94461. * Downloads a blob in the browser
  94462. * @param blob defines the blob to download
  94463. * @param fileName defines the name of the downloaded file
  94464. */
  94465. static Download(blob: Blob, fileName: string): void;
  94466. /**
  94467. * Captures a screenshot of the current rendering
  94468. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  94469. * @param engine defines the rendering engine
  94470. * @param camera defines the source camera
  94471. * @param size This parameter can be set to a single number or to an object with the
  94472. * following (optional) properties: precision, width, height. If a single number is passed,
  94473. * it will be used for both width and height. If an object is passed, the screenshot size
  94474. * will be derived from the parameters. The precision property is a multiplier allowing
  94475. * rendering at a higher or lower resolution
  94476. * @param successCallback defines the callback receives a single parameter which contains the
  94477. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  94478. * src parameter of an <img> to display it
  94479. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  94480. * Check your browser for supported MIME types
  94481. */
  94482. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  94483. /**
  94484. * Generates an image screenshot from the specified camera.
  94485. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  94486. * @param engine The engine to use for rendering
  94487. * @param camera The camera to use for rendering
  94488. * @param size This parameter can be set to a single number or to an object with the
  94489. * following (optional) properties: precision, width, height. If a single number is passed,
  94490. * it will be used for both width and height. If an object is passed, the screenshot size
  94491. * will be derived from the parameters. The precision property is a multiplier allowing
  94492. * rendering at a higher or lower resolution
  94493. * @param successCallback The callback receives a single parameter which contains the
  94494. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  94495. * src parameter of an <img> to display it
  94496. * @param mimeType The MIME type of the screenshot image (default: image/png).
  94497. * Check your browser for supported MIME types
  94498. * @param samples Texture samples (default: 1)
  94499. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  94500. * @param fileName A name for for the downloaded file.
  94501. */
  94502. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  94503. /**
  94504. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  94505. * Be aware Math.random() could cause collisions, but:
  94506. * "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"
  94507. * @returns a pseudo random id
  94508. */
  94509. static RandomId(): string;
  94510. /**
  94511. * Test if the given uri is a base64 string
  94512. * @param uri The uri to test
  94513. * @return True if the uri is a base64 string or false otherwise
  94514. */
  94515. static IsBase64(uri: string): boolean;
  94516. /**
  94517. * Decode the given base64 uri.
  94518. * @param uri The uri to decode
  94519. * @return The decoded base64 data.
  94520. */
  94521. static DecodeBase64(uri: string): ArrayBuffer;
  94522. /**
  94523. * Gets the absolute url.
  94524. * @param url the input url
  94525. * @return the absolute url
  94526. */
  94527. static GetAbsoluteUrl(url: string): string;
  94528. /**
  94529. * No log
  94530. */
  94531. static readonly NoneLogLevel: number;
  94532. /**
  94533. * Only message logs
  94534. */
  94535. static readonly MessageLogLevel: number;
  94536. /**
  94537. * Only warning logs
  94538. */
  94539. static readonly WarningLogLevel: number;
  94540. /**
  94541. * Only error logs
  94542. */
  94543. static readonly ErrorLogLevel: number;
  94544. /**
  94545. * All logs
  94546. */
  94547. static readonly AllLogLevel: number;
  94548. /**
  94549. * Gets a value indicating the number of loading errors
  94550. * @ignorenaming
  94551. */
  94552. static readonly errorsCount: number;
  94553. /**
  94554. * Callback called when a new log is added
  94555. */
  94556. static OnNewCacheEntry: (entry: string) => void;
  94557. /**
  94558. * Log a message to the console
  94559. * @param message defines the message to log
  94560. */
  94561. static Log(message: string): void;
  94562. /**
  94563. * Write a warning message to the console
  94564. * @param message defines the message to log
  94565. */
  94566. static Warn(message: string): void;
  94567. /**
  94568. * Write an error message to the console
  94569. * @param message defines the message to log
  94570. */
  94571. static Error(message: string): void;
  94572. /**
  94573. * Gets current log cache (list of logs)
  94574. */
  94575. static readonly LogCache: string;
  94576. /**
  94577. * Clears the log cache
  94578. */
  94579. static ClearLogCache(): void;
  94580. /**
  94581. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  94582. */
  94583. static LogLevels: number;
  94584. /**
  94585. * Checks if the loaded document was accessed via `file:`-Protocol.
  94586. * @returns boolean
  94587. */
  94588. static IsFileURL(): boolean;
  94589. /**
  94590. * Checks if the window object exists
  94591. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  94592. */
  94593. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  94594. /**
  94595. * No performance log
  94596. */
  94597. static readonly PerformanceNoneLogLevel: number;
  94598. /**
  94599. * Use user marks to log performance
  94600. */
  94601. static readonly PerformanceUserMarkLogLevel: number;
  94602. /**
  94603. * Log performance to the console
  94604. */
  94605. static readonly PerformanceConsoleLogLevel: number;
  94606. private static _performance;
  94607. /**
  94608. * Sets the current performance log level
  94609. */
  94610. static PerformanceLogLevel: number;
  94611. private static _StartPerformanceCounterDisabled;
  94612. private static _EndPerformanceCounterDisabled;
  94613. private static _StartUserMark;
  94614. private static _EndUserMark;
  94615. private static _StartPerformanceConsole;
  94616. private static _EndPerformanceConsole;
  94617. /**
  94618. * Starts a performance counter
  94619. */
  94620. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  94621. /**
  94622. * Ends a specific performance coutner
  94623. */
  94624. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  94625. /**
  94626. * Gets either window.performance.now() if supported or Date.now() else
  94627. */
  94628. static readonly Now: number;
  94629. /**
  94630. * This method will return the name of the class used to create the instance of the given object.
  94631. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  94632. * @param object the object to get the class name from
  94633. * @param isType defines if the object is actually a type
  94634. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  94635. */
  94636. static GetClassName(object: any, isType?: boolean): string;
  94637. /**
  94638. * Gets the first element of an array satisfying a given predicate
  94639. * @param array defines the array to browse
  94640. * @param predicate defines the predicate to use
  94641. * @returns null if not found or the element
  94642. */
  94643. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  94644. /**
  94645. * This method will return the name of the full name of the class, including its owning module (if any).
  94646. * 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).
  94647. * @param object the object to get the class name from
  94648. * @param isType defines if the object is actually a type
  94649. * @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.
  94650. * @ignorenaming
  94651. */
  94652. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  94653. /**
  94654. * Returns a promise that resolves after the given amount of time.
  94655. * @param delay Number of milliseconds to delay
  94656. * @returns Promise that resolves after the given amount of time
  94657. */
  94658. static DelayAsync(delay: number): Promise<void>;
  94659. /**
  94660. * Gets the current gradient from an array of IValueGradient
  94661. * @param ratio defines the current ratio to get
  94662. * @param gradients defines the array of IValueGradient
  94663. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  94664. */
  94665. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  94666. }
  94667. /**
  94668. * This class is used to track a performance counter which is number based.
  94669. * The user has access to many properties which give statistics of different nature.
  94670. *
  94671. * The implementer can track two kinds of Performance Counter: time and count.
  94672. * 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.
  94673. * 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.
  94674. */
  94675. export class PerfCounter {
  94676. /**
  94677. * Gets or sets a global boolean to turn on and off all the counters
  94678. */
  94679. static Enabled: boolean;
  94680. /**
  94681. * Returns the smallest value ever
  94682. */
  94683. readonly min: number;
  94684. /**
  94685. * Returns the biggest value ever
  94686. */
  94687. readonly max: number;
  94688. /**
  94689. * Returns the average value since the performance counter is running
  94690. */
  94691. readonly average: number;
  94692. /**
  94693. * Returns the average value of the last second the counter was monitored
  94694. */
  94695. readonly lastSecAverage: number;
  94696. /**
  94697. * Returns the current value
  94698. */
  94699. readonly current: number;
  94700. /**
  94701. * Gets the accumulated total
  94702. */
  94703. readonly total: number;
  94704. /**
  94705. * Gets the total value count
  94706. */
  94707. readonly count: number;
  94708. /**
  94709. * Creates a new counter
  94710. */
  94711. constructor();
  94712. /**
  94713. * Call this method to start monitoring a new frame.
  94714. * 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.
  94715. */
  94716. fetchNewFrame(): void;
  94717. /**
  94718. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  94719. * @param newCount the count value to add to the monitored count
  94720. * @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.
  94721. */
  94722. addCount(newCount: number, fetchResult: boolean): void;
  94723. /**
  94724. * Start monitoring this performance counter
  94725. */
  94726. beginMonitoring(): void;
  94727. /**
  94728. * Compute the time lapsed since the previous beginMonitoring() call.
  94729. * @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
  94730. */
  94731. endMonitoring(newFrame?: boolean): void;
  94732. private _fetchResult;
  94733. private _startMonitoringTime;
  94734. private _min;
  94735. private _max;
  94736. private _average;
  94737. private _current;
  94738. private _totalValueCount;
  94739. private _totalAccumulated;
  94740. private _lastSecAverage;
  94741. private _lastSecAccumulated;
  94742. private _lastSecTime;
  94743. private _lastSecValueCount;
  94744. }
  94745. /**
  94746. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  94747. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  94748. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  94749. * @param name The name of the class, case should be preserved
  94750. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  94751. */
  94752. export function className(name: string, module?: string): (target: Object) => void;
  94753. /**
  94754. * An implementation of a loop for asynchronous functions.
  94755. */
  94756. export class AsyncLoop {
  94757. /**
  94758. * Defines the number of iterations for the loop
  94759. */
  94760. iterations: number;
  94761. /**
  94762. * Defines the current index of the loop.
  94763. */
  94764. index: number;
  94765. private _done;
  94766. private _fn;
  94767. private _successCallback;
  94768. /**
  94769. * Constructor.
  94770. * @param iterations the number of iterations.
  94771. * @param func the function to run each iteration
  94772. * @param successCallback the callback that will be called upon succesful execution
  94773. * @param offset starting offset.
  94774. */
  94775. constructor(
  94776. /**
  94777. * Defines the number of iterations for the loop
  94778. */
  94779. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  94780. /**
  94781. * Execute the next iteration. Must be called after the last iteration was finished.
  94782. */
  94783. executeNext(): void;
  94784. /**
  94785. * Break the loop and run the success callback.
  94786. */
  94787. breakLoop(): void;
  94788. /**
  94789. * Create and run an async loop.
  94790. * @param iterations the number of iterations.
  94791. * @param fn the function to run each iteration
  94792. * @param successCallback the callback that will be called upon succesful execution
  94793. * @param offset starting offset.
  94794. * @returns the created async loop object
  94795. */
  94796. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  94797. /**
  94798. * A for-loop that will run a given number of iterations synchronous and the rest async.
  94799. * @param iterations total number of iterations
  94800. * @param syncedIterations number of synchronous iterations in each async iteration.
  94801. * @param fn the function to call each iteration.
  94802. * @param callback a success call back that will be called when iterating stops.
  94803. * @param breakFunction a break condition (optional)
  94804. * @param timeout timeout settings for the setTimeout function. default - 0.
  94805. * @returns the created async loop object
  94806. */
  94807. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  94808. }
  94809. }
  94810. declare module BABYLON {
  94811. /** @hidden */
  94812. export interface ICollisionCoordinator {
  94813. createCollider(): Collider;
  94814. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  94815. init(scene: Scene): void;
  94816. }
  94817. /** @hidden */
  94818. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  94819. private _scene;
  94820. private _scaledPosition;
  94821. private _scaledVelocity;
  94822. private _finalPosition;
  94823. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  94824. createCollider(): Collider;
  94825. init(scene: Scene): void;
  94826. private _collideWithWorld;
  94827. }
  94828. }
  94829. declare module BABYLON {
  94830. /**
  94831. * Class used to manage all inputs for the scene.
  94832. */
  94833. export class InputManager {
  94834. /** The distance in pixel that you have to move to prevent some events */
  94835. static DragMovementThreshold: number;
  94836. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  94837. static LongPressDelay: number;
  94838. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  94839. static DoubleClickDelay: number;
  94840. /** If you need to check double click without raising a single click at first click, enable this flag */
  94841. static ExclusiveDoubleClickMode: boolean;
  94842. private _wheelEventName;
  94843. private _onPointerMove;
  94844. private _onPointerDown;
  94845. private _onPointerUp;
  94846. private _initClickEvent;
  94847. private _initActionManager;
  94848. private _delayedSimpleClick;
  94849. private _delayedSimpleClickTimeout;
  94850. private _previousDelayedSimpleClickTimeout;
  94851. private _meshPickProceed;
  94852. private _previousButtonPressed;
  94853. private _currentPickResult;
  94854. private _previousPickResult;
  94855. private _totalPointersPressed;
  94856. private _doubleClickOccured;
  94857. private _pointerOverMesh;
  94858. private _pickedDownMesh;
  94859. private _pickedUpMesh;
  94860. private _pointerX;
  94861. private _pointerY;
  94862. private _unTranslatedPointerX;
  94863. private _unTranslatedPointerY;
  94864. private _startingPointerPosition;
  94865. private _previousStartingPointerPosition;
  94866. private _startingPointerTime;
  94867. private _previousStartingPointerTime;
  94868. private _pointerCaptures;
  94869. private _onKeyDown;
  94870. private _onKeyUp;
  94871. private _onCanvasFocusObserver;
  94872. private _onCanvasBlurObserver;
  94873. private _scene;
  94874. /**
  94875. * Creates a new InputManager
  94876. * @param scene defines the hosting scene
  94877. */
  94878. constructor(scene: Scene);
  94879. /**
  94880. * Gets the mesh that is currently under the pointer
  94881. */
  94882. readonly meshUnderPointer: Nullable<AbstractMesh>;
  94883. /**
  94884. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  94885. */
  94886. readonly unTranslatedPointer: Vector2;
  94887. /**
  94888. * Gets or sets the current on-screen X position of the pointer
  94889. */
  94890. pointerX: number;
  94891. /**
  94892. * Gets or sets the current on-screen Y position of the pointer
  94893. */
  94894. pointerY: number;
  94895. private _updatePointerPosition;
  94896. private _processPointerMove;
  94897. private _setRayOnPointerInfo;
  94898. private _checkPrePointerObservable;
  94899. /**
  94900. * Use this method to simulate a pointer move on a mesh
  94901. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  94902. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  94903. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  94904. */
  94905. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  94906. /**
  94907. * Use this method to simulate a pointer down on a mesh
  94908. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  94909. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  94910. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  94911. */
  94912. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  94913. private _processPointerDown;
  94914. /** @hidden */
  94915. _isPointerSwiping(): boolean;
  94916. /**
  94917. * Use this method to simulate a pointer up on a mesh
  94918. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  94919. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  94920. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  94921. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  94922. */
  94923. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  94924. private _processPointerUp;
  94925. /**
  94926. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  94927. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  94928. * @returns true if the pointer was captured
  94929. */
  94930. isPointerCaptured(pointerId?: number): boolean;
  94931. /**
  94932. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  94933. * @param attachUp defines if you want to attach events to pointerup
  94934. * @param attachDown defines if you want to attach events to pointerdown
  94935. * @param attachMove defines if you want to attach events to pointermove
  94936. */
  94937. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  94938. /**
  94939. * Detaches all event handlers
  94940. */
  94941. detachControl(): void;
  94942. /**
  94943. * Force the value of meshUnderPointer
  94944. * @param mesh defines the mesh to use
  94945. */
  94946. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  94947. /**
  94948. * Gets the mesh under the pointer
  94949. * @returns a Mesh or null if no mesh is under the pointer
  94950. */
  94951. getPointerOverMesh(): Nullable<AbstractMesh>;
  94952. }
  94953. }
  94954. declare module BABYLON {
  94955. /**
  94956. * This class defines the direct association between an animation and a target
  94957. */
  94958. export class TargetedAnimation {
  94959. /**
  94960. * Animation to perform
  94961. */
  94962. animation: Animation;
  94963. /**
  94964. * Target to animate
  94965. */
  94966. target: any;
  94967. /**
  94968. * Serialize the object
  94969. * @returns the JSON object representing the current entity
  94970. */
  94971. serialize(): any;
  94972. }
  94973. /**
  94974. * Use this class to create coordinated animations on multiple targets
  94975. */
  94976. export class AnimationGroup implements IDisposable {
  94977. /** The name of the animation group */
  94978. name: string;
  94979. private _scene;
  94980. private _targetedAnimations;
  94981. private _animatables;
  94982. private _from;
  94983. private _to;
  94984. private _isStarted;
  94985. private _isPaused;
  94986. private _speedRatio;
  94987. private _loopAnimation;
  94988. /**
  94989. * Gets or sets the unique id of the node
  94990. */
  94991. uniqueId: number;
  94992. /**
  94993. * This observable will notify when one animation have ended
  94994. */
  94995. onAnimationEndObservable: Observable<TargetedAnimation>;
  94996. /**
  94997. * Observer raised when one animation loops
  94998. */
  94999. onAnimationLoopObservable: Observable<TargetedAnimation>;
  95000. /**
  95001. * This observable will notify when all animations have ended.
  95002. */
  95003. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  95004. /**
  95005. * This observable will notify when all animations have paused.
  95006. */
  95007. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  95008. /**
  95009. * This observable will notify when all animations are playing.
  95010. */
  95011. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  95012. /**
  95013. * Gets the first frame
  95014. */
  95015. readonly from: number;
  95016. /**
  95017. * Gets the last frame
  95018. */
  95019. readonly to: number;
  95020. /**
  95021. * Define if the animations are started
  95022. */
  95023. readonly isStarted: boolean;
  95024. /**
  95025. * Gets a value indicating that the current group is playing
  95026. */
  95027. readonly isPlaying: boolean;
  95028. /**
  95029. * Gets or sets the speed ratio to use for all animations
  95030. */
  95031. /**
  95032. * Gets or sets the speed ratio to use for all animations
  95033. */
  95034. speedRatio: number;
  95035. /**
  95036. * Gets or sets if all animations should loop or not
  95037. */
  95038. loopAnimation: boolean;
  95039. /**
  95040. * Gets the targeted animations for this animation group
  95041. */
  95042. readonly targetedAnimations: Array<TargetedAnimation>;
  95043. /**
  95044. * returning the list of animatables controlled by this animation group.
  95045. */
  95046. readonly animatables: Array<Animatable>;
  95047. /**
  95048. * Instantiates a new Animation Group.
  95049. * This helps managing several animations at once.
  95050. * @see http://doc.babylonjs.com/how_to/group
  95051. * @param name Defines the name of the group
  95052. * @param scene Defines the scene the group belongs to
  95053. */
  95054. constructor(
  95055. /** The name of the animation group */
  95056. name: string, scene?: Nullable<Scene>);
  95057. /**
  95058. * Add an animation (with its target) in the group
  95059. * @param animation defines the animation we want to add
  95060. * @param target defines the target of the animation
  95061. * @returns the TargetedAnimation object
  95062. */
  95063. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  95064. /**
  95065. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  95066. * It can add constant keys at begin or end
  95067. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  95068. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  95069. * @returns the animation group
  95070. */
  95071. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  95072. /**
  95073. * Start all animations on given targets
  95074. * @param loop defines if animations must loop
  95075. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  95076. * @param from defines the from key (optional)
  95077. * @param to defines the to key (optional)
  95078. * @returns the current animation group
  95079. */
  95080. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  95081. /**
  95082. * Pause all animations
  95083. * @returns the animation group
  95084. */
  95085. pause(): AnimationGroup;
  95086. /**
  95087. * Play all animations to initial state
  95088. * This function will start() the animations if they were not started or will restart() them if they were paused
  95089. * @param loop defines if animations must loop
  95090. * @returns the animation group
  95091. */
  95092. play(loop?: boolean): AnimationGroup;
  95093. /**
  95094. * Reset all animations to initial state
  95095. * @returns the animation group
  95096. */
  95097. reset(): AnimationGroup;
  95098. /**
  95099. * Restart animations from key 0
  95100. * @returns the animation group
  95101. */
  95102. restart(): AnimationGroup;
  95103. /**
  95104. * Stop all animations
  95105. * @returns the animation group
  95106. */
  95107. stop(): AnimationGroup;
  95108. /**
  95109. * Set animation weight for all animatables
  95110. * @param weight defines the weight to use
  95111. * @return the animationGroup
  95112. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  95113. */
  95114. setWeightForAllAnimatables(weight: number): AnimationGroup;
  95115. /**
  95116. * Synchronize and normalize all animatables with a source animatable
  95117. * @param root defines the root animatable to synchronize with
  95118. * @return the animationGroup
  95119. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  95120. */
  95121. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  95122. /**
  95123. * Goes to a specific frame in this animation group
  95124. * @param frame the frame number to go to
  95125. * @return the animationGroup
  95126. */
  95127. goToFrame(frame: number): AnimationGroup;
  95128. /**
  95129. * Dispose all associated resources
  95130. */
  95131. dispose(): void;
  95132. private _checkAnimationGroupEnded;
  95133. /**
  95134. * Clone the current animation group and returns a copy
  95135. * @param newName defines the name of the new group
  95136. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  95137. * @returns the new aniamtion group
  95138. */
  95139. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  95140. /**
  95141. * Serializes the animationGroup to an object
  95142. * @returns Serialized object
  95143. */
  95144. serialize(): any;
  95145. /**
  95146. * Returns a new AnimationGroup object parsed from the source provided.
  95147. * @param parsedAnimationGroup defines the source
  95148. * @param scene defines the scene that will receive the animationGroup
  95149. * @returns a new AnimationGroup
  95150. */
  95151. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  95152. /**
  95153. * Returns the string "AnimationGroup"
  95154. * @returns "AnimationGroup"
  95155. */
  95156. getClassName(): string;
  95157. /**
  95158. * Creates a detailled string about the object
  95159. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  95160. * @returns a string representing the object
  95161. */
  95162. toString(fullDetails?: boolean): string;
  95163. }
  95164. }
  95165. declare module BABYLON {
  95166. /**
  95167. * Define an interface for all classes that will hold resources
  95168. */
  95169. export interface IDisposable {
  95170. /**
  95171. * Releases all held resources
  95172. */
  95173. dispose(): void;
  95174. }
  95175. /** Interface defining initialization parameters for Scene class */
  95176. export interface SceneOptions {
  95177. /**
  95178. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  95179. * It will improve performance when the number of geometries becomes important.
  95180. */
  95181. useGeometryUniqueIdsMap?: boolean;
  95182. /**
  95183. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  95184. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  95185. */
  95186. useMaterialMeshMap?: boolean;
  95187. /**
  95188. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  95189. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  95190. */
  95191. useClonedMeshhMap?: boolean;
  95192. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  95193. virtual?: boolean;
  95194. }
  95195. /**
  95196. * Represents a scene to be rendered by the engine.
  95197. * @see http://doc.babylonjs.com/features/scene
  95198. */
  95199. export class Scene extends AbstractScene implements IAnimatable {
  95200. private static _uniqueIdCounter;
  95201. /** The fog is deactivated */
  95202. static readonly FOGMODE_NONE: number;
  95203. /** The fog density is following an exponential function */
  95204. static readonly FOGMODE_EXP: number;
  95205. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  95206. static readonly FOGMODE_EXP2: number;
  95207. /** The fog density is following a linear function. */
  95208. static readonly FOGMODE_LINEAR: number;
  95209. /**
  95210. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  95211. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95212. */
  95213. static MinDeltaTime: number;
  95214. /**
  95215. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  95216. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95217. */
  95218. static MaxDeltaTime: number;
  95219. /**
  95220. * Factory used to create the default material.
  95221. * @param name The name of the material to create
  95222. * @param scene The scene to create the material for
  95223. * @returns The default material
  95224. */
  95225. static DefaultMaterialFactory(scene: Scene): Material;
  95226. /**
  95227. * Factory used to create the a collision coordinator.
  95228. * @returns The collision coordinator
  95229. */
  95230. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  95231. /** @hidden */
  95232. _inputManager: InputManager;
  95233. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  95234. cameraToUseForPointers: Nullable<Camera>;
  95235. /** @hidden */
  95236. readonly _isScene: boolean;
  95237. /**
  95238. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  95239. */
  95240. autoClear: boolean;
  95241. /**
  95242. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  95243. */
  95244. autoClearDepthAndStencil: boolean;
  95245. /**
  95246. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  95247. */
  95248. clearColor: Color4;
  95249. /**
  95250. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  95251. */
  95252. ambientColor: Color3;
  95253. /**
  95254. * This is use to store the default BRDF lookup for PBR materials in your scene.
  95255. * It should only be one of the following (if not the default embedded one):
  95256. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  95257. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  95258. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  95259. * The material properties need to be setup according to the type of texture in use.
  95260. */
  95261. environmentBRDFTexture: BaseTexture;
  95262. /** @hidden */
  95263. protected _environmentTexture: Nullable<BaseTexture>;
  95264. /**
  95265. * Texture used in all pbr material as the reflection texture.
  95266. * As in the majority of the scene they are the same (exception for multi room and so on),
  95267. * this is easier to reference from here than from all the materials.
  95268. */
  95269. /**
  95270. * Texture used in all pbr material as the reflection texture.
  95271. * As in the majority of the scene they are the same (exception for multi room and so on),
  95272. * this is easier to set here than in all the materials.
  95273. */
  95274. environmentTexture: Nullable<BaseTexture>;
  95275. /** @hidden */
  95276. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  95277. /**
  95278. * Default image processing configuration used either in the rendering
  95279. * Forward main pass or through the imageProcessingPostProcess if present.
  95280. * As in the majority of the scene they are the same (exception for multi camera),
  95281. * this is easier to reference from here than from all the materials and post process.
  95282. *
  95283. * No setter as we it is a shared configuration, you can set the values instead.
  95284. */
  95285. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  95286. private _forceWireframe;
  95287. /**
  95288. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  95289. */
  95290. forceWireframe: boolean;
  95291. private _forcePointsCloud;
  95292. /**
  95293. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  95294. */
  95295. forcePointsCloud: boolean;
  95296. /**
  95297. * Gets or sets the active clipplane 1
  95298. */
  95299. clipPlane: Nullable<Plane>;
  95300. /**
  95301. * Gets or sets the active clipplane 2
  95302. */
  95303. clipPlane2: Nullable<Plane>;
  95304. /**
  95305. * Gets or sets the active clipplane 3
  95306. */
  95307. clipPlane3: Nullable<Plane>;
  95308. /**
  95309. * Gets or sets the active clipplane 4
  95310. */
  95311. clipPlane4: Nullable<Plane>;
  95312. /**
  95313. * Gets or sets a boolean indicating if animations are enabled
  95314. */
  95315. animationsEnabled: boolean;
  95316. private _animationPropertiesOverride;
  95317. /**
  95318. * Gets or sets the animation properties override
  95319. */
  95320. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  95321. /**
  95322. * Gets or sets a boolean indicating if a constant deltatime has to be used
  95323. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  95324. */
  95325. useConstantAnimationDeltaTime: boolean;
  95326. /**
  95327. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  95328. * Please note that it requires to run a ray cast through the scene on every frame
  95329. */
  95330. constantlyUpdateMeshUnderPointer: boolean;
  95331. /**
  95332. * Defines the HTML cursor to use when hovering over interactive elements
  95333. */
  95334. hoverCursor: string;
  95335. /**
  95336. * Defines the HTML default cursor to use (empty by default)
  95337. */
  95338. defaultCursor: string;
  95339. /**
  95340. * This is used to call preventDefault() on pointer down
  95341. * in order to block unwanted artifacts like system double clicks
  95342. */
  95343. preventDefaultOnPointerDown: boolean;
  95344. /**
  95345. * This is used to call preventDefault() on pointer up
  95346. * in order to block unwanted artifacts like system double clicks
  95347. */
  95348. preventDefaultOnPointerUp: boolean;
  95349. /**
  95350. * Gets or sets user defined metadata
  95351. */
  95352. metadata: any;
  95353. /**
  95354. * For internal use only. Please do not use.
  95355. */
  95356. reservedDataStore: any;
  95357. /**
  95358. * Gets the name of the plugin used to load this scene (null by default)
  95359. */
  95360. loadingPluginName: string;
  95361. /**
  95362. * Use this array to add regular expressions used to disable offline support for specific urls
  95363. */
  95364. disableOfflineSupportExceptionRules: RegExp[];
  95365. /**
  95366. * An event triggered when the scene is disposed.
  95367. */
  95368. onDisposeObservable: Observable<Scene>;
  95369. private _onDisposeObserver;
  95370. /** Sets a function to be executed when this scene is disposed. */
  95371. onDispose: () => void;
  95372. /**
  95373. * An event triggered before rendering the scene (right after animations and physics)
  95374. */
  95375. onBeforeRenderObservable: Observable<Scene>;
  95376. private _onBeforeRenderObserver;
  95377. /** Sets a function to be executed before rendering this scene */
  95378. beforeRender: Nullable<() => void>;
  95379. /**
  95380. * An event triggered after rendering the scene
  95381. */
  95382. onAfterRenderObservable: Observable<Scene>;
  95383. /**
  95384. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  95385. */
  95386. onAfterRenderCameraObservable: Observable<Camera>;
  95387. private _onAfterRenderObserver;
  95388. /** Sets a function to be executed after rendering this scene */
  95389. afterRender: Nullable<() => void>;
  95390. /**
  95391. * An event triggered before animating the scene
  95392. */
  95393. onBeforeAnimationsObservable: Observable<Scene>;
  95394. /**
  95395. * An event triggered after animations processing
  95396. */
  95397. onAfterAnimationsObservable: Observable<Scene>;
  95398. /**
  95399. * An event triggered before draw calls are ready to be sent
  95400. */
  95401. onBeforeDrawPhaseObservable: Observable<Scene>;
  95402. /**
  95403. * An event triggered after draw calls have been sent
  95404. */
  95405. onAfterDrawPhaseObservable: Observable<Scene>;
  95406. /**
  95407. * An event triggered when the scene is ready
  95408. */
  95409. onReadyObservable: Observable<Scene>;
  95410. /**
  95411. * An event triggered before rendering a camera
  95412. */
  95413. onBeforeCameraRenderObservable: Observable<Camera>;
  95414. private _onBeforeCameraRenderObserver;
  95415. /** Sets a function to be executed before rendering a camera*/
  95416. beforeCameraRender: () => void;
  95417. /**
  95418. * An event triggered after rendering a camera
  95419. */
  95420. onAfterCameraRenderObservable: Observable<Camera>;
  95421. private _onAfterCameraRenderObserver;
  95422. /** Sets a function to be executed after rendering a camera*/
  95423. afterCameraRender: () => void;
  95424. /**
  95425. * An event triggered when active meshes evaluation is about to start
  95426. */
  95427. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  95428. /**
  95429. * An event triggered when active meshes evaluation is done
  95430. */
  95431. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  95432. /**
  95433. * An event triggered when particles rendering is about to start
  95434. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  95435. */
  95436. onBeforeParticlesRenderingObservable: Observable<Scene>;
  95437. /**
  95438. * An event triggered when particles rendering is done
  95439. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  95440. */
  95441. onAfterParticlesRenderingObservable: Observable<Scene>;
  95442. /**
  95443. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  95444. */
  95445. onDataLoadedObservable: Observable<Scene>;
  95446. /**
  95447. * An event triggered when a camera is created
  95448. */
  95449. onNewCameraAddedObservable: Observable<Camera>;
  95450. /**
  95451. * An event triggered when a camera is removed
  95452. */
  95453. onCameraRemovedObservable: Observable<Camera>;
  95454. /**
  95455. * An event triggered when a light is created
  95456. */
  95457. onNewLightAddedObservable: Observable<Light>;
  95458. /**
  95459. * An event triggered when a light is removed
  95460. */
  95461. onLightRemovedObservable: Observable<Light>;
  95462. /**
  95463. * An event triggered when a geometry is created
  95464. */
  95465. onNewGeometryAddedObservable: Observable<Geometry>;
  95466. /**
  95467. * An event triggered when a geometry is removed
  95468. */
  95469. onGeometryRemovedObservable: Observable<Geometry>;
  95470. /**
  95471. * An event triggered when a transform node is created
  95472. */
  95473. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  95474. /**
  95475. * An event triggered when a transform node is removed
  95476. */
  95477. onTransformNodeRemovedObservable: Observable<TransformNode>;
  95478. /**
  95479. * An event triggered when a mesh is created
  95480. */
  95481. onNewMeshAddedObservable: Observable<AbstractMesh>;
  95482. /**
  95483. * An event triggered when a mesh is removed
  95484. */
  95485. onMeshRemovedObservable: Observable<AbstractMesh>;
  95486. /**
  95487. * An event triggered when a skeleton is created
  95488. */
  95489. onNewSkeletonAddedObservable: Observable<Skeleton>;
  95490. /**
  95491. * An event triggered when a skeleton is removed
  95492. */
  95493. onSkeletonRemovedObservable: Observable<Skeleton>;
  95494. /**
  95495. * An event triggered when a material is created
  95496. */
  95497. onNewMaterialAddedObservable: Observable<Material>;
  95498. /**
  95499. * An event triggered when a material is removed
  95500. */
  95501. onMaterialRemovedObservable: Observable<Material>;
  95502. /**
  95503. * An event triggered when a texture is created
  95504. */
  95505. onNewTextureAddedObservable: Observable<BaseTexture>;
  95506. /**
  95507. * An event triggered when a texture is removed
  95508. */
  95509. onTextureRemovedObservable: Observable<BaseTexture>;
  95510. /**
  95511. * An event triggered when render targets are about to be rendered
  95512. * Can happen multiple times per frame.
  95513. */
  95514. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  95515. /**
  95516. * An event triggered when render targets were rendered.
  95517. * Can happen multiple times per frame.
  95518. */
  95519. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  95520. /**
  95521. * An event triggered before calculating deterministic simulation step
  95522. */
  95523. onBeforeStepObservable: Observable<Scene>;
  95524. /**
  95525. * An event triggered after calculating deterministic simulation step
  95526. */
  95527. onAfterStepObservable: Observable<Scene>;
  95528. /**
  95529. * An event triggered when the activeCamera property is updated
  95530. */
  95531. onActiveCameraChanged: Observable<Scene>;
  95532. /**
  95533. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  95534. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  95535. * 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)
  95536. */
  95537. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  95538. /**
  95539. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  95540. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  95541. * 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)
  95542. */
  95543. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  95544. /**
  95545. * This Observable will when a mesh has been imported into the scene.
  95546. */
  95547. onMeshImportedObservable: Observable<AbstractMesh>;
  95548. /**
  95549. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  95550. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  95551. */
  95552. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  95553. /** @hidden */
  95554. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  95555. /**
  95556. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  95557. */
  95558. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  95559. /**
  95560. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  95561. */
  95562. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  95563. /**
  95564. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  95565. */
  95566. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  95567. /** Callback called when a pointer move is detected */
  95568. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  95569. /** Callback called when a pointer down is detected */
  95570. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  95571. /** Callback called when a pointer up is detected */
  95572. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  95573. /** Callback called when a pointer pick is detected */
  95574. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  95575. /**
  95576. * 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).
  95577. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  95578. */
  95579. onPrePointerObservable: Observable<PointerInfoPre>;
  95580. /**
  95581. * Observable event triggered each time an input event is received from the rendering canvas
  95582. */
  95583. onPointerObservable: Observable<PointerInfo>;
  95584. /**
  95585. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  95586. */
  95587. readonly unTranslatedPointer: Vector2;
  95588. /**
  95589. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  95590. */
  95591. static DragMovementThreshold: number;
  95592. /**
  95593. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  95594. */
  95595. static LongPressDelay: number;
  95596. /**
  95597. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  95598. */
  95599. static DoubleClickDelay: number;
  95600. /** If you need to check double click without raising a single click at first click, enable this flag */
  95601. static ExclusiveDoubleClickMode: boolean;
  95602. /** @hidden */
  95603. _mirroredCameraPosition: Nullable<Vector3>;
  95604. /**
  95605. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  95606. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  95607. */
  95608. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  95609. /**
  95610. * Observable event triggered each time an keyboard event is received from the hosting window
  95611. */
  95612. onKeyboardObservable: Observable<KeyboardInfo>;
  95613. private _useRightHandedSystem;
  95614. /**
  95615. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  95616. */
  95617. useRightHandedSystem: boolean;
  95618. private _timeAccumulator;
  95619. private _currentStepId;
  95620. private _currentInternalStep;
  95621. /**
  95622. * Sets the step Id used by deterministic lock step
  95623. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95624. * @param newStepId defines the step Id
  95625. */
  95626. setStepId(newStepId: number): void;
  95627. /**
  95628. * Gets the step Id used by deterministic lock step
  95629. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95630. * @returns the step Id
  95631. */
  95632. getStepId(): number;
  95633. /**
  95634. * Gets the internal step used by deterministic lock step
  95635. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95636. * @returns the internal step
  95637. */
  95638. getInternalStep(): number;
  95639. private _fogEnabled;
  95640. /**
  95641. * Gets or sets a boolean indicating if fog is enabled on this scene
  95642. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95643. * (Default is true)
  95644. */
  95645. fogEnabled: boolean;
  95646. private _fogMode;
  95647. /**
  95648. * Gets or sets the fog mode to use
  95649. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95650. * | mode | value |
  95651. * | --- | --- |
  95652. * | FOGMODE_NONE | 0 |
  95653. * | FOGMODE_EXP | 1 |
  95654. * | FOGMODE_EXP2 | 2 |
  95655. * | FOGMODE_LINEAR | 3 |
  95656. */
  95657. fogMode: number;
  95658. /**
  95659. * Gets or sets the fog color to use
  95660. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95661. * (Default is Color3(0.2, 0.2, 0.3))
  95662. */
  95663. fogColor: Color3;
  95664. /**
  95665. * Gets or sets the fog density to use
  95666. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95667. * (Default is 0.1)
  95668. */
  95669. fogDensity: number;
  95670. /**
  95671. * Gets or sets the fog start distance to use
  95672. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95673. * (Default is 0)
  95674. */
  95675. fogStart: number;
  95676. /**
  95677. * Gets or sets the fog end distance to use
  95678. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95679. * (Default is 1000)
  95680. */
  95681. fogEnd: number;
  95682. private _shadowsEnabled;
  95683. /**
  95684. * Gets or sets a boolean indicating if shadows are enabled on this scene
  95685. */
  95686. shadowsEnabled: boolean;
  95687. private _lightsEnabled;
  95688. /**
  95689. * Gets or sets a boolean indicating if lights are enabled on this scene
  95690. */
  95691. lightsEnabled: boolean;
  95692. /** All of the active cameras added to this scene. */
  95693. activeCameras: Camera[];
  95694. /** @hidden */
  95695. _activeCamera: Nullable<Camera>;
  95696. /** Gets or sets the current active camera */
  95697. activeCamera: Nullable<Camera>;
  95698. private _defaultMaterial;
  95699. /** The default material used on meshes when no material is affected */
  95700. /** The default material used on meshes when no material is affected */
  95701. defaultMaterial: Material;
  95702. private _texturesEnabled;
  95703. /**
  95704. * Gets or sets a boolean indicating if textures are enabled on this scene
  95705. */
  95706. texturesEnabled: boolean;
  95707. /**
  95708. * Gets or sets a boolean indicating if particles are enabled on this scene
  95709. */
  95710. particlesEnabled: boolean;
  95711. /**
  95712. * Gets or sets a boolean indicating if sprites are enabled on this scene
  95713. */
  95714. spritesEnabled: boolean;
  95715. private _skeletonsEnabled;
  95716. /**
  95717. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  95718. */
  95719. skeletonsEnabled: boolean;
  95720. /**
  95721. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  95722. */
  95723. lensFlaresEnabled: boolean;
  95724. /**
  95725. * Gets or sets a boolean indicating if collisions are enabled on this scene
  95726. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  95727. */
  95728. collisionsEnabled: boolean;
  95729. private _collisionCoordinator;
  95730. /** @hidden */
  95731. readonly collisionCoordinator: ICollisionCoordinator;
  95732. /**
  95733. * Defines the gravity applied to this scene (used only for collisions)
  95734. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  95735. */
  95736. gravity: Vector3;
  95737. /**
  95738. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  95739. */
  95740. postProcessesEnabled: boolean;
  95741. /**
  95742. * The list of postprocesses added to the scene
  95743. */
  95744. postProcesses: PostProcess[];
  95745. /**
  95746. * Gets the current postprocess manager
  95747. */
  95748. postProcessManager: PostProcessManager;
  95749. /**
  95750. * Gets or sets a boolean indicating if render targets are enabled on this scene
  95751. */
  95752. renderTargetsEnabled: boolean;
  95753. /**
  95754. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  95755. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  95756. */
  95757. dumpNextRenderTargets: boolean;
  95758. /**
  95759. * The list of user defined render targets added to the scene
  95760. */
  95761. customRenderTargets: RenderTargetTexture[];
  95762. /**
  95763. * Defines if texture loading must be delayed
  95764. * If true, textures will only be loaded when they need to be rendered
  95765. */
  95766. useDelayedTextureLoading: boolean;
  95767. /**
  95768. * Gets the list of meshes imported to the scene through SceneLoader
  95769. */
  95770. importedMeshesFiles: String[];
  95771. /**
  95772. * Gets or sets a boolean indicating if probes are enabled on this scene
  95773. */
  95774. probesEnabled: boolean;
  95775. /**
  95776. * Gets or sets the current offline provider to use to store scene data
  95777. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  95778. */
  95779. offlineProvider: IOfflineProvider;
  95780. /**
  95781. * Gets or sets the action manager associated with the scene
  95782. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  95783. */
  95784. actionManager: AbstractActionManager;
  95785. private _meshesForIntersections;
  95786. /**
  95787. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  95788. */
  95789. proceduralTexturesEnabled: boolean;
  95790. private _engine;
  95791. private _totalVertices;
  95792. /** @hidden */
  95793. _activeIndices: PerfCounter;
  95794. /** @hidden */
  95795. _activeParticles: PerfCounter;
  95796. /** @hidden */
  95797. _activeBones: PerfCounter;
  95798. private _animationRatio;
  95799. /** @hidden */
  95800. _animationTimeLast: number;
  95801. /** @hidden */
  95802. _animationTime: number;
  95803. /**
  95804. * Gets or sets a general scale for animation speed
  95805. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  95806. */
  95807. animationTimeScale: number;
  95808. /** @hidden */
  95809. _cachedMaterial: Nullable<Material>;
  95810. /** @hidden */
  95811. _cachedEffect: Nullable<Effect>;
  95812. /** @hidden */
  95813. _cachedVisibility: Nullable<number>;
  95814. private _renderId;
  95815. private _frameId;
  95816. private _executeWhenReadyTimeoutId;
  95817. private _intermediateRendering;
  95818. private _viewUpdateFlag;
  95819. private _projectionUpdateFlag;
  95820. /** @hidden */
  95821. _toBeDisposed: Nullable<IDisposable>[];
  95822. private _activeRequests;
  95823. /** @hidden */
  95824. _pendingData: any[];
  95825. private _isDisposed;
  95826. /**
  95827. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  95828. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  95829. */
  95830. dispatchAllSubMeshesOfActiveMeshes: boolean;
  95831. private _activeMeshes;
  95832. private _processedMaterials;
  95833. private _renderTargets;
  95834. /** @hidden */
  95835. _activeParticleSystems: SmartArray<IParticleSystem>;
  95836. private _activeSkeletons;
  95837. private _softwareSkinnedMeshes;
  95838. private _renderingManager;
  95839. /** @hidden */
  95840. _activeAnimatables: Animatable[];
  95841. private _transformMatrix;
  95842. private _sceneUbo;
  95843. /** @hidden */
  95844. _viewMatrix: Matrix;
  95845. private _projectionMatrix;
  95846. /** @hidden */
  95847. _forcedViewPosition: Nullable<Vector3>;
  95848. /** @hidden */
  95849. _frustumPlanes: Plane[];
  95850. /**
  95851. * Gets the list of frustum planes (built from the active camera)
  95852. */
  95853. readonly frustumPlanes: Plane[];
  95854. /**
  95855. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  95856. * This is useful if there are more lights that the maximum simulteanous authorized
  95857. */
  95858. requireLightSorting: boolean;
  95859. /** @hidden */
  95860. readonly useMaterialMeshMap: boolean;
  95861. /** @hidden */
  95862. readonly useClonedMeshhMap: boolean;
  95863. private _externalData;
  95864. private _uid;
  95865. /**
  95866. * @hidden
  95867. * Backing store of defined scene components.
  95868. */
  95869. _components: ISceneComponent[];
  95870. /**
  95871. * @hidden
  95872. * Backing store of defined scene components.
  95873. */
  95874. _serializableComponents: ISceneSerializableComponent[];
  95875. /**
  95876. * List of components to register on the next registration step.
  95877. */
  95878. private _transientComponents;
  95879. /**
  95880. * Registers the transient components if needed.
  95881. */
  95882. private _registerTransientComponents;
  95883. /**
  95884. * @hidden
  95885. * Add a component to the scene.
  95886. * Note that the ccomponent could be registered on th next frame if this is called after
  95887. * the register component stage.
  95888. * @param component Defines the component to add to the scene
  95889. */
  95890. _addComponent(component: ISceneComponent): void;
  95891. /**
  95892. * @hidden
  95893. * Gets a component from the scene.
  95894. * @param name defines the name of the component to retrieve
  95895. * @returns the component or null if not present
  95896. */
  95897. _getComponent(name: string): Nullable<ISceneComponent>;
  95898. /**
  95899. * @hidden
  95900. * Defines the actions happening before camera updates.
  95901. */
  95902. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  95903. /**
  95904. * @hidden
  95905. * Defines the actions happening before clear the canvas.
  95906. */
  95907. _beforeClearStage: Stage<SimpleStageAction>;
  95908. /**
  95909. * @hidden
  95910. * Defines the actions when collecting render targets for the frame.
  95911. */
  95912. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  95913. /**
  95914. * @hidden
  95915. * Defines the actions happening for one camera in the frame.
  95916. */
  95917. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  95918. /**
  95919. * @hidden
  95920. * Defines the actions happening during the per mesh ready checks.
  95921. */
  95922. _isReadyForMeshStage: Stage<MeshStageAction>;
  95923. /**
  95924. * @hidden
  95925. * Defines the actions happening before evaluate active mesh checks.
  95926. */
  95927. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  95928. /**
  95929. * @hidden
  95930. * Defines the actions happening during the evaluate sub mesh checks.
  95931. */
  95932. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  95933. /**
  95934. * @hidden
  95935. * Defines the actions happening during the active mesh stage.
  95936. */
  95937. _activeMeshStage: Stage<ActiveMeshStageAction>;
  95938. /**
  95939. * @hidden
  95940. * Defines the actions happening during the per camera render target step.
  95941. */
  95942. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  95943. /**
  95944. * @hidden
  95945. * Defines the actions happening just before the active camera is drawing.
  95946. */
  95947. _beforeCameraDrawStage: Stage<CameraStageAction>;
  95948. /**
  95949. * @hidden
  95950. * Defines the actions happening just before a render target is drawing.
  95951. */
  95952. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  95953. /**
  95954. * @hidden
  95955. * Defines the actions happening just before a rendering group is drawing.
  95956. */
  95957. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  95958. /**
  95959. * @hidden
  95960. * Defines the actions happening just before a mesh is drawing.
  95961. */
  95962. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  95963. /**
  95964. * @hidden
  95965. * Defines the actions happening just after a mesh has been drawn.
  95966. */
  95967. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  95968. /**
  95969. * @hidden
  95970. * Defines the actions happening just after a rendering group has been drawn.
  95971. */
  95972. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  95973. /**
  95974. * @hidden
  95975. * Defines the actions happening just after the active camera has been drawn.
  95976. */
  95977. _afterCameraDrawStage: Stage<CameraStageAction>;
  95978. /**
  95979. * @hidden
  95980. * Defines the actions happening just after a render target has been drawn.
  95981. */
  95982. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  95983. /**
  95984. * @hidden
  95985. * Defines the actions happening just after rendering all cameras and computing intersections.
  95986. */
  95987. _afterRenderStage: Stage<SimpleStageAction>;
  95988. /**
  95989. * @hidden
  95990. * Defines the actions happening when a pointer move event happens.
  95991. */
  95992. _pointerMoveStage: Stage<PointerMoveStageAction>;
  95993. /**
  95994. * @hidden
  95995. * Defines the actions happening when a pointer down event happens.
  95996. */
  95997. _pointerDownStage: Stage<PointerUpDownStageAction>;
  95998. /**
  95999. * @hidden
  96000. * Defines the actions happening when a pointer up event happens.
  96001. */
  96002. _pointerUpStage: Stage<PointerUpDownStageAction>;
  96003. /**
  96004. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  96005. */
  96006. private geometriesByUniqueId;
  96007. /**
  96008. * Creates a new Scene
  96009. * @param engine defines the engine to use to render this scene
  96010. * @param options defines the scene options
  96011. */
  96012. constructor(engine: Engine, options?: SceneOptions);
  96013. /**
  96014. * Gets a string idenfifying the name of the class
  96015. * @returns "Scene" string
  96016. */
  96017. getClassName(): string;
  96018. private _defaultMeshCandidates;
  96019. /**
  96020. * @hidden
  96021. */
  96022. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  96023. private _defaultSubMeshCandidates;
  96024. /**
  96025. * @hidden
  96026. */
  96027. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  96028. /**
  96029. * Sets the default candidate providers for the scene.
  96030. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  96031. * and getCollidingSubMeshCandidates to their default function
  96032. */
  96033. setDefaultCandidateProviders(): void;
  96034. /**
  96035. * Gets the mesh that is currently under the pointer
  96036. */
  96037. readonly meshUnderPointer: Nullable<AbstractMesh>;
  96038. /**
  96039. * Gets or sets the current on-screen X position of the pointer
  96040. */
  96041. pointerX: number;
  96042. /**
  96043. * Gets or sets the current on-screen Y position of the pointer
  96044. */
  96045. pointerY: number;
  96046. /**
  96047. * Gets the cached material (ie. the latest rendered one)
  96048. * @returns the cached material
  96049. */
  96050. getCachedMaterial(): Nullable<Material>;
  96051. /**
  96052. * Gets the cached effect (ie. the latest rendered one)
  96053. * @returns the cached effect
  96054. */
  96055. getCachedEffect(): Nullable<Effect>;
  96056. /**
  96057. * Gets the cached visibility state (ie. the latest rendered one)
  96058. * @returns the cached visibility state
  96059. */
  96060. getCachedVisibility(): Nullable<number>;
  96061. /**
  96062. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  96063. * @param material defines the current material
  96064. * @param effect defines the current effect
  96065. * @param visibility defines the current visibility state
  96066. * @returns true if one parameter is not cached
  96067. */
  96068. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  96069. /**
  96070. * Gets the engine associated with the scene
  96071. * @returns an Engine
  96072. */
  96073. getEngine(): Engine;
  96074. /**
  96075. * Gets the total number of vertices rendered per frame
  96076. * @returns the total number of vertices rendered per frame
  96077. */
  96078. getTotalVertices(): number;
  96079. /**
  96080. * Gets the performance counter for total vertices
  96081. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  96082. */
  96083. readonly totalVerticesPerfCounter: PerfCounter;
  96084. /**
  96085. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  96086. * @returns the total number of active indices rendered per frame
  96087. */
  96088. getActiveIndices(): number;
  96089. /**
  96090. * Gets the performance counter for active indices
  96091. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  96092. */
  96093. readonly totalActiveIndicesPerfCounter: PerfCounter;
  96094. /**
  96095. * Gets the total number of active particles rendered per frame
  96096. * @returns the total number of active particles rendered per frame
  96097. */
  96098. getActiveParticles(): number;
  96099. /**
  96100. * Gets the performance counter for active particles
  96101. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  96102. */
  96103. readonly activeParticlesPerfCounter: PerfCounter;
  96104. /**
  96105. * Gets the total number of active bones rendered per frame
  96106. * @returns the total number of active bones rendered per frame
  96107. */
  96108. getActiveBones(): number;
  96109. /**
  96110. * Gets the performance counter for active bones
  96111. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  96112. */
  96113. readonly activeBonesPerfCounter: PerfCounter;
  96114. /**
  96115. * Gets the array of active meshes
  96116. * @returns an array of AbstractMesh
  96117. */
  96118. getActiveMeshes(): SmartArray<AbstractMesh>;
  96119. /**
  96120. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  96121. * @returns a number
  96122. */
  96123. getAnimationRatio(): number;
  96124. /**
  96125. * Gets an unique Id for the current render phase
  96126. * @returns a number
  96127. */
  96128. getRenderId(): number;
  96129. /**
  96130. * Gets an unique Id for the current frame
  96131. * @returns a number
  96132. */
  96133. getFrameId(): number;
  96134. /** Call this function if you want to manually increment the render Id*/
  96135. incrementRenderId(): void;
  96136. private _createUbo;
  96137. /**
  96138. * Use this method to simulate a pointer move on a mesh
  96139. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  96140. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  96141. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  96142. * @returns the current scene
  96143. */
  96144. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  96145. /**
  96146. * Use this method to simulate a pointer down on a mesh
  96147. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  96148. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  96149. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  96150. * @returns the current scene
  96151. */
  96152. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  96153. /**
  96154. * Use this method to simulate a pointer up on a mesh
  96155. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  96156. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  96157. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  96158. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  96159. * @returns the current scene
  96160. */
  96161. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  96162. /**
  96163. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  96164. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  96165. * @returns true if the pointer was captured
  96166. */
  96167. isPointerCaptured(pointerId?: number): boolean;
  96168. /**
  96169. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  96170. * @param attachUp defines if you want to attach events to pointerup
  96171. * @param attachDown defines if you want to attach events to pointerdown
  96172. * @param attachMove defines if you want to attach events to pointermove
  96173. */
  96174. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  96175. /** Detaches all event handlers*/
  96176. detachControl(): void;
  96177. /**
  96178. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  96179. * Delay loaded resources are not taking in account
  96180. * @return true if all required resources are ready
  96181. */
  96182. isReady(): boolean;
  96183. /** Resets all cached information relative to material (including effect and visibility) */
  96184. resetCachedMaterial(): void;
  96185. /**
  96186. * Registers a function to be called before every frame render
  96187. * @param func defines the function to register
  96188. */
  96189. registerBeforeRender(func: () => void): void;
  96190. /**
  96191. * Unregisters a function called before every frame render
  96192. * @param func defines the function to unregister
  96193. */
  96194. unregisterBeforeRender(func: () => void): void;
  96195. /**
  96196. * Registers a function to be called after every frame render
  96197. * @param func defines the function to register
  96198. */
  96199. registerAfterRender(func: () => void): void;
  96200. /**
  96201. * Unregisters a function called after every frame render
  96202. * @param func defines the function to unregister
  96203. */
  96204. unregisterAfterRender(func: () => void): void;
  96205. private _executeOnceBeforeRender;
  96206. /**
  96207. * The provided function will run before render once and will be disposed afterwards.
  96208. * A timeout delay can be provided so that the function will be executed in N ms.
  96209. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  96210. * @param func The function to be executed.
  96211. * @param timeout optional delay in ms
  96212. */
  96213. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  96214. /** @hidden */
  96215. _addPendingData(data: any): void;
  96216. /** @hidden */
  96217. _removePendingData(data: any): void;
  96218. /**
  96219. * Returns the number of items waiting to be loaded
  96220. * @returns the number of items waiting to be loaded
  96221. */
  96222. getWaitingItemsCount(): number;
  96223. /**
  96224. * Returns a boolean indicating if the scene is still loading data
  96225. */
  96226. readonly isLoading: boolean;
  96227. /**
  96228. * Registers a function to be executed when the scene is ready
  96229. * @param {Function} func - the function to be executed
  96230. */
  96231. executeWhenReady(func: () => void): void;
  96232. /**
  96233. * Returns a promise that resolves when the scene is ready
  96234. * @returns A promise that resolves when the scene is ready
  96235. */
  96236. whenReadyAsync(): Promise<void>;
  96237. /** @hidden */
  96238. _checkIsReady(): void;
  96239. /**
  96240. * Gets all animatable attached to the scene
  96241. */
  96242. readonly animatables: Animatable[];
  96243. /**
  96244. * Resets the last animation time frame.
  96245. * Useful to override when animations start running when loading a scene for the first time.
  96246. */
  96247. resetLastAnimationTimeFrame(): void;
  96248. /**
  96249. * Gets the current view matrix
  96250. * @returns a Matrix
  96251. */
  96252. getViewMatrix(): Matrix;
  96253. /**
  96254. * Gets the current projection matrix
  96255. * @returns a Matrix
  96256. */
  96257. getProjectionMatrix(): Matrix;
  96258. /**
  96259. * Gets the current transform matrix
  96260. * @returns a Matrix made of View * Projection
  96261. */
  96262. getTransformMatrix(): Matrix;
  96263. /**
  96264. * Sets the current transform matrix
  96265. * @param viewL defines the View matrix to use
  96266. * @param projectionL defines the Projection matrix to use
  96267. * @param viewR defines the right View matrix to use (if provided)
  96268. * @param projectionR defines the right Projection matrix to use (if provided)
  96269. */
  96270. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  96271. /**
  96272. * Gets the uniform buffer used to store scene data
  96273. * @returns a UniformBuffer
  96274. */
  96275. getSceneUniformBuffer(): UniformBuffer;
  96276. /**
  96277. * Gets an unique (relatively to the current scene) Id
  96278. * @returns an unique number for the scene
  96279. */
  96280. getUniqueId(): number;
  96281. /**
  96282. * Add a mesh to the list of scene's meshes
  96283. * @param newMesh defines the mesh to add
  96284. * @param recursive if all child meshes should also be added to the scene
  96285. */
  96286. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  96287. /**
  96288. * Remove a mesh for the list of scene's meshes
  96289. * @param toRemove defines the mesh to remove
  96290. * @param recursive if all child meshes should also be removed from the scene
  96291. * @returns the index where the mesh was in the mesh list
  96292. */
  96293. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  96294. /**
  96295. * Add a transform node to the list of scene's transform nodes
  96296. * @param newTransformNode defines the transform node to add
  96297. */
  96298. addTransformNode(newTransformNode: TransformNode): void;
  96299. /**
  96300. * Remove a transform node for the list of scene's transform nodes
  96301. * @param toRemove defines the transform node to remove
  96302. * @returns the index where the transform node was in the transform node list
  96303. */
  96304. removeTransformNode(toRemove: TransformNode): number;
  96305. /**
  96306. * Remove a skeleton for the list of scene's skeletons
  96307. * @param toRemove defines the skeleton to remove
  96308. * @returns the index where the skeleton was in the skeleton list
  96309. */
  96310. removeSkeleton(toRemove: Skeleton): number;
  96311. /**
  96312. * Remove a morph target for the list of scene's morph targets
  96313. * @param toRemove defines the morph target to remove
  96314. * @returns the index where the morph target was in the morph target list
  96315. */
  96316. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  96317. /**
  96318. * Remove a light for the list of scene's lights
  96319. * @param toRemove defines the light to remove
  96320. * @returns the index where the light was in the light list
  96321. */
  96322. removeLight(toRemove: Light): number;
  96323. /**
  96324. * Remove a camera for the list of scene's cameras
  96325. * @param toRemove defines the camera to remove
  96326. * @returns the index where the camera was in the camera list
  96327. */
  96328. removeCamera(toRemove: Camera): number;
  96329. /**
  96330. * Remove a particle system for the list of scene's particle systems
  96331. * @param toRemove defines the particle system to remove
  96332. * @returns the index where the particle system was in the particle system list
  96333. */
  96334. removeParticleSystem(toRemove: IParticleSystem): number;
  96335. /**
  96336. * Remove a animation for the list of scene's animations
  96337. * @param toRemove defines the animation to remove
  96338. * @returns the index where the animation was in the animation list
  96339. */
  96340. removeAnimation(toRemove: Animation): number;
  96341. /**
  96342. * Will stop the animation of the given target
  96343. * @param target - the target
  96344. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  96345. * @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)
  96346. */
  96347. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  96348. /**
  96349. * Removes the given animation group from this scene.
  96350. * @param toRemove The animation group to remove
  96351. * @returns The index of the removed animation group
  96352. */
  96353. removeAnimationGroup(toRemove: AnimationGroup): number;
  96354. /**
  96355. * Removes the given multi-material from this scene.
  96356. * @param toRemove The multi-material to remove
  96357. * @returns The index of the removed multi-material
  96358. */
  96359. removeMultiMaterial(toRemove: MultiMaterial): number;
  96360. /**
  96361. * Removes the given material from this scene.
  96362. * @param toRemove The material to remove
  96363. * @returns The index of the removed material
  96364. */
  96365. removeMaterial(toRemove: Material): number;
  96366. /**
  96367. * Removes the given action manager from this scene.
  96368. * @param toRemove The action manager to remove
  96369. * @returns The index of the removed action manager
  96370. */
  96371. removeActionManager(toRemove: AbstractActionManager): number;
  96372. /**
  96373. * Removes the given texture from this scene.
  96374. * @param toRemove The texture to remove
  96375. * @returns The index of the removed texture
  96376. */
  96377. removeTexture(toRemove: BaseTexture): number;
  96378. /**
  96379. * Adds the given light to this scene
  96380. * @param newLight The light to add
  96381. */
  96382. addLight(newLight: Light): void;
  96383. /**
  96384. * Sorts the list list based on light priorities
  96385. */
  96386. sortLightsByPriority(): void;
  96387. /**
  96388. * Adds the given camera to this scene
  96389. * @param newCamera The camera to add
  96390. */
  96391. addCamera(newCamera: Camera): void;
  96392. /**
  96393. * Adds the given skeleton to this scene
  96394. * @param newSkeleton The skeleton to add
  96395. */
  96396. addSkeleton(newSkeleton: Skeleton): void;
  96397. /**
  96398. * Adds the given particle system to this scene
  96399. * @param newParticleSystem The particle system to add
  96400. */
  96401. addParticleSystem(newParticleSystem: IParticleSystem): void;
  96402. /**
  96403. * Adds the given animation to this scene
  96404. * @param newAnimation The animation to add
  96405. */
  96406. addAnimation(newAnimation: Animation): void;
  96407. /**
  96408. * Adds the given animation group to this scene.
  96409. * @param newAnimationGroup The animation group to add
  96410. */
  96411. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  96412. /**
  96413. * Adds the given multi-material to this scene
  96414. * @param newMultiMaterial The multi-material to add
  96415. */
  96416. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  96417. /**
  96418. * Adds the given material to this scene
  96419. * @param newMaterial The material to add
  96420. */
  96421. addMaterial(newMaterial: Material): void;
  96422. /**
  96423. * Adds the given morph target to this scene
  96424. * @param newMorphTargetManager The morph target to add
  96425. */
  96426. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  96427. /**
  96428. * Adds the given geometry to this scene
  96429. * @param newGeometry The geometry to add
  96430. */
  96431. addGeometry(newGeometry: Geometry): void;
  96432. /**
  96433. * Adds the given action manager to this scene
  96434. * @param newActionManager The action manager to add
  96435. */
  96436. addActionManager(newActionManager: AbstractActionManager): void;
  96437. /**
  96438. * Adds the given texture to this scene.
  96439. * @param newTexture The texture to add
  96440. */
  96441. addTexture(newTexture: BaseTexture): void;
  96442. /**
  96443. * Switch active camera
  96444. * @param newCamera defines the new active camera
  96445. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  96446. */
  96447. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  96448. /**
  96449. * sets the active camera of the scene using its ID
  96450. * @param id defines the camera's ID
  96451. * @return the new active camera or null if none found.
  96452. */
  96453. setActiveCameraByID(id: string): Nullable<Camera>;
  96454. /**
  96455. * sets the active camera of the scene using its name
  96456. * @param name defines the camera's name
  96457. * @returns the new active camera or null if none found.
  96458. */
  96459. setActiveCameraByName(name: string): Nullable<Camera>;
  96460. /**
  96461. * get an animation group using its name
  96462. * @param name defines the material's name
  96463. * @return the animation group or null if none found.
  96464. */
  96465. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  96466. /**
  96467. * Get a material using its unique id
  96468. * @param uniqueId defines the material's unique id
  96469. * @return the material or null if none found.
  96470. */
  96471. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  96472. /**
  96473. * get a material using its id
  96474. * @param id defines the material's ID
  96475. * @return the material or null if none found.
  96476. */
  96477. getMaterialByID(id: string): Nullable<Material>;
  96478. /**
  96479. * Gets a material using its name
  96480. * @param name defines the material's name
  96481. * @return the material or null if none found.
  96482. */
  96483. getMaterialByName(name: string): Nullable<Material>;
  96484. /**
  96485. * Gets a camera using its id
  96486. * @param id defines the id to look for
  96487. * @returns the camera or null if not found
  96488. */
  96489. getCameraByID(id: string): Nullable<Camera>;
  96490. /**
  96491. * Gets a camera using its unique id
  96492. * @param uniqueId defines the unique id to look for
  96493. * @returns the camera or null if not found
  96494. */
  96495. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  96496. /**
  96497. * Gets a camera using its name
  96498. * @param name defines the camera's name
  96499. * @return the camera or null if none found.
  96500. */
  96501. getCameraByName(name: string): Nullable<Camera>;
  96502. /**
  96503. * Gets a bone using its id
  96504. * @param id defines the bone's id
  96505. * @return the bone or null if not found
  96506. */
  96507. getBoneByID(id: string): Nullable<Bone>;
  96508. /**
  96509. * Gets a bone using its id
  96510. * @param name defines the bone's name
  96511. * @return the bone or null if not found
  96512. */
  96513. getBoneByName(name: string): Nullable<Bone>;
  96514. /**
  96515. * Gets a light node using its name
  96516. * @param name defines the the light's name
  96517. * @return the light or null if none found.
  96518. */
  96519. getLightByName(name: string): Nullable<Light>;
  96520. /**
  96521. * Gets a light node using its id
  96522. * @param id defines the light's id
  96523. * @return the light or null if none found.
  96524. */
  96525. getLightByID(id: string): Nullable<Light>;
  96526. /**
  96527. * Gets a light node using its scene-generated unique ID
  96528. * @param uniqueId defines the light's unique id
  96529. * @return the light or null if none found.
  96530. */
  96531. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  96532. /**
  96533. * Gets a particle system by id
  96534. * @param id defines the particle system id
  96535. * @return the corresponding system or null if none found
  96536. */
  96537. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  96538. /**
  96539. * Gets a geometry using its ID
  96540. * @param id defines the geometry's id
  96541. * @return the geometry or null if none found.
  96542. */
  96543. getGeometryByID(id: string): Nullable<Geometry>;
  96544. private _getGeometryByUniqueID;
  96545. /**
  96546. * Add a new geometry to this scene
  96547. * @param geometry defines the geometry to be added to the scene.
  96548. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  96549. * @return a boolean defining if the geometry was added or not
  96550. */
  96551. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  96552. /**
  96553. * Removes an existing geometry
  96554. * @param geometry defines the geometry to be removed from the scene
  96555. * @return a boolean defining if the geometry was removed or not
  96556. */
  96557. removeGeometry(geometry: Geometry): boolean;
  96558. /**
  96559. * Gets the list of geometries attached to the scene
  96560. * @returns an array of Geometry
  96561. */
  96562. getGeometries(): Geometry[];
  96563. /**
  96564. * Gets the first added mesh found of a given ID
  96565. * @param id defines the id to search for
  96566. * @return the mesh found or null if not found at all
  96567. */
  96568. getMeshByID(id: string): Nullable<AbstractMesh>;
  96569. /**
  96570. * Gets a list of meshes using their id
  96571. * @param id defines the id to search for
  96572. * @returns a list of meshes
  96573. */
  96574. getMeshesByID(id: string): Array<AbstractMesh>;
  96575. /**
  96576. * Gets the first added transform node found of a given ID
  96577. * @param id defines the id to search for
  96578. * @return the found transform node or null if not found at all.
  96579. */
  96580. getTransformNodeByID(id: string): Nullable<TransformNode>;
  96581. /**
  96582. * Gets a transform node with its auto-generated unique id
  96583. * @param uniqueId efines the unique id to search for
  96584. * @return the found transform node or null if not found at all.
  96585. */
  96586. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  96587. /**
  96588. * Gets a list of transform nodes using their id
  96589. * @param id defines the id to search for
  96590. * @returns a list of transform nodes
  96591. */
  96592. getTransformNodesByID(id: string): Array<TransformNode>;
  96593. /**
  96594. * Gets a mesh with its auto-generated unique id
  96595. * @param uniqueId defines the unique id to search for
  96596. * @return the found mesh or null if not found at all.
  96597. */
  96598. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  96599. /**
  96600. * Gets a the last added mesh using a given id
  96601. * @param id defines the id to search for
  96602. * @return the found mesh or null if not found at all.
  96603. */
  96604. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  96605. /**
  96606. * Gets a the last added node (Mesh, Camera, Light) using a given id
  96607. * @param id defines the id to search for
  96608. * @return the found node or null if not found at all
  96609. */
  96610. getLastEntryByID(id: string): Nullable<Node>;
  96611. /**
  96612. * Gets a node (Mesh, Camera, Light) using a given id
  96613. * @param id defines the id to search for
  96614. * @return the found node or null if not found at all
  96615. */
  96616. getNodeByID(id: string): Nullable<Node>;
  96617. /**
  96618. * Gets a node (Mesh, Camera, Light) using a given name
  96619. * @param name defines the name to search for
  96620. * @return the found node or null if not found at all.
  96621. */
  96622. getNodeByName(name: string): Nullable<Node>;
  96623. /**
  96624. * Gets a mesh using a given name
  96625. * @param name defines the name to search for
  96626. * @return the found mesh or null if not found at all.
  96627. */
  96628. getMeshByName(name: string): Nullable<AbstractMesh>;
  96629. /**
  96630. * Gets a transform node using a given name
  96631. * @param name defines the name to search for
  96632. * @return the found transform node or null if not found at all.
  96633. */
  96634. getTransformNodeByName(name: string): Nullable<TransformNode>;
  96635. /**
  96636. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  96637. * @param id defines the id to search for
  96638. * @return the found skeleton or null if not found at all.
  96639. */
  96640. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  96641. /**
  96642. * Gets a skeleton using a given auto generated unique id
  96643. * @param uniqueId defines the unique id to search for
  96644. * @return the found skeleton or null if not found at all.
  96645. */
  96646. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  96647. /**
  96648. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  96649. * @param id defines the id to search for
  96650. * @return the found skeleton or null if not found at all.
  96651. */
  96652. getSkeletonById(id: string): Nullable<Skeleton>;
  96653. /**
  96654. * Gets a skeleton using a given name
  96655. * @param name defines the name to search for
  96656. * @return the found skeleton or null if not found at all.
  96657. */
  96658. getSkeletonByName(name: string): Nullable<Skeleton>;
  96659. /**
  96660. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  96661. * @param id defines the id to search for
  96662. * @return the found morph target manager or null if not found at all.
  96663. */
  96664. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  96665. /**
  96666. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  96667. * @param id defines the id to search for
  96668. * @return the found morph target or null if not found at all.
  96669. */
  96670. getMorphTargetById(id: string): Nullable<MorphTarget>;
  96671. /**
  96672. * Gets a boolean indicating if the given mesh is active
  96673. * @param mesh defines the mesh to look for
  96674. * @returns true if the mesh is in the active list
  96675. */
  96676. isActiveMesh(mesh: AbstractMesh): boolean;
  96677. /**
  96678. * Return a unique id as a string which can serve as an identifier for the scene
  96679. */
  96680. readonly uid: string;
  96681. /**
  96682. * Add an externaly attached data from its key.
  96683. * This method call will fail and return false, if such key already exists.
  96684. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  96685. * @param key the unique key that identifies the data
  96686. * @param data the data object to associate to the key for this Engine instance
  96687. * @return true if no such key were already present and the data was added successfully, false otherwise
  96688. */
  96689. addExternalData<T>(key: string, data: T): boolean;
  96690. /**
  96691. * Get an externaly attached data from its key
  96692. * @param key the unique key that identifies the data
  96693. * @return the associated data, if present (can be null), or undefined if not present
  96694. */
  96695. getExternalData<T>(key: string): Nullable<T>;
  96696. /**
  96697. * Get an externaly attached data from its key, create it using a factory if it's not already present
  96698. * @param key the unique key that identifies the data
  96699. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  96700. * @return the associated data, can be null if the factory returned null.
  96701. */
  96702. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  96703. /**
  96704. * Remove an externaly attached data from the Engine instance
  96705. * @param key the unique key that identifies the data
  96706. * @return true if the data was successfully removed, false if it doesn't exist
  96707. */
  96708. removeExternalData(key: string): boolean;
  96709. private _evaluateSubMesh;
  96710. /**
  96711. * Clear the processed materials smart array preventing retention point in material dispose.
  96712. */
  96713. freeProcessedMaterials(): void;
  96714. private _preventFreeActiveMeshesAndRenderingGroups;
  96715. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  96716. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  96717. * when disposing several meshes in a row or a hierarchy of meshes.
  96718. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  96719. */
  96720. blockfreeActiveMeshesAndRenderingGroups: boolean;
  96721. /**
  96722. * Clear the active meshes smart array preventing retention point in mesh dispose.
  96723. */
  96724. freeActiveMeshes(): void;
  96725. /**
  96726. * Clear the info related to rendering groups preventing retention points during dispose.
  96727. */
  96728. freeRenderingGroups(): void;
  96729. /** @hidden */
  96730. _isInIntermediateRendering(): boolean;
  96731. /**
  96732. * Lambda returning the list of potentially active meshes.
  96733. */
  96734. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  96735. /**
  96736. * Lambda returning the list of potentially active sub meshes.
  96737. */
  96738. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  96739. /**
  96740. * Lambda returning the list of potentially intersecting sub meshes.
  96741. */
  96742. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  96743. /**
  96744. * Lambda returning the list of potentially colliding sub meshes.
  96745. */
  96746. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  96747. private _activeMeshesFrozen;
  96748. /**
  96749. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  96750. * @returns the current scene
  96751. */
  96752. freezeActiveMeshes(): Scene;
  96753. /**
  96754. * Use this function to restart evaluating active meshes on every frame
  96755. * @returns the current scene
  96756. */
  96757. unfreezeActiveMeshes(): Scene;
  96758. private _evaluateActiveMeshes;
  96759. private _activeMesh;
  96760. /**
  96761. * Update the transform matrix to update from the current active camera
  96762. * @param force defines a boolean used to force the update even if cache is up to date
  96763. */
  96764. updateTransformMatrix(force?: boolean): void;
  96765. private _bindFrameBuffer;
  96766. /** @hidden */
  96767. _allowPostProcessClearColor: boolean;
  96768. /** @hidden */
  96769. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  96770. private _processSubCameras;
  96771. private _checkIntersections;
  96772. /** @hidden */
  96773. _advancePhysicsEngineStep(step: number): void;
  96774. /**
  96775. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  96776. */
  96777. getDeterministicFrameTime: () => number;
  96778. /** @hidden */
  96779. _animate(): void;
  96780. /** Execute all animations (for a frame) */
  96781. animate(): void;
  96782. /**
  96783. * Render the scene
  96784. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  96785. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  96786. */
  96787. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  96788. /**
  96789. * Freeze all materials
  96790. * A frozen material will not be updatable but should be faster to render
  96791. */
  96792. freezeMaterials(): void;
  96793. /**
  96794. * Unfreeze all materials
  96795. * A frozen material will not be updatable but should be faster to render
  96796. */
  96797. unfreezeMaterials(): void;
  96798. /**
  96799. * Releases all held ressources
  96800. */
  96801. dispose(): void;
  96802. /**
  96803. * Gets if the scene is already disposed
  96804. */
  96805. readonly isDisposed: boolean;
  96806. /**
  96807. * Call this function to reduce memory footprint of the scene.
  96808. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  96809. */
  96810. clearCachedVertexData(): void;
  96811. /**
  96812. * This function will remove the local cached buffer data from texture.
  96813. * It will save memory but will prevent the texture from being rebuilt
  96814. */
  96815. cleanCachedTextureBuffer(): void;
  96816. /**
  96817. * Get the world extend vectors with an optional filter
  96818. *
  96819. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  96820. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  96821. */
  96822. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  96823. min: Vector3;
  96824. max: Vector3;
  96825. };
  96826. /**
  96827. * Creates a ray that can be used to pick in the scene
  96828. * @param x defines the x coordinate of the origin (on-screen)
  96829. * @param y defines the y coordinate of the origin (on-screen)
  96830. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  96831. * @param camera defines the camera to use for the picking
  96832. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  96833. * @returns a Ray
  96834. */
  96835. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  96836. /**
  96837. * Creates a ray that can be used to pick in the scene
  96838. * @param x defines the x coordinate of the origin (on-screen)
  96839. * @param y defines the y coordinate of the origin (on-screen)
  96840. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  96841. * @param result defines the ray where to store the picking ray
  96842. * @param camera defines the camera to use for the picking
  96843. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  96844. * @returns the current scene
  96845. */
  96846. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  96847. /**
  96848. * Creates a ray that can be used to pick in the scene
  96849. * @param x defines the x coordinate of the origin (on-screen)
  96850. * @param y defines the y coordinate of the origin (on-screen)
  96851. * @param camera defines the camera to use for the picking
  96852. * @returns a Ray
  96853. */
  96854. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  96855. /**
  96856. * Creates a ray that can be used to pick in the scene
  96857. * @param x defines the x coordinate of the origin (on-screen)
  96858. * @param y defines the y coordinate of the origin (on-screen)
  96859. * @param result defines the ray where to store the picking ray
  96860. * @param camera defines the camera to use for the picking
  96861. * @returns the current scene
  96862. */
  96863. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  96864. /** Launch a ray to try to pick a mesh in the scene
  96865. * @param x position on screen
  96866. * @param y position on screen
  96867. * @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
  96868. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  96869. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  96870. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  96871. * @returns a PickingInfo
  96872. */
  96873. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  96874. /** Use the given ray to pick a mesh in the scene
  96875. * @param ray The ray to use to pick meshes
  96876. * @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
  96877. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  96878. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  96879. * @returns a PickingInfo
  96880. */
  96881. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  96882. /**
  96883. * Launch a ray to try to pick a mesh in the scene
  96884. * @param x X position on screen
  96885. * @param y Y position on screen
  96886. * @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
  96887. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  96888. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  96889. * @returns an array of PickingInfo
  96890. */
  96891. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  96892. /**
  96893. * Launch a ray to try to pick a mesh in the scene
  96894. * @param ray Ray to use
  96895. * @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
  96896. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  96897. * @returns an array of PickingInfo
  96898. */
  96899. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  96900. /**
  96901. * Force the value of meshUnderPointer
  96902. * @param mesh defines the mesh to use
  96903. */
  96904. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  96905. /**
  96906. * Gets the mesh under the pointer
  96907. * @returns a Mesh or null if no mesh is under the pointer
  96908. */
  96909. getPointerOverMesh(): Nullable<AbstractMesh>;
  96910. /** @hidden */
  96911. _rebuildGeometries(): void;
  96912. /** @hidden */
  96913. _rebuildTextures(): void;
  96914. private _getByTags;
  96915. /**
  96916. * Get a list of meshes by tags
  96917. * @param tagsQuery defines the tags query to use
  96918. * @param forEach defines a predicate used to filter results
  96919. * @returns an array of Mesh
  96920. */
  96921. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  96922. /**
  96923. * Get a list of cameras by tags
  96924. * @param tagsQuery defines the tags query to use
  96925. * @param forEach defines a predicate used to filter results
  96926. * @returns an array of Camera
  96927. */
  96928. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  96929. /**
  96930. * Get a list of lights by tags
  96931. * @param tagsQuery defines the tags query to use
  96932. * @param forEach defines a predicate used to filter results
  96933. * @returns an array of Light
  96934. */
  96935. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  96936. /**
  96937. * Get a list of materials by tags
  96938. * @param tagsQuery defines the tags query to use
  96939. * @param forEach defines a predicate used to filter results
  96940. * @returns an array of Material
  96941. */
  96942. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  96943. /**
  96944. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  96945. * This allowed control for front to back rendering or reversly depending of the special needs.
  96946. *
  96947. * @param renderingGroupId The rendering group id corresponding to its index
  96948. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  96949. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  96950. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  96951. */
  96952. 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;
  96953. /**
  96954. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  96955. *
  96956. * @param renderingGroupId The rendering group id corresponding to its index
  96957. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  96958. * @param depth Automatically clears depth between groups if true and autoClear is true.
  96959. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  96960. */
  96961. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  96962. /**
  96963. * Gets the current auto clear configuration for one rendering group of the rendering
  96964. * manager.
  96965. * @param index the rendering group index to get the information for
  96966. * @returns The auto clear setup for the requested rendering group
  96967. */
  96968. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  96969. private _blockMaterialDirtyMechanism;
  96970. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  96971. blockMaterialDirtyMechanism: boolean;
  96972. /**
  96973. * Will flag all materials as dirty to trigger new shader compilation
  96974. * @param flag defines the flag used to specify which material part must be marked as dirty
  96975. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  96976. */
  96977. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  96978. /** @hidden */
  96979. _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;
  96980. /** @hidden */
  96981. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  96982. }
  96983. }
  96984. declare module BABYLON {
  96985. /**
  96986. * Set of assets to keep when moving a scene into an asset container.
  96987. */
  96988. export class KeepAssets extends AbstractScene {
  96989. }
  96990. /**
  96991. * Container with a set of assets that can be added or removed from a scene.
  96992. */
  96993. export class AssetContainer extends AbstractScene {
  96994. /**
  96995. * The scene the AssetContainer belongs to.
  96996. */
  96997. scene: Scene;
  96998. /**
  96999. * Instantiates an AssetContainer.
  97000. * @param scene The scene the AssetContainer belongs to.
  97001. */
  97002. constructor(scene: Scene);
  97003. /**
  97004. * Adds all the assets from the container to the scene.
  97005. */
  97006. addAllToScene(): void;
  97007. /**
  97008. * Removes all the assets in the container from the scene
  97009. */
  97010. removeAllFromScene(): void;
  97011. /**
  97012. * Disposes all the assets in the container
  97013. */
  97014. dispose(): void;
  97015. private _moveAssets;
  97016. /**
  97017. * Removes all the assets contained in the scene and adds them to the container.
  97018. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  97019. */
  97020. moveAllFromScene(keepAssets?: KeepAssets): void;
  97021. /**
  97022. * 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.
  97023. * @returns the root mesh
  97024. */
  97025. createRootMesh(): Mesh;
  97026. }
  97027. }
  97028. declare module BABYLON {
  97029. /**
  97030. * Defines how the parser contract is defined.
  97031. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  97032. */
  97033. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  97034. /**
  97035. * Defines how the individual parser contract is defined.
  97036. * These parser can parse an individual asset
  97037. */
  97038. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  97039. /**
  97040. * Base class of the scene acting as a container for the different elements composing a scene.
  97041. * This class is dynamically extended by the different components of the scene increasing
  97042. * flexibility and reducing coupling
  97043. */
  97044. export abstract class AbstractScene {
  97045. /**
  97046. * Stores the list of available parsers in the application.
  97047. */
  97048. private static _BabylonFileParsers;
  97049. /**
  97050. * Stores the list of available individual parsers in the application.
  97051. */
  97052. private static _IndividualBabylonFileParsers;
  97053. /**
  97054. * Adds a parser in the list of available ones
  97055. * @param name Defines the name of the parser
  97056. * @param parser Defines the parser to add
  97057. */
  97058. static AddParser(name: string, parser: BabylonFileParser): void;
  97059. /**
  97060. * Gets a general parser from the list of avaialble ones
  97061. * @param name Defines the name of the parser
  97062. * @returns the requested parser or null
  97063. */
  97064. static GetParser(name: string): Nullable<BabylonFileParser>;
  97065. /**
  97066. * Adds n individual parser in the list of available ones
  97067. * @param name Defines the name of the parser
  97068. * @param parser Defines the parser to add
  97069. */
  97070. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  97071. /**
  97072. * Gets an individual parser from the list of avaialble ones
  97073. * @param name Defines the name of the parser
  97074. * @returns the requested parser or null
  97075. */
  97076. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  97077. /**
  97078. * Parser json data and populate both a scene and its associated container object
  97079. * @param jsonData Defines the data to parse
  97080. * @param scene Defines the scene to parse the data for
  97081. * @param container Defines the container attached to the parsing sequence
  97082. * @param rootUrl Defines the root url of the data
  97083. */
  97084. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  97085. /**
  97086. * Gets the list of root nodes (ie. nodes with no parent)
  97087. */
  97088. rootNodes: Node[];
  97089. /** All of the cameras added to this scene
  97090. * @see http://doc.babylonjs.com/babylon101/cameras
  97091. */
  97092. cameras: Camera[];
  97093. /**
  97094. * All of the lights added to this scene
  97095. * @see http://doc.babylonjs.com/babylon101/lights
  97096. */
  97097. lights: Light[];
  97098. /**
  97099. * All of the (abstract) meshes added to this scene
  97100. */
  97101. meshes: AbstractMesh[];
  97102. /**
  97103. * The list of skeletons added to the scene
  97104. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  97105. */
  97106. skeletons: Skeleton[];
  97107. /**
  97108. * All of the particle systems added to this scene
  97109. * @see http://doc.babylonjs.com/babylon101/particles
  97110. */
  97111. particleSystems: IParticleSystem[];
  97112. /**
  97113. * Gets a list of Animations associated with the scene
  97114. */
  97115. animations: Animation[];
  97116. /**
  97117. * All of the animation groups added to this scene
  97118. * @see http://doc.babylonjs.com/how_to/group
  97119. */
  97120. animationGroups: AnimationGroup[];
  97121. /**
  97122. * All of the multi-materials added to this scene
  97123. * @see http://doc.babylonjs.com/how_to/multi_materials
  97124. */
  97125. multiMaterials: MultiMaterial[];
  97126. /**
  97127. * All of the materials added to this scene
  97128. * In the context of a Scene, it is not supposed to be modified manually.
  97129. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  97130. * Note also that the order of the Material wihin the array is not significant and might change.
  97131. * @see http://doc.babylonjs.com/babylon101/materials
  97132. */
  97133. materials: Material[];
  97134. /**
  97135. * The list of morph target managers added to the scene
  97136. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  97137. */
  97138. morphTargetManagers: MorphTargetManager[];
  97139. /**
  97140. * The list of geometries used in the scene.
  97141. */
  97142. geometries: Geometry[];
  97143. /**
  97144. * All of the tranform nodes added to this scene
  97145. * In the context of a Scene, it is not supposed to be modified manually.
  97146. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  97147. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  97148. * @see http://doc.babylonjs.com/how_to/transformnode
  97149. */
  97150. transformNodes: TransformNode[];
  97151. /**
  97152. * ActionManagers available on the scene.
  97153. */
  97154. actionManagers: AbstractActionManager[];
  97155. /**
  97156. * Textures to keep.
  97157. */
  97158. textures: BaseTexture[];
  97159. /**
  97160. * Environment texture for the scene
  97161. */
  97162. environmentTexture: Nullable<BaseTexture>;
  97163. }
  97164. }
  97165. declare module BABYLON {
  97166. /**
  97167. * Interface used to define options for Sound class
  97168. */
  97169. export interface ISoundOptions {
  97170. /**
  97171. * Does the sound autoplay once loaded.
  97172. */
  97173. autoplay?: boolean;
  97174. /**
  97175. * Does the sound loop after it finishes playing once.
  97176. */
  97177. loop?: boolean;
  97178. /**
  97179. * Sound's volume
  97180. */
  97181. volume?: number;
  97182. /**
  97183. * Is it a spatial sound?
  97184. */
  97185. spatialSound?: boolean;
  97186. /**
  97187. * Maximum distance to hear that sound
  97188. */
  97189. maxDistance?: number;
  97190. /**
  97191. * Uses user defined attenuation function
  97192. */
  97193. useCustomAttenuation?: boolean;
  97194. /**
  97195. * Define the roll off factor of spatial sounds.
  97196. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97197. */
  97198. rolloffFactor?: number;
  97199. /**
  97200. * Define the reference distance the sound should be heard perfectly.
  97201. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97202. */
  97203. refDistance?: number;
  97204. /**
  97205. * Define the distance attenuation model the sound will follow.
  97206. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97207. */
  97208. distanceModel?: string;
  97209. /**
  97210. * Defines the playback speed (1 by default)
  97211. */
  97212. playbackRate?: number;
  97213. /**
  97214. * Defines if the sound is from a streaming source
  97215. */
  97216. streaming?: boolean;
  97217. /**
  97218. * Defines an optional length (in seconds) inside the sound file
  97219. */
  97220. length?: number;
  97221. /**
  97222. * Defines an optional offset (in seconds) inside the sound file
  97223. */
  97224. offset?: number;
  97225. }
  97226. /**
  97227. * Defines a sound that can be played in the application.
  97228. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  97229. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97230. */
  97231. export class Sound {
  97232. /**
  97233. * The name of the sound in the scene.
  97234. */
  97235. name: string;
  97236. /**
  97237. * Does the sound autoplay once loaded.
  97238. */
  97239. autoplay: boolean;
  97240. /**
  97241. * Does the sound loop after it finishes playing once.
  97242. */
  97243. loop: boolean;
  97244. /**
  97245. * Does the sound use a custom attenuation curve to simulate the falloff
  97246. * happening when the source gets further away from the camera.
  97247. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  97248. */
  97249. useCustomAttenuation: boolean;
  97250. /**
  97251. * The sound track id this sound belongs to.
  97252. */
  97253. soundTrackId: number;
  97254. /**
  97255. * Is this sound currently played.
  97256. */
  97257. isPlaying: boolean;
  97258. /**
  97259. * Is this sound currently paused.
  97260. */
  97261. isPaused: boolean;
  97262. /**
  97263. * Does this sound enables spatial sound.
  97264. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97265. */
  97266. spatialSound: boolean;
  97267. /**
  97268. * Define the reference distance the sound should be heard perfectly.
  97269. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97270. */
  97271. refDistance: number;
  97272. /**
  97273. * Define the roll off factor of spatial sounds.
  97274. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97275. */
  97276. rolloffFactor: number;
  97277. /**
  97278. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  97279. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97280. */
  97281. maxDistance: number;
  97282. /**
  97283. * Define the distance attenuation model the sound will follow.
  97284. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97285. */
  97286. distanceModel: string;
  97287. /**
  97288. * @hidden
  97289. * Back Compat
  97290. **/
  97291. onended: () => any;
  97292. /**
  97293. * Observable event when the current playing sound finishes.
  97294. */
  97295. onEndedObservable: Observable<Sound>;
  97296. private _panningModel;
  97297. private _playbackRate;
  97298. private _streaming;
  97299. private _startTime;
  97300. private _startOffset;
  97301. private _position;
  97302. /** @hidden */
  97303. _positionInEmitterSpace: boolean;
  97304. private _localDirection;
  97305. private _volume;
  97306. private _isReadyToPlay;
  97307. private _isDirectional;
  97308. private _readyToPlayCallback;
  97309. private _audioBuffer;
  97310. private _soundSource;
  97311. private _streamingSource;
  97312. private _soundPanner;
  97313. private _soundGain;
  97314. private _inputAudioNode;
  97315. private _outputAudioNode;
  97316. private _coneInnerAngle;
  97317. private _coneOuterAngle;
  97318. private _coneOuterGain;
  97319. private _scene;
  97320. private _connectedTransformNode;
  97321. private _customAttenuationFunction;
  97322. private _registerFunc;
  97323. private _isOutputConnected;
  97324. private _htmlAudioElement;
  97325. private _urlType;
  97326. private _length?;
  97327. private _offset?;
  97328. /** @hidden */
  97329. static _SceneComponentInitialization: (scene: Scene) => void;
  97330. /**
  97331. * Create a sound and attach it to a scene
  97332. * @param name Name of your sound
  97333. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  97334. * @param scene defines the scene the sound belongs to
  97335. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  97336. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  97337. */
  97338. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  97339. /**
  97340. * Release the sound and its associated resources
  97341. */
  97342. dispose(): void;
  97343. /**
  97344. * Gets if the sounds is ready to be played or not.
  97345. * @returns true if ready, otherwise false
  97346. */
  97347. isReady(): boolean;
  97348. private _soundLoaded;
  97349. /**
  97350. * Sets the data of the sound from an audiobuffer
  97351. * @param audioBuffer The audioBuffer containing the data
  97352. */
  97353. setAudioBuffer(audioBuffer: AudioBuffer): void;
  97354. /**
  97355. * Updates the current sounds options such as maxdistance, loop...
  97356. * @param options A JSON object containing values named as the object properties
  97357. */
  97358. updateOptions(options: ISoundOptions): void;
  97359. private _createSpatialParameters;
  97360. private _updateSpatialParameters;
  97361. /**
  97362. * Switch the panning model to HRTF:
  97363. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  97364. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97365. */
  97366. switchPanningModelToHRTF(): void;
  97367. /**
  97368. * Switch the panning model to Equal Power:
  97369. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  97370. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97371. */
  97372. switchPanningModelToEqualPower(): void;
  97373. private _switchPanningModel;
  97374. /**
  97375. * Connect this sound to a sound track audio node like gain...
  97376. * @param soundTrackAudioNode the sound track audio node to connect to
  97377. */
  97378. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  97379. /**
  97380. * Transform this sound into a directional source
  97381. * @param coneInnerAngle Size of the inner cone in degree
  97382. * @param coneOuterAngle Size of the outer cone in degree
  97383. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  97384. */
  97385. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  97386. /**
  97387. * Gets or sets the inner angle for the directional cone.
  97388. */
  97389. /**
  97390. * Gets or sets the inner angle for the directional cone.
  97391. */
  97392. directionalConeInnerAngle: number;
  97393. /**
  97394. * Gets or sets the outer angle for the directional cone.
  97395. */
  97396. /**
  97397. * Gets or sets the outer angle for the directional cone.
  97398. */
  97399. directionalConeOuterAngle: number;
  97400. /**
  97401. * Sets the position of the emitter if spatial sound is enabled
  97402. * @param newPosition Defines the new posisiton
  97403. */
  97404. setPosition(newPosition: Vector3): void;
  97405. /**
  97406. * Sets the local direction of the emitter if spatial sound is enabled
  97407. * @param newLocalDirection Defines the new local direction
  97408. */
  97409. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  97410. private _updateDirection;
  97411. /** @hidden */
  97412. updateDistanceFromListener(): void;
  97413. /**
  97414. * Sets a new custom attenuation function for the sound.
  97415. * @param callback Defines the function used for the attenuation
  97416. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  97417. */
  97418. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  97419. /**
  97420. * Play the sound
  97421. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  97422. * @param offset (optional) Start the sound at a specific time in seconds
  97423. * @param length (optional) Sound duration (in seconds)
  97424. */
  97425. play(time?: number, offset?: number, length?: number): void;
  97426. private _onended;
  97427. /**
  97428. * Stop the sound
  97429. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  97430. */
  97431. stop(time?: number): void;
  97432. /**
  97433. * Put the sound in pause
  97434. */
  97435. pause(): void;
  97436. /**
  97437. * Sets a dedicated volume for this sounds
  97438. * @param newVolume Define the new volume of the sound
  97439. * @param time Define time for gradual change to new volume
  97440. */
  97441. setVolume(newVolume: number, time?: number): void;
  97442. /**
  97443. * Set the sound play back rate
  97444. * @param newPlaybackRate Define the playback rate the sound should be played at
  97445. */
  97446. setPlaybackRate(newPlaybackRate: number): void;
  97447. /**
  97448. * Gets the volume of the sound.
  97449. * @returns the volume of the sound
  97450. */
  97451. getVolume(): number;
  97452. /**
  97453. * Attach the sound to a dedicated mesh
  97454. * @param transformNode The transform node to connect the sound with
  97455. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  97456. */
  97457. attachToMesh(transformNode: TransformNode): void;
  97458. /**
  97459. * Detach the sound from the previously attached mesh
  97460. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  97461. */
  97462. detachFromMesh(): void;
  97463. private _onRegisterAfterWorldMatrixUpdate;
  97464. /**
  97465. * Clone the current sound in the scene.
  97466. * @returns the new sound clone
  97467. */
  97468. clone(): Nullable<Sound>;
  97469. /**
  97470. * Gets the current underlying audio buffer containing the data
  97471. * @returns the audio buffer
  97472. */
  97473. getAudioBuffer(): Nullable<AudioBuffer>;
  97474. /**
  97475. * Serializes the Sound in a JSON representation
  97476. * @returns the JSON representation of the sound
  97477. */
  97478. serialize(): any;
  97479. /**
  97480. * Parse a JSON representation of a sound to innstantiate in a given scene
  97481. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  97482. * @param scene Define the scene the new parsed sound should be created in
  97483. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  97484. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  97485. * @returns the newly parsed sound
  97486. */
  97487. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  97488. }
  97489. }
  97490. declare module BABYLON {
  97491. /**
  97492. * This defines an action helpful to play a defined sound on a triggered action.
  97493. */
  97494. export class PlaySoundAction extends Action {
  97495. private _sound;
  97496. /**
  97497. * Instantiate the action
  97498. * @param triggerOptions defines the trigger options
  97499. * @param sound defines the sound to play
  97500. * @param condition defines the trigger related conditions
  97501. */
  97502. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  97503. /** @hidden */
  97504. _prepare(): void;
  97505. /**
  97506. * Execute the action and play the sound.
  97507. */
  97508. execute(): void;
  97509. /**
  97510. * Serializes the actions and its related information.
  97511. * @param parent defines the object to serialize in
  97512. * @returns the serialized object
  97513. */
  97514. serialize(parent: any): any;
  97515. }
  97516. /**
  97517. * This defines an action helpful to stop a defined sound on a triggered action.
  97518. */
  97519. export class StopSoundAction extends Action {
  97520. private _sound;
  97521. /**
  97522. * Instantiate the action
  97523. * @param triggerOptions defines the trigger options
  97524. * @param sound defines the sound to stop
  97525. * @param condition defines the trigger related conditions
  97526. */
  97527. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  97528. /** @hidden */
  97529. _prepare(): void;
  97530. /**
  97531. * Execute the action and stop the sound.
  97532. */
  97533. execute(): void;
  97534. /**
  97535. * Serializes the actions and its related information.
  97536. * @param parent defines the object to serialize in
  97537. * @returns the serialized object
  97538. */
  97539. serialize(parent: any): any;
  97540. }
  97541. }
  97542. declare module BABYLON {
  97543. /**
  97544. * This defines an action responsible to change the value of a property
  97545. * by interpolating between its current value and the newly set one once triggered.
  97546. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  97547. */
  97548. export class InterpolateValueAction extends Action {
  97549. /**
  97550. * Defines the path of the property where the value should be interpolated
  97551. */
  97552. propertyPath: string;
  97553. /**
  97554. * Defines the target value at the end of the interpolation.
  97555. */
  97556. value: any;
  97557. /**
  97558. * Defines the time it will take for the property to interpolate to the value.
  97559. */
  97560. duration: number;
  97561. /**
  97562. * Defines if the other scene animations should be stopped when the action has been triggered
  97563. */
  97564. stopOtherAnimations?: boolean;
  97565. /**
  97566. * Defines a callback raised once the interpolation animation has been done.
  97567. */
  97568. onInterpolationDone?: () => void;
  97569. /**
  97570. * Observable triggered once the interpolation animation has been done.
  97571. */
  97572. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  97573. private _target;
  97574. private _effectiveTarget;
  97575. private _property;
  97576. /**
  97577. * Instantiate the action
  97578. * @param triggerOptions defines the trigger options
  97579. * @param target defines the object containing the value to interpolate
  97580. * @param propertyPath defines the path to the property in the target object
  97581. * @param value defines the target value at the end of the interpolation
  97582. * @param duration deines the time it will take for the property to interpolate to the value.
  97583. * @param condition defines the trigger related conditions
  97584. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  97585. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  97586. */
  97587. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  97588. /** @hidden */
  97589. _prepare(): void;
  97590. /**
  97591. * Execute the action starts the value interpolation.
  97592. */
  97593. execute(): void;
  97594. /**
  97595. * Serializes the actions and its related information.
  97596. * @param parent defines the object to serialize in
  97597. * @returns the serialized object
  97598. */
  97599. serialize(parent: any): any;
  97600. }
  97601. }
  97602. declare module BABYLON {
  97603. /**
  97604. * Options allowed during the creation of a sound track.
  97605. */
  97606. export interface ISoundTrackOptions {
  97607. /**
  97608. * The volume the sound track should take during creation
  97609. */
  97610. volume?: number;
  97611. /**
  97612. * Define if the sound track is the main sound track of the scene
  97613. */
  97614. mainTrack?: boolean;
  97615. }
  97616. /**
  97617. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  97618. * It will be also used in a future release to apply effects on a specific track.
  97619. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  97620. */
  97621. export class SoundTrack {
  97622. /**
  97623. * The unique identifier of the sound track in the scene.
  97624. */
  97625. id: number;
  97626. /**
  97627. * The list of sounds included in the sound track.
  97628. */
  97629. soundCollection: Array<Sound>;
  97630. private _outputAudioNode;
  97631. private _scene;
  97632. private _isMainTrack;
  97633. private _connectedAnalyser;
  97634. private _options;
  97635. private _isInitialized;
  97636. /**
  97637. * Creates a new sound track.
  97638. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  97639. * @param scene Define the scene the sound track belongs to
  97640. * @param options
  97641. */
  97642. constructor(scene: Scene, options?: ISoundTrackOptions);
  97643. private _initializeSoundTrackAudioGraph;
  97644. /**
  97645. * Release the sound track and its associated resources
  97646. */
  97647. dispose(): void;
  97648. /**
  97649. * Adds a sound to this sound track
  97650. * @param sound define the cound to add
  97651. * @ignoreNaming
  97652. */
  97653. AddSound(sound: Sound): void;
  97654. /**
  97655. * Removes a sound to this sound track
  97656. * @param sound define the cound to remove
  97657. * @ignoreNaming
  97658. */
  97659. RemoveSound(sound: Sound): void;
  97660. /**
  97661. * Set a global volume for the full sound track.
  97662. * @param newVolume Define the new volume of the sound track
  97663. */
  97664. setVolume(newVolume: number): void;
  97665. /**
  97666. * Switch the panning model to HRTF:
  97667. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  97668. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97669. */
  97670. switchPanningModelToHRTF(): void;
  97671. /**
  97672. * Switch the panning model to Equal Power:
  97673. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  97674. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97675. */
  97676. switchPanningModelToEqualPower(): void;
  97677. /**
  97678. * Connect the sound track to an audio analyser allowing some amazing
  97679. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  97680. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  97681. * @param analyser The analyser to connect to the engine
  97682. */
  97683. connectToAnalyser(analyser: Analyser): void;
  97684. }
  97685. }
  97686. declare module BABYLON {
  97687. interface AbstractScene {
  97688. /**
  97689. * The list of sounds used in the scene.
  97690. */
  97691. sounds: Nullable<Array<Sound>>;
  97692. }
  97693. interface Scene {
  97694. /**
  97695. * @hidden
  97696. * Backing field
  97697. */
  97698. _mainSoundTrack: SoundTrack;
  97699. /**
  97700. * The main sound track played by the scene.
  97701. * It cotains your primary collection of sounds.
  97702. */
  97703. mainSoundTrack: SoundTrack;
  97704. /**
  97705. * The list of sound tracks added to the scene
  97706. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97707. */
  97708. soundTracks: Nullable<Array<SoundTrack>>;
  97709. /**
  97710. * Gets a sound using a given name
  97711. * @param name defines the name to search for
  97712. * @return the found sound or null if not found at all.
  97713. */
  97714. getSoundByName(name: string): Nullable<Sound>;
  97715. /**
  97716. * Gets or sets if audio support is enabled
  97717. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97718. */
  97719. audioEnabled: boolean;
  97720. /**
  97721. * Gets or sets if audio will be output to headphones
  97722. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97723. */
  97724. headphone: boolean;
  97725. }
  97726. /**
  97727. * Defines the sound scene component responsible to manage any sounds
  97728. * in a given scene.
  97729. */
  97730. export class AudioSceneComponent implements ISceneSerializableComponent {
  97731. /**
  97732. * The component name helpfull to identify the component in the list of scene components.
  97733. */
  97734. readonly name: string;
  97735. /**
  97736. * The scene the component belongs to.
  97737. */
  97738. scene: Scene;
  97739. private _audioEnabled;
  97740. /**
  97741. * Gets whether audio is enabled or not.
  97742. * Please use related enable/disable method to switch state.
  97743. */
  97744. readonly audioEnabled: boolean;
  97745. private _headphone;
  97746. /**
  97747. * Gets whether audio is outputing to headphone or not.
  97748. * Please use the according Switch methods to change output.
  97749. */
  97750. readonly headphone: boolean;
  97751. /**
  97752. * Creates a new instance of the component for the given scene
  97753. * @param scene Defines the scene to register the component in
  97754. */
  97755. constructor(scene: Scene);
  97756. /**
  97757. * Registers the component in a given scene
  97758. */
  97759. register(): void;
  97760. /**
  97761. * Rebuilds the elements related to this component in case of
  97762. * context lost for instance.
  97763. */
  97764. rebuild(): void;
  97765. /**
  97766. * Serializes the component data to the specified json object
  97767. * @param serializationObject The object to serialize to
  97768. */
  97769. serialize(serializationObject: any): void;
  97770. /**
  97771. * Adds all the elements from the container to the scene
  97772. * @param container the container holding the elements
  97773. */
  97774. addFromContainer(container: AbstractScene): void;
  97775. /**
  97776. * Removes all the elements in the container from the scene
  97777. * @param container contains the elements to remove
  97778. * @param dispose if the removed element should be disposed (default: false)
  97779. */
  97780. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  97781. /**
  97782. * Disposes the component and the associated ressources.
  97783. */
  97784. dispose(): void;
  97785. /**
  97786. * Disables audio in the associated scene.
  97787. */
  97788. disableAudio(): void;
  97789. /**
  97790. * Enables audio in the associated scene.
  97791. */
  97792. enableAudio(): void;
  97793. /**
  97794. * Switch audio to headphone output.
  97795. */
  97796. switchAudioModeForHeadphones(): void;
  97797. /**
  97798. * Switch audio to normal speakers.
  97799. */
  97800. switchAudioModeForNormalSpeakers(): void;
  97801. private _afterRender;
  97802. }
  97803. }
  97804. declare module BABYLON {
  97805. /**
  97806. * Wraps one or more Sound objects and selects one with random weight for playback.
  97807. */
  97808. export class WeightedSound {
  97809. /** When true a Sound will be selected and played when the current playing Sound completes. */
  97810. loop: boolean;
  97811. private _coneInnerAngle;
  97812. private _coneOuterAngle;
  97813. private _volume;
  97814. /** A Sound is currently playing. */
  97815. isPlaying: boolean;
  97816. /** A Sound is currently paused. */
  97817. isPaused: boolean;
  97818. private _sounds;
  97819. private _weights;
  97820. private _currentIndex?;
  97821. /**
  97822. * Creates a new WeightedSound from the list of sounds given.
  97823. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  97824. * @param sounds Array of Sounds that will be selected from.
  97825. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  97826. */
  97827. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  97828. /**
  97829. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  97830. */
  97831. /**
  97832. * The size of cone in degress for a directional sound in which there will be no attenuation.
  97833. */
  97834. directionalConeInnerAngle: number;
  97835. /**
  97836. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  97837. * Listener angles between innerAngle and outerAngle will falloff linearly.
  97838. */
  97839. /**
  97840. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  97841. * Listener angles between innerAngle and outerAngle will falloff linearly.
  97842. */
  97843. directionalConeOuterAngle: number;
  97844. /**
  97845. * Playback volume.
  97846. */
  97847. /**
  97848. * Playback volume.
  97849. */
  97850. volume: number;
  97851. private _onended;
  97852. /**
  97853. * Suspend playback
  97854. */
  97855. pause(): void;
  97856. /**
  97857. * Stop playback
  97858. */
  97859. stop(): void;
  97860. /**
  97861. * Start playback.
  97862. * @param startOffset Position the clip head at a specific time in seconds.
  97863. */
  97864. play(startOffset?: number): void;
  97865. }
  97866. }
  97867. declare module BABYLON {
  97868. /**
  97869. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  97870. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  97871. */
  97872. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  97873. /**
  97874. * Gets the name of the behavior.
  97875. */
  97876. readonly name: string;
  97877. /**
  97878. * The easing function used by animations
  97879. */
  97880. static EasingFunction: BackEase;
  97881. /**
  97882. * The easing mode used by animations
  97883. */
  97884. static EasingMode: number;
  97885. /**
  97886. * The duration of the animation, in milliseconds
  97887. */
  97888. transitionDuration: number;
  97889. /**
  97890. * Length of the distance animated by the transition when lower radius is reached
  97891. */
  97892. lowerRadiusTransitionRange: number;
  97893. /**
  97894. * Length of the distance animated by the transition when upper radius is reached
  97895. */
  97896. upperRadiusTransitionRange: number;
  97897. private _autoTransitionRange;
  97898. /**
  97899. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  97900. */
  97901. /**
  97902. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  97903. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  97904. */
  97905. autoTransitionRange: boolean;
  97906. private _attachedCamera;
  97907. private _onAfterCheckInputsObserver;
  97908. private _onMeshTargetChangedObserver;
  97909. /**
  97910. * Initializes the behavior.
  97911. */
  97912. init(): void;
  97913. /**
  97914. * Attaches the behavior to its arc rotate camera.
  97915. * @param camera Defines the camera to attach the behavior to
  97916. */
  97917. attach(camera: ArcRotateCamera): void;
  97918. /**
  97919. * Detaches the behavior from its current arc rotate camera.
  97920. */
  97921. detach(): void;
  97922. private _radiusIsAnimating;
  97923. private _radiusBounceTransition;
  97924. private _animatables;
  97925. private _cachedWheelPrecision;
  97926. /**
  97927. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  97928. * @param radiusLimit The limit to check against.
  97929. * @return Bool to indicate if at limit.
  97930. */
  97931. private _isRadiusAtLimit;
  97932. /**
  97933. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  97934. * @param radiusDelta The delta by which to animate to. Can be negative.
  97935. */
  97936. private _applyBoundRadiusAnimation;
  97937. /**
  97938. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  97939. */
  97940. protected _clearAnimationLocks(): void;
  97941. /**
  97942. * Stops and removes all animations that have been applied to the camera
  97943. */
  97944. stopAllAnimations(): void;
  97945. }
  97946. }
  97947. declare module BABYLON {
  97948. /**
  97949. * 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.
  97950. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  97951. */
  97952. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  97953. /**
  97954. * Gets the name of the behavior.
  97955. */
  97956. readonly name: string;
  97957. private _mode;
  97958. private _radiusScale;
  97959. private _positionScale;
  97960. private _defaultElevation;
  97961. private _elevationReturnTime;
  97962. private _elevationReturnWaitTime;
  97963. private _zoomStopsAnimation;
  97964. private _framingTime;
  97965. /**
  97966. * The easing function used by animations
  97967. */
  97968. static EasingFunction: ExponentialEase;
  97969. /**
  97970. * The easing mode used by animations
  97971. */
  97972. static EasingMode: number;
  97973. /**
  97974. * Sets the current mode used by the behavior
  97975. */
  97976. /**
  97977. * Gets current mode used by the behavior.
  97978. */
  97979. mode: number;
  97980. /**
  97981. * Sets the scale applied to the radius (1 by default)
  97982. */
  97983. /**
  97984. * Gets the scale applied to the radius
  97985. */
  97986. radiusScale: number;
  97987. /**
  97988. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  97989. */
  97990. /**
  97991. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  97992. */
  97993. positionScale: number;
  97994. /**
  97995. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  97996. * behaviour is triggered, in radians.
  97997. */
  97998. /**
  97999. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  98000. * behaviour is triggered, in radians.
  98001. */
  98002. defaultElevation: number;
  98003. /**
  98004. * Sets the time (in milliseconds) taken to return to the default beta position.
  98005. * Negative value indicates camera should not return to default.
  98006. */
  98007. /**
  98008. * Gets the time (in milliseconds) taken to return to the default beta position.
  98009. * Negative value indicates camera should not return to default.
  98010. */
  98011. elevationReturnTime: number;
  98012. /**
  98013. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  98014. */
  98015. /**
  98016. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  98017. */
  98018. elevationReturnWaitTime: number;
  98019. /**
  98020. * Sets the flag that indicates if user zooming should stop animation.
  98021. */
  98022. /**
  98023. * Gets the flag that indicates if user zooming should stop animation.
  98024. */
  98025. zoomStopsAnimation: boolean;
  98026. /**
  98027. * Sets the transition time when framing the mesh, in milliseconds
  98028. */
  98029. /**
  98030. * Gets the transition time when framing the mesh, in milliseconds
  98031. */
  98032. framingTime: number;
  98033. /**
  98034. * Define if the behavior should automatically change the configured
  98035. * camera limits and sensibilities.
  98036. */
  98037. autoCorrectCameraLimitsAndSensibility: boolean;
  98038. private _onPrePointerObservableObserver;
  98039. private _onAfterCheckInputsObserver;
  98040. private _onMeshTargetChangedObserver;
  98041. private _attachedCamera;
  98042. private _isPointerDown;
  98043. private _lastInteractionTime;
  98044. /**
  98045. * Initializes the behavior.
  98046. */
  98047. init(): void;
  98048. /**
  98049. * Attaches the behavior to its arc rotate camera.
  98050. * @param camera Defines the camera to attach the behavior to
  98051. */
  98052. attach(camera: ArcRotateCamera): void;
  98053. /**
  98054. * Detaches the behavior from its current arc rotate camera.
  98055. */
  98056. detach(): void;
  98057. private _animatables;
  98058. private _betaIsAnimating;
  98059. private _betaTransition;
  98060. private _radiusTransition;
  98061. private _vectorTransition;
  98062. /**
  98063. * Targets the given mesh and updates zoom level accordingly.
  98064. * @param mesh The mesh to target.
  98065. * @param radius Optional. If a cached radius position already exists, overrides default.
  98066. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  98067. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  98068. * @param onAnimationEnd Callback triggered at the end of the framing animation
  98069. */
  98070. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  98071. /**
  98072. * Targets the given mesh with its children and updates zoom level accordingly.
  98073. * @param mesh The mesh to target.
  98074. * @param radius Optional. If a cached radius position already exists, overrides default.
  98075. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  98076. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  98077. * @param onAnimationEnd Callback triggered at the end of the framing animation
  98078. */
  98079. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  98080. /**
  98081. * Targets the given meshes with their children and updates zoom level accordingly.
  98082. * @param meshes The mesh to target.
  98083. * @param radius Optional. If a cached radius position already exists, overrides default.
  98084. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  98085. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  98086. * @param onAnimationEnd Callback triggered at the end of the framing animation
  98087. */
  98088. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  98089. /**
  98090. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  98091. * @param minimumWorld Determines the smaller position of the bounding box extend
  98092. * @param maximumWorld Determines the bigger position of the bounding box extend
  98093. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  98094. * @param onAnimationEnd Callback triggered at the end of the framing animation
  98095. */
  98096. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  98097. /**
  98098. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  98099. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  98100. * frustum width.
  98101. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  98102. * to fully enclose the mesh in the viewing frustum.
  98103. */
  98104. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  98105. /**
  98106. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  98107. * is automatically returned to its default position (expected to be above ground plane).
  98108. */
  98109. private _maintainCameraAboveGround;
  98110. /**
  98111. * Returns the frustum slope based on the canvas ratio and camera FOV
  98112. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  98113. */
  98114. private _getFrustumSlope;
  98115. /**
  98116. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  98117. */
  98118. private _clearAnimationLocks;
  98119. /**
  98120. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  98121. */
  98122. private _applyUserInteraction;
  98123. /**
  98124. * Stops and removes all animations that have been applied to the camera
  98125. */
  98126. stopAllAnimations(): void;
  98127. /**
  98128. * Gets a value indicating if the user is moving the camera
  98129. */
  98130. readonly isUserIsMoving: boolean;
  98131. /**
  98132. * The camera can move all the way towards the mesh.
  98133. */
  98134. static IgnoreBoundsSizeMode: number;
  98135. /**
  98136. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  98137. */
  98138. static FitFrustumSidesMode: number;
  98139. }
  98140. }
  98141. declare module BABYLON {
  98142. /**
  98143. * Base class for Camera Pointer Inputs.
  98144. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  98145. * for example usage.
  98146. */
  98147. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  98148. /**
  98149. * Defines the camera the input is attached to.
  98150. */
  98151. abstract camera: Camera;
  98152. /**
  98153. * Whether keyboard modifier keys are pressed at time of last mouse event.
  98154. */
  98155. protected _altKey: boolean;
  98156. protected _ctrlKey: boolean;
  98157. protected _metaKey: boolean;
  98158. protected _shiftKey: boolean;
  98159. /**
  98160. * Which mouse buttons were pressed at time of last mouse event.
  98161. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  98162. */
  98163. protected _buttonsPressed: number;
  98164. /**
  98165. * Defines the buttons associated with the input to handle camera move.
  98166. */
  98167. buttons: number[];
  98168. /**
  98169. * Attach the input controls to a specific dom element to get the input from.
  98170. * @param element Defines the element the controls should be listened from
  98171. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98172. */
  98173. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98174. /**
  98175. * Detach the current controls from the specified dom element.
  98176. * @param element Defines the element to stop listening the inputs from
  98177. */
  98178. detachControl(element: Nullable<HTMLElement>): void;
  98179. /**
  98180. * Gets the class name of the current input.
  98181. * @returns the class name
  98182. */
  98183. getClassName(): string;
  98184. /**
  98185. * Get the friendly name associated with the input class.
  98186. * @returns the input friendly name
  98187. */
  98188. getSimpleName(): string;
  98189. /**
  98190. * Called on pointer POINTERDOUBLETAP event.
  98191. * Override this method to provide functionality on POINTERDOUBLETAP event.
  98192. */
  98193. protected onDoubleTap(type: string): void;
  98194. /**
  98195. * Called on pointer POINTERMOVE event if only a single touch is active.
  98196. * Override this method to provide functionality.
  98197. */
  98198. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  98199. /**
  98200. * Called on pointer POINTERMOVE event if multiple touches are active.
  98201. * Override this method to provide functionality.
  98202. */
  98203. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  98204. /**
  98205. * Called on JS contextmenu event.
  98206. * Override this method to provide functionality.
  98207. */
  98208. protected onContextMenu(evt: PointerEvent): void;
  98209. /**
  98210. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  98211. * press.
  98212. * Override this method to provide functionality.
  98213. */
  98214. protected onButtonDown(evt: PointerEvent): void;
  98215. /**
  98216. * Called each time a new POINTERUP event occurs. Ie, for each button
  98217. * release.
  98218. * Override this method to provide functionality.
  98219. */
  98220. protected onButtonUp(evt: PointerEvent): void;
  98221. /**
  98222. * Called when window becomes inactive.
  98223. * Override this method to provide functionality.
  98224. */
  98225. protected onLostFocus(): void;
  98226. private _pointerInput;
  98227. private _observer;
  98228. private _onLostFocus;
  98229. private pointA;
  98230. private pointB;
  98231. }
  98232. }
  98233. declare module BABYLON {
  98234. /**
  98235. * Manage the pointers inputs to control an arc rotate camera.
  98236. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  98237. */
  98238. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  98239. /**
  98240. * Defines the camera the input is attached to.
  98241. */
  98242. camera: ArcRotateCamera;
  98243. /**
  98244. * Gets the class name of the current input.
  98245. * @returns the class name
  98246. */
  98247. getClassName(): string;
  98248. /**
  98249. * Defines the buttons associated with the input to handle camera move.
  98250. */
  98251. buttons: number[];
  98252. /**
  98253. * Defines the pointer angular sensibility along the X axis or how fast is
  98254. * the camera rotating.
  98255. */
  98256. angularSensibilityX: number;
  98257. /**
  98258. * Defines the pointer angular sensibility along the Y axis or how fast is
  98259. * the camera rotating.
  98260. */
  98261. angularSensibilityY: number;
  98262. /**
  98263. * Defines the pointer pinch precision or how fast is the camera zooming.
  98264. */
  98265. pinchPrecision: number;
  98266. /**
  98267. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  98268. * from 0.
  98269. * It defines the percentage of current camera.radius to use as delta when
  98270. * pinch zoom is used.
  98271. */
  98272. pinchDeltaPercentage: number;
  98273. /**
  98274. * Defines the pointer panning sensibility or how fast is the camera moving.
  98275. */
  98276. panningSensibility: number;
  98277. /**
  98278. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  98279. */
  98280. multiTouchPanning: boolean;
  98281. /**
  98282. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  98283. * zoom (pinch) through multitouch.
  98284. */
  98285. multiTouchPanAndZoom: boolean;
  98286. /**
  98287. * Revers pinch action direction.
  98288. */
  98289. pinchInwards: boolean;
  98290. private _isPanClick;
  98291. private _twoFingerActivityCount;
  98292. private _isPinching;
  98293. /**
  98294. * Called on pointer POINTERMOVE event if only a single touch is active.
  98295. */
  98296. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  98297. /**
  98298. * Called on pointer POINTERDOUBLETAP event.
  98299. */
  98300. protected onDoubleTap(type: string): void;
  98301. /**
  98302. * Called on pointer POINTERMOVE event if multiple touches are active.
  98303. */
  98304. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  98305. /**
  98306. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  98307. * press.
  98308. */
  98309. protected onButtonDown(evt: PointerEvent): void;
  98310. /**
  98311. * Called each time a new POINTERUP event occurs. Ie, for each button
  98312. * release.
  98313. */
  98314. protected onButtonUp(evt: PointerEvent): void;
  98315. /**
  98316. * Called when window becomes inactive.
  98317. */
  98318. protected onLostFocus(): void;
  98319. }
  98320. }
  98321. declare module BABYLON {
  98322. /**
  98323. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  98324. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  98325. */
  98326. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  98327. /**
  98328. * Defines the camera the input is attached to.
  98329. */
  98330. camera: ArcRotateCamera;
  98331. /**
  98332. * Defines the list of key codes associated with the up action (increase alpha)
  98333. */
  98334. keysUp: number[];
  98335. /**
  98336. * Defines the list of key codes associated with the down action (decrease alpha)
  98337. */
  98338. keysDown: number[];
  98339. /**
  98340. * Defines the list of key codes associated with the left action (increase beta)
  98341. */
  98342. keysLeft: number[];
  98343. /**
  98344. * Defines the list of key codes associated with the right action (decrease beta)
  98345. */
  98346. keysRight: number[];
  98347. /**
  98348. * Defines the list of key codes associated with the reset action.
  98349. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  98350. */
  98351. keysReset: number[];
  98352. /**
  98353. * Defines the panning sensibility of the inputs.
  98354. * (How fast is the camera paning)
  98355. */
  98356. panningSensibility: number;
  98357. /**
  98358. * Defines the zooming sensibility of the inputs.
  98359. * (How fast is the camera zooming)
  98360. */
  98361. zoomingSensibility: number;
  98362. /**
  98363. * Defines wether maintaining the alt key down switch the movement mode from
  98364. * orientation to zoom.
  98365. */
  98366. useAltToZoom: boolean;
  98367. /**
  98368. * Rotation speed of the camera
  98369. */
  98370. angularSpeed: number;
  98371. private _keys;
  98372. private _ctrlPressed;
  98373. private _altPressed;
  98374. private _onCanvasBlurObserver;
  98375. private _onKeyboardObserver;
  98376. private _engine;
  98377. private _scene;
  98378. /**
  98379. * Attach the input controls to a specific dom element to get the input from.
  98380. * @param element Defines the element the controls should be listened from
  98381. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98382. */
  98383. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98384. /**
  98385. * Detach the current controls from the specified dom element.
  98386. * @param element Defines the element to stop listening the inputs from
  98387. */
  98388. detachControl(element: Nullable<HTMLElement>): void;
  98389. /**
  98390. * Update the current camera state depending on the inputs that have been used this frame.
  98391. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  98392. */
  98393. checkInputs(): void;
  98394. /**
  98395. * Gets the class name of the current intput.
  98396. * @returns the class name
  98397. */
  98398. getClassName(): string;
  98399. /**
  98400. * Get the friendly name associated with the input class.
  98401. * @returns the input friendly name
  98402. */
  98403. getSimpleName(): string;
  98404. }
  98405. }
  98406. declare module BABYLON {
  98407. /**
  98408. * Manage the mouse wheel inputs to control an arc rotate camera.
  98409. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  98410. */
  98411. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  98412. /**
  98413. * Defines the camera the input is attached to.
  98414. */
  98415. camera: ArcRotateCamera;
  98416. /**
  98417. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  98418. */
  98419. wheelPrecision: number;
  98420. /**
  98421. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  98422. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  98423. */
  98424. wheelDeltaPercentage: number;
  98425. private _wheel;
  98426. private _observer;
  98427. private computeDeltaFromMouseWheelLegacyEvent;
  98428. /**
  98429. * Attach the input controls to a specific dom element to get the input from.
  98430. * @param element Defines the element the controls should be listened from
  98431. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98432. */
  98433. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98434. /**
  98435. * Detach the current controls from the specified dom element.
  98436. * @param element Defines the element to stop listening the inputs from
  98437. */
  98438. detachControl(element: Nullable<HTMLElement>): void;
  98439. /**
  98440. * Gets the class name of the current intput.
  98441. * @returns the class name
  98442. */
  98443. getClassName(): string;
  98444. /**
  98445. * Get the friendly name associated with the input class.
  98446. * @returns the input friendly name
  98447. */
  98448. getSimpleName(): string;
  98449. }
  98450. }
  98451. declare module BABYLON {
  98452. /**
  98453. * Default Inputs manager for the ArcRotateCamera.
  98454. * It groups all the default supported inputs for ease of use.
  98455. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  98456. */
  98457. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  98458. /**
  98459. * Instantiates a new ArcRotateCameraInputsManager.
  98460. * @param camera Defines the camera the inputs belong to
  98461. */
  98462. constructor(camera: ArcRotateCamera);
  98463. /**
  98464. * Add mouse wheel input support to the input manager.
  98465. * @returns the current input manager
  98466. */
  98467. addMouseWheel(): ArcRotateCameraInputsManager;
  98468. /**
  98469. * Add pointers input support to the input manager.
  98470. * @returns the current input manager
  98471. */
  98472. addPointers(): ArcRotateCameraInputsManager;
  98473. /**
  98474. * Add keyboard input support to the input manager.
  98475. * @returns the current input manager
  98476. */
  98477. addKeyboard(): ArcRotateCameraInputsManager;
  98478. }
  98479. }
  98480. declare module BABYLON {
  98481. /**
  98482. * This represents an orbital type of camera.
  98483. *
  98484. * 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.
  98485. * 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.
  98486. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  98487. */
  98488. export class ArcRotateCamera extends TargetCamera {
  98489. /**
  98490. * Defines the rotation angle of the camera along the longitudinal axis.
  98491. */
  98492. alpha: number;
  98493. /**
  98494. * Defines the rotation angle of the camera along the latitudinal axis.
  98495. */
  98496. beta: number;
  98497. /**
  98498. * Defines the radius of the camera from it s target point.
  98499. */
  98500. radius: number;
  98501. protected _target: Vector3;
  98502. protected _targetHost: Nullable<AbstractMesh>;
  98503. /**
  98504. * Defines the target point of the camera.
  98505. * The camera looks towards it form the radius distance.
  98506. */
  98507. target: Vector3;
  98508. /**
  98509. * Define the current local position of the camera in the scene
  98510. */
  98511. position: Vector3;
  98512. protected _upVector: Vector3;
  98513. protected _upToYMatrix: Matrix;
  98514. protected _YToUpMatrix: Matrix;
  98515. /**
  98516. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  98517. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  98518. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  98519. */
  98520. upVector: Vector3;
  98521. /**
  98522. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  98523. */
  98524. setMatUp(): void;
  98525. /**
  98526. * Current inertia value on the longitudinal axis.
  98527. * The bigger this number the longer it will take for the camera to stop.
  98528. */
  98529. inertialAlphaOffset: number;
  98530. /**
  98531. * Current inertia value on the latitudinal axis.
  98532. * The bigger this number the longer it will take for the camera to stop.
  98533. */
  98534. inertialBetaOffset: number;
  98535. /**
  98536. * Current inertia value on the radius axis.
  98537. * The bigger this number the longer it will take for the camera to stop.
  98538. */
  98539. inertialRadiusOffset: number;
  98540. /**
  98541. * Minimum allowed angle on the longitudinal axis.
  98542. * This can help limiting how the Camera is able to move in the scene.
  98543. */
  98544. lowerAlphaLimit: Nullable<number>;
  98545. /**
  98546. * Maximum allowed angle on the longitudinal axis.
  98547. * This can help limiting how the Camera is able to move in the scene.
  98548. */
  98549. upperAlphaLimit: Nullable<number>;
  98550. /**
  98551. * Minimum allowed angle on the latitudinal axis.
  98552. * This can help limiting how the Camera is able to move in the scene.
  98553. */
  98554. lowerBetaLimit: number;
  98555. /**
  98556. * Maximum allowed angle on the latitudinal axis.
  98557. * This can help limiting how the Camera is able to move in the scene.
  98558. */
  98559. upperBetaLimit: number;
  98560. /**
  98561. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  98562. * This can help limiting how the Camera is able to move in the scene.
  98563. */
  98564. lowerRadiusLimit: Nullable<number>;
  98565. /**
  98566. * Maximum allowed distance of the camera to the target (The camera can not get further).
  98567. * This can help limiting how the Camera is able to move in the scene.
  98568. */
  98569. upperRadiusLimit: Nullable<number>;
  98570. /**
  98571. * Defines the current inertia value used during panning of the camera along the X axis.
  98572. */
  98573. inertialPanningX: number;
  98574. /**
  98575. * Defines the current inertia value used during panning of the camera along the Y axis.
  98576. */
  98577. inertialPanningY: number;
  98578. /**
  98579. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  98580. * Basically if your fingers moves away from more than this distance you will be considered
  98581. * in pinch mode.
  98582. */
  98583. pinchToPanMaxDistance: number;
  98584. /**
  98585. * Defines the maximum distance the camera can pan.
  98586. * This could help keeping the cammera always in your scene.
  98587. */
  98588. panningDistanceLimit: Nullable<number>;
  98589. /**
  98590. * Defines the target of the camera before paning.
  98591. */
  98592. panningOriginTarget: Vector3;
  98593. /**
  98594. * Defines the value of the inertia used during panning.
  98595. * 0 would mean stop inertia and one would mean no decelleration at all.
  98596. */
  98597. panningInertia: number;
  98598. /**
  98599. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  98600. */
  98601. angularSensibilityX: number;
  98602. /**
  98603. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  98604. */
  98605. angularSensibilityY: number;
  98606. /**
  98607. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  98608. */
  98609. pinchPrecision: number;
  98610. /**
  98611. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  98612. * It will be used instead of pinchDeltaPrecision if different from 0.
  98613. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  98614. */
  98615. pinchDeltaPercentage: number;
  98616. /**
  98617. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  98618. */
  98619. panningSensibility: number;
  98620. /**
  98621. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  98622. */
  98623. keysUp: number[];
  98624. /**
  98625. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  98626. */
  98627. keysDown: number[];
  98628. /**
  98629. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  98630. */
  98631. keysLeft: number[];
  98632. /**
  98633. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  98634. */
  98635. keysRight: number[];
  98636. /**
  98637. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  98638. */
  98639. wheelPrecision: number;
  98640. /**
  98641. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  98642. * It will be used instead of pinchDeltaPrecision if different from 0.
  98643. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  98644. */
  98645. wheelDeltaPercentage: number;
  98646. /**
  98647. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  98648. */
  98649. zoomOnFactor: number;
  98650. /**
  98651. * Defines a screen offset for the camera position.
  98652. */
  98653. targetScreenOffset: Vector2;
  98654. /**
  98655. * Allows the camera to be completely reversed.
  98656. * If false the camera can not arrive upside down.
  98657. */
  98658. allowUpsideDown: boolean;
  98659. /**
  98660. * Define if double tap/click is used to restore the previously saved state of the camera.
  98661. */
  98662. useInputToRestoreState: boolean;
  98663. /** @hidden */
  98664. _viewMatrix: Matrix;
  98665. /** @hidden */
  98666. _useCtrlForPanning: boolean;
  98667. /** @hidden */
  98668. _panningMouseButton: number;
  98669. /**
  98670. * Defines the input associated to the camera.
  98671. */
  98672. inputs: ArcRotateCameraInputsManager;
  98673. /** @hidden */
  98674. _reset: () => void;
  98675. /**
  98676. * Defines the allowed panning axis.
  98677. */
  98678. panningAxis: Vector3;
  98679. protected _localDirection: Vector3;
  98680. protected _transformedDirection: Vector3;
  98681. private _bouncingBehavior;
  98682. /**
  98683. * Gets the bouncing behavior of the camera if it has been enabled.
  98684. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  98685. */
  98686. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  98687. /**
  98688. * Defines if the bouncing behavior of the camera is enabled on the camera.
  98689. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  98690. */
  98691. useBouncingBehavior: boolean;
  98692. private _framingBehavior;
  98693. /**
  98694. * Gets the framing behavior of the camera if it has been enabled.
  98695. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  98696. */
  98697. readonly framingBehavior: Nullable<FramingBehavior>;
  98698. /**
  98699. * Defines if the framing behavior of the camera is enabled on the camera.
  98700. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  98701. */
  98702. useFramingBehavior: boolean;
  98703. private _autoRotationBehavior;
  98704. /**
  98705. * Gets the auto rotation behavior of the camera if it has been enabled.
  98706. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  98707. */
  98708. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  98709. /**
  98710. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  98711. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  98712. */
  98713. useAutoRotationBehavior: boolean;
  98714. /**
  98715. * Observable triggered when the mesh target has been changed on the camera.
  98716. */
  98717. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  98718. /**
  98719. * Event raised when the camera is colliding with a mesh.
  98720. */
  98721. onCollide: (collidedMesh: AbstractMesh) => void;
  98722. /**
  98723. * Defines whether the camera should check collision with the objects oh the scene.
  98724. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  98725. */
  98726. checkCollisions: boolean;
  98727. /**
  98728. * Defines the collision radius of the camera.
  98729. * This simulates a sphere around the camera.
  98730. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  98731. */
  98732. collisionRadius: Vector3;
  98733. protected _collider: Collider;
  98734. protected _previousPosition: Vector3;
  98735. protected _collisionVelocity: Vector3;
  98736. protected _newPosition: Vector3;
  98737. protected _previousAlpha: number;
  98738. protected _previousBeta: number;
  98739. protected _previousRadius: number;
  98740. protected _collisionTriggered: boolean;
  98741. protected _targetBoundingCenter: Nullable<Vector3>;
  98742. private _computationVector;
  98743. /**
  98744. * Instantiates a new ArcRotateCamera in a given scene
  98745. * @param name Defines the name of the camera
  98746. * @param alpha Defines the camera rotation along the logitudinal axis
  98747. * @param beta Defines the camera rotation along the latitudinal axis
  98748. * @param radius Defines the camera distance from its target
  98749. * @param target Defines the camera target
  98750. * @param scene Defines the scene the camera belongs to
  98751. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  98752. */
  98753. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  98754. /** @hidden */
  98755. _initCache(): void;
  98756. /** @hidden */
  98757. _updateCache(ignoreParentClass?: boolean): void;
  98758. protected _getTargetPosition(): Vector3;
  98759. private _storedAlpha;
  98760. private _storedBeta;
  98761. private _storedRadius;
  98762. private _storedTarget;
  98763. /**
  98764. * Stores the current state of the camera (alpha, beta, radius and target)
  98765. * @returns the camera itself
  98766. */
  98767. storeState(): Camera;
  98768. /**
  98769. * @hidden
  98770. * Restored camera state. You must call storeState() first
  98771. */
  98772. _restoreStateValues(): boolean;
  98773. /** @hidden */
  98774. _isSynchronizedViewMatrix(): boolean;
  98775. /**
  98776. * Attached controls to the current camera.
  98777. * @param element Defines the element the controls should be listened from
  98778. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98779. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  98780. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  98781. */
  98782. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  98783. /**
  98784. * Detach the current controls from the camera.
  98785. * The camera will stop reacting to inputs.
  98786. * @param element Defines the element to stop listening the inputs from
  98787. */
  98788. detachControl(element: HTMLElement): void;
  98789. /** @hidden */
  98790. _checkInputs(): void;
  98791. protected _checkLimits(): void;
  98792. /**
  98793. * Rebuilds angles (alpha, beta) and radius from the give position and target
  98794. */
  98795. rebuildAnglesAndRadius(): void;
  98796. /**
  98797. * Use a position to define the current camera related information like aplha, beta and radius
  98798. * @param position Defines the position to set the camera at
  98799. */
  98800. setPosition(position: Vector3): void;
  98801. /**
  98802. * Defines the target the camera should look at.
  98803. * This will automatically adapt alpha beta and radius to fit within the new target.
  98804. * @param target Defines the new target as a Vector or a mesh
  98805. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  98806. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  98807. */
  98808. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  98809. /** @hidden */
  98810. _getViewMatrix(): Matrix;
  98811. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  98812. /**
  98813. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  98814. * @param meshes Defines the mesh to zoom on
  98815. * @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)
  98816. */
  98817. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  98818. /**
  98819. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  98820. * The target will be changed but the radius
  98821. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  98822. * @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)
  98823. */
  98824. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  98825. min: Vector3;
  98826. max: Vector3;
  98827. distance: number;
  98828. }, doNotUpdateMaxZ?: boolean): void;
  98829. /**
  98830. * @override
  98831. * Override Camera.createRigCamera
  98832. */
  98833. createRigCamera(name: string, cameraIndex: number): Camera;
  98834. /**
  98835. * @hidden
  98836. * @override
  98837. * Override Camera._updateRigCameras
  98838. */
  98839. _updateRigCameras(): void;
  98840. /**
  98841. * Destroy the camera and release the current resources hold by it.
  98842. */
  98843. dispose(): void;
  98844. /**
  98845. * Gets the current object class name.
  98846. * @return the class name
  98847. */
  98848. getClassName(): string;
  98849. }
  98850. }
  98851. declare module BABYLON {
  98852. /**
  98853. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  98854. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  98855. */
  98856. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  98857. /**
  98858. * Gets the name of the behavior.
  98859. */
  98860. readonly name: string;
  98861. private _zoomStopsAnimation;
  98862. private _idleRotationSpeed;
  98863. private _idleRotationWaitTime;
  98864. private _idleRotationSpinupTime;
  98865. /**
  98866. * Sets the flag that indicates if user zooming should stop animation.
  98867. */
  98868. /**
  98869. * Gets the flag that indicates if user zooming should stop animation.
  98870. */
  98871. zoomStopsAnimation: boolean;
  98872. /**
  98873. * Sets the default speed at which the camera rotates around the model.
  98874. */
  98875. /**
  98876. * Gets the default speed at which the camera rotates around the model.
  98877. */
  98878. idleRotationSpeed: number;
  98879. /**
  98880. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  98881. */
  98882. /**
  98883. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  98884. */
  98885. idleRotationWaitTime: number;
  98886. /**
  98887. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  98888. */
  98889. /**
  98890. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  98891. */
  98892. idleRotationSpinupTime: number;
  98893. /**
  98894. * Gets a value indicating if the camera is currently rotating because of this behavior
  98895. */
  98896. readonly rotationInProgress: boolean;
  98897. private _onPrePointerObservableObserver;
  98898. private _onAfterCheckInputsObserver;
  98899. private _attachedCamera;
  98900. private _isPointerDown;
  98901. private _lastFrameTime;
  98902. private _lastInteractionTime;
  98903. private _cameraRotationSpeed;
  98904. /**
  98905. * Initializes the behavior.
  98906. */
  98907. init(): void;
  98908. /**
  98909. * Attaches the behavior to its arc rotate camera.
  98910. * @param camera Defines the camera to attach the behavior to
  98911. */
  98912. attach(camera: ArcRotateCamera): void;
  98913. /**
  98914. * Detaches the behavior from its current arc rotate camera.
  98915. */
  98916. detach(): void;
  98917. /**
  98918. * Returns true if user is scrolling.
  98919. * @return true if user is scrolling.
  98920. */
  98921. private _userIsZooming;
  98922. private _lastFrameRadius;
  98923. private _shouldAnimationStopForInteraction;
  98924. /**
  98925. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  98926. */
  98927. private _applyUserInteraction;
  98928. private _userIsMoving;
  98929. }
  98930. }
  98931. declare module BABYLON {
  98932. /**
  98933. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  98934. */
  98935. export class AttachToBoxBehavior implements Behavior<Mesh> {
  98936. private ui;
  98937. /**
  98938. * The name of the behavior
  98939. */
  98940. name: string;
  98941. /**
  98942. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  98943. */
  98944. distanceAwayFromFace: number;
  98945. /**
  98946. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  98947. */
  98948. distanceAwayFromBottomOfFace: number;
  98949. private _faceVectors;
  98950. private _target;
  98951. private _scene;
  98952. private _onRenderObserver;
  98953. private _tmpMatrix;
  98954. private _tmpVector;
  98955. /**
  98956. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  98957. * @param ui The transform node that should be attched to the mesh
  98958. */
  98959. constructor(ui: TransformNode);
  98960. /**
  98961. * Initializes the behavior
  98962. */
  98963. init(): void;
  98964. private _closestFace;
  98965. private _zeroVector;
  98966. private _lookAtTmpMatrix;
  98967. private _lookAtToRef;
  98968. /**
  98969. * Attaches the AttachToBoxBehavior to the passed in mesh
  98970. * @param target The mesh that the specified node will be attached to
  98971. */
  98972. attach(target: Mesh): void;
  98973. /**
  98974. * Detaches the behavior from the mesh
  98975. */
  98976. detach(): void;
  98977. }
  98978. }
  98979. declare module BABYLON {
  98980. /**
  98981. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  98982. */
  98983. export class FadeInOutBehavior implements Behavior<Mesh> {
  98984. /**
  98985. * Time in milliseconds to delay before fading in (Default: 0)
  98986. */
  98987. delay: number;
  98988. /**
  98989. * Time in milliseconds for the mesh to fade in (Default: 300)
  98990. */
  98991. fadeInTime: number;
  98992. private _millisecondsPerFrame;
  98993. private _hovered;
  98994. private _hoverValue;
  98995. private _ownerNode;
  98996. /**
  98997. * Instatiates the FadeInOutBehavior
  98998. */
  98999. constructor();
  99000. /**
  99001. * The name of the behavior
  99002. */
  99003. readonly name: string;
  99004. /**
  99005. * Initializes the behavior
  99006. */
  99007. init(): void;
  99008. /**
  99009. * Attaches the fade behavior on the passed in mesh
  99010. * @param ownerNode The mesh that will be faded in/out once attached
  99011. */
  99012. attach(ownerNode: Mesh): void;
  99013. /**
  99014. * Detaches the behavior from the mesh
  99015. */
  99016. detach(): void;
  99017. /**
  99018. * Triggers the mesh to begin fading in or out
  99019. * @param value if the object should fade in or out (true to fade in)
  99020. */
  99021. fadeIn(value: boolean): void;
  99022. private _update;
  99023. private _setAllVisibility;
  99024. }
  99025. }
  99026. declare module BABYLON {
  99027. /**
  99028. * Class containing a set of static utilities functions for managing Pivots
  99029. * @hidden
  99030. */
  99031. export class PivotTools {
  99032. private static _PivotCached;
  99033. private static _OldPivotPoint;
  99034. private static _PivotTranslation;
  99035. private static _PivotTmpVector;
  99036. /** @hidden */
  99037. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  99038. /** @hidden */
  99039. static _RestorePivotPoint(mesh: AbstractMesh): void;
  99040. }
  99041. }
  99042. declare module BABYLON {
  99043. /**
  99044. * Class containing static functions to help procedurally build meshes
  99045. */
  99046. export class PlaneBuilder {
  99047. /**
  99048. * Creates a plane mesh
  99049. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  99050. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  99051. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  99052. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  99053. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  99054. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99055. * @param name defines the name of the mesh
  99056. * @param options defines the options used to create the mesh
  99057. * @param scene defines the hosting scene
  99058. * @returns the plane mesh
  99059. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  99060. */
  99061. static CreatePlane(name: string, options: {
  99062. size?: number;
  99063. width?: number;
  99064. height?: number;
  99065. sideOrientation?: number;
  99066. frontUVs?: Vector4;
  99067. backUVs?: Vector4;
  99068. updatable?: boolean;
  99069. sourcePlane?: Plane;
  99070. }, scene?: Nullable<Scene>): Mesh;
  99071. }
  99072. }
  99073. declare module BABYLON {
  99074. /**
  99075. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  99076. */
  99077. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  99078. private static _AnyMouseID;
  99079. /**
  99080. * Abstract mesh the behavior is set on
  99081. */
  99082. attachedNode: AbstractMesh;
  99083. private _dragPlane;
  99084. private _scene;
  99085. private _pointerObserver;
  99086. private _beforeRenderObserver;
  99087. private static _planeScene;
  99088. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  99089. /**
  99090. * 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)
  99091. */
  99092. maxDragAngle: number;
  99093. /**
  99094. * @hidden
  99095. */
  99096. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  99097. /**
  99098. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  99099. */
  99100. currentDraggingPointerID: number;
  99101. /**
  99102. * The last position where the pointer hit the drag plane in world space
  99103. */
  99104. lastDragPosition: Vector3;
  99105. /**
  99106. * If the behavior is currently in a dragging state
  99107. */
  99108. dragging: boolean;
  99109. /**
  99110. * 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)
  99111. */
  99112. dragDeltaRatio: number;
  99113. /**
  99114. * If the drag plane orientation should be updated during the dragging (Default: true)
  99115. */
  99116. updateDragPlane: boolean;
  99117. private _debugMode;
  99118. private _moving;
  99119. /**
  99120. * Fires each time the attached mesh is dragged with the pointer
  99121. * * delta between last drag position and current drag position in world space
  99122. * * dragDistance along the drag axis
  99123. * * dragPlaneNormal normal of the current drag plane used during the drag
  99124. * * dragPlanePoint in world space where the drag intersects the drag plane
  99125. */
  99126. onDragObservable: Observable<{
  99127. delta: Vector3;
  99128. dragPlanePoint: Vector3;
  99129. dragPlaneNormal: Vector3;
  99130. dragDistance: number;
  99131. pointerId: number;
  99132. }>;
  99133. /**
  99134. * Fires each time a drag begins (eg. mouse down on mesh)
  99135. */
  99136. onDragStartObservable: Observable<{
  99137. dragPlanePoint: Vector3;
  99138. pointerId: number;
  99139. }>;
  99140. /**
  99141. * Fires each time a drag ends (eg. mouse release after drag)
  99142. */
  99143. onDragEndObservable: Observable<{
  99144. dragPlanePoint: Vector3;
  99145. pointerId: number;
  99146. }>;
  99147. /**
  99148. * If the attached mesh should be moved when dragged
  99149. */
  99150. moveAttached: boolean;
  99151. /**
  99152. * If the drag behavior will react to drag events (Default: true)
  99153. */
  99154. enabled: boolean;
  99155. /**
  99156. * If camera controls should be detached during the drag
  99157. */
  99158. detachCameraControls: boolean;
  99159. /**
  99160. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  99161. */
  99162. useObjectOrienationForDragging: boolean;
  99163. private _options;
  99164. /**
  99165. * Creates a pointer drag behavior that can be attached to a mesh
  99166. * @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)
  99167. */
  99168. constructor(options?: {
  99169. dragAxis?: Vector3;
  99170. dragPlaneNormal?: Vector3;
  99171. });
  99172. /**
  99173. * Predicate to determine if it is valid to move the object to a new position when it is moved
  99174. */
  99175. validateDrag: (targetPosition: Vector3) => boolean;
  99176. /**
  99177. * The name of the behavior
  99178. */
  99179. readonly name: string;
  99180. /**
  99181. * Initializes the behavior
  99182. */
  99183. init(): void;
  99184. private _tmpVector;
  99185. private _alternatePickedPoint;
  99186. private _worldDragAxis;
  99187. private _targetPosition;
  99188. private _attachedElement;
  99189. /**
  99190. * Attaches the drag behavior the passed in mesh
  99191. * @param ownerNode The mesh that will be dragged around once attached
  99192. */
  99193. attach(ownerNode: AbstractMesh): void;
  99194. /**
  99195. * Force relase the drag action by code.
  99196. */
  99197. releaseDrag(): void;
  99198. private _startDragRay;
  99199. private _lastPointerRay;
  99200. /**
  99201. * Simulates the start of a pointer drag event on the behavior
  99202. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  99203. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  99204. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  99205. */
  99206. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  99207. private _startDrag;
  99208. private _dragDelta;
  99209. private _moveDrag;
  99210. private _pickWithRayOnDragPlane;
  99211. private _pointA;
  99212. private _pointB;
  99213. private _pointC;
  99214. private _lineA;
  99215. private _lineB;
  99216. private _localAxis;
  99217. private _lookAt;
  99218. private _updateDragPlanePosition;
  99219. /**
  99220. * Detaches the behavior from the mesh
  99221. */
  99222. detach(): void;
  99223. }
  99224. }
  99225. declare module BABYLON {
  99226. /**
  99227. * A behavior that when attached to a mesh will allow the mesh to be scaled
  99228. */
  99229. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  99230. private _dragBehaviorA;
  99231. private _dragBehaviorB;
  99232. private _startDistance;
  99233. private _initialScale;
  99234. private _targetScale;
  99235. private _ownerNode;
  99236. private _sceneRenderObserver;
  99237. /**
  99238. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  99239. */
  99240. constructor();
  99241. /**
  99242. * The name of the behavior
  99243. */
  99244. readonly name: string;
  99245. /**
  99246. * Initializes the behavior
  99247. */
  99248. init(): void;
  99249. private _getCurrentDistance;
  99250. /**
  99251. * Attaches the scale behavior the passed in mesh
  99252. * @param ownerNode The mesh that will be scaled around once attached
  99253. */
  99254. attach(ownerNode: Mesh): void;
  99255. /**
  99256. * Detaches the behavior from the mesh
  99257. */
  99258. detach(): void;
  99259. }
  99260. }
  99261. declare module BABYLON {
  99262. /**
  99263. * 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
  99264. */
  99265. export class SixDofDragBehavior implements Behavior<Mesh> {
  99266. private static _virtualScene;
  99267. private _ownerNode;
  99268. private _sceneRenderObserver;
  99269. private _scene;
  99270. private _targetPosition;
  99271. private _virtualOriginMesh;
  99272. private _virtualDragMesh;
  99273. private _pointerObserver;
  99274. private _moving;
  99275. private _startingOrientation;
  99276. /**
  99277. * 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)
  99278. */
  99279. private zDragFactor;
  99280. /**
  99281. * If the object should rotate to face the drag origin
  99282. */
  99283. rotateDraggedObject: boolean;
  99284. /**
  99285. * If the behavior is currently in a dragging state
  99286. */
  99287. dragging: boolean;
  99288. /**
  99289. * 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)
  99290. */
  99291. dragDeltaRatio: number;
  99292. /**
  99293. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  99294. */
  99295. currentDraggingPointerID: number;
  99296. /**
  99297. * If camera controls should be detached during the drag
  99298. */
  99299. detachCameraControls: boolean;
  99300. /**
  99301. * Fires each time a drag starts
  99302. */
  99303. onDragStartObservable: Observable<{}>;
  99304. /**
  99305. * Fires each time a drag ends (eg. mouse release after drag)
  99306. */
  99307. onDragEndObservable: Observable<{}>;
  99308. /**
  99309. * 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
  99310. */
  99311. constructor();
  99312. /**
  99313. * The name of the behavior
  99314. */
  99315. readonly name: string;
  99316. /**
  99317. * Initializes the behavior
  99318. */
  99319. init(): void;
  99320. /**
  99321. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  99322. */
  99323. private readonly _pointerCamera;
  99324. /**
  99325. * Attaches the scale behavior the passed in mesh
  99326. * @param ownerNode The mesh that will be scaled around once attached
  99327. */
  99328. attach(ownerNode: Mesh): void;
  99329. /**
  99330. * Detaches the behavior from the mesh
  99331. */
  99332. detach(): void;
  99333. }
  99334. }
  99335. declare module BABYLON {
  99336. /**
  99337. * Class used to apply inverse kinematics to bones
  99338. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  99339. */
  99340. export class BoneIKController {
  99341. private static _tmpVecs;
  99342. private static _tmpQuat;
  99343. private static _tmpMats;
  99344. /**
  99345. * Gets or sets the target mesh
  99346. */
  99347. targetMesh: AbstractMesh;
  99348. /** Gets or sets the mesh used as pole */
  99349. poleTargetMesh: AbstractMesh;
  99350. /**
  99351. * Gets or sets the bone used as pole
  99352. */
  99353. poleTargetBone: Nullable<Bone>;
  99354. /**
  99355. * Gets or sets the target position
  99356. */
  99357. targetPosition: Vector3;
  99358. /**
  99359. * Gets or sets the pole target position
  99360. */
  99361. poleTargetPosition: Vector3;
  99362. /**
  99363. * Gets or sets the pole target local offset
  99364. */
  99365. poleTargetLocalOffset: Vector3;
  99366. /**
  99367. * Gets or sets the pole angle
  99368. */
  99369. poleAngle: number;
  99370. /**
  99371. * Gets or sets the mesh associated with the controller
  99372. */
  99373. mesh: AbstractMesh;
  99374. /**
  99375. * 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)
  99376. */
  99377. slerpAmount: number;
  99378. private _bone1Quat;
  99379. private _bone1Mat;
  99380. private _bone2Ang;
  99381. private _bone1;
  99382. private _bone2;
  99383. private _bone1Length;
  99384. private _bone2Length;
  99385. private _maxAngle;
  99386. private _maxReach;
  99387. private _rightHandedSystem;
  99388. private _bendAxis;
  99389. private _slerping;
  99390. private _adjustRoll;
  99391. /**
  99392. * Gets or sets maximum allowed angle
  99393. */
  99394. maxAngle: number;
  99395. /**
  99396. * Creates a new BoneIKController
  99397. * @param mesh defines the mesh to control
  99398. * @param bone defines the bone to control
  99399. * @param options defines options to set up the controller
  99400. */
  99401. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  99402. targetMesh?: AbstractMesh;
  99403. poleTargetMesh?: AbstractMesh;
  99404. poleTargetBone?: Bone;
  99405. poleTargetLocalOffset?: Vector3;
  99406. poleAngle?: number;
  99407. bendAxis?: Vector3;
  99408. maxAngle?: number;
  99409. slerpAmount?: number;
  99410. });
  99411. private _setMaxAngle;
  99412. /**
  99413. * Force the controller to update the bones
  99414. */
  99415. update(): void;
  99416. }
  99417. }
  99418. declare module BABYLON {
  99419. /**
  99420. * Class used to make a bone look toward a point in space
  99421. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  99422. */
  99423. export class BoneLookController {
  99424. private static _tmpVecs;
  99425. private static _tmpQuat;
  99426. private static _tmpMats;
  99427. /**
  99428. * The target Vector3 that the bone will look at
  99429. */
  99430. target: Vector3;
  99431. /**
  99432. * The mesh that the bone is attached to
  99433. */
  99434. mesh: AbstractMesh;
  99435. /**
  99436. * The bone that will be looking to the target
  99437. */
  99438. bone: Bone;
  99439. /**
  99440. * The up axis of the coordinate system that is used when the bone is rotated
  99441. */
  99442. upAxis: Vector3;
  99443. /**
  99444. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  99445. */
  99446. upAxisSpace: Space;
  99447. /**
  99448. * Used to make an adjustment to the yaw of the bone
  99449. */
  99450. adjustYaw: number;
  99451. /**
  99452. * Used to make an adjustment to the pitch of the bone
  99453. */
  99454. adjustPitch: number;
  99455. /**
  99456. * Used to make an adjustment to the roll of the bone
  99457. */
  99458. adjustRoll: number;
  99459. /**
  99460. * 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)
  99461. */
  99462. slerpAmount: number;
  99463. private _minYaw;
  99464. private _maxYaw;
  99465. private _minPitch;
  99466. private _maxPitch;
  99467. private _minYawSin;
  99468. private _minYawCos;
  99469. private _maxYawSin;
  99470. private _maxYawCos;
  99471. private _midYawConstraint;
  99472. private _minPitchTan;
  99473. private _maxPitchTan;
  99474. private _boneQuat;
  99475. private _slerping;
  99476. private _transformYawPitch;
  99477. private _transformYawPitchInv;
  99478. private _firstFrameSkipped;
  99479. private _yawRange;
  99480. private _fowardAxis;
  99481. /**
  99482. * Gets or sets the minimum yaw angle that the bone can look to
  99483. */
  99484. minYaw: number;
  99485. /**
  99486. * Gets or sets the maximum yaw angle that the bone can look to
  99487. */
  99488. maxYaw: number;
  99489. /**
  99490. * Gets or sets the minimum pitch angle that the bone can look to
  99491. */
  99492. minPitch: number;
  99493. /**
  99494. * Gets or sets the maximum pitch angle that the bone can look to
  99495. */
  99496. maxPitch: number;
  99497. /**
  99498. * Create a BoneLookController
  99499. * @param mesh the mesh that the bone belongs to
  99500. * @param bone the bone that will be looking to the target
  99501. * @param target the target Vector3 to look at
  99502. * @param options optional settings:
  99503. * * maxYaw: the maximum angle the bone will yaw to
  99504. * * minYaw: the minimum angle the bone will yaw to
  99505. * * maxPitch: the maximum angle the bone will pitch to
  99506. * * minPitch: the minimum angle the bone will yaw to
  99507. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  99508. * * upAxis: the up axis of the coordinate system
  99509. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  99510. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  99511. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  99512. * * adjustYaw: used to make an adjustment to the yaw of the bone
  99513. * * adjustPitch: used to make an adjustment to the pitch of the bone
  99514. * * adjustRoll: used to make an adjustment to the roll of the bone
  99515. **/
  99516. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  99517. maxYaw?: number;
  99518. minYaw?: number;
  99519. maxPitch?: number;
  99520. minPitch?: number;
  99521. slerpAmount?: number;
  99522. upAxis?: Vector3;
  99523. upAxisSpace?: Space;
  99524. yawAxis?: Vector3;
  99525. pitchAxis?: Vector3;
  99526. adjustYaw?: number;
  99527. adjustPitch?: number;
  99528. adjustRoll?: number;
  99529. });
  99530. /**
  99531. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  99532. */
  99533. update(): void;
  99534. private _getAngleDiff;
  99535. private _getAngleBetween;
  99536. private _isAngleBetween;
  99537. }
  99538. }
  99539. declare module BABYLON {
  99540. /**
  99541. * Manage the gamepad inputs to control an arc rotate camera.
  99542. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99543. */
  99544. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  99545. /**
  99546. * Defines the camera the input is attached to.
  99547. */
  99548. camera: ArcRotateCamera;
  99549. /**
  99550. * Defines the gamepad the input is gathering event from.
  99551. */
  99552. gamepad: Nullable<Gamepad>;
  99553. /**
  99554. * Defines the gamepad rotation sensiblity.
  99555. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  99556. */
  99557. gamepadRotationSensibility: number;
  99558. /**
  99559. * Defines the gamepad move sensiblity.
  99560. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  99561. */
  99562. gamepadMoveSensibility: number;
  99563. private _onGamepadConnectedObserver;
  99564. private _onGamepadDisconnectedObserver;
  99565. /**
  99566. * Attach the input controls to a specific dom element to get the input from.
  99567. * @param element Defines the element the controls should be listened from
  99568. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99569. */
  99570. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99571. /**
  99572. * Detach the current controls from the specified dom element.
  99573. * @param element Defines the element to stop listening the inputs from
  99574. */
  99575. detachControl(element: Nullable<HTMLElement>): void;
  99576. /**
  99577. * Update the current camera state depending on the inputs that have been used this frame.
  99578. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99579. */
  99580. checkInputs(): void;
  99581. /**
  99582. * Gets the class name of the current intput.
  99583. * @returns the class name
  99584. */
  99585. getClassName(): string;
  99586. /**
  99587. * Get the friendly name associated with the input class.
  99588. * @returns the input friendly name
  99589. */
  99590. getSimpleName(): string;
  99591. }
  99592. }
  99593. declare module BABYLON {
  99594. interface ArcRotateCameraInputsManager {
  99595. /**
  99596. * Add orientation input support to the input manager.
  99597. * @returns the current input manager
  99598. */
  99599. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  99600. }
  99601. /**
  99602. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  99603. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99604. */
  99605. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  99606. /**
  99607. * Defines the camera the input is attached to.
  99608. */
  99609. camera: ArcRotateCamera;
  99610. /**
  99611. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  99612. */
  99613. alphaCorrection: number;
  99614. /**
  99615. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  99616. */
  99617. gammaCorrection: number;
  99618. private _alpha;
  99619. private _gamma;
  99620. private _dirty;
  99621. private _deviceOrientationHandler;
  99622. /**
  99623. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  99624. */
  99625. constructor();
  99626. /**
  99627. * Attach the input controls to a specific dom element to get the input from.
  99628. * @param element Defines the element the controls should be listened from
  99629. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99630. */
  99631. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99632. /** @hidden */
  99633. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  99634. /**
  99635. * Update the current camera state depending on the inputs that have been used this frame.
  99636. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99637. */
  99638. checkInputs(): void;
  99639. /**
  99640. * Detach the current controls from the specified dom element.
  99641. * @param element Defines the element to stop listening the inputs from
  99642. */
  99643. detachControl(element: Nullable<HTMLElement>): void;
  99644. /**
  99645. * Gets the class name of the current intput.
  99646. * @returns the class name
  99647. */
  99648. getClassName(): string;
  99649. /**
  99650. * Get the friendly name associated with the input class.
  99651. * @returns the input friendly name
  99652. */
  99653. getSimpleName(): string;
  99654. }
  99655. }
  99656. declare module BABYLON {
  99657. /**
  99658. * Listen to mouse events to control the camera.
  99659. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99660. */
  99661. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  99662. /**
  99663. * Defines the camera the input is attached to.
  99664. */
  99665. camera: FlyCamera;
  99666. /**
  99667. * Defines if touch is enabled. (Default is true.)
  99668. */
  99669. touchEnabled: boolean;
  99670. /**
  99671. * Defines the buttons associated with the input to handle camera rotation.
  99672. */
  99673. buttons: number[];
  99674. /**
  99675. * Assign buttons for Yaw control.
  99676. */
  99677. buttonsYaw: number[];
  99678. /**
  99679. * Assign buttons for Pitch control.
  99680. */
  99681. buttonsPitch: number[];
  99682. /**
  99683. * Assign buttons for Roll control.
  99684. */
  99685. buttonsRoll: number[];
  99686. /**
  99687. * Detect if any button is being pressed while mouse is moved.
  99688. * -1 = Mouse locked.
  99689. * 0 = Left button.
  99690. * 1 = Middle Button.
  99691. * 2 = Right Button.
  99692. */
  99693. activeButton: number;
  99694. /**
  99695. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  99696. * Higher values reduce its sensitivity.
  99697. */
  99698. angularSensibility: number;
  99699. private _mousemoveCallback;
  99700. private _observer;
  99701. private _rollObserver;
  99702. private previousPosition;
  99703. private noPreventDefault;
  99704. private element;
  99705. /**
  99706. * Listen to mouse events to control the camera.
  99707. * @param touchEnabled Define if touch is enabled. (Default is true.)
  99708. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99709. */
  99710. constructor(touchEnabled?: boolean);
  99711. /**
  99712. * Attach the mouse control to the HTML DOM element.
  99713. * @param element Defines the element that listens to the input events.
  99714. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  99715. */
  99716. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99717. /**
  99718. * Detach the current controls from the specified dom element.
  99719. * @param element Defines the element to stop listening the inputs from
  99720. */
  99721. detachControl(element: Nullable<HTMLElement>): void;
  99722. /**
  99723. * Gets the class name of the current input.
  99724. * @returns the class name.
  99725. */
  99726. getClassName(): string;
  99727. /**
  99728. * Get the friendly name associated with the input class.
  99729. * @returns the input's friendly name.
  99730. */
  99731. getSimpleName(): string;
  99732. private _pointerInput;
  99733. private _onMouseMove;
  99734. /**
  99735. * Rotate camera by mouse offset.
  99736. */
  99737. private rotateCamera;
  99738. }
  99739. }
  99740. declare module BABYLON {
  99741. /**
  99742. * Default Inputs manager for the FlyCamera.
  99743. * It groups all the default supported inputs for ease of use.
  99744. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99745. */
  99746. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  99747. /**
  99748. * Instantiates a new FlyCameraInputsManager.
  99749. * @param camera Defines the camera the inputs belong to.
  99750. */
  99751. constructor(camera: FlyCamera);
  99752. /**
  99753. * Add keyboard input support to the input manager.
  99754. * @returns the new FlyCameraKeyboardMoveInput().
  99755. */
  99756. addKeyboard(): FlyCameraInputsManager;
  99757. /**
  99758. * Add mouse input support to the input manager.
  99759. * @param touchEnabled Enable touch screen support.
  99760. * @returns the new FlyCameraMouseInput().
  99761. */
  99762. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  99763. }
  99764. }
  99765. declare module BABYLON {
  99766. /**
  99767. * This is a flying camera, designed for 3D movement and rotation in all directions,
  99768. * such as in a 3D Space Shooter or a Flight Simulator.
  99769. */
  99770. export class FlyCamera extends TargetCamera {
  99771. /**
  99772. * Define the collision ellipsoid of the camera.
  99773. * This is helpful for simulating a camera body, like a player's body.
  99774. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  99775. */
  99776. ellipsoid: Vector3;
  99777. /**
  99778. * Define an offset for the position of the ellipsoid around the camera.
  99779. * This can be helpful if the camera is attached away from the player's body center,
  99780. * such as at its head.
  99781. */
  99782. ellipsoidOffset: Vector3;
  99783. /**
  99784. * Enable or disable collisions of the camera with the rest of the scene objects.
  99785. */
  99786. checkCollisions: boolean;
  99787. /**
  99788. * Enable or disable gravity on the camera.
  99789. */
  99790. applyGravity: boolean;
  99791. /**
  99792. * Define the current direction the camera is moving to.
  99793. */
  99794. cameraDirection: Vector3;
  99795. /**
  99796. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  99797. * This overrides and empties cameraRotation.
  99798. */
  99799. rotationQuaternion: Quaternion;
  99800. /**
  99801. * Track Roll to maintain the wanted Rolling when looking around.
  99802. */
  99803. _trackRoll: number;
  99804. /**
  99805. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  99806. */
  99807. rollCorrect: number;
  99808. /**
  99809. * Mimic a banked turn, Rolling the camera when Yawing.
  99810. * It's recommended to use rollCorrect = 10 for faster banking correction.
  99811. */
  99812. bankedTurn: boolean;
  99813. /**
  99814. * Limit in radians for how much Roll banking will add. (Default: 90°)
  99815. */
  99816. bankedTurnLimit: number;
  99817. /**
  99818. * Value of 0 disables the banked Roll.
  99819. * Value of 1 is equal to the Yaw angle in radians.
  99820. */
  99821. bankedTurnMultiplier: number;
  99822. /**
  99823. * The inputs manager loads all the input sources, such as keyboard and mouse.
  99824. */
  99825. inputs: FlyCameraInputsManager;
  99826. /**
  99827. * Gets the input sensibility for mouse input.
  99828. * Higher values reduce sensitivity.
  99829. */
  99830. /**
  99831. * Sets the input sensibility for a mouse input.
  99832. * Higher values reduce sensitivity.
  99833. */
  99834. angularSensibility: number;
  99835. /**
  99836. * Get the keys for camera movement forward.
  99837. */
  99838. /**
  99839. * Set the keys for camera movement forward.
  99840. */
  99841. keysForward: number[];
  99842. /**
  99843. * Get the keys for camera movement backward.
  99844. */
  99845. keysBackward: number[];
  99846. /**
  99847. * Get the keys for camera movement up.
  99848. */
  99849. /**
  99850. * Set the keys for camera movement up.
  99851. */
  99852. keysUp: number[];
  99853. /**
  99854. * Get the keys for camera movement down.
  99855. */
  99856. /**
  99857. * Set the keys for camera movement down.
  99858. */
  99859. keysDown: number[];
  99860. /**
  99861. * Get the keys for camera movement left.
  99862. */
  99863. /**
  99864. * Set the keys for camera movement left.
  99865. */
  99866. keysLeft: number[];
  99867. /**
  99868. * Set the keys for camera movement right.
  99869. */
  99870. /**
  99871. * Set the keys for camera movement right.
  99872. */
  99873. keysRight: number[];
  99874. /**
  99875. * Event raised when the camera collides with a mesh in the scene.
  99876. */
  99877. onCollide: (collidedMesh: AbstractMesh) => void;
  99878. private _collider;
  99879. private _needMoveForGravity;
  99880. private _oldPosition;
  99881. private _diffPosition;
  99882. private _newPosition;
  99883. /** @hidden */
  99884. _localDirection: Vector3;
  99885. /** @hidden */
  99886. _transformedDirection: Vector3;
  99887. /**
  99888. * Instantiates a FlyCamera.
  99889. * This is a flying camera, designed for 3D movement and rotation in all directions,
  99890. * such as in a 3D Space Shooter or a Flight Simulator.
  99891. * @param name Define the name of the camera in the scene.
  99892. * @param position Define the starting position of the camera in the scene.
  99893. * @param scene Define the scene the camera belongs to.
  99894. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  99895. */
  99896. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  99897. /**
  99898. * Attach a control to the HTML DOM element.
  99899. * @param element Defines the element that listens to the input events.
  99900. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  99901. */
  99902. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99903. /**
  99904. * Detach a control from the HTML DOM element.
  99905. * The camera will stop reacting to that input.
  99906. * @param element Defines the element that listens to the input events.
  99907. */
  99908. detachControl(element: HTMLElement): void;
  99909. private _collisionMask;
  99910. /**
  99911. * Get the mask that the camera ignores in collision events.
  99912. */
  99913. /**
  99914. * Set the mask that the camera ignores in collision events.
  99915. */
  99916. collisionMask: number;
  99917. /** @hidden */
  99918. _collideWithWorld(displacement: Vector3): void;
  99919. /** @hidden */
  99920. private _onCollisionPositionChange;
  99921. /** @hidden */
  99922. _checkInputs(): void;
  99923. /** @hidden */
  99924. _decideIfNeedsToMove(): boolean;
  99925. /** @hidden */
  99926. _updatePosition(): void;
  99927. /**
  99928. * Restore the Roll to its target value at the rate specified.
  99929. * @param rate - Higher means slower restoring.
  99930. * @hidden
  99931. */
  99932. restoreRoll(rate: number): void;
  99933. /**
  99934. * Destroy the camera and release the current resources held by it.
  99935. */
  99936. dispose(): void;
  99937. /**
  99938. * Get the current object class name.
  99939. * @returns the class name.
  99940. */
  99941. getClassName(): string;
  99942. }
  99943. }
  99944. declare module BABYLON {
  99945. /**
  99946. * Listen to keyboard events to control the camera.
  99947. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99948. */
  99949. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  99950. /**
  99951. * Defines the camera the input is attached to.
  99952. */
  99953. camera: FlyCamera;
  99954. /**
  99955. * The list of keyboard keys used to control the forward move of the camera.
  99956. */
  99957. keysForward: number[];
  99958. /**
  99959. * The list of keyboard keys used to control the backward move of the camera.
  99960. */
  99961. keysBackward: number[];
  99962. /**
  99963. * The list of keyboard keys used to control the forward move of the camera.
  99964. */
  99965. keysUp: number[];
  99966. /**
  99967. * The list of keyboard keys used to control the backward move of the camera.
  99968. */
  99969. keysDown: number[];
  99970. /**
  99971. * The list of keyboard keys used to control the right strafe move of the camera.
  99972. */
  99973. keysRight: number[];
  99974. /**
  99975. * The list of keyboard keys used to control the left strafe move of the camera.
  99976. */
  99977. keysLeft: number[];
  99978. private _keys;
  99979. private _onCanvasBlurObserver;
  99980. private _onKeyboardObserver;
  99981. private _engine;
  99982. private _scene;
  99983. /**
  99984. * Attach the input controls to a specific dom element to get the input from.
  99985. * @param element Defines the element the controls should be listened from
  99986. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99987. */
  99988. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99989. /**
  99990. * Detach the current controls from the specified dom element.
  99991. * @param element Defines the element to stop listening the inputs from
  99992. */
  99993. detachControl(element: Nullable<HTMLElement>): void;
  99994. /**
  99995. * Gets the class name of the current intput.
  99996. * @returns the class name
  99997. */
  99998. getClassName(): string;
  99999. /** @hidden */
  100000. _onLostFocus(e: FocusEvent): void;
  100001. /**
  100002. * Get the friendly name associated with the input class.
  100003. * @returns the input friendly name
  100004. */
  100005. getSimpleName(): string;
  100006. /**
  100007. * Update the current camera state depending on the inputs that have been used this frame.
  100008. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  100009. */
  100010. checkInputs(): void;
  100011. }
  100012. }
  100013. declare module BABYLON {
  100014. /**
  100015. * Manage the mouse wheel inputs to control a follow camera.
  100016. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100017. */
  100018. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  100019. /**
  100020. * Defines the camera the input is attached to.
  100021. */
  100022. camera: FollowCamera;
  100023. /**
  100024. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  100025. */
  100026. axisControlRadius: boolean;
  100027. /**
  100028. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  100029. */
  100030. axisControlHeight: boolean;
  100031. /**
  100032. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  100033. */
  100034. axisControlRotation: boolean;
  100035. /**
  100036. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  100037. * relation to mouseWheel events.
  100038. */
  100039. wheelPrecision: number;
  100040. /**
  100041. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  100042. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  100043. */
  100044. wheelDeltaPercentage: number;
  100045. private _wheel;
  100046. private _observer;
  100047. /**
  100048. * Attach the input controls to a specific dom element to get the input from.
  100049. * @param element Defines the element the controls should be listened from
  100050. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100051. */
  100052. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100053. /**
  100054. * Detach the current controls from the specified dom element.
  100055. * @param element Defines the element to stop listening the inputs from
  100056. */
  100057. detachControl(element: Nullable<HTMLElement>): void;
  100058. /**
  100059. * Gets the class name of the current intput.
  100060. * @returns the class name
  100061. */
  100062. getClassName(): string;
  100063. /**
  100064. * Get the friendly name associated with the input class.
  100065. * @returns the input friendly name
  100066. */
  100067. getSimpleName(): string;
  100068. }
  100069. }
  100070. declare module BABYLON {
  100071. /**
  100072. * Manage the pointers inputs to control an follow camera.
  100073. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100074. */
  100075. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  100076. /**
  100077. * Defines the camera the input is attached to.
  100078. */
  100079. camera: FollowCamera;
  100080. /**
  100081. * Gets the class name of the current input.
  100082. * @returns the class name
  100083. */
  100084. getClassName(): string;
  100085. /**
  100086. * Defines the pointer angular sensibility along the X axis or how fast is
  100087. * the camera rotating.
  100088. * A negative number will reverse the axis direction.
  100089. */
  100090. angularSensibilityX: number;
  100091. /**
  100092. * Defines the pointer angular sensibility along the Y axis or how fast is
  100093. * the camera rotating.
  100094. * A negative number will reverse the axis direction.
  100095. */
  100096. angularSensibilityY: number;
  100097. /**
  100098. * Defines the pointer pinch precision or how fast is the camera zooming.
  100099. * A negative number will reverse the axis direction.
  100100. */
  100101. pinchPrecision: number;
  100102. /**
  100103. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  100104. * from 0.
  100105. * It defines the percentage of current camera.radius to use as delta when
  100106. * pinch zoom is used.
  100107. */
  100108. pinchDeltaPercentage: number;
  100109. /**
  100110. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  100111. */
  100112. axisXControlRadius: boolean;
  100113. /**
  100114. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  100115. */
  100116. axisXControlHeight: boolean;
  100117. /**
  100118. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  100119. */
  100120. axisXControlRotation: boolean;
  100121. /**
  100122. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  100123. */
  100124. axisYControlRadius: boolean;
  100125. /**
  100126. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  100127. */
  100128. axisYControlHeight: boolean;
  100129. /**
  100130. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  100131. */
  100132. axisYControlRotation: boolean;
  100133. /**
  100134. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  100135. */
  100136. axisPinchControlRadius: boolean;
  100137. /**
  100138. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  100139. */
  100140. axisPinchControlHeight: boolean;
  100141. /**
  100142. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  100143. */
  100144. axisPinchControlRotation: boolean;
  100145. /**
  100146. * Log error messages if basic misconfiguration has occurred.
  100147. */
  100148. warningEnable: boolean;
  100149. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  100150. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  100151. private _warningCounter;
  100152. private _warning;
  100153. }
  100154. }
  100155. declare module BABYLON {
  100156. /**
  100157. * Default Inputs manager for the FollowCamera.
  100158. * It groups all the default supported inputs for ease of use.
  100159. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100160. */
  100161. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  100162. /**
  100163. * Instantiates a new FollowCameraInputsManager.
  100164. * @param camera Defines the camera the inputs belong to
  100165. */
  100166. constructor(camera: FollowCamera);
  100167. /**
  100168. * Add keyboard input support to the input manager.
  100169. * @returns the current input manager
  100170. */
  100171. addKeyboard(): FollowCameraInputsManager;
  100172. /**
  100173. * Add mouse wheel input support to the input manager.
  100174. * @returns the current input manager
  100175. */
  100176. addMouseWheel(): FollowCameraInputsManager;
  100177. /**
  100178. * Add pointers input support to the input manager.
  100179. * @returns the current input manager
  100180. */
  100181. addPointers(): FollowCameraInputsManager;
  100182. /**
  100183. * Add orientation input support to the input manager.
  100184. * @returns the current input manager
  100185. */
  100186. addVRDeviceOrientation(): FollowCameraInputsManager;
  100187. }
  100188. }
  100189. declare module BABYLON {
  100190. /**
  100191. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  100192. * an arc rotate version arcFollowCamera are available.
  100193. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  100194. */
  100195. export class FollowCamera extends TargetCamera {
  100196. /**
  100197. * Distance the follow camera should follow an object at
  100198. */
  100199. radius: number;
  100200. /**
  100201. * Minimum allowed distance of the camera to the axis of rotation
  100202. * (The camera can not get closer).
  100203. * This can help limiting how the Camera is able to move in the scene.
  100204. */
  100205. lowerRadiusLimit: Nullable<number>;
  100206. /**
  100207. * Maximum allowed distance of the camera to the axis of rotation
  100208. * (The camera can not get further).
  100209. * This can help limiting how the Camera is able to move in the scene.
  100210. */
  100211. upperRadiusLimit: Nullable<number>;
  100212. /**
  100213. * Define a rotation offset between the camera and the object it follows
  100214. */
  100215. rotationOffset: number;
  100216. /**
  100217. * Minimum allowed angle to camera position relative to target object.
  100218. * This can help limiting how the Camera is able to move in the scene.
  100219. */
  100220. lowerRotationOffsetLimit: Nullable<number>;
  100221. /**
  100222. * Maximum allowed angle to camera position relative to target object.
  100223. * This can help limiting how the Camera is able to move in the scene.
  100224. */
  100225. upperRotationOffsetLimit: Nullable<number>;
  100226. /**
  100227. * Define a height offset between the camera and the object it follows.
  100228. * It can help following an object from the top (like a car chaing a plane)
  100229. */
  100230. heightOffset: number;
  100231. /**
  100232. * Minimum allowed height of camera position relative to target object.
  100233. * This can help limiting how the Camera is able to move in the scene.
  100234. */
  100235. lowerHeightOffsetLimit: Nullable<number>;
  100236. /**
  100237. * Maximum allowed height of camera position relative to target object.
  100238. * This can help limiting how the Camera is able to move in the scene.
  100239. */
  100240. upperHeightOffsetLimit: Nullable<number>;
  100241. /**
  100242. * Define how fast the camera can accelerate to follow it s target.
  100243. */
  100244. cameraAcceleration: number;
  100245. /**
  100246. * Define the speed limit of the camera following an object.
  100247. */
  100248. maxCameraSpeed: number;
  100249. /**
  100250. * Define the target of the camera.
  100251. */
  100252. lockedTarget: Nullable<AbstractMesh>;
  100253. /**
  100254. * Defines the input associated with the camera.
  100255. */
  100256. inputs: FollowCameraInputsManager;
  100257. /**
  100258. * Instantiates the follow camera.
  100259. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  100260. * @param name Define the name of the camera in the scene
  100261. * @param position Define the position of the camera
  100262. * @param scene Define the scene the camera belong to
  100263. * @param lockedTarget Define the target of the camera
  100264. */
  100265. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  100266. private _follow;
  100267. /**
  100268. * Attached controls to the current camera.
  100269. * @param element Defines the element the controls should be listened from
  100270. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100271. */
  100272. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100273. /**
  100274. * Detach the current controls from the camera.
  100275. * The camera will stop reacting to inputs.
  100276. * @param element Defines the element to stop listening the inputs from
  100277. */
  100278. detachControl(element: HTMLElement): void;
  100279. /** @hidden */
  100280. _checkInputs(): void;
  100281. private _checkLimits;
  100282. /**
  100283. * Gets the camera class name.
  100284. * @returns the class name
  100285. */
  100286. getClassName(): string;
  100287. }
  100288. /**
  100289. * Arc Rotate version of the follow camera.
  100290. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  100291. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  100292. */
  100293. export class ArcFollowCamera extends TargetCamera {
  100294. /** The longitudinal angle of the camera */
  100295. alpha: number;
  100296. /** The latitudinal angle of the camera */
  100297. beta: number;
  100298. /** The radius of the camera from its target */
  100299. radius: number;
  100300. /** Define the camera target (the messh it should follow) */
  100301. target: Nullable<AbstractMesh>;
  100302. private _cartesianCoordinates;
  100303. /**
  100304. * Instantiates a new ArcFollowCamera
  100305. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  100306. * @param name Define the name of the camera
  100307. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  100308. * @param beta Define the rotation angle of the camera around the elevation axis
  100309. * @param radius Define the radius of the camera from its target point
  100310. * @param target Define the target of the camera
  100311. * @param scene Define the scene the camera belongs to
  100312. */
  100313. constructor(name: string,
  100314. /** The longitudinal angle of the camera */
  100315. alpha: number,
  100316. /** The latitudinal angle of the camera */
  100317. beta: number,
  100318. /** The radius of the camera from its target */
  100319. radius: number,
  100320. /** Define the camera target (the messh it should follow) */
  100321. target: Nullable<AbstractMesh>, scene: Scene);
  100322. private _follow;
  100323. /** @hidden */
  100324. _checkInputs(): void;
  100325. /**
  100326. * Returns the class name of the object.
  100327. * It is mostly used internally for serialization purposes.
  100328. */
  100329. getClassName(): string;
  100330. }
  100331. }
  100332. declare module BABYLON {
  100333. /**
  100334. * Manage the keyboard inputs to control the movement of a follow camera.
  100335. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100336. */
  100337. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  100338. /**
  100339. * Defines the camera the input is attached to.
  100340. */
  100341. camera: FollowCamera;
  100342. /**
  100343. * Defines the list of key codes associated with the up action (increase heightOffset)
  100344. */
  100345. keysHeightOffsetIncr: number[];
  100346. /**
  100347. * Defines the list of key codes associated with the down action (decrease heightOffset)
  100348. */
  100349. keysHeightOffsetDecr: number[];
  100350. /**
  100351. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  100352. */
  100353. keysHeightOffsetModifierAlt: boolean;
  100354. /**
  100355. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  100356. */
  100357. keysHeightOffsetModifierCtrl: boolean;
  100358. /**
  100359. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  100360. */
  100361. keysHeightOffsetModifierShift: boolean;
  100362. /**
  100363. * Defines the list of key codes associated with the left action (increase rotationOffset)
  100364. */
  100365. keysRotationOffsetIncr: number[];
  100366. /**
  100367. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  100368. */
  100369. keysRotationOffsetDecr: number[];
  100370. /**
  100371. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  100372. */
  100373. keysRotationOffsetModifierAlt: boolean;
  100374. /**
  100375. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  100376. */
  100377. keysRotationOffsetModifierCtrl: boolean;
  100378. /**
  100379. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  100380. */
  100381. keysRotationOffsetModifierShift: boolean;
  100382. /**
  100383. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  100384. */
  100385. keysRadiusIncr: number[];
  100386. /**
  100387. * Defines the list of key codes associated with the zoom-out action (increase radius)
  100388. */
  100389. keysRadiusDecr: number[];
  100390. /**
  100391. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  100392. */
  100393. keysRadiusModifierAlt: boolean;
  100394. /**
  100395. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  100396. */
  100397. keysRadiusModifierCtrl: boolean;
  100398. /**
  100399. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  100400. */
  100401. keysRadiusModifierShift: boolean;
  100402. /**
  100403. * Defines the rate of change of heightOffset.
  100404. */
  100405. heightSensibility: number;
  100406. /**
  100407. * Defines the rate of change of rotationOffset.
  100408. */
  100409. rotationSensibility: number;
  100410. /**
  100411. * Defines the rate of change of radius.
  100412. */
  100413. radiusSensibility: number;
  100414. private _keys;
  100415. private _ctrlPressed;
  100416. private _altPressed;
  100417. private _shiftPressed;
  100418. private _onCanvasBlurObserver;
  100419. private _onKeyboardObserver;
  100420. private _engine;
  100421. private _scene;
  100422. /**
  100423. * Attach the input controls to a specific dom element to get the input from.
  100424. * @param element Defines the element the controls should be listened from
  100425. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100426. */
  100427. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100428. /**
  100429. * Detach the current controls from the specified dom element.
  100430. * @param element Defines the element to stop listening the inputs from
  100431. */
  100432. detachControl(element: Nullable<HTMLElement>): void;
  100433. /**
  100434. * Update the current camera state depending on the inputs that have been used this frame.
  100435. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  100436. */
  100437. checkInputs(): void;
  100438. /**
  100439. * Gets the class name of the current input.
  100440. * @returns the class name
  100441. */
  100442. getClassName(): string;
  100443. /**
  100444. * Get the friendly name associated with the input class.
  100445. * @returns the input friendly name
  100446. */
  100447. getSimpleName(): string;
  100448. /**
  100449. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  100450. * allow modification of the heightOffset value.
  100451. */
  100452. private _modifierHeightOffset;
  100453. /**
  100454. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  100455. * allow modification of the rotationOffset value.
  100456. */
  100457. private _modifierRotationOffset;
  100458. /**
  100459. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  100460. * allow modification of the radius value.
  100461. */
  100462. private _modifierRadius;
  100463. }
  100464. }
  100465. declare module BABYLON {
  100466. interface FreeCameraInputsManager {
  100467. /**
  100468. * @hidden
  100469. */
  100470. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  100471. /**
  100472. * Add orientation input support to the input manager.
  100473. * @returns the current input manager
  100474. */
  100475. addDeviceOrientation(): FreeCameraInputsManager;
  100476. }
  100477. /**
  100478. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  100479. * Screen rotation is taken into account.
  100480. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100481. */
  100482. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  100483. private _camera;
  100484. private _screenOrientationAngle;
  100485. private _constantTranform;
  100486. private _screenQuaternion;
  100487. private _alpha;
  100488. private _beta;
  100489. private _gamma;
  100490. /**
  100491. * Can be used to detect if a device orientation sensor is availible on a device
  100492. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  100493. * @returns a promise that will resolve on orientation change
  100494. */
  100495. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  100496. /**
  100497. * @hidden
  100498. */
  100499. _onDeviceOrientationChangedObservable: Observable<void>;
  100500. /**
  100501. * Instantiates a new input
  100502. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100503. */
  100504. constructor();
  100505. /**
  100506. * Define the camera controlled by the input.
  100507. */
  100508. camera: FreeCamera;
  100509. /**
  100510. * Attach the input controls to a specific dom element to get the input from.
  100511. * @param element Defines the element the controls should be listened from
  100512. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100513. */
  100514. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100515. private _orientationChanged;
  100516. private _deviceOrientation;
  100517. /**
  100518. * Detach the current controls from the specified dom element.
  100519. * @param element Defines the element to stop listening the inputs from
  100520. */
  100521. detachControl(element: Nullable<HTMLElement>): void;
  100522. /**
  100523. * Update the current camera state depending on the inputs that have been used this frame.
  100524. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  100525. */
  100526. checkInputs(): void;
  100527. /**
  100528. * Gets the class name of the current intput.
  100529. * @returns the class name
  100530. */
  100531. getClassName(): string;
  100532. /**
  100533. * Get the friendly name associated with the input class.
  100534. * @returns the input friendly name
  100535. */
  100536. getSimpleName(): string;
  100537. }
  100538. }
  100539. declare module BABYLON {
  100540. /**
  100541. * Manage the gamepad inputs to control a free camera.
  100542. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100543. */
  100544. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  100545. /**
  100546. * Define the camera the input is attached to.
  100547. */
  100548. camera: FreeCamera;
  100549. /**
  100550. * Define the Gamepad controlling the input
  100551. */
  100552. gamepad: Nullable<Gamepad>;
  100553. /**
  100554. * Defines the gamepad rotation sensiblity.
  100555. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  100556. */
  100557. gamepadAngularSensibility: number;
  100558. /**
  100559. * Defines the gamepad move sensiblity.
  100560. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  100561. */
  100562. gamepadMoveSensibility: number;
  100563. private _onGamepadConnectedObserver;
  100564. private _onGamepadDisconnectedObserver;
  100565. private _cameraTransform;
  100566. private _deltaTransform;
  100567. private _vector3;
  100568. private _vector2;
  100569. /**
  100570. * Attach the input controls to a specific dom element to get the input from.
  100571. * @param element Defines the element the controls should be listened from
  100572. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100573. */
  100574. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100575. /**
  100576. * Detach the current controls from the specified dom element.
  100577. * @param element Defines the element to stop listening the inputs from
  100578. */
  100579. detachControl(element: Nullable<HTMLElement>): void;
  100580. /**
  100581. * Update the current camera state depending on the inputs that have been used this frame.
  100582. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  100583. */
  100584. checkInputs(): void;
  100585. /**
  100586. * Gets the class name of the current intput.
  100587. * @returns the class name
  100588. */
  100589. getClassName(): string;
  100590. /**
  100591. * Get the friendly name associated with the input class.
  100592. * @returns the input friendly name
  100593. */
  100594. getSimpleName(): string;
  100595. }
  100596. }
  100597. declare module BABYLON {
  100598. /**
  100599. * Defines the potential axis of a Joystick
  100600. */
  100601. export enum JoystickAxis {
  100602. /** X axis */
  100603. X = 0,
  100604. /** Y axis */
  100605. Y = 1,
  100606. /** Z axis */
  100607. Z = 2
  100608. }
  100609. /**
  100610. * Class used to define virtual joystick (used in touch mode)
  100611. */
  100612. export class VirtualJoystick {
  100613. /**
  100614. * Gets or sets a boolean indicating that left and right values must be inverted
  100615. */
  100616. reverseLeftRight: boolean;
  100617. /**
  100618. * Gets or sets a boolean indicating that up and down values must be inverted
  100619. */
  100620. reverseUpDown: boolean;
  100621. /**
  100622. * Gets the offset value for the position (ie. the change of the position value)
  100623. */
  100624. deltaPosition: Vector3;
  100625. /**
  100626. * Gets a boolean indicating if the virtual joystick was pressed
  100627. */
  100628. pressed: boolean;
  100629. /**
  100630. * Canvas the virtual joystick will render onto, default z-index of this is 5
  100631. */
  100632. static Canvas: Nullable<HTMLCanvasElement>;
  100633. private static _globalJoystickIndex;
  100634. private static vjCanvasContext;
  100635. private static vjCanvasWidth;
  100636. private static vjCanvasHeight;
  100637. private static halfWidth;
  100638. private _action;
  100639. private _axisTargetedByLeftAndRight;
  100640. private _axisTargetedByUpAndDown;
  100641. private _joystickSensibility;
  100642. private _inversedSensibility;
  100643. private _joystickPointerID;
  100644. private _joystickColor;
  100645. private _joystickPointerPos;
  100646. private _joystickPreviousPointerPos;
  100647. private _joystickPointerStartPos;
  100648. private _deltaJoystickVector;
  100649. private _leftJoystick;
  100650. private _touches;
  100651. private _onPointerDownHandlerRef;
  100652. private _onPointerMoveHandlerRef;
  100653. private _onPointerUpHandlerRef;
  100654. private _onResize;
  100655. /**
  100656. * Creates a new virtual joystick
  100657. * @param leftJoystick defines that the joystick is for left hand (false by default)
  100658. */
  100659. constructor(leftJoystick?: boolean);
  100660. /**
  100661. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  100662. * @param newJoystickSensibility defines the new sensibility
  100663. */
  100664. setJoystickSensibility(newJoystickSensibility: number): void;
  100665. private _onPointerDown;
  100666. private _onPointerMove;
  100667. private _onPointerUp;
  100668. /**
  100669. * Change the color of the virtual joystick
  100670. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  100671. */
  100672. setJoystickColor(newColor: string): void;
  100673. /**
  100674. * Defines a callback to call when the joystick is touched
  100675. * @param action defines the callback
  100676. */
  100677. setActionOnTouch(action: () => any): void;
  100678. /**
  100679. * Defines which axis you'd like to control for left & right
  100680. * @param axis defines the axis to use
  100681. */
  100682. setAxisForLeftRight(axis: JoystickAxis): void;
  100683. /**
  100684. * Defines which axis you'd like to control for up & down
  100685. * @param axis defines the axis to use
  100686. */
  100687. setAxisForUpDown(axis: JoystickAxis): void;
  100688. private _drawVirtualJoystick;
  100689. /**
  100690. * Release internal HTML canvas
  100691. */
  100692. releaseCanvas(): void;
  100693. }
  100694. }
  100695. declare module BABYLON {
  100696. interface FreeCameraInputsManager {
  100697. /**
  100698. * Add virtual joystick input support to the input manager.
  100699. * @returns the current input manager
  100700. */
  100701. addVirtualJoystick(): FreeCameraInputsManager;
  100702. }
  100703. /**
  100704. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  100705. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100706. */
  100707. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  100708. /**
  100709. * Defines the camera the input is attached to.
  100710. */
  100711. camera: FreeCamera;
  100712. private _leftjoystick;
  100713. private _rightjoystick;
  100714. /**
  100715. * Gets the left stick of the virtual joystick.
  100716. * @returns The virtual Joystick
  100717. */
  100718. getLeftJoystick(): VirtualJoystick;
  100719. /**
  100720. * Gets the right stick of the virtual joystick.
  100721. * @returns The virtual Joystick
  100722. */
  100723. getRightJoystick(): VirtualJoystick;
  100724. /**
  100725. * Update the current camera state depending on the inputs that have been used this frame.
  100726. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  100727. */
  100728. checkInputs(): void;
  100729. /**
  100730. * Attach the input controls to a specific dom element to get the input from.
  100731. * @param element Defines the element the controls should be listened from
  100732. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100733. */
  100734. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100735. /**
  100736. * Detach the current controls from the specified dom element.
  100737. * @param element Defines the element to stop listening the inputs from
  100738. */
  100739. detachControl(element: Nullable<HTMLElement>): void;
  100740. /**
  100741. * Gets the class name of the current intput.
  100742. * @returns the class name
  100743. */
  100744. getClassName(): string;
  100745. /**
  100746. * Get the friendly name associated with the input class.
  100747. * @returns the input friendly name
  100748. */
  100749. getSimpleName(): string;
  100750. }
  100751. }
  100752. declare module BABYLON {
  100753. /**
  100754. * This represents a FPS type of camera controlled by touch.
  100755. * This is like a universal camera minus the Gamepad controls.
  100756. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  100757. */
  100758. export class TouchCamera extends FreeCamera {
  100759. /**
  100760. * Defines the touch sensibility for rotation.
  100761. * The higher the faster.
  100762. */
  100763. touchAngularSensibility: number;
  100764. /**
  100765. * Defines the touch sensibility for move.
  100766. * The higher the faster.
  100767. */
  100768. touchMoveSensibility: number;
  100769. /**
  100770. * Instantiates a new touch camera.
  100771. * This represents a FPS type of camera controlled by touch.
  100772. * This is like a universal camera minus the Gamepad controls.
  100773. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  100774. * @param name Define the name of the camera in the scene
  100775. * @param position Define the start position of the camera in the scene
  100776. * @param scene Define the scene the camera belongs to
  100777. */
  100778. constructor(name: string, position: Vector3, scene: Scene);
  100779. /**
  100780. * Gets the current object class name.
  100781. * @return the class name
  100782. */
  100783. getClassName(): string;
  100784. /** @hidden */
  100785. _setupInputs(): void;
  100786. }
  100787. }
  100788. declare module BABYLON {
  100789. /**
  100790. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  100791. * being tilted forward or back and left or right.
  100792. */
  100793. export class DeviceOrientationCamera extends FreeCamera {
  100794. private _initialQuaternion;
  100795. private _quaternionCache;
  100796. private _tmpDragQuaternion;
  100797. /**
  100798. * Creates a new device orientation camera
  100799. * @param name The name of the camera
  100800. * @param position The start position camera
  100801. * @param scene The scene the camera belongs to
  100802. */
  100803. constructor(name: string, position: Vector3, scene: Scene);
  100804. /**
  100805. * @hidden
  100806. * Disabled pointer input on first orientation sensor update (Default: true)
  100807. */
  100808. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  100809. private _dragFactor;
  100810. /**
  100811. * Enabled turning on the y axis when the orientation sensor is active
  100812. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  100813. */
  100814. enableHorizontalDragging(dragFactor?: number): void;
  100815. /**
  100816. * Gets the current instance class name ("DeviceOrientationCamera").
  100817. * This helps avoiding instanceof at run time.
  100818. * @returns the class name
  100819. */
  100820. getClassName(): string;
  100821. /**
  100822. * @hidden
  100823. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  100824. */
  100825. _checkInputs(): void;
  100826. /**
  100827. * Reset the camera to its default orientation on the specified axis only.
  100828. * @param axis The axis to reset
  100829. */
  100830. resetToCurrentRotation(axis?: Axis): void;
  100831. }
  100832. }
  100833. declare module BABYLON {
  100834. /**
  100835. * Defines supported buttons for XBox360 compatible gamepads
  100836. */
  100837. export enum Xbox360Button {
  100838. /** A */
  100839. A = 0,
  100840. /** B */
  100841. B = 1,
  100842. /** X */
  100843. X = 2,
  100844. /** Y */
  100845. Y = 3,
  100846. /** Start */
  100847. Start = 4,
  100848. /** Back */
  100849. Back = 5,
  100850. /** Left button */
  100851. LB = 6,
  100852. /** Right button */
  100853. RB = 7,
  100854. /** Left stick */
  100855. LeftStick = 8,
  100856. /** Right stick */
  100857. RightStick = 9
  100858. }
  100859. /** Defines values for XBox360 DPad */
  100860. export enum Xbox360Dpad {
  100861. /** Up */
  100862. Up = 0,
  100863. /** Down */
  100864. Down = 1,
  100865. /** Left */
  100866. Left = 2,
  100867. /** Right */
  100868. Right = 3
  100869. }
  100870. /**
  100871. * Defines a XBox360 gamepad
  100872. */
  100873. export class Xbox360Pad extends Gamepad {
  100874. private _leftTrigger;
  100875. private _rightTrigger;
  100876. private _onlefttriggerchanged;
  100877. private _onrighttriggerchanged;
  100878. private _onbuttondown;
  100879. private _onbuttonup;
  100880. private _ondpaddown;
  100881. private _ondpadup;
  100882. /** Observable raised when a button is pressed */
  100883. onButtonDownObservable: Observable<Xbox360Button>;
  100884. /** Observable raised when a button is released */
  100885. onButtonUpObservable: Observable<Xbox360Button>;
  100886. /** Observable raised when a pad is pressed */
  100887. onPadDownObservable: Observable<Xbox360Dpad>;
  100888. /** Observable raised when a pad is released */
  100889. onPadUpObservable: Observable<Xbox360Dpad>;
  100890. private _buttonA;
  100891. private _buttonB;
  100892. private _buttonX;
  100893. private _buttonY;
  100894. private _buttonBack;
  100895. private _buttonStart;
  100896. private _buttonLB;
  100897. private _buttonRB;
  100898. private _buttonLeftStick;
  100899. private _buttonRightStick;
  100900. private _dPadUp;
  100901. private _dPadDown;
  100902. private _dPadLeft;
  100903. private _dPadRight;
  100904. private _isXboxOnePad;
  100905. /**
  100906. * Creates a new XBox360 gamepad object
  100907. * @param id defines the id of this gamepad
  100908. * @param index defines its index
  100909. * @param gamepad defines the internal HTML gamepad object
  100910. * @param xboxOne defines if it is a XBox One gamepad
  100911. */
  100912. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  100913. /**
  100914. * Defines the callback to call when left trigger is pressed
  100915. * @param callback defines the callback to use
  100916. */
  100917. onlefttriggerchanged(callback: (value: number) => void): void;
  100918. /**
  100919. * Defines the callback to call when right trigger is pressed
  100920. * @param callback defines the callback to use
  100921. */
  100922. onrighttriggerchanged(callback: (value: number) => void): void;
  100923. /**
  100924. * Gets the left trigger value
  100925. */
  100926. /**
  100927. * Sets the left trigger value
  100928. */
  100929. leftTrigger: number;
  100930. /**
  100931. * Gets the right trigger value
  100932. */
  100933. /**
  100934. * Sets the right trigger value
  100935. */
  100936. rightTrigger: number;
  100937. /**
  100938. * Defines the callback to call when a button is pressed
  100939. * @param callback defines the callback to use
  100940. */
  100941. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  100942. /**
  100943. * Defines the callback to call when a button is released
  100944. * @param callback defines the callback to use
  100945. */
  100946. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  100947. /**
  100948. * Defines the callback to call when a pad is pressed
  100949. * @param callback defines the callback to use
  100950. */
  100951. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  100952. /**
  100953. * Defines the callback to call when a pad is released
  100954. * @param callback defines the callback to use
  100955. */
  100956. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  100957. private _setButtonValue;
  100958. private _setDPadValue;
  100959. /**
  100960. * Gets the value of the `A` button
  100961. */
  100962. /**
  100963. * Sets the value of the `A` button
  100964. */
  100965. buttonA: number;
  100966. /**
  100967. * Gets the value of the `B` button
  100968. */
  100969. /**
  100970. * Sets the value of the `B` button
  100971. */
  100972. buttonB: number;
  100973. /**
  100974. * Gets the value of the `X` button
  100975. */
  100976. /**
  100977. * Sets the value of the `X` button
  100978. */
  100979. buttonX: number;
  100980. /**
  100981. * Gets the value of the `Y` button
  100982. */
  100983. /**
  100984. * Sets the value of the `Y` button
  100985. */
  100986. buttonY: number;
  100987. /**
  100988. * Gets the value of the `Start` button
  100989. */
  100990. /**
  100991. * Sets the value of the `Start` button
  100992. */
  100993. buttonStart: number;
  100994. /**
  100995. * Gets the value of the `Back` button
  100996. */
  100997. /**
  100998. * Sets the value of the `Back` button
  100999. */
  101000. buttonBack: number;
  101001. /**
  101002. * Gets the value of the `Left` button
  101003. */
  101004. /**
  101005. * Sets the value of the `Left` button
  101006. */
  101007. buttonLB: number;
  101008. /**
  101009. * Gets the value of the `Right` button
  101010. */
  101011. /**
  101012. * Sets the value of the `Right` button
  101013. */
  101014. buttonRB: number;
  101015. /**
  101016. * Gets the value of the Left joystick
  101017. */
  101018. /**
  101019. * Sets the value of the Left joystick
  101020. */
  101021. buttonLeftStick: number;
  101022. /**
  101023. * Gets the value of the Right joystick
  101024. */
  101025. /**
  101026. * Sets the value of the Right joystick
  101027. */
  101028. buttonRightStick: number;
  101029. /**
  101030. * Gets the value of D-pad up
  101031. */
  101032. /**
  101033. * Sets the value of D-pad up
  101034. */
  101035. dPadUp: number;
  101036. /**
  101037. * Gets the value of D-pad down
  101038. */
  101039. /**
  101040. * Sets the value of D-pad down
  101041. */
  101042. dPadDown: number;
  101043. /**
  101044. * Gets the value of D-pad left
  101045. */
  101046. /**
  101047. * Sets the value of D-pad left
  101048. */
  101049. dPadLeft: number;
  101050. /**
  101051. * Gets the value of D-pad right
  101052. */
  101053. /**
  101054. * Sets the value of D-pad right
  101055. */
  101056. dPadRight: number;
  101057. /**
  101058. * Force the gamepad to synchronize with device values
  101059. */
  101060. update(): void;
  101061. /**
  101062. * Disposes the gamepad
  101063. */
  101064. dispose(): void;
  101065. }
  101066. }
  101067. declare module BABYLON {
  101068. /**
  101069. * Manager for handling gamepads
  101070. */
  101071. export class GamepadManager {
  101072. private _scene?;
  101073. private _babylonGamepads;
  101074. private _oneGamepadConnected;
  101075. /** @hidden */
  101076. _isMonitoring: boolean;
  101077. private _gamepadEventSupported;
  101078. private _gamepadSupport;
  101079. /**
  101080. * observable to be triggered when the gamepad controller has been connected
  101081. */
  101082. onGamepadConnectedObservable: Observable<Gamepad>;
  101083. /**
  101084. * observable to be triggered when the gamepad controller has been disconnected
  101085. */
  101086. onGamepadDisconnectedObservable: Observable<Gamepad>;
  101087. private _onGamepadConnectedEvent;
  101088. private _onGamepadDisconnectedEvent;
  101089. /**
  101090. * Initializes the gamepad manager
  101091. * @param _scene BabylonJS scene
  101092. */
  101093. constructor(_scene?: Scene | undefined);
  101094. /**
  101095. * The gamepads in the game pad manager
  101096. */
  101097. readonly gamepads: Gamepad[];
  101098. /**
  101099. * Get the gamepad controllers based on type
  101100. * @param type The type of gamepad controller
  101101. * @returns Nullable gamepad
  101102. */
  101103. getGamepadByType(type?: number): Nullable<Gamepad>;
  101104. /**
  101105. * Disposes the gamepad manager
  101106. */
  101107. dispose(): void;
  101108. private _addNewGamepad;
  101109. private _startMonitoringGamepads;
  101110. private _stopMonitoringGamepads;
  101111. /** @hidden */
  101112. _checkGamepadsStatus(): void;
  101113. private _updateGamepadObjects;
  101114. }
  101115. }
  101116. declare module BABYLON {
  101117. interface Scene {
  101118. /** @hidden */
  101119. _gamepadManager: Nullable<GamepadManager>;
  101120. /**
  101121. * Gets the gamepad manager associated with the scene
  101122. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  101123. */
  101124. gamepadManager: GamepadManager;
  101125. }
  101126. /**
  101127. * Interface representing a free camera inputs manager
  101128. */
  101129. interface FreeCameraInputsManager {
  101130. /**
  101131. * Adds gamepad input support to the FreeCameraInputsManager.
  101132. * @returns the FreeCameraInputsManager
  101133. */
  101134. addGamepad(): FreeCameraInputsManager;
  101135. }
  101136. /**
  101137. * Interface representing an arc rotate camera inputs manager
  101138. */
  101139. interface ArcRotateCameraInputsManager {
  101140. /**
  101141. * Adds gamepad input support to the ArcRotateCamera InputManager.
  101142. * @returns the camera inputs manager
  101143. */
  101144. addGamepad(): ArcRotateCameraInputsManager;
  101145. }
  101146. /**
  101147. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  101148. */
  101149. export class GamepadSystemSceneComponent implements ISceneComponent {
  101150. /**
  101151. * The component name helpfull to identify the component in the list of scene components.
  101152. */
  101153. readonly name: string;
  101154. /**
  101155. * The scene the component belongs to.
  101156. */
  101157. scene: Scene;
  101158. /**
  101159. * Creates a new instance of the component for the given scene
  101160. * @param scene Defines the scene to register the component in
  101161. */
  101162. constructor(scene: Scene);
  101163. /**
  101164. * Registers the component in a given scene
  101165. */
  101166. register(): void;
  101167. /**
  101168. * Rebuilds the elements related to this component in case of
  101169. * context lost for instance.
  101170. */
  101171. rebuild(): void;
  101172. /**
  101173. * Disposes the component and the associated ressources
  101174. */
  101175. dispose(): void;
  101176. private _beforeCameraUpdate;
  101177. }
  101178. }
  101179. declare module BABYLON {
  101180. /**
  101181. * 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,
  101182. * which still works and will still be found in many Playgrounds.
  101183. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  101184. */
  101185. export class UniversalCamera extends TouchCamera {
  101186. /**
  101187. * Defines the gamepad rotation sensiblity.
  101188. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  101189. */
  101190. gamepadAngularSensibility: number;
  101191. /**
  101192. * Defines the gamepad move sensiblity.
  101193. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  101194. */
  101195. gamepadMoveSensibility: number;
  101196. /**
  101197. * 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,
  101198. * which still works and will still be found in many Playgrounds.
  101199. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  101200. * @param name Define the name of the camera in the scene
  101201. * @param position Define the start position of the camera in the scene
  101202. * @param scene Define the scene the camera belongs to
  101203. */
  101204. constructor(name: string, position: Vector3, scene: Scene);
  101205. /**
  101206. * Gets the current object class name.
  101207. * @return the class name
  101208. */
  101209. getClassName(): string;
  101210. }
  101211. }
  101212. declare module BABYLON {
  101213. /**
  101214. * This represents a FPS type of camera. This is only here for back compat purpose.
  101215. * Please use the UniversalCamera instead as both are identical.
  101216. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  101217. */
  101218. export class GamepadCamera extends UniversalCamera {
  101219. /**
  101220. * Instantiates a new Gamepad Camera
  101221. * This represents a FPS type of camera. This is only here for back compat purpose.
  101222. * Please use the UniversalCamera instead as both are identical.
  101223. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  101224. * @param name Define the name of the camera in the scene
  101225. * @param position Define the start position of the camera in the scene
  101226. * @param scene Define the scene the camera belongs to
  101227. */
  101228. constructor(name: string, position: Vector3, scene: Scene);
  101229. /**
  101230. * Gets the current object class name.
  101231. * @return the class name
  101232. */
  101233. getClassName(): string;
  101234. }
  101235. }
  101236. declare module BABYLON {
  101237. /** @hidden */
  101238. export var passPixelShader: {
  101239. name: string;
  101240. shader: string;
  101241. };
  101242. }
  101243. declare module BABYLON {
  101244. /** @hidden */
  101245. export var passCubePixelShader: {
  101246. name: string;
  101247. shader: string;
  101248. };
  101249. }
  101250. declare module BABYLON {
  101251. /**
  101252. * PassPostProcess which produces an output the same as it's input
  101253. */
  101254. export class PassPostProcess extends PostProcess {
  101255. /**
  101256. * Creates the PassPostProcess
  101257. * @param name The name of the effect.
  101258. * @param options The required width/height ratio to downsize to before computing the render pass.
  101259. * @param camera The camera to apply the render pass to.
  101260. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  101261. * @param engine The engine which the post process will be applied. (default: current engine)
  101262. * @param reusable If the post process can be reused on the same frame. (default: false)
  101263. * @param textureType The type of texture to be used when performing the post processing.
  101264. * @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)
  101265. */
  101266. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  101267. }
  101268. /**
  101269. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  101270. */
  101271. export class PassCubePostProcess extends PostProcess {
  101272. private _face;
  101273. /**
  101274. * Gets or sets the cube face to display.
  101275. * * 0 is +X
  101276. * * 1 is -X
  101277. * * 2 is +Y
  101278. * * 3 is -Y
  101279. * * 4 is +Z
  101280. * * 5 is -Z
  101281. */
  101282. face: number;
  101283. /**
  101284. * Creates the PassCubePostProcess
  101285. * @param name The name of the effect.
  101286. * @param options The required width/height ratio to downsize to before computing the render pass.
  101287. * @param camera The camera to apply the render pass to.
  101288. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  101289. * @param engine The engine which the post process will be applied. (default: current engine)
  101290. * @param reusable If the post process can be reused on the same frame. (default: false)
  101291. * @param textureType The type of texture to be used when performing the post processing.
  101292. * @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)
  101293. */
  101294. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  101295. }
  101296. }
  101297. declare module BABYLON {
  101298. /** @hidden */
  101299. export var anaglyphPixelShader: {
  101300. name: string;
  101301. shader: string;
  101302. };
  101303. }
  101304. declare module BABYLON {
  101305. /**
  101306. * Postprocess used to generate anaglyphic rendering
  101307. */
  101308. export class AnaglyphPostProcess extends PostProcess {
  101309. private _passedProcess;
  101310. /**
  101311. * Creates a new AnaglyphPostProcess
  101312. * @param name defines postprocess name
  101313. * @param options defines creation options or target ratio scale
  101314. * @param rigCameras defines cameras using this postprocess
  101315. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  101316. * @param engine defines hosting engine
  101317. * @param reusable defines if the postprocess will be reused multiple times per frame
  101318. */
  101319. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  101320. }
  101321. }
  101322. declare module BABYLON {
  101323. /**
  101324. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  101325. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  101326. */
  101327. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  101328. /**
  101329. * Creates a new AnaglyphArcRotateCamera
  101330. * @param name defines camera name
  101331. * @param alpha defines alpha angle (in radians)
  101332. * @param beta defines beta angle (in radians)
  101333. * @param radius defines radius
  101334. * @param target defines camera target
  101335. * @param interaxialDistance defines distance between each color axis
  101336. * @param scene defines the hosting scene
  101337. */
  101338. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  101339. /**
  101340. * Gets camera class name
  101341. * @returns AnaglyphArcRotateCamera
  101342. */
  101343. getClassName(): string;
  101344. }
  101345. }
  101346. declare module BABYLON {
  101347. /**
  101348. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  101349. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  101350. */
  101351. export class AnaglyphFreeCamera extends FreeCamera {
  101352. /**
  101353. * Creates a new AnaglyphFreeCamera
  101354. * @param name defines camera name
  101355. * @param position defines initial position
  101356. * @param interaxialDistance defines distance between each color axis
  101357. * @param scene defines the hosting scene
  101358. */
  101359. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  101360. /**
  101361. * Gets camera class name
  101362. * @returns AnaglyphFreeCamera
  101363. */
  101364. getClassName(): string;
  101365. }
  101366. }
  101367. declare module BABYLON {
  101368. /**
  101369. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  101370. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  101371. */
  101372. export class AnaglyphGamepadCamera extends GamepadCamera {
  101373. /**
  101374. * Creates a new AnaglyphGamepadCamera
  101375. * @param name defines camera name
  101376. * @param position defines initial position
  101377. * @param interaxialDistance defines distance between each color axis
  101378. * @param scene defines the hosting scene
  101379. */
  101380. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  101381. /**
  101382. * Gets camera class name
  101383. * @returns AnaglyphGamepadCamera
  101384. */
  101385. getClassName(): string;
  101386. }
  101387. }
  101388. declare module BABYLON {
  101389. /**
  101390. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  101391. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  101392. */
  101393. export class AnaglyphUniversalCamera extends UniversalCamera {
  101394. /**
  101395. * Creates a new AnaglyphUniversalCamera
  101396. * @param name defines camera name
  101397. * @param position defines initial position
  101398. * @param interaxialDistance defines distance between each color axis
  101399. * @param scene defines the hosting scene
  101400. */
  101401. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  101402. /**
  101403. * Gets camera class name
  101404. * @returns AnaglyphUniversalCamera
  101405. */
  101406. getClassName(): string;
  101407. }
  101408. }
  101409. declare module BABYLON {
  101410. /** @hidden */
  101411. export var stereoscopicInterlacePixelShader: {
  101412. name: string;
  101413. shader: string;
  101414. };
  101415. }
  101416. declare module BABYLON {
  101417. /**
  101418. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  101419. */
  101420. export class StereoscopicInterlacePostProcess extends PostProcess {
  101421. private _stepSize;
  101422. private _passedProcess;
  101423. /**
  101424. * Initializes a StereoscopicInterlacePostProcess
  101425. * @param name The name of the effect.
  101426. * @param rigCameras The rig cameras to be appled to the post process
  101427. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  101428. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  101429. * @param engine The engine which the post process will be applied. (default: current engine)
  101430. * @param reusable If the post process can be reused on the same frame. (default: false)
  101431. */
  101432. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  101433. }
  101434. }
  101435. declare module BABYLON {
  101436. /**
  101437. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  101438. * @see http://doc.babylonjs.com/features/cameras
  101439. */
  101440. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  101441. /**
  101442. * Creates a new StereoscopicArcRotateCamera
  101443. * @param name defines camera name
  101444. * @param alpha defines alpha angle (in radians)
  101445. * @param beta defines beta angle (in radians)
  101446. * @param radius defines radius
  101447. * @param target defines camera target
  101448. * @param interaxialDistance defines distance between each color axis
  101449. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  101450. * @param scene defines the hosting scene
  101451. */
  101452. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  101453. /**
  101454. * Gets camera class name
  101455. * @returns StereoscopicArcRotateCamera
  101456. */
  101457. getClassName(): string;
  101458. }
  101459. }
  101460. declare module BABYLON {
  101461. /**
  101462. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  101463. * @see http://doc.babylonjs.com/features/cameras
  101464. */
  101465. export class StereoscopicFreeCamera extends FreeCamera {
  101466. /**
  101467. * Creates a new StereoscopicFreeCamera
  101468. * @param name defines camera name
  101469. * @param position defines initial position
  101470. * @param interaxialDistance defines distance between each color axis
  101471. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  101472. * @param scene defines the hosting scene
  101473. */
  101474. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  101475. /**
  101476. * Gets camera class name
  101477. * @returns StereoscopicFreeCamera
  101478. */
  101479. getClassName(): string;
  101480. }
  101481. }
  101482. declare module BABYLON {
  101483. /**
  101484. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  101485. * @see http://doc.babylonjs.com/features/cameras
  101486. */
  101487. export class StereoscopicGamepadCamera extends GamepadCamera {
  101488. /**
  101489. * Creates a new StereoscopicGamepadCamera
  101490. * @param name defines camera name
  101491. * @param position defines initial position
  101492. * @param interaxialDistance defines distance between each color axis
  101493. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  101494. * @param scene defines the hosting scene
  101495. */
  101496. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  101497. /**
  101498. * Gets camera class name
  101499. * @returns StereoscopicGamepadCamera
  101500. */
  101501. getClassName(): string;
  101502. }
  101503. }
  101504. declare module BABYLON {
  101505. /**
  101506. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  101507. * @see http://doc.babylonjs.com/features/cameras
  101508. */
  101509. export class StereoscopicUniversalCamera extends UniversalCamera {
  101510. /**
  101511. * Creates a new StereoscopicUniversalCamera
  101512. * @param name defines camera name
  101513. * @param position defines initial position
  101514. * @param interaxialDistance defines distance between each color axis
  101515. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  101516. * @param scene defines the hosting scene
  101517. */
  101518. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  101519. /**
  101520. * Gets camera class name
  101521. * @returns StereoscopicUniversalCamera
  101522. */
  101523. getClassName(): string;
  101524. }
  101525. }
  101526. declare module BABYLON {
  101527. /**
  101528. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  101529. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  101530. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  101531. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  101532. */
  101533. export class VirtualJoysticksCamera extends FreeCamera {
  101534. /**
  101535. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  101536. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  101537. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  101538. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  101539. * @param name Define the name of the camera in the scene
  101540. * @param position Define the start position of the camera in the scene
  101541. * @param scene Define the scene the camera belongs to
  101542. */
  101543. constructor(name: string, position: Vector3, scene: Scene);
  101544. /**
  101545. * Gets the current object class name.
  101546. * @return the class name
  101547. */
  101548. getClassName(): string;
  101549. }
  101550. }
  101551. declare module BABYLON {
  101552. /**
  101553. * This represents all the required metrics to create a VR camera.
  101554. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  101555. */
  101556. export class VRCameraMetrics {
  101557. /**
  101558. * Define the horizontal resolution off the screen.
  101559. */
  101560. hResolution: number;
  101561. /**
  101562. * Define the vertical resolution off the screen.
  101563. */
  101564. vResolution: number;
  101565. /**
  101566. * Define the horizontal screen size.
  101567. */
  101568. hScreenSize: number;
  101569. /**
  101570. * Define the vertical screen size.
  101571. */
  101572. vScreenSize: number;
  101573. /**
  101574. * Define the vertical screen center position.
  101575. */
  101576. vScreenCenter: number;
  101577. /**
  101578. * Define the distance of the eyes to the screen.
  101579. */
  101580. eyeToScreenDistance: number;
  101581. /**
  101582. * Define the distance between both lenses
  101583. */
  101584. lensSeparationDistance: number;
  101585. /**
  101586. * Define the distance between both viewer's eyes.
  101587. */
  101588. interpupillaryDistance: number;
  101589. /**
  101590. * Define the distortion factor of the VR postprocess.
  101591. * Please, touch with care.
  101592. */
  101593. distortionK: number[];
  101594. /**
  101595. * Define the chromatic aberration correction factors for the VR post process.
  101596. */
  101597. chromaAbCorrection: number[];
  101598. /**
  101599. * Define the scale factor of the post process.
  101600. * The smaller the better but the slower.
  101601. */
  101602. postProcessScaleFactor: number;
  101603. /**
  101604. * Define an offset for the lens center.
  101605. */
  101606. lensCenterOffset: number;
  101607. /**
  101608. * Define if the current vr camera should compensate the distortion of the lense or not.
  101609. */
  101610. compensateDistortion: boolean;
  101611. /**
  101612. * Defines if multiview should be enabled when rendering (Default: false)
  101613. */
  101614. multiviewEnabled: boolean;
  101615. /**
  101616. * Gets the rendering aspect ratio based on the provided resolutions.
  101617. */
  101618. readonly aspectRatio: number;
  101619. /**
  101620. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  101621. */
  101622. readonly aspectRatioFov: number;
  101623. /**
  101624. * @hidden
  101625. */
  101626. readonly leftHMatrix: Matrix;
  101627. /**
  101628. * @hidden
  101629. */
  101630. readonly rightHMatrix: Matrix;
  101631. /**
  101632. * @hidden
  101633. */
  101634. readonly leftPreViewMatrix: Matrix;
  101635. /**
  101636. * @hidden
  101637. */
  101638. readonly rightPreViewMatrix: Matrix;
  101639. /**
  101640. * Get the default VRMetrics based on the most generic setup.
  101641. * @returns the default vr metrics
  101642. */
  101643. static GetDefault(): VRCameraMetrics;
  101644. }
  101645. }
  101646. declare module BABYLON {
  101647. /** @hidden */
  101648. export var vrDistortionCorrectionPixelShader: {
  101649. name: string;
  101650. shader: string;
  101651. };
  101652. }
  101653. declare module BABYLON {
  101654. /**
  101655. * VRDistortionCorrectionPostProcess used for mobile VR
  101656. */
  101657. export class VRDistortionCorrectionPostProcess extends PostProcess {
  101658. private _isRightEye;
  101659. private _distortionFactors;
  101660. private _postProcessScaleFactor;
  101661. private _lensCenterOffset;
  101662. private _scaleIn;
  101663. private _scaleFactor;
  101664. private _lensCenter;
  101665. /**
  101666. * Initializes the VRDistortionCorrectionPostProcess
  101667. * @param name The name of the effect.
  101668. * @param camera The camera to apply the render pass to.
  101669. * @param isRightEye If this is for the right eye distortion
  101670. * @param vrMetrics All the required metrics for the VR camera
  101671. */
  101672. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  101673. }
  101674. }
  101675. declare module BABYLON {
  101676. /**
  101677. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  101678. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  101679. */
  101680. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  101681. /**
  101682. * Creates a new VRDeviceOrientationArcRotateCamera
  101683. * @param name defines camera name
  101684. * @param alpha defines the camera rotation along the logitudinal axis
  101685. * @param beta defines the camera rotation along the latitudinal axis
  101686. * @param radius defines the camera distance from its target
  101687. * @param target defines the camera target
  101688. * @param scene defines the scene the camera belongs to
  101689. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  101690. * @param vrCameraMetrics defines the vr metrics associated to the camera
  101691. */
  101692. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  101693. /**
  101694. * Gets camera class name
  101695. * @returns VRDeviceOrientationArcRotateCamera
  101696. */
  101697. getClassName(): string;
  101698. }
  101699. }
  101700. declare module BABYLON {
  101701. /**
  101702. * Camera used to simulate VR rendering (based on FreeCamera)
  101703. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  101704. */
  101705. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  101706. /**
  101707. * Creates a new VRDeviceOrientationFreeCamera
  101708. * @param name defines camera name
  101709. * @param position defines the start position of the camera
  101710. * @param scene defines the scene the camera belongs to
  101711. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  101712. * @param vrCameraMetrics defines the vr metrics associated to the camera
  101713. */
  101714. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  101715. /**
  101716. * Gets camera class name
  101717. * @returns VRDeviceOrientationFreeCamera
  101718. */
  101719. getClassName(): string;
  101720. }
  101721. }
  101722. declare module BABYLON {
  101723. /**
  101724. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  101725. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  101726. */
  101727. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  101728. /**
  101729. * Creates a new VRDeviceOrientationGamepadCamera
  101730. * @param name defines camera name
  101731. * @param position defines the start position of the camera
  101732. * @param scene defines the scene the camera belongs to
  101733. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  101734. * @param vrCameraMetrics defines the vr metrics associated to the camera
  101735. */
  101736. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  101737. /**
  101738. * Gets camera class name
  101739. * @returns VRDeviceOrientationGamepadCamera
  101740. */
  101741. getClassName(): string;
  101742. }
  101743. }
  101744. declare module BABYLON {
  101745. /**
  101746. * Base class of materials working in push mode in babylon JS
  101747. * @hidden
  101748. */
  101749. export class PushMaterial extends Material {
  101750. protected _activeEffect: Effect;
  101751. protected _normalMatrix: Matrix;
  101752. /**
  101753. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  101754. * This means that the material can keep using a previous shader while a new one is being compiled.
  101755. * This is mostly used when shader parallel compilation is supported (true by default)
  101756. */
  101757. allowShaderHotSwapping: boolean;
  101758. constructor(name: string, scene: Scene);
  101759. getEffect(): Effect;
  101760. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  101761. /**
  101762. * Binds the given world matrix to the active effect
  101763. *
  101764. * @param world the matrix to bind
  101765. */
  101766. bindOnlyWorldMatrix(world: Matrix): void;
  101767. /**
  101768. * Binds the given normal matrix to the active effect
  101769. *
  101770. * @param normalMatrix the matrix to bind
  101771. */
  101772. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  101773. bind(world: Matrix, mesh?: Mesh): void;
  101774. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  101775. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  101776. }
  101777. }
  101778. declare module BABYLON {
  101779. /**
  101780. * This groups all the flags used to control the materials channel.
  101781. */
  101782. export class MaterialFlags {
  101783. private static _DiffuseTextureEnabled;
  101784. /**
  101785. * Are diffuse textures enabled in the application.
  101786. */
  101787. static DiffuseTextureEnabled: boolean;
  101788. private static _AmbientTextureEnabled;
  101789. /**
  101790. * Are ambient textures enabled in the application.
  101791. */
  101792. static AmbientTextureEnabled: boolean;
  101793. private static _OpacityTextureEnabled;
  101794. /**
  101795. * Are opacity textures enabled in the application.
  101796. */
  101797. static OpacityTextureEnabled: boolean;
  101798. private static _ReflectionTextureEnabled;
  101799. /**
  101800. * Are reflection textures enabled in the application.
  101801. */
  101802. static ReflectionTextureEnabled: boolean;
  101803. private static _EmissiveTextureEnabled;
  101804. /**
  101805. * Are emissive textures enabled in the application.
  101806. */
  101807. static EmissiveTextureEnabled: boolean;
  101808. private static _SpecularTextureEnabled;
  101809. /**
  101810. * Are specular textures enabled in the application.
  101811. */
  101812. static SpecularTextureEnabled: boolean;
  101813. private static _BumpTextureEnabled;
  101814. /**
  101815. * Are bump textures enabled in the application.
  101816. */
  101817. static BumpTextureEnabled: boolean;
  101818. private static _LightmapTextureEnabled;
  101819. /**
  101820. * Are lightmap textures enabled in the application.
  101821. */
  101822. static LightmapTextureEnabled: boolean;
  101823. private static _RefractionTextureEnabled;
  101824. /**
  101825. * Are refraction textures enabled in the application.
  101826. */
  101827. static RefractionTextureEnabled: boolean;
  101828. private static _ColorGradingTextureEnabled;
  101829. /**
  101830. * Are color grading textures enabled in the application.
  101831. */
  101832. static ColorGradingTextureEnabled: boolean;
  101833. private static _FresnelEnabled;
  101834. /**
  101835. * Are fresnels enabled in the application.
  101836. */
  101837. static FresnelEnabled: boolean;
  101838. private static _ClearCoatTextureEnabled;
  101839. /**
  101840. * Are clear coat textures enabled in the application.
  101841. */
  101842. static ClearCoatTextureEnabled: boolean;
  101843. private static _ClearCoatBumpTextureEnabled;
  101844. /**
  101845. * Are clear coat bump textures enabled in the application.
  101846. */
  101847. static ClearCoatBumpTextureEnabled: boolean;
  101848. private static _ClearCoatTintTextureEnabled;
  101849. /**
  101850. * Are clear coat tint textures enabled in the application.
  101851. */
  101852. static ClearCoatTintTextureEnabled: boolean;
  101853. private static _SheenTextureEnabled;
  101854. /**
  101855. * Are sheen textures enabled in the application.
  101856. */
  101857. static SheenTextureEnabled: boolean;
  101858. private static _AnisotropicTextureEnabled;
  101859. /**
  101860. * Are anisotropic textures enabled in the application.
  101861. */
  101862. static AnisotropicTextureEnabled: boolean;
  101863. private static _ThicknessTextureEnabled;
  101864. /**
  101865. * Are thickness textures enabled in the application.
  101866. */
  101867. static ThicknessTextureEnabled: boolean;
  101868. }
  101869. }
  101870. declare module BABYLON {
  101871. /** @hidden */
  101872. export var defaultFragmentDeclaration: {
  101873. name: string;
  101874. shader: string;
  101875. };
  101876. }
  101877. declare module BABYLON {
  101878. /** @hidden */
  101879. export var defaultUboDeclaration: {
  101880. name: string;
  101881. shader: string;
  101882. };
  101883. }
  101884. declare module BABYLON {
  101885. /** @hidden */
  101886. export var lightFragmentDeclaration: {
  101887. name: string;
  101888. shader: string;
  101889. };
  101890. }
  101891. declare module BABYLON {
  101892. /** @hidden */
  101893. export var lightUboDeclaration: {
  101894. name: string;
  101895. shader: string;
  101896. };
  101897. }
  101898. declare module BABYLON {
  101899. /** @hidden */
  101900. export var lightsFragmentFunctions: {
  101901. name: string;
  101902. shader: string;
  101903. };
  101904. }
  101905. declare module BABYLON {
  101906. /** @hidden */
  101907. export var shadowsFragmentFunctions: {
  101908. name: string;
  101909. shader: string;
  101910. };
  101911. }
  101912. declare module BABYLON {
  101913. /** @hidden */
  101914. export var fresnelFunction: {
  101915. name: string;
  101916. shader: string;
  101917. };
  101918. }
  101919. declare module BABYLON {
  101920. /** @hidden */
  101921. export var reflectionFunction: {
  101922. name: string;
  101923. shader: string;
  101924. };
  101925. }
  101926. declare module BABYLON {
  101927. /** @hidden */
  101928. export var bumpFragmentFunctions: {
  101929. name: string;
  101930. shader: string;
  101931. };
  101932. }
  101933. declare module BABYLON {
  101934. /** @hidden */
  101935. export var logDepthDeclaration: {
  101936. name: string;
  101937. shader: string;
  101938. };
  101939. }
  101940. declare module BABYLON {
  101941. /** @hidden */
  101942. export var bumpFragment: {
  101943. name: string;
  101944. shader: string;
  101945. };
  101946. }
  101947. declare module BABYLON {
  101948. /** @hidden */
  101949. export var depthPrePass: {
  101950. name: string;
  101951. shader: string;
  101952. };
  101953. }
  101954. declare module BABYLON {
  101955. /** @hidden */
  101956. export var lightFragment: {
  101957. name: string;
  101958. shader: string;
  101959. };
  101960. }
  101961. declare module BABYLON {
  101962. /** @hidden */
  101963. export var logDepthFragment: {
  101964. name: string;
  101965. shader: string;
  101966. };
  101967. }
  101968. declare module BABYLON {
  101969. /** @hidden */
  101970. export var defaultPixelShader: {
  101971. name: string;
  101972. shader: string;
  101973. };
  101974. }
  101975. declare module BABYLON {
  101976. /** @hidden */
  101977. export var defaultVertexDeclaration: {
  101978. name: string;
  101979. shader: string;
  101980. };
  101981. }
  101982. declare module BABYLON {
  101983. /** @hidden */
  101984. export var bumpVertexDeclaration: {
  101985. name: string;
  101986. shader: string;
  101987. };
  101988. }
  101989. declare module BABYLON {
  101990. /** @hidden */
  101991. export var bumpVertex: {
  101992. name: string;
  101993. shader: string;
  101994. };
  101995. }
  101996. declare module BABYLON {
  101997. /** @hidden */
  101998. export var fogVertex: {
  101999. name: string;
  102000. shader: string;
  102001. };
  102002. }
  102003. declare module BABYLON {
  102004. /** @hidden */
  102005. export var shadowsVertex: {
  102006. name: string;
  102007. shader: string;
  102008. };
  102009. }
  102010. declare module BABYLON {
  102011. /** @hidden */
  102012. export var pointCloudVertex: {
  102013. name: string;
  102014. shader: string;
  102015. };
  102016. }
  102017. declare module BABYLON {
  102018. /** @hidden */
  102019. export var logDepthVertex: {
  102020. name: string;
  102021. shader: string;
  102022. };
  102023. }
  102024. declare module BABYLON {
  102025. /** @hidden */
  102026. export var defaultVertexShader: {
  102027. name: string;
  102028. shader: string;
  102029. };
  102030. }
  102031. declare module BABYLON {
  102032. /** @hidden */
  102033. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  102034. MAINUV1: boolean;
  102035. MAINUV2: boolean;
  102036. DIFFUSE: boolean;
  102037. DIFFUSEDIRECTUV: number;
  102038. AMBIENT: boolean;
  102039. AMBIENTDIRECTUV: number;
  102040. OPACITY: boolean;
  102041. OPACITYDIRECTUV: number;
  102042. OPACITYRGB: boolean;
  102043. REFLECTION: boolean;
  102044. EMISSIVE: boolean;
  102045. EMISSIVEDIRECTUV: number;
  102046. SPECULAR: boolean;
  102047. SPECULARDIRECTUV: number;
  102048. BUMP: boolean;
  102049. BUMPDIRECTUV: number;
  102050. PARALLAX: boolean;
  102051. PARALLAXOCCLUSION: boolean;
  102052. SPECULAROVERALPHA: boolean;
  102053. CLIPPLANE: boolean;
  102054. CLIPPLANE2: boolean;
  102055. CLIPPLANE3: boolean;
  102056. CLIPPLANE4: boolean;
  102057. ALPHATEST: boolean;
  102058. DEPTHPREPASS: boolean;
  102059. ALPHAFROMDIFFUSE: boolean;
  102060. POINTSIZE: boolean;
  102061. FOG: boolean;
  102062. SPECULARTERM: boolean;
  102063. DIFFUSEFRESNEL: boolean;
  102064. OPACITYFRESNEL: boolean;
  102065. REFLECTIONFRESNEL: boolean;
  102066. REFRACTIONFRESNEL: boolean;
  102067. EMISSIVEFRESNEL: boolean;
  102068. FRESNEL: boolean;
  102069. NORMAL: boolean;
  102070. UV1: boolean;
  102071. UV2: boolean;
  102072. VERTEXCOLOR: boolean;
  102073. VERTEXALPHA: boolean;
  102074. NUM_BONE_INFLUENCERS: number;
  102075. BonesPerMesh: number;
  102076. BONETEXTURE: boolean;
  102077. INSTANCES: boolean;
  102078. GLOSSINESS: boolean;
  102079. ROUGHNESS: boolean;
  102080. EMISSIVEASILLUMINATION: boolean;
  102081. LINKEMISSIVEWITHDIFFUSE: boolean;
  102082. REFLECTIONFRESNELFROMSPECULAR: boolean;
  102083. LIGHTMAP: boolean;
  102084. LIGHTMAPDIRECTUV: number;
  102085. OBJECTSPACE_NORMALMAP: boolean;
  102086. USELIGHTMAPASSHADOWMAP: boolean;
  102087. REFLECTIONMAP_3D: boolean;
  102088. REFLECTIONMAP_SPHERICAL: boolean;
  102089. REFLECTIONMAP_PLANAR: boolean;
  102090. REFLECTIONMAP_CUBIC: boolean;
  102091. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  102092. REFLECTIONMAP_PROJECTION: boolean;
  102093. REFLECTIONMAP_SKYBOX: boolean;
  102094. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  102095. REFLECTIONMAP_EXPLICIT: boolean;
  102096. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  102097. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  102098. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  102099. INVERTCUBICMAP: boolean;
  102100. LOGARITHMICDEPTH: boolean;
  102101. REFRACTION: boolean;
  102102. REFRACTIONMAP_3D: boolean;
  102103. REFLECTIONOVERALPHA: boolean;
  102104. TWOSIDEDLIGHTING: boolean;
  102105. SHADOWFLOAT: boolean;
  102106. MORPHTARGETS: boolean;
  102107. MORPHTARGETS_NORMAL: boolean;
  102108. MORPHTARGETS_TANGENT: boolean;
  102109. MORPHTARGETS_UV: boolean;
  102110. NUM_MORPH_INFLUENCERS: number;
  102111. NONUNIFORMSCALING: boolean;
  102112. PREMULTIPLYALPHA: boolean;
  102113. IMAGEPROCESSING: boolean;
  102114. VIGNETTE: boolean;
  102115. VIGNETTEBLENDMODEMULTIPLY: boolean;
  102116. VIGNETTEBLENDMODEOPAQUE: boolean;
  102117. TONEMAPPING: boolean;
  102118. TONEMAPPING_ACES: boolean;
  102119. CONTRAST: boolean;
  102120. COLORCURVES: boolean;
  102121. COLORGRADING: boolean;
  102122. COLORGRADING3D: boolean;
  102123. SAMPLER3DGREENDEPTH: boolean;
  102124. SAMPLER3DBGRMAP: boolean;
  102125. IMAGEPROCESSINGPOSTPROCESS: boolean;
  102126. MULTIVIEW: boolean;
  102127. /**
  102128. * If the reflection texture on this material is in linear color space
  102129. * @hidden
  102130. */
  102131. IS_REFLECTION_LINEAR: boolean;
  102132. /**
  102133. * If the refraction texture on this material is in linear color space
  102134. * @hidden
  102135. */
  102136. IS_REFRACTION_LINEAR: boolean;
  102137. EXPOSURE: boolean;
  102138. constructor();
  102139. setReflectionMode(modeToEnable: string): void;
  102140. }
  102141. /**
  102142. * This is the default material used in Babylon. It is the best trade off between quality
  102143. * and performances.
  102144. * @see http://doc.babylonjs.com/babylon101/materials
  102145. */
  102146. export class StandardMaterial extends PushMaterial {
  102147. private _diffuseTexture;
  102148. /**
  102149. * The basic texture of the material as viewed under a light.
  102150. */
  102151. diffuseTexture: Nullable<BaseTexture>;
  102152. private _ambientTexture;
  102153. /**
  102154. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  102155. */
  102156. ambientTexture: Nullable<BaseTexture>;
  102157. private _opacityTexture;
  102158. /**
  102159. * Define the transparency of the material from a texture.
  102160. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  102161. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  102162. */
  102163. opacityTexture: Nullable<BaseTexture>;
  102164. private _reflectionTexture;
  102165. /**
  102166. * Define the texture used to display the reflection.
  102167. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  102168. */
  102169. reflectionTexture: Nullable<BaseTexture>;
  102170. private _emissiveTexture;
  102171. /**
  102172. * Define texture of the material as if self lit.
  102173. * This will be mixed in the final result even in the absence of light.
  102174. */
  102175. emissiveTexture: Nullable<BaseTexture>;
  102176. private _specularTexture;
  102177. /**
  102178. * Define how the color and intensity of the highlight given by the light in the material.
  102179. */
  102180. specularTexture: Nullable<BaseTexture>;
  102181. private _bumpTexture;
  102182. /**
  102183. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  102184. * 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.
  102185. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  102186. */
  102187. bumpTexture: Nullable<BaseTexture>;
  102188. private _lightmapTexture;
  102189. /**
  102190. * Complex lighting can be computationally expensive to compute at runtime.
  102191. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  102192. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  102193. */
  102194. lightmapTexture: Nullable<BaseTexture>;
  102195. private _refractionTexture;
  102196. /**
  102197. * Define the texture used to display the refraction.
  102198. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  102199. */
  102200. refractionTexture: Nullable<BaseTexture>;
  102201. /**
  102202. * The color of the material lit by the environmental background lighting.
  102203. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  102204. */
  102205. ambientColor: Color3;
  102206. /**
  102207. * The basic color of the material as viewed under a light.
  102208. */
  102209. diffuseColor: Color3;
  102210. /**
  102211. * Define how the color and intensity of the highlight given by the light in the material.
  102212. */
  102213. specularColor: Color3;
  102214. /**
  102215. * Define the color of the material as if self lit.
  102216. * This will be mixed in the final result even in the absence of light.
  102217. */
  102218. emissiveColor: Color3;
  102219. /**
  102220. * Defines how sharp are the highlights in the material.
  102221. * The bigger the value the sharper giving a more glossy feeling to the result.
  102222. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  102223. */
  102224. specularPower: number;
  102225. private _useAlphaFromDiffuseTexture;
  102226. /**
  102227. * Does the transparency come from the diffuse texture alpha channel.
  102228. */
  102229. useAlphaFromDiffuseTexture: boolean;
  102230. private _useEmissiveAsIllumination;
  102231. /**
  102232. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  102233. */
  102234. useEmissiveAsIllumination: boolean;
  102235. private _linkEmissiveWithDiffuse;
  102236. /**
  102237. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  102238. * the emissive level when the final color is close to one.
  102239. */
  102240. linkEmissiveWithDiffuse: boolean;
  102241. private _useSpecularOverAlpha;
  102242. /**
  102243. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  102244. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  102245. */
  102246. useSpecularOverAlpha: boolean;
  102247. private _useReflectionOverAlpha;
  102248. /**
  102249. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  102250. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  102251. */
  102252. useReflectionOverAlpha: boolean;
  102253. private _disableLighting;
  102254. /**
  102255. * Does lights from the scene impacts this material.
  102256. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  102257. */
  102258. disableLighting: boolean;
  102259. private _useObjectSpaceNormalMap;
  102260. /**
  102261. * Allows using an object space normal map (instead of tangent space).
  102262. */
  102263. useObjectSpaceNormalMap: boolean;
  102264. private _useParallax;
  102265. /**
  102266. * Is parallax enabled or not.
  102267. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  102268. */
  102269. useParallax: boolean;
  102270. private _useParallaxOcclusion;
  102271. /**
  102272. * Is parallax occlusion enabled or not.
  102273. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  102274. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  102275. */
  102276. useParallaxOcclusion: boolean;
  102277. /**
  102278. * 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.
  102279. */
  102280. parallaxScaleBias: number;
  102281. private _roughness;
  102282. /**
  102283. * Helps to define how blurry the reflections should appears in the material.
  102284. */
  102285. roughness: number;
  102286. /**
  102287. * In case of refraction, define the value of the index of refraction.
  102288. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  102289. */
  102290. indexOfRefraction: number;
  102291. /**
  102292. * Invert the refraction texture alongside the y axis.
  102293. * It can be useful with procedural textures or probe for instance.
  102294. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  102295. */
  102296. invertRefractionY: boolean;
  102297. /**
  102298. * Defines the alpha limits in alpha test mode.
  102299. */
  102300. alphaCutOff: number;
  102301. private _useLightmapAsShadowmap;
  102302. /**
  102303. * In case of light mapping, define whether the map contains light or shadow informations.
  102304. */
  102305. useLightmapAsShadowmap: boolean;
  102306. private _diffuseFresnelParameters;
  102307. /**
  102308. * Define the diffuse fresnel parameters of the material.
  102309. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  102310. */
  102311. diffuseFresnelParameters: FresnelParameters;
  102312. private _opacityFresnelParameters;
  102313. /**
  102314. * Define the opacity fresnel parameters of the material.
  102315. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  102316. */
  102317. opacityFresnelParameters: FresnelParameters;
  102318. private _reflectionFresnelParameters;
  102319. /**
  102320. * Define the reflection fresnel parameters of the material.
  102321. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  102322. */
  102323. reflectionFresnelParameters: FresnelParameters;
  102324. private _refractionFresnelParameters;
  102325. /**
  102326. * Define the refraction fresnel parameters of the material.
  102327. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  102328. */
  102329. refractionFresnelParameters: FresnelParameters;
  102330. private _emissiveFresnelParameters;
  102331. /**
  102332. * Define the emissive fresnel parameters of the material.
  102333. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  102334. */
  102335. emissiveFresnelParameters: FresnelParameters;
  102336. private _useReflectionFresnelFromSpecular;
  102337. /**
  102338. * If true automatically deducts the fresnels values from the material specularity.
  102339. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  102340. */
  102341. useReflectionFresnelFromSpecular: boolean;
  102342. private _useGlossinessFromSpecularMapAlpha;
  102343. /**
  102344. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  102345. */
  102346. useGlossinessFromSpecularMapAlpha: boolean;
  102347. private _maxSimultaneousLights;
  102348. /**
  102349. * Defines the maximum number of lights that can be used in the material
  102350. */
  102351. maxSimultaneousLights: number;
  102352. private _invertNormalMapX;
  102353. /**
  102354. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  102355. */
  102356. invertNormalMapX: boolean;
  102357. private _invertNormalMapY;
  102358. /**
  102359. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  102360. */
  102361. invertNormalMapY: boolean;
  102362. private _twoSidedLighting;
  102363. /**
  102364. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  102365. */
  102366. twoSidedLighting: boolean;
  102367. /**
  102368. * Default configuration related to image processing available in the standard Material.
  102369. */
  102370. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  102371. /**
  102372. * Gets the image processing configuration used either in this material.
  102373. */
  102374. /**
  102375. * Sets the Default image processing configuration used either in the this material.
  102376. *
  102377. * If sets to null, the scene one is in use.
  102378. */
  102379. imageProcessingConfiguration: ImageProcessingConfiguration;
  102380. /**
  102381. * Keep track of the image processing observer to allow dispose and replace.
  102382. */
  102383. private _imageProcessingObserver;
  102384. /**
  102385. * Attaches a new image processing configuration to the Standard Material.
  102386. * @param configuration
  102387. */
  102388. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  102389. /**
  102390. * Gets wether the color curves effect is enabled.
  102391. */
  102392. /**
  102393. * Sets wether the color curves effect is enabled.
  102394. */
  102395. cameraColorCurvesEnabled: boolean;
  102396. /**
  102397. * Gets wether the color grading effect is enabled.
  102398. */
  102399. /**
  102400. * Gets wether the color grading effect is enabled.
  102401. */
  102402. cameraColorGradingEnabled: boolean;
  102403. /**
  102404. * Gets wether tonemapping is enabled or not.
  102405. */
  102406. /**
  102407. * Sets wether tonemapping is enabled or not
  102408. */
  102409. cameraToneMappingEnabled: boolean;
  102410. /**
  102411. * The camera exposure used on this material.
  102412. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  102413. * This corresponds to a photographic exposure.
  102414. */
  102415. /**
  102416. * The camera exposure used on this material.
  102417. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  102418. * This corresponds to a photographic exposure.
  102419. */
  102420. cameraExposure: number;
  102421. /**
  102422. * Gets The camera contrast used on this material.
  102423. */
  102424. /**
  102425. * Sets The camera contrast used on this material.
  102426. */
  102427. cameraContrast: number;
  102428. /**
  102429. * Gets the Color Grading 2D Lookup Texture.
  102430. */
  102431. /**
  102432. * Sets the Color Grading 2D Lookup Texture.
  102433. */
  102434. cameraColorGradingTexture: Nullable<BaseTexture>;
  102435. /**
  102436. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  102437. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  102438. * 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;
  102439. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  102440. */
  102441. /**
  102442. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  102443. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  102444. * 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;
  102445. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  102446. */
  102447. cameraColorCurves: Nullable<ColorCurves>;
  102448. /**
  102449. * Custom callback helping to override the default shader used in the material.
  102450. */
  102451. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  102452. protected _renderTargets: SmartArray<RenderTargetTexture>;
  102453. protected _worldViewProjectionMatrix: Matrix;
  102454. protected _globalAmbientColor: Color3;
  102455. protected _useLogarithmicDepth: boolean;
  102456. /**
  102457. * Instantiates a new standard material.
  102458. * This is the default material used in Babylon. It is the best trade off between quality
  102459. * and performances.
  102460. * @see http://doc.babylonjs.com/babylon101/materials
  102461. * @param name Define the name of the material in the scene
  102462. * @param scene Define the scene the material belong to
  102463. */
  102464. constructor(name: string, scene: Scene);
  102465. /**
  102466. * Gets a boolean indicating that current material needs to register RTT
  102467. */
  102468. readonly hasRenderTargetTextures: boolean;
  102469. /**
  102470. * Gets the current class name of the material e.g. "StandardMaterial"
  102471. * Mainly use in serialization.
  102472. * @returns the class name
  102473. */
  102474. getClassName(): string;
  102475. /**
  102476. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  102477. * You can try switching to logarithmic depth.
  102478. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  102479. */
  102480. useLogarithmicDepth: boolean;
  102481. /**
  102482. * Specifies if the material will require alpha blending
  102483. * @returns a boolean specifying if alpha blending is needed
  102484. */
  102485. needAlphaBlending(): boolean;
  102486. /**
  102487. * Specifies if this material should be rendered in alpha test mode
  102488. * @returns a boolean specifying if an alpha test is needed.
  102489. */
  102490. needAlphaTesting(): boolean;
  102491. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  102492. /**
  102493. * Get the texture used for alpha test purpose.
  102494. * @returns the diffuse texture in case of the standard material.
  102495. */
  102496. getAlphaTestTexture(): Nullable<BaseTexture>;
  102497. /**
  102498. * Get if the submesh is ready to be used and all its information available.
  102499. * Child classes can use it to update shaders
  102500. * @param mesh defines the mesh to check
  102501. * @param subMesh defines which submesh to check
  102502. * @param useInstances specifies that instances should be used
  102503. * @returns a boolean indicating that the submesh is ready or not
  102504. */
  102505. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  102506. /**
  102507. * Builds the material UBO layouts.
  102508. * Used internally during the effect preparation.
  102509. */
  102510. buildUniformLayout(): void;
  102511. /**
  102512. * Unbinds the material from the mesh
  102513. */
  102514. unbind(): void;
  102515. /**
  102516. * Binds the submesh to this material by preparing the effect and shader to draw
  102517. * @param world defines the world transformation matrix
  102518. * @param mesh defines the mesh containing the submesh
  102519. * @param subMesh defines the submesh to bind the material to
  102520. */
  102521. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  102522. /**
  102523. * Get the list of animatables in the material.
  102524. * @returns the list of animatables object used in the material
  102525. */
  102526. getAnimatables(): IAnimatable[];
  102527. /**
  102528. * Gets the active textures from the material
  102529. * @returns an array of textures
  102530. */
  102531. getActiveTextures(): BaseTexture[];
  102532. /**
  102533. * Specifies if the material uses a texture
  102534. * @param texture defines the texture to check against the material
  102535. * @returns a boolean specifying if the material uses the texture
  102536. */
  102537. hasTexture(texture: BaseTexture): boolean;
  102538. /**
  102539. * Disposes the material
  102540. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  102541. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  102542. */
  102543. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  102544. /**
  102545. * Makes a duplicate of the material, and gives it a new name
  102546. * @param name defines the new name for the duplicated material
  102547. * @returns the cloned material
  102548. */
  102549. clone(name: string): StandardMaterial;
  102550. /**
  102551. * Serializes this material in a JSON representation
  102552. * @returns the serialized material object
  102553. */
  102554. serialize(): any;
  102555. /**
  102556. * Creates a standard material from parsed material data
  102557. * @param source defines the JSON representation of the material
  102558. * @param scene defines the hosting scene
  102559. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  102560. * @returns a new standard material
  102561. */
  102562. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  102563. /**
  102564. * Are diffuse textures enabled in the application.
  102565. */
  102566. static DiffuseTextureEnabled: boolean;
  102567. /**
  102568. * Are ambient textures enabled in the application.
  102569. */
  102570. static AmbientTextureEnabled: boolean;
  102571. /**
  102572. * Are opacity textures enabled in the application.
  102573. */
  102574. static OpacityTextureEnabled: boolean;
  102575. /**
  102576. * Are reflection textures enabled in the application.
  102577. */
  102578. static ReflectionTextureEnabled: boolean;
  102579. /**
  102580. * Are emissive textures enabled in the application.
  102581. */
  102582. static EmissiveTextureEnabled: boolean;
  102583. /**
  102584. * Are specular textures enabled in the application.
  102585. */
  102586. static SpecularTextureEnabled: boolean;
  102587. /**
  102588. * Are bump textures enabled in the application.
  102589. */
  102590. static BumpTextureEnabled: boolean;
  102591. /**
  102592. * Are lightmap textures enabled in the application.
  102593. */
  102594. static LightmapTextureEnabled: boolean;
  102595. /**
  102596. * Are refraction textures enabled in the application.
  102597. */
  102598. static RefractionTextureEnabled: boolean;
  102599. /**
  102600. * Are color grading textures enabled in the application.
  102601. */
  102602. static ColorGradingTextureEnabled: boolean;
  102603. /**
  102604. * Are fresnels enabled in the application.
  102605. */
  102606. static FresnelEnabled: boolean;
  102607. }
  102608. }
  102609. declare module BABYLON {
  102610. /**
  102611. * A class extending Texture allowing drawing on a texture
  102612. * @see http://doc.babylonjs.com/how_to/dynamictexture
  102613. */
  102614. export class DynamicTexture extends Texture {
  102615. private _generateMipMaps;
  102616. private _canvas;
  102617. private _context;
  102618. private _engine;
  102619. /**
  102620. * Creates a DynamicTexture
  102621. * @param name defines the name of the texture
  102622. * @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
  102623. * @param scene defines the scene where you want the texture
  102624. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  102625. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  102626. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  102627. */
  102628. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  102629. /**
  102630. * Get the current class name of the texture useful for serialization or dynamic coding.
  102631. * @returns "DynamicTexture"
  102632. */
  102633. getClassName(): string;
  102634. /**
  102635. * Gets the current state of canRescale
  102636. */
  102637. readonly canRescale: boolean;
  102638. private _recreate;
  102639. /**
  102640. * Scales the texture
  102641. * @param ratio the scale factor to apply to both width and height
  102642. */
  102643. scale(ratio: number): void;
  102644. /**
  102645. * Resizes the texture
  102646. * @param width the new width
  102647. * @param height the new height
  102648. */
  102649. scaleTo(width: number, height: number): void;
  102650. /**
  102651. * Gets the context of the canvas used by the texture
  102652. * @returns the canvas context of the dynamic texture
  102653. */
  102654. getContext(): CanvasRenderingContext2D;
  102655. /**
  102656. * Clears the texture
  102657. */
  102658. clear(): void;
  102659. /**
  102660. * Updates the texture
  102661. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  102662. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  102663. */
  102664. update(invertY?: boolean, premulAlpha?: boolean): void;
  102665. /**
  102666. * Draws text onto the texture
  102667. * @param text defines the text to be drawn
  102668. * @param x defines the placement of the text from the left
  102669. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  102670. * @param font defines the font to be used with font-style, font-size, font-name
  102671. * @param color defines the color used for the text
  102672. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  102673. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  102674. * @param update defines whether texture is immediately update (default is true)
  102675. */
  102676. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  102677. /**
  102678. * Clones the texture
  102679. * @returns the clone of the texture.
  102680. */
  102681. clone(): DynamicTexture;
  102682. /**
  102683. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  102684. * @returns a serialized dynamic texture object
  102685. */
  102686. serialize(): any;
  102687. /** @hidden */
  102688. _rebuild(): void;
  102689. }
  102690. }
  102691. declare module BABYLON {
  102692. /** @hidden */
  102693. export var imageProcessingPixelShader: {
  102694. name: string;
  102695. shader: string;
  102696. };
  102697. }
  102698. declare module BABYLON {
  102699. /**
  102700. * ImageProcessingPostProcess
  102701. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  102702. */
  102703. export class ImageProcessingPostProcess extends PostProcess {
  102704. /**
  102705. * Default configuration related to image processing available in the PBR Material.
  102706. */
  102707. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  102708. /**
  102709. * Gets the image processing configuration used either in this material.
  102710. */
  102711. /**
  102712. * Sets the Default image processing configuration used either in the this material.
  102713. *
  102714. * If sets to null, the scene one is in use.
  102715. */
  102716. imageProcessingConfiguration: ImageProcessingConfiguration;
  102717. /**
  102718. * Keep track of the image processing observer to allow dispose and replace.
  102719. */
  102720. private _imageProcessingObserver;
  102721. /**
  102722. * Attaches a new image processing configuration to the PBR Material.
  102723. * @param configuration
  102724. */
  102725. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  102726. /**
  102727. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  102728. */
  102729. /**
  102730. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  102731. */
  102732. colorCurves: Nullable<ColorCurves>;
  102733. /**
  102734. * Gets wether the color curves effect is enabled.
  102735. */
  102736. /**
  102737. * Sets wether the color curves effect is enabled.
  102738. */
  102739. colorCurvesEnabled: boolean;
  102740. /**
  102741. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  102742. */
  102743. /**
  102744. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  102745. */
  102746. colorGradingTexture: Nullable<BaseTexture>;
  102747. /**
  102748. * Gets wether the color grading effect is enabled.
  102749. */
  102750. /**
  102751. * Gets wether the color grading effect is enabled.
  102752. */
  102753. colorGradingEnabled: boolean;
  102754. /**
  102755. * Gets exposure used in the effect.
  102756. */
  102757. /**
  102758. * Sets exposure used in the effect.
  102759. */
  102760. exposure: number;
  102761. /**
  102762. * Gets wether tonemapping is enabled or not.
  102763. */
  102764. /**
  102765. * Sets wether tonemapping is enabled or not
  102766. */
  102767. toneMappingEnabled: boolean;
  102768. /**
  102769. * Gets the type of tone mapping effect.
  102770. */
  102771. /**
  102772. * Sets the type of tone mapping effect.
  102773. */
  102774. toneMappingType: number;
  102775. /**
  102776. * Gets contrast used in the effect.
  102777. */
  102778. /**
  102779. * Sets contrast used in the effect.
  102780. */
  102781. contrast: number;
  102782. /**
  102783. * Gets Vignette stretch size.
  102784. */
  102785. /**
  102786. * Sets Vignette stretch size.
  102787. */
  102788. vignetteStretch: number;
  102789. /**
  102790. * Gets Vignette centre X Offset.
  102791. */
  102792. /**
  102793. * Sets Vignette centre X Offset.
  102794. */
  102795. vignetteCentreX: number;
  102796. /**
  102797. * Gets Vignette centre Y Offset.
  102798. */
  102799. /**
  102800. * Sets Vignette centre Y Offset.
  102801. */
  102802. vignetteCentreY: number;
  102803. /**
  102804. * Gets Vignette weight or intensity of the vignette effect.
  102805. */
  102806. /**
  102807. * Sets Vignette weight or intensity of the vignette effect.
  102808. */
  102809. vignetteWeight: number;
  102810. /**
  102811. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  102812. * if vignetteEnabled is set to true.
  102813. */
  102814. /**
  102815. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  102816. * if vignetteEnabled is set to true.
  102817. */
  102818. vignetteColor: Color4;
  102819. /**
  102820. * Gets Camera field of view used by the Vignette effect.
  102821. */
  102822. /**
  102823. * Sets Camera field of view used by the Vignette effect.
  102824. */
  102825. vignetteCameraFov: number;
  102826. /**
  102827. * Gets the vignette blend mode allowing different kind of effect.
  102828. */
  102829. /**
  102830. * Sets the vignette blend mode allowing different kind of effect.
  102831. */
  102832. vignetteBlendMode: number;
  102833. /**
  102834. * Gets wether the vignette effect is enabled.
  102835. */
  102836. /**
  102837. * Sets wether the vignette effect is enabled.
  102838. */
  102839. vignetteEnabled: boolean;
  102840. private _fromLinearSpace;
  102841. /**
  102842. * Gets wether the input of the processing is in Gamma or Linear Space.
  102843. */
  102844. /**
  102845. * Sets wether the input of the processing is in Gamma or Linear Space.
  102846. */
  102847. fromLinearSpace: boolean;
  102848. /**
  102849. * Defines cache preventing GC.
  102850. */
  102851. private _defines;
  102852. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  102853. /**
  102854. * "ImageProcessingPostProcess"
  102855. * @returns "ImageProcessingPostProcess"
  102856. */
  102857. getClassName(): string;
  102858. protected _updateParameters(): void;
  102859. dispose(camera?: Camera): void;
  102860. }
  102861. }
  102862. declare module BABYLON {
  102863. /**
  102864. * Class containing static functions to help procedurally build meshes
  102865. */
  102866. export class GroundBuilder {
  102867. /**
  102868. * Creates a ground mesh
  102869. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  102870. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  102871. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  102872. * @param name defines the name of the mesh
  102873. * @param options defines the options used to create the mesh
  102874. * @param scene defines the hosting scene
  102875. * @returns the ground mesh
  102876. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  102877. */
  102878. static CreateGround(name: string, options: {
  102879. width?: number;
  102880. height?: number;
  102881. subdivisions?: number;
  102882. subdivisionsX?: number;
  102883. subdivisionsY?: number;
  102884. updatable?: boolean;
  102885. }, scene: any): Mesh;
  102886. /**
  102887. * Creates a tiled ground mesh
  102888. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  102889. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  102890. * * 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
  102891. * * 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
  102892. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  102893. * @param name defines the name of the mesh
  102894. * @param options defines the options used to create the mesh
  102895. * @param scene defines the hosting scene
  102896. * @returns the tiled ground mesh
  102897. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  102898. */
  102899. static CreateTiledGround(name: string, options: {
  102900. xmin: number;
  102901. zmin: number;
  102902. xmax: number;
  102903. zmax: number;
  102904. subdivisions?: {
  102905. w: number;
  102906. h: number;
  102907. };
  102908. precision?: {
  102909. w: number;
  102910. h: number;
  102911. };
  102912. updatable?: boolean;
  102913. }, scene?: Nullable<Scene>): Mesh;
  102914. /**
  102915. * Creates a ground mesh from a height map
  102916. * * The parameter `url` sets the URL of the height map image resource.
  102917. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  102918. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  102919. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  102920. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  102921. * * 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.
  102922. * * 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).
  102923. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  102924. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  102925. * @param name defines the name of the mesh
  102926. * @param url defines the url to the height map
  102927. * @param options defines the options used to create the mesh
  102928. * @param scene defines the hosting scene
  102929. * @returns the ground mesh
  102930. * @see https://doc.babylonjs.com/babylon101/height_map
  102931. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  102932. */
  102933. static CreateGroundFromHeightMap(name: string, url: string, options: {
  102934. width?: number;
  102935. height?: number;
  102936. subdivisions?: number;
  102937. minHeight?: number;
  102938. maxHeight?: number;
  102939. colorFilter?: Color3;
  102940. alphaFilter?: number;
  102941. updatable?: boolean;
  102942. onReady?: (mesh: GroundMesh) => void;
  102943. }, scene?: Nullable<Scene>): GroundMesh;
  102944. }
  102945. }
  102946. declare module BABYLON {
  102947. /**
  102948. * Class containing static functions to help procedurally build meshes
  102949. */
  102950. export class TorusBuilder {
  102951. /**
  102952. * Creates a torus mesh
  102953. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  102954. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  102955. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  102956. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  102957. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  102958. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  102959. * @param name defines the name of the mesh
  102960. * @param options defines the options used to create the mesh
  102961. * @param scene defines the hosting scene
  102962. * @returns the torus mesh
  102963. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  102964. */
  102965. static CreateTorus(name: string, options: {
  102966. diameter?: number;
  102967. thickness?: number;
  102968. tessellation?: number;
  102969. updatable?: boolean;
  102970. sideOrientation?: number;
  102971. frontUVs?: Vector4;
  102972. backUVs?: Vector4;
  102973. }, scene: any): Mesh;
  102974. }
  102975. }
  102976. declare module BABYLON {
  102977. /**
  102978. * Class containing static functions to help procedurally build meshes
  102979. */
  102980. export class CylinderBuilder {
  102981. /**
  102982. * Creates a cylinder or a cone mesh
  102983. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  102984. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  102985. * * 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.
  102986. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  102987. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  102988. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  102989. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  102990. * * 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).
  102991. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  102992. * * 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).
  102993. * * 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
  102994. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  102995. * * 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
  102996. * * 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.
  102997. * * If `enclose` is false, a ring surface is one element.
  102998. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  102999. * * 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
  103000. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103001. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103002. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  103003. * @param name defines the name of the mesh
  103004. * @param options defines the options used to create the mesh
  103005. * @param scene defines the hosting scene
  103006. * @returns the cylinder mesh
  103007. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  103008. */
  103009. static CreateCylinder(name: string, options: {
  103010. height?: number;
  103011. diameterTop?: number;
  103012. diameterBottom?: number;
  103013. diameter?: number;
  103014. tessellation?: number;
  103015. subdivisions?: number;
  103016. arc?: number;
  103017. faceColors?: Color4[];
  103018. faceUV?: Vector4[];
  103019. updatable?: boolean;
  103020. hasRings?: boolean;
  103021. enclose?: boolean;
  103022. cap?: number;
  103023. sideOrientation?: number;
  103024. frontUVs?: Vector4;
  103025. backUVs?: Vector4;
  103026. }, scene: any): Mesh;
  103027. }
  103028. }
  103029. declare module BABYLON {
  103030. /**
  103031. * Options to modify the vr teleportation behavior.
  103032. */
  103033. export interface VRTeleportationOptions {
  103034. /**
  103035. * The name of the mesh which should be used as the teleportation floor. (default: null)
  103036. */
  103037. floorMeshName?: string;
  103038. /**
  103039. * A list of meshes to be used as the teleportation floor. (default: empty)
  103040. */
  103041. floorMeshes?: Mesh[];
  103042. }
  103043. /**
  103044. * Options to modify the vr experience helper's behavior.
  103045. */
  103046. export interface VRExperienceHelperOptions extends WebVROptions {
  103047. /**
  103048. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  103049. */
  103050. createDeviceOrientationCamera?: boolean;
  103051. /**
  103052. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  103053. */
  103054. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  103055. /**
  103056. * Uses the main button on the controller to toggle the laser casted. (default: true)
  103057. */
  103058. laserToggle?: boolean;
  103059. /**
  103060. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  103061. */
  103062. floorMeshes?: Mesh[];
  103063. /**
  103064. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  103065. */
  103066. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  103067. }
  103068. /**
  103069. * Event containing information after VR has been entered
  103070. */
  103071. export class OnAfterEnteringVRObservableEvent {
  103072. /**
  103073. * If entering vr was successful
  103074. */
  103075. success: boolean;
  103076. }
  103077. /**
  103078. * Helps to quickly add VR support to an existing scene.
  103079. * See http://doc.babylonjs.com/how_to/webvr_helper
  103080. */
  103081. export class VRExperienceHelper {
  103082. /** Options to modify the vr experience helper's behavior. */
  103083. webVROptions: VRExperienceHelperOptions;
  103084. private _scene;
  103085. private _position;
  103086. private _btnVR;
  103087. private _btnVRDisplayed;
  103088. private _webVRsupported;
  103089. private _webVRready;
  103090. private _webVRrequesting;
  103091. private _webVRpresenting;
  103092. private _hasEnteredVR;
  103093. private _fullscreenVRpresenting;
  103094. private _canvas;
  103095. private _webVRCamera;
  103096. private _vrDeviceOrientationCamera;
  103097. private _deviceOrientationCamera;
  103098. private _existingCamera;
  103099. private _onKeyDown;
  103100. private _onVrDisplayPresentChange;
  103101. private _onVRDisplayChanged;
  103102. private _onVRRequestPresentStart;
  103103. private _onVRRequestPresentComplete;
  103104. /**
  103105. * Observable raised right before entering VR.
  103106. */
  103107. onEnteringVRObservable: Observable<VRExperienceHelper>;
  103108. /**
  103109. * Observable raised when entering VR has completed.
  103110. */
  103111. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  103112. /**
  103113. * Observable raised when exiting VR.
  103114. */
  103115. onExitingVRObservable: Observable<VRExperienceHelper>;
  103116. /**
  103117. * Observable raised when controller mesh is loaded.
  103118. */
  103119. onControllerMeshLoadedObservable: Observable<WebVRController>;
  103120. /** Return this.onEnteringVRObservable
  103121. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  103122. */
  103123. readonly onEnteringVR: Observable<VRExperienceHelper>;
  103124. /** Return this.onExitingVRObservable
  103125. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  103126. */
  103127. readonly onExitingVR: Observable<VRExperienceHelper>;
  103128. /** Return this.onControllerMeshLoadedObservable
  103129. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  103130. */
  103131. readonly onControllerMeshLoaded: Observable<WebVRController>;
  103132. private _rayLength;
  103133. private _useCustomVRButton;
  103134. private _teleportationRequested;
  103135. private _teleportActive;
  103136. private _floorMeshName;
  103137. private _floorMeshesCollection;
  103138. private _rotationAllowed;
  103139. private _teleportBackwardsVector;
  103140. private _teleportationTarget;
  103141. private _isDefaultTeleportationTarget;
  103142. private _postProcessMove;
  103143. private _teleportationFillColor;
  103144. private _teleportationBorderColor;
  103145. private _rotationAngle;
  103146. private _haloCenter;
  103147. private _cameraGazer;
  103148. private _padSensibilityUp;
  103149. private _padSensibilityDown;
  103150. private _leftController;
  103151. private _rightController;
  103152. /**
  103153. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  103154. */
  103155. onNewMeshSelected: Observable<AbstractMesh>;
  103156. /**
  103157. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  103158. */
  103159. onNewMeshPicked: Observable<PickingInfo>;
  103160. private _circleEase;
  103161. /**
  103162. * Observable raised before camera teleportation
  103163. */
  103164. onBeforeCameraTeleport: Observable<Vector3>;
  103165. /**
  103166. * Observable raised after camera teleportation
  103167. */
  103168. onAfterCameraTeleport: Observable<Vector3>;
  103169. /**
  103170. * Observable raised when current selected mesh gets unselected
  103171. */
  103172. onSelectedMeshUnselected: Observable<AbstractMesh>;
  103173. private _raySelectionPredicate;
  103174. /**
  103175. * To be optionaly changed by user to define custom ray selection
  103176. */
  103177. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  103178. /**
  103179. * To be optionaly changed by user to define custom selection logic (after ray selection)
  103180. */
  103181. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  103182. /**
  103183. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  103184. */
  103185. teleportationEnabled: boolean;
  103186. private _defaultHeight;
  103187. private _teleportationInitialized;
  103188. private _interactionsEnabled;
  103189. private _interactionsRequested;
  103190. private _displayGaze;
  103191. private _displayLaserPointer;
  103192. /**
  103193. * The mesh used to display where the user is going to teleport.
  103194. */
  103195. /**
  103196. * Sets the mesh to be used to display where the user is going to teleport.
  103197. */
  103198. teleportationTarget: Mesh;
  103199. /**
  103200. * 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
  103201. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  103202. * See http://doc.babylonjs.com/resources/baking_transformations
  103203. */
  103204. gazeTrackerMesh: Mesh;
  103205. /**
  103206. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  103207. */
  103208. updateGazeTrackerScale: boolean;
  103209. /**
  103210. * If the gaze trackers color should be updated when selecting meshes
  103211. */
  103212. updateGazeTrackerColor: boolean;
  103213. /**
  103214. * The gaze tracking mesh corresponding to the left controller
  103215. */
  103216. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  103217. /**
  103218. * The gaze tracking mesh corresponding to the right controller
  103219. */
  103220. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  103221. /**
  103222. * If the ray of the gaze should be displayed.
  103223. */
  103224. /**
  103225. * Sets if the ray of the gaze should be displayed.
  103226. */
  103227. displayGaze: boolean;
  103228. /**
  103229. * If the ray of the LaserPointer should be displayed.
  103230. */
  103231. /**
  103232. * Sets if the ray of the LaserPointer should be displayed.
  103233. */
  103234. displayLaserPointer: boolean;
  103235. /**
  103236. * The deviceOrientationCamera used as the camera when not in VR.
  103237. */
  103238. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  103239. /**
  103240. * Based on the current WebVR support, returns the current VR camera used.
  103241. */
  103242. readonly currentVRCamera: Nullable<Camera>;
  103243. /**
  103244. * The webVRCamera which is used when in VR.
  103245. */
  103246. readonly webVRCamera: WebVRFreeCamera;
  103247. /**
  103248. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  103249. */
  103250. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  103251. private readonly _teleportationRequestInitiated;
  103252. /**
  103253. * Defines wether or not Pointer lock should be requested when switching to
  103254. * full screen.
  103255. */
  103256. requestPointerLockOnFullScreen: boolean;
  103257. /**
  103258. * Instantiates a VRExperienceHelper.
  103259. * Helps to quickly add VR support to an existing scene.
  103260. * @param scene The scene the VRExperienceHelper belongs to.
  103261. * @param webVROptions Options to modify the vr experience helper's behavior.
  103262. */
  103263. constructor(scene: Scene,
  103264. /** Options to modify the vr experience helper's behavior. */
  103265. webVROptions?: VRExperienceHelperOptions);
  103266. private _onDefaultMeshLoaded;
  103267. private _onResize;
  103268. private _onFullscreenChange;
  103269. /**
  103270. * Gets a value indicating if we are currently in VR mode.
  103271. */
  103272. readonly isInVRMode: boolean;
  103273. private onVrDisplayPresentChange;
  103274. private onVRDisplayChanged;
  103275. private moveButtonToBottomRight;
  103276. private displayVRButton;
  103277. private updateButtonVisibility;
  103278. private _cachedAngularSensibility;
  103279. /**
  103280. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  103281. * Otherwise, will use the fullscreen API.
  103282. */
  103283. enterVR(): void;
  103284. /**
  103285. * Attempt to exit VR, or fullscreen.
  103286. */
  103287. exitVR(): void;
  103288. /**
  103289. * The position of the vr experience helper.
  103290. */
  103291. /**
  103292. * Sets the position of the vr experience helper.
  103293. */
  103294. position: Vector3;
  103295. /**
  103296. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  103297. */
  103298. enableInteractions(): void;
  103299. private readonly _noControllerIsActive;
  103300. private beforeRender;
  103301. private _isTeleportationFloor;
  103302. /**
  103303. * Adds a floor mesh to be used for teleportation.
  103304. * @param floorMesh the mesh to be used for teleportation.
  103305. */
  103306. addFloorMesh(floorMesh: Mesh): void;
  103307. /**
  103308. * Removes a floor mesh from being used for teleportation.
  103309. * @param floorMesh the mesh to be removed.
  103310. */
  103311. removeFloorMesh(floorMesh: Mesh): void;
  103312. /**
  103313. * Enables interactions and teleportation using the VR controllers and gaze.
  103314. * @param vrTeleportationOptions options to modify teleportation behavior.
  103315. */
  103316. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  103317. private _onNewGamepadConnected;
  103318. private _tryEnableInteractionOnController;
  103319. private _onNewGamepadDisconnected;
  103320. private _enableInteractionOnController;
  103321. private _checkTeleportWithRay;
  103322. private _checkRotate;
  103323. private _checkTeleportBackwards;
  103324. private _enableTeleportationOnController;
  103325. private _createTeleportationCircles;
  103326. private _displayTeleportationTarget;
  103327. private _hideTeleportationTarget;
  103328. private _rotateCamera;
  103329. private _moveTeleportationSelectorTo;
  103330. private _workingVector;
  103331. private _workingQuaternion;
  103332. private _workingMatrix;
  103333. /**
  103334. * Teleports the users feet to the desired location
  103335. * @param location The location where the user's feet should be placed
  103336. */
  103337. teleportCamera(location: Vector3): void;
  103338. private _convertNormalToDirectionOfRay;
  103339. private _castRayAndSelectObject;
  103340. private _notifySelectedMeshUnselected;
  103341. /**
  103342. * Sets the color of the laser ray from the vr controllers.
  103343. * @param color new color for the ray.
  103344. */
  103345. changeLaserColor(color: Color3): void;
  103346. /**
  103347. * Sets the color of the ray from the vr headsets gaze.
  103348. * @param color new color for the ray.
  103349. */
  103350. changeGazeColor(color: Color3): void;
  103351. /**
  103352. * Exits VR and disposes of the vr experience helper
  103353. */
  103354. dispose(): void;
  103355. /**
  103356. * Gets the name of the VRExperienceHelper class
  103357. * @returns "VRExperienceHelper"
  103358. */
  103359. getClassName(): string;
  103360. }
  103361. }
  103362. declare module BABYLON {
  103363. /**
  103364. * Manages an XRSession
  103365. * @see https://doc.babylonjs.com/how_to/webxr
  103366. */
  103367. export class WebXRSessionManager implements IDisposable {
  103368. private scene;
  103369. /**
  103370. * Fires every time a new xrFrame arrives which can be used to update the camera
  103371. */
  103372. onXRFrameObservable: Observable<any>;
  103373. /**
  103374. * Fires when the xr session is ended either by the device or manually done
  103375. */
  103376. onXRSessionEnded: Observable<any>;
  103377. /** @hidden */
  103378. _xrSession: XRSession;
  103379. /** @hidden */
  103380. _frameOfReference: XRFrameOfReference;
  103381. /** @hidden */
  103382. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  103383. /** @hidden */
  103384. _currentXRFrame: Nullable<XRFrame>;
  103385. private _xrNavigator;
  103386. private _xrDevice;
  103387. private _tmpMatrix;
  103388. /**
  103389. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  103390. * @param scene The scene which the session should be created for
  103391. */
  103392. constructor(scene: Scene);
  103393. /**
  103394. * Initializes the manager
  103395. * After initialization enterXR can be called to start an XR session
  103396. * @returns Promise which resolves after it is initialized
  103397. */
  103398. initializeAsync(): Promise<void>;
  103399. /**
  103400. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  103401. * @param sessionCreationOptions xr options to create the session with
  103402. * @param frameOfReferenceType option to configure how the xr pose is expressed
  103403. * @returns Promise which resolves after it enters XR
  103404. */
  103405. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  103406. /**
  103407. * Stops the xrSession and restores the renderloop
  103408. * @returns Promise which resolves after it exits XR
  103409. */
  103410. exitXRAsync(): Promise<void>;
  103411. /**
  103412. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  103413. * @param ray ray to cast into the environment
  103414. * @returns Promise which resolves with a collision point in the environment if it exists
  103415. */
  103416. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  103417. /**
  103418. * Checks if a session would be supported for the creation options specified
  103419. * @param options creation options to check if they are supported
  103420. * @returns true if supported
  103421. */
  103422. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  103423. /**
  103424. * @hidden
  103425. * Converts the render layer of xrSession to a render target
  103426. * @param session session to create render target for
  103427. * @param scene scene the new render target should be created for
  103428. */
  103429. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  103430. /**
  103431. * Disposes of the session manager
  103432. */
  103433. dispose(): void;
  103434. }
  103435. }
  103436. declare module BABYLON {
  103437. /**
  103438. * WebXR Camera which holds the views for the xrSession
  103439. * @see https://doc.babylonjs.com/how_to/webxr
  103440. */
  103441. export class WebXRCamera extends FreeCamera {
  103442. private static _TmpMatrix;
  103443. /**
  103444. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  103445. * @param name the name of the camera
  103446. * @param scene the scene to add the camera to
  103447. */
  103448. constructor(name: string, scene: Scene);
  103449. private _updateNumberOfRigCameras;
  103450. /** @hidden */
  103451. _updateForDualEyeDebugging(pupilDistance?: number): void;
  103452. /**
  103453. * Updates the cameras position from the current pose information of the XR session
  103454. * @param xrSessionManager the session containing pose information
  103455. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  103456. */
  103457. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  103458. }
  103459. }
  103460. declare module BABYLON {
  103461. /**
  103462. * States of the webXR experience
  103463. */
  103464. export enum WebXRState {
  103465. /**
  103466. * Transitioning to being in XR mode
  103467. */
  103468. ENTERING_XR = 0,
  103469. /**
  103470. * Transitioning to non XR mode
  103471. */
  103472. EXITING_XR = 1,
  103473. /**
  103474. * In XR mode and presenting
  103475. */
  103476. IN_XR = 2,
  103477. /**
  103478. * Not entered XR mode
  103479. */
  103480. NOT_IN_XR = 3
  103481. }
  103482. /**
  103483. * Helper class used to enable XR
  103484. * @see https://doc.babylonjs.com/how_to/webxr
  103485. */
  103486. export class WebXRExperienceHelper implements IDisposable {
  103487. private scene;
  103488. /**
  103489. * 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
  103490. */
  103491. container: AbstractMesh;
  103492. /**
  103493. * Camera used to render xr content
  103494. */
  103495. camera: WebXRCamera;
  103496. /**
  103497. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  103498. */
  103499. state: WebXRState;
  103500. private _setState;
  103501. private static _TmpVector;
  103502. /**
  103503. * Fires when the state of the experience helper has changed
  103504. */
  103505. onStateChangedObservable: Observable<WebXRState>;
  103506. /** @hidden */
  103507. _sessionManager: WebXRSessionManager;
  103508. private _nonVRCamera;
  103509. private _originalSceneAutoClear;
  103510. private _supported;
  103511. /**
  103512. * Creates the experience helper
  103513. * @param scene the scene to attach the experience helper to
  103514. * @returns a promise for the experience helper
  103515. */
  103516. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  103517. /**
  103518. * Creates a WebXRExperienceHelper
  103519. * @param scene The scene the helper should be created in
  103520. */
  103521. private constructor();
  103522. /**
  103523. * Exits XR mode and returns the scene to its original state
  103524. * @returns promise that resolves after xr mode has exited
  103525. */
  103526. exitXRAsync(): Promise<void>;
  103527. /**
  103528. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  103529. * @param sessionCreationOptions options for the XR session
  103530. * @param frameOfReference frame of reference of the XR session
  103531. * @returns promise that resolves after xr mode has entered
  103532. */
  103533. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  103534. /**
  103535. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  103536. * @param ray ray to cast into the environment
  103537. * @returns Promise which resolves with a collision point in the environment if it exists
  103538. */
  103539. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  103540. /**
  103541. * Updates the global position of the camera by moving the camera's container
  103542. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  103543. * @param position The desired global position of the camera
  103544. */
  103545. setPositionOfCameraUsingContainer(position: Vector3): void;
  103546. /**
  103547. * Rotates the xr camera by rotating the camera's container around the camera's position
  103548. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  103549. * @param rotation the desired quaternion rotation to apply to the camera
  103550. */
  103551. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  103552. /**
  103553. * Checks if the creation options are supported by the xr session
  103554. * @param options creation options
  103555. * @returns true if supported
  103556. */
  103557. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  103558. /**
  103559. * Disposes of the experience helper
  103560. */
  103561. dispose(): void;
  103562. }
  103563. }
  103564. declare module BABYLON {
  103565. /**
  103566. * Button which can be used to enter a different mode of XR
  103567. */
  103568. export class WebXREnterExitUIButton {
  103569. /** button element */
  103570. element: HTMLElement;
  103571. /** XR initialization options for the button */
  103572. initializationOptions: XRSessionCreationOptions;
  103573. /**
  103574. * Creates a WebXREnterExitUIButton
  103575. * @param element button element
  103576. * @param initializationOptions XR initialization options for the button
  103577. */
  103578. constructor(
  103579. /** button element */
  103580. element: HTMLElement,
  103581. /** XR initialization options for the button */
  103582. initializationOptions: XRSessionCreationOptions);
  103583. /**
  103584. * Overwritable function which can be used to update the button's visuals when the state changes
  103585. * @param activeButton the current active button in the UI
  103586. */
  103587. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  103588. }
  103589. /**
  103590. * Options to create the webXR UI
  103591. */
  103592. export class WebXREnterExitUIOptions {
  103593. /**
  103594. * Context to enter xr with
  103595. */
  103596. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  103597. /**
  103598. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  103599. */
  103600. customButtons?: Array<WebXREnterExitUIButton>;
  103601. }
  103602. /**
  103603. * UI to allow the user to enter/exit XR mode
  103604. */
  103605. export class WebXREnterExitUI implements IDisposable {
  103606. private scene;
  103607. private _overlay;
  103608. private _buttons;
  103609. private _activeButton;
  103610. /**
  103611. * Fired every time the active button is changed.
  103612. *
  103613. * When xr is entered via a button that launches xr that button will be the callback parameter
  103614. *
  103615. * When exiting xr the callback parameter will be null)
  103616. */
  103617. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  103618. /**
  103619. * Creates UI to allow the user to enter/exit XR mode
  103620. * @param scene the scene to add the ui to
  103621. * @param helper the xr experience helper to enter/exit xr with
  103622. * @param options options to configure the UI
  103623. * @returns the created ui
  103624. */
  103625. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  103626. private constructor();
  103627. private _updateButtons;
  103628. /**
  103629. * Disposes of the object
  103630. */
  103631. dispose(): void;
  103632. }
  103633. }
  103634. declare module BABYLON {
  103635. /**
  103636. * Represents an XR input
  103637. */
  103638. export class WebXRController {
  103639. /**
  103640. * 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
  103641. */
  103642. grip?: AbstractMesh;
  103643. /**
  103644. * Pointer which can be used to select objects or attach a visible laser to
  103645. */
  103646. pointer: AbstractMesh;
  103647. /**
  103648. * Creates the controller
  103649. * @see https://doc.babylonjs.com/how_to/webxr
  103650. * @param scene the scene which the controller should be associated to
  103651. */
  103652. constructor(scene: Scene);
  103653. /**
  103654. * Disposes of the object
  103655. */
  103656. dispose(): void;
  103657. }
  103658. /**
  103659. * XR input used to track XR inputs such as controllers/rays
  103660. */
  103661. export class WebXRInput implements IDisposable {
  103662. private helper;
  103663. /**
  103664. * XR controllers being tracked
  103665. */
  103666. controllers: Array<WebXRController>;
  103667. private _tmpMatrix;
  103668. private _frameObserver;
  103669. /**
  103670. * Initializes the WebXRInput
  103671. * @param helper experience helper which the input should be created for
  103672. */
  103673. constructor(helper: WebXRExperienceHelper);
  103674. /**
  103675. * Disposes of the object
  103676. */
  103677. dispose(): void;
  103678. }
  103679. }
  103680. declare module BABYLON {
  103681. /**
  103682. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  103683. */
  103684. export class WebXRManagedOutputCanvas implements IDisposable {
  103685. private _canvas;
  103686. /**
  103687. * xrpresent context of the canvas which can be used to display/mirror xr content
  103688. */
  103689. canvasContext: Nullable<WebGLRenderingContext>;
  103690. /**
  103691. * Initializes the canvas to be added/removed upon entering/exiting xr
  103692. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  103693. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  103694. */
  103695. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  103696. /**
  103697. * Disposes of the object
  103698. */
  103699. dispose(): void;
  103700. private _setManagedOutputCanvas;
  103701. private _addCanvas;
  103702. private _removeCanvas;
  103703. }
  103704. }
  103705. declare module BABYLON {
  103706. /**
  103707. * Contains an array of blocks representing the octree
  103708. */
  103709. export interface IOctreeContainer<T> {
  103710. /**
  103711. * Blocks within the octree
  103712. */
  103713. blocks: Array<OctreeBlock<T>>;
  103714. }
  103715. /**
  103716. * Class used to store a cell in an octree
  103717. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103718. */
  103719. export class OctreeBlock<T> {
  103720. /**
  103721. * Gets the content of the current block
  103722. */
  103723. entries: T[];
  103724. /**
  103725. * Gets the list of block children
  103726. */
  103727. blocks: Array<OctreeBlock<T>>;
  103728. private _depth;
  103729. private _maxDepth;
  103730. private _capacity;
  103731. private _minPoint;
  103732. private _maxPoint;
  103733. private _boundingVectors;
  103734. private _creationFunc;
  103735. /**
  103736. * Creates a new block
  103737. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  103738. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  103739. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  103740. * @param depth defines the current depth of this block in the octree
  103741. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  103742. * @param creationFunc defines a callback to call when an element is added to the block
  103743. */
  103744. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  103745. /**
  103746. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  103747. */
  103748. readonly capacity: number;
  103749. /**
  103750. * Gets the minimum vector (in world space) of the block's bounding box
  103751. */
  103752. readonly minPoint: Vector3;
  103753. /**
  103754. * Gets the maximum vector (in world space) of the block's bounding box
  103755. */
  103756. readonly maxPoint: Vector3;
  103757. /**
  103758. * Add a new element to this block
  103759. * @param entry defines the element to add
  103760. */
  103761. addEntry(entry: T): void;
  103762. /**
  103763. * Remove an element from this block
  103764. * @param entry defines the element to remove
  103765. */
  103766. removeEntry(entry: T): void;
  103767. /**
  103768. * Add an array of elements to this block
  103769. * @param entries defines the array of elements to add
  103770. */
  103771. addEntries(entries: T[]): void;
  103772. /**
  103773. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  103774. * @param frustumPlanes defines the frustum planes to test
  103775. * @param selection defines the array to store current content if selection is positive
  103776. * @param allowDuplicate defines if the selection array can contains duplicated entries
  103777. */
  103778. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  103779. /**
  103780. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  103781. * @param sphereCenter defines the bounding sphere center
  103782. * @param sphereRadius defines the bounding sphere radius
  103783. * @param selection defines the array to store current content if selection is positive
  103784. * @param allowDuplicate defines if the selection array can contains duplicated entries
  103785. */
  103786. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  103787. /**
  103788. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  103789. * @param ray defines the ray to test with
  103790. * @param selection defines the array to store current content if selection is positive
  103791. */
  103792. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  103793. /**
  103794. * Subdivide the content into child blocks (this block will then be empty)
  103795. */
  103796. createInnerBlocks(): void;
  103797. /**
  103798. * @hidden
  103799. */
  103800. 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;
  103801. }
  103802. }
  103803. declare module BABYLON {
  103804. /**
  103805. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  103806. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103807. */
  103808. export class Octree<T> {
  103809. /** 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.) */
  103810. maxDepth: number;
  103811. /**
  103812. * Blocks within the octree containing objects
  103813. */
  103814. blocks: Array<OctreeBlock<T>>;
  103815. /**
  103816. * Content stored in the octree
  103817. */
  103818. dynamicContent: T[];
  103819. private _maxBlockCapacity;
  103820. private _selectionContent;
  103821. private _creationFunc;
  103822. /**
  103823. * Creates a octree
  103824. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103825. * @param creationFunc function to be used to instatiate the octree
  103826. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  103827. * @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.)
  103828. */
  103829. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  103830. /** 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.) */
  103831. maxDepth?: number);
  103832. /**
  103833. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  103834. * @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);
  103835. * @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);
  103836. * @param entries meshes to be added to the octree blocks
  103837. */
  103838. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  103839. /**
  103840. * Adds a mesh to the octree
  103841. * @param entry Mesh to add to the octree
  103842. */
  103843. addMesh(entry: T): void;
  103844. /**
  103845. * Remove an element from the octree
  103846. * @param entry defines the element to remove
  103847. */
  103848. removeMesh(entry: T): void;
  103849. /**
  103850. * Selects an array of meshes within the frustum
  103851. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  103852. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  103853. * @returns array of meshes within the frustum
  103854. */
  103855. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  103856. /**
  103857. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  103858. * @param sphereCenter defines the bounding sphere center
  103859. * @param sphereRadius defines the bounding sphere radius
  103860. * @param allowDuplicate defines if the selection array can contains duplicated entries
  103861. * @returns an array of objects that intersect the sphere
  103862. */
  103863. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  103864. /**
  103865. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  103866. * @param ray defines the ray to test with
  103867. * @returns array of intersected objects
  103868. */
  103869. intersectsRay(ray: Ray): SmartArray<T>;
  103870. /**
  103871. * Adds a mesh into the octree block if it intersects the block
  103872. */
  103873. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  103874. /**
  103875. * Adds a submesh into the octree block if it intersects the block
  103876. */
  103877. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  103878. }
  103879. }
  103880. declare module BABYLON {
  103881. interface Scene {
  103882. /**
  103883. * @hidden
  103884. * Backing Filed
  103885. */
  103886. _selectionOctree: Octree<AbstractMesh>;
  103887. /**
  103888. * Gets the octree used to boost mesh selection (picking)
  103889. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103890. */
  103891. selectionOctree: Octree<AbstractMesh>;
  103892. /**
  103893. * Creates or updates the octree used to boost selection (picking)
  103894. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103895. * @param maxCapacity defines the maximum capacity per leaf
  103896. * @param maxDepth defines the maximum depth of the octree
  103897. * @returns an octree of AbstractMesh
  103898. */
  103899. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  103900. }
  103901. interface AbstractMesh {
  103902. /**
  103903. * @hidden
  103904. * Backing Field
  103905. */
  103906. _submeshesOctree: Octree<SubMesh>;
  103907. /**
  103908. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  103909. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  103910. * @param maxCapacity defines the maximum size of each block (64 by default)
  103911. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  103912. * @returns the new octree
  103913. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  103914. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103915. */
  103916. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  103917. }
  103918. /**
  103919. * Defines the octree scene component responsible to manage any octrees
  103920. * in a given scene.
  103921. */
  103922. export class OctreeSceneComponent {
  103923. /**
  103924. * The component name help to identify the component in the list of scene components.
  103925. */
  103926. readonly name: string;
  103927. /**
  103928. * The scene the component belongs to.
  103929. */
  103930. scene: Scene;
  103931. /**
  103932. * Indicates if the meshes have been checked to make sure they are isEnabled()
  103933. */
  103934. readonly checksIsEnabled: boolean;
  103935. /**
  103936. * Creates a new instance of the component for the given scene
  103937. * @param scene Defines the scene to register the component in
  103938. */
  103939. constructor(scene: Scene);
  103940. /**
  103941. * Registers the component in a given scene
  103942. */
  103943. register(): void;
  103944. /**
  103945. * Return the list of active meshes
  103946. * @returns the list of active meshes
  103947. */
  103948. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  103949. /**
  103950. * Return the list of active sub meshes
  103951. * @param mesh The mesh to get the candidates sub meshes from
  103952. * @returns the list of active sub meshes
  103953. */
  103954. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  103955. private _tempRay;
  103956. /**
  103957. * Return the list of sub meshes intersecting with a given local ray
  103958. * @param mesh defines the mesh to find the submesh for
  103959. * @param localRay defines the ray in local space
  103960. * @returns the list of intersecting sub meshes
  103961. */
  103962. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  103963. /**
  103964. * Return the list of sub meshes colliding with a collider
  103965. * @param mesh defines the mesh to find the submesh for
  103966. * @param collider defines the collider to evaluate the collision against
  103967. * @returns the list of colliding sub meshes
  103968. */
  103969. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  103970. /**
  103971. * Rebuilds the elements related to this component in case of
  103972. * context lost for instance.
  103973. */
  103974. rebuild(): void;
  103975. /**
  103976. * Disposes the component and the associated ressources.
  103977. */
  103978. dispose(): void;
  103979. }
  103980. }
  103981. declare module BABYLON {
  103982. /**
  103983. * Renders a layer on top of an existing scene
  103984. */
  103985. export class UtilityLayerRenderer implements IDisposable {
  103986. /** the original scene that will be rendered on top of */
  103987. originalScene: Scene;
  103988. private _pointerCaptures;
  103989. private _lastPointerEvents;
  103990. private static _DefaultUtilityLayer;
  103991. private static _DefaultKeepDepthUtilityLayer;
  103992. private _sharedGizmoLight;
  103993. private _renderCamera;
  103994. /**
  103995. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  103996. * @returns the camera that is used when rendering the utility layer
  103997. */
  103998. getRenderCamera(): Nullable<Camera>;
  103999. /**
  104000. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  104001. * @param cam the camera that should be used when rendering the utility layer
  104002. */
  104003. setRenderCamera(cam: Nullable<Camera>): void;
  104004. /**
  104005. * @hidden
  104006. * Light which used by gizmos to get light shading
  104007. */
  104008. _getSharedGizmoLight(): HemisphericLight;
  104009. /**
  104010. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  104011. */
  104012. pickUtilitySceneFirst: boolean;
  104013. /**
  104014. * 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)
  104015. */
  104016. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  104017. /**
  104018. * 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)
  104019. */
  104020. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  104021. /**
  104022. * The scene that is rendered on top of the original scene
  104023. */
  104024. utilityLayerScene: Scene;
  104025. /**
  104026. * If the utility layer should automatically be rendered on top of existing scene
  104027. */
  104028. shouldRender: boolean;
  104029. /**
  104030. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  104031. */
  104032. onlyCheckPointerDownEvents: boolean;
  104033. /**
  104034. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  104035. */
  104036. processAllEvents: boolean;
  104037. /**
  104038. * Observable raised when the pointer move from the utility layer scene to the main scene
  104039. */
  104040. onPointerOutObservable: Observable<number>;
  104041. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  104042. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  104043. private _afterRenderObserver;
  104044. private _sceneDisposeObserver;
  104045. private _originalPointerObserver;
  104046. /**
  104047. * Instantiates a UtilityLayerRenderer
  104048. * @param originalScene the original scene that will be rendered on top of
  104049. * @param handleEvents boolean indicating if the utility layer should handle events
  104050. */
  104051. constructor(
  104052. /** the original scene that will be rendered on top of */
  104053. originalScene: Scene, handleEvents?: boolean);
  104054. private _notifyObservers;
  104055. /**
  104056. * Renders the utility layers scene on top of the original scene
  104057. */
  104058. render(): void;
  104059. /**
  104060. * Disposes of the renderer
  104061. */
  104062. dispose(): void;
  104063. private _updateCamera;
  104064. }
  104065. }
  104066. declare module BABYLON {
  104067. /**
  104068. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  104069. */
  104070. export class Gizmo implements IDisposable {
  104071. /** The utility layer the gizmo will be added to */
  104072. gizmoLayer: UtilityLayerRenderer;
  104073. /**
  104074. * The root mesh of the gizmo
  104075. */
  104076. _rootMesh: Mesh;
  104077. private _attachedMesh;
  104078. /**
  104079. * Ratio for the scale of the gizmo (Default: 1)
  104080. */
  104081. scaleRatio: number;
  104082. /**
  104083. * If a custom mesh has been set (Default: false)
  104084. */
  104085. protected _customMeshSet: boolean;
  104086. /**
  104087. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  104088. * * When set, interactions will be enabled
  104089. */
  104090. attachedMesh: Nullable<AbstractMesh>;
  104091. /**
  104092. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  104093. * @param mesh The mesh to replace the default mesh of the gizmo
  104094. */
  104095. setCustomMesh(mesh: Mesh): void;
  104096. /**
  104097. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  104098. */
  104099. updateGizmoRotationToMatchAttachedMesh: boolean;
  104100. /**
  104101. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  104102. */
  104103. updateGizmoPositionToMatchAttachedMesh: boolean;
  104104. /**
  104105. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  104106. */
  104107. protected _updateScale: boolean;
  104108. protected _interactionsEnabled: boolean;
  104109. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  104110. private _beforeRenderObserver;
  104111. private _tempVector;
  104112. /**
  104113. * Creates a gizmo
  104114. * @param gizmoLayer The utility layer the gizmo will be added to
  104115. */
  104116. constructor(
  104117. /** The utility layer the gizmo will be added to */
  104118. gizmoLayer?: UtilityLayerRenderer);
  104119. /**
  104120. * Updates the gizmo to match the attached mesh's position/rotation
  104121. */
  104122. protected _update(): void;
  104123. /**
  104124. * Disposes of the gizmo
  104125. */
  104126. dispose(): void;
  104127. }
  104128. }
  104129. declare module BABYLON {
  104130. /**
  104131. * Single plane drag gizmo
  104132. */
  104133. export class PlaneDragGizmo extends Gizmo {
  104134. /**
  104135. * Drag behavior responsible for the gizmos dragging interactions
  104136. */
  104137. dragBehavior: PointerDragBehavior;
  104138. private _pointerObserver;
  104139. /**
  104140. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  104141. */
  104142. snapDistance: number;
  104143. /**
  104144. * Event that fires each time the gizmo snaps to a new location.
  104145. * * snapDistance is the the change in distance
  104146. */
  104147. onSnapObservable: Observable<{
  104148. snapDistance: number;
  104149. }>;
  104150. private _plane;
  104151. private _coloredMaterial;
  104152. private _hoverMaterial;
  104153. private _isEnabled;
  104154. private _parent;
  104155. /** @hidden */
  104156. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  104157. /** @hidden */
  104158. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  104159. /**
  104160. * Creates a PlaneDragGizmo
  104161. * @param gizmoLayer The utility layer the gizmo will be added to
  104162. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  104163. * @param color The color of the gizmo
  104164. */
  104165. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  104166. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  104167. /**
  104168. * If the gizmo is enabled
  104169. */
  104170. isEnabled: boolean;
  104171. /**
  104172. * Disposes of the gizmo
  104173. */
  104174. dispose(): void;
  104175. }
  104176. }
  104177. declare module BABYLON {
  104178. /**
  104179. * Gizmo that enables dragging a mesh along 3 axis
  104180. */
  104181. export class PositionGizmo extends Gizmo {
  104182. /**
  104183. * Internal gizmo used for interactions on the x axis
  104184. */
  104185. xGizmo: AxisDragGizmo;
  104186. /**
  104187. * Internal gizmo used for interactions on the y axis
  104188. */
  104189. yGizmo: AxisDragGizmo;
  104190. /**
  104191. * Internal gizmo used for interactions on the z axis
  104192. */
  104193. zGizmo: AxisDragGizmo;
  104194. /**
  104195. * Internal gizmo used for interactions on the yz plane
  104196. */
  104197. xPlaneGizmo: PlaneDragGizmo;
  104198. /**
  104199. * Internal gizmo used for interactions on the xz plane
  104200. */
  104201. yPlaneGizmo: PlaneDragGizmo;
  104202. /**
  104203. * Internal gizmo used for interactions on the xy plane
  104204. */
  104205. zPlaneGizmo: PlaneDragGizmo;
  104206. /**
  104207. * private variables
  104208. */
  104209. private _meshAttached;
  104210. private _updateGizmoRotationToMatchAttachedMesh;
  104211. private _snapDistance;
  104212. private _scaleRatio;
  104213. /** Fires an event when any of it's sub gizmos are dragged */
  104214. onDragStartObservable: Observable<unknown>;
  104215. /** Fires an event when any of it's sub gizmos are released from dragging */
  104216. onDragEndObservable: Observable<unknown>;
  104217. /**
  104218. * If set to true, planar drag is enabled
  104219. */
  104220. private _planarGizmoEnabled;
  104221. attachedMesh: Nullable<AbstractMesh>;
  104222. /**
  104223. * Creates a PositionGizmo
  104224. * @param gizmoLayer The utility layer the gizmo will be added to
  104225. */
  104226. constructor(gizmoLayer?: UtilityLayerRenderer);
  104227. /**
  104228. * If the planar drag gizmo is enabled
  104229. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  104230. */
  104231. planarGizmoEnabled: boolean;
  104232. updateGizmoRotationToMatchAttachedMesh: boolean;
  104233. /**
  104234. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  104235. */
  104236. snapDistance: number;
  104237. /**
  104238. * Ratio for the scale of the gizmo (Default: 1)
  104239. */
  104240. scaleRatio: number;
  104241. /**
  104242. * Disposes of the gizmo
  104243. */
  104244. dispose(): void;
  104245. /**
  104246. * CustomMeshes are not supported by this gizmo
  104247. * @param mesh The mesh to replace the default mesh of the gizmo
  104248. */
  104249. setCustomMesh(mesh: Mesh): void;
  104250. }
  104251. }
  104252. declare module BABYLON {
  104253. /**
  104254. * Single axis drag gizmo
  104255. */
  104256. export class AxisDragGizmo extends Gizmo {
  104257. /**
  104258. * Drag behavior responsible for the gizmos dragging interactions
  104259. */
  104260. dragBehavior: PointerDragBehavior;
  104261. private _pointerObserver;
  104262. /**
  104263. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  104264. */
  104265. snapDistance: number;
  104266. /**
  104267. * Event that fires each time the gizmo snaps to a new location.
  104268. * * snapDistance is the the change in distance
  104269. */
  104270. onSnapObservable: Observable<{
  104271. snapDistance: number;
  104272. }>;
  104273. private _isEnabled;
  104274. private _parent;
  104275. private _arrow;
  104276. private _coloredMaterial;
  104277. private _hoverMaterial;
  104278. /** @hidden */
  104279. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  104280. /** @hidden */
  104281. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  104282. /**
  104283. * Creates an AxisDragGizmo
  104284. * @param gizmoLayer The utility layer the gizmo will be added to
  104285. * @param dragAxis The axis which the gizmo will be able to drag on
  104286. * @param color The color of the gizmo
  104287. */
  104288. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  104289. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  104290. /**
  104291. * If the gizmo is enabled
  104292. */
  104293. isEnabled: boolean;
  104294. /**
  104295. * Disposes of the gizmo
  104296. */
  104297. dispose(): void;
  104298. }
  104299. }
  104300. declare module BABYLON.Debug {
  104301. /**
  104302. * The Axes viewer will show 3 axes in a specific point in space
  104303. */
  104304. export class AxesViewer {
  104305. private _xAxis;
  104306. private _yAxis;
  104307. private _zAxis;
  104308. private _scaleLinesFactor;
  104309. private _instanced;
  104310. /**
  104311. * Gets the hosting scene
  104312. */
  104313. scene: Scene;
  104314. /**
  104315. * Gets or sets a number used to scale line length
  104316. */
  104317. scaleLines: number;
  104318. /** Gets the node hierarchy used to render x-axis */
  104319. readonly xAxis: TransformNode;
  104320. /** Gets the node hierarchy used to render y-axis */
  104321. readonly yAxis: TransformNode;
  104322. /** Gets the node hierarchy used to render z-axis */
  104323. readonly zAxis: TransformNode;
  104324. /**
  104325. * Creates a new AxesViewer
  104326. * @param scene defines the hosting scene
  104327. * @param scaleLines defines a number used to scale line length (1 by default)
  104328. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  104329. * @param xAxis defines the node hierarchy used to render the x-axis
  104330. * @param yAxis defines the node hierarchy used to render the y-axis
  104331. * @param zAxis defines the node hierarchy used to render the z-axis
  104332. */
  104333. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  104334. /**
  104335. * Force the viewer to update
  104336. * @param position defines the position of the viewer
  104337. * @param xaxis defines the x axis of the viewer
  104338. * @param yaxis defines the y axis of the viewer
  104339. * @param zaxis defines the z axis of the viewer
  104340. */
  104341. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  104342. /**
  104343. * Creates an instance of this axes viewer.
  104344. * @returns a new axes viewer with instanced meshes
  104345. */
  104346. createInstance(): AxesViewer;
  104347. /** Releases resources */
  104348. dispose(): void;
  104349. private static _SetRenderingGroupId;
  104350. }
  104351. }
  104352. declare module BABYLON.Debug {
  104353. /**
  104354. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  104355. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  104356. */
  104357. export class BoneAxesViewer extends AxesViewer {
  104358. /**
  104359. * Gets or sets the target mesh where to display the axes viewer
  104360. */
  104361. mesh: Nullable<Mesh>;
  104362. /**
  104363. * Gets or sets the target bone where to display the axes viewer
  104364. */
  104365. bone: Nullable<Bone>;
  104366. /** Gets current position */
  104367. pos: Vector3;
  104368. /** Gets direction of X axis */
  104369. xaxis: Vector3;
  104370. /** Gets direction of Y axis */
  104371. yaxis: Vector3;
  104372. /** Gets direction of Z axis */
  104373. zaxis: Vector3;
  104374. /**
  104375. * Creates a new BoneAxesViewer
  104376. * @param scene defines the hosting scene
  104377. * @param bone defines the target bone
  104378. * @param mesh defines the target mesh
  104379. * @param scaleLines defines a scaling factor for line length (1 by default)
  104380. */
  104381. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  104382. /**
  104383. * Force the viewer to update
  104384. */
  104385. update(): void;
  104386. /** Releases resources */
  104387. dispose(): void;
  104388. }
  104389. }
  104390. declare module BABYLON {
  104391. /**
  104392. * Interface used to define scene explorer extensibility option
  104393. */
  104394. export interface IExplorerExtensibilityOption {
  104395. /**
  104396. * Define the option label
  104397. */
  104398. label: string;
  104399. /**
  104400. * Defines the action to execute on click
  104401. */
  104402. action: (entity: any) => void;
  104403. }
  104404. /**
  104405. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  104406. */
  104407. export interface IExplorerExtensibilityGroup {
  104408. /**
  104409. * Defines a predicate to test if a given type mut be extended
  104410. */
  104411. predicate: (entity: any) => boolean;
  104412. /**
  104413. * Gets the list of options added to a type
  104414. */
  104415. entries: IExplorerExtensibilityOption[];
  104416. }
  104417. /**
  104418. * Interface used to define the options to use to create the Inspector
  104419. */
  104420. export interface IInspectorOptions {
  104421. /**
  104422. * Display in overlay mode (default: false)
  104423. */
  104424. overlay?: boolean;
  104425. /**
  104426. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  104427. */
  104428. globalRoot?: HTMLElement;
  104429. /**
  104430. * Display the Scene explorer
  104431. */
  104432. showExplorer?: boolean;
  104433. /**
  104434. * Display the property inspector
  104435. */
  104436. showInspector?: boolean;
  104437. /**
  104438. * Display in embed mode (both panes on the right)
  104439. */
  104440. embedMode?: boolean;
  104441. /**
  104442. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  104443. */
  104444. handleResize?: boolean;
  104445. /**
  104446. * Allow the panes to popup (default: true)
  104447. */
  104448. enablePopup?: boolean;
  104449. /**
  104450. * Allow the panes to be closed by users (default: true)
  104451. */
  104452. enableClose?: boolean;
  104453. /**
  104454. * Optional list of extensibility entries
  104455. */
  104456. explorerExtensibility?: IExplorerExtensibilityGroup[];
  104457. /**
  104458. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  104459. */
  104460. inspectorURL?: string;
  104461. }
  104462. interface Scene {
  104463. /**
  104464. * @hidden
  104465. * Backing field
  104466. */
  104467. _debugLayer: DebugLayer;
  104468. /**
  104469. * Gets the debug layer (aka Inspector) associated with the scene
  104470. * @see http://doc.babylonjs.com/features/playground_debuglayer
  104471. */
  104472. debugLayer: DebugLayer;
  104473. }
  104474. /**
  104475. * The debug layer (aka Inspector) is the go to tool in order to better understand
  104476. * what is happening in your scene
  104477. * @see http://doc.babylonjs.com/features/playground_debuglayer
  104478. */
  104479. export class DebugLayer {
  104480. /**
  104481. * Define the url to get the inspector script from.
  104482. * By default it uses the babylonjs CDN.
  104483. * @ignoreNaming
  104484. */
  104485. static InspectorURL: string;
  104486. private _scene;
  104487. private BJSINSPECTOR;
  104488. /**
  104489. * Observable triggered when a property is changed through the inspector.
  104490. */
  104491. onPropertyChangedObservable: Observable<{
  104492. object: any;
  104493. property: string;
  104494. value: any;
  104495. initialValue: any;
  104496. }>;
  104497. /**
  104498. * Instantiates a new debug layer.
  104499. * The debug layer (aka Inspector) is the go to tool in order to better understand
  104500. * what is happening in your scene
  104501. * @see http://doc.babylonjs.com/features/playground_debuglayer
  104502. * @param scene Defines the scene to inspect
  104503. */
  104504. constructor(scene: Scene);
  104505. /** Creates the inspector window. */
  104506. private _createInspector;
  104507. /**
  104508. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  104509. * @param entity defines the entity to select
  104510. * @param lineContainerTitle defines the specific block to highlight
  104511. */
  104512. select(entity: any, lineContainerTitle?: string): void;
  104513. /** Get the inspector from bundle or global */
  104514. private _getGlobalInspector;
  104515. /**
  104516. * Get if the inspector is visible or not.
  104517. * @returns true if visible otherwise, false
  104518. */
  104519. isVisible(): boolean;
  104520. /**
  104521. * Hide the inspector and close its window.
  104522. */
  104523. hide(): void;
  104524. /**
  104525. * Launch the debugLayer.
  104526. * @param config Define the configuration of the inspector
  104527. * @return a promise fulfilled when the debug layer is visible
  104528. */
  104529. show(config?: IInspectorOptions): Promise<DebugLayer>;
  104530. }
  104531. }
  104532. declare module BABYLON {
  104533. /**
  104534. * Class containing static functions to help procedurally build meshes
  104535. */
  104536. export class BoxBuilder {
  104537. /**
  104538. * Creates a box mesh
  104539. * * The parameter `size` sets the size (float) of each box side (default 1)
  104540. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  104541. * * 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)
  104542. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  104543. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104544. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104545. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104546. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  104547. * @param name defines the name of the mesh
  104548. * @param options defines the options used to create the mesh
  104549. * @param scene defines the hosting scene
  104550. * @returns the box mesh
  104551. */
  104552. static CreateBox(name: string, options: {
  104553. size?: number;
  104554. width?: number;
  104555. height?: number;
  104556. depth?: number;
  104557. faceUV?: Vector4[];
  104558. faceColors?: Color4[];
  104559. sideOrientation?: number;
  104560. frontUVs?: Vector4;
  104561. backUVs?: Vector4;
  104562. wrap?: boolean;
  104563. topBaseAt?: number;
  104564. bottomBaseAt?: number;
  104565. updatable?: boolean;
  104566. }, scene?: Nullable<Scene>): Mesh;
  104567. }
  104568. }
  104569. declare module BABYLON {
  104570. /**
  104571. * Class containing static functions to help procedurally build meshes
  104572. */
  104573. export class SphereBuilder {
  104574. /**
  104575. * Creates a sphere mesh
  104576. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  104577. * * 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`)
  104578. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  104579. * * 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
  104580. * * 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)
  104581. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104582. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104583. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104584. * @param name defines the name of the mesh
  104585. * @param options defines the options used to create the mesh
  104586. * @param scene defines the hosting scene
  104587. * @returns the sphere mesh
  104588. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  104589. */
  104590. static CreateSphere(name: string, options: {
  104591. segments?: number;
  104592. diameter?: number;
  104593. diameterX?: number;
  104594. diameterY?: number;
  104595. diameterZ?: number;
  104596. arc?: number;
  104597. slice?: number;
  104598. sideOrientation?: number;
  104599. frontUVs?: Vector4;
  104600. backUVs?: Vector4;
  104601. updatable?: boolean;
  104602. }, scene: any): Mesh;
  104603. }
  104604. }
  104605. declare module BABYLON.Debug {
  104606. /**
  104607. * Used to show the physics impostor around the specific mesh
  104608. */
  104609. export class PhysicsViewer {
  104610. /** @hidden */
  104611. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  104612. /** @hidden */
  104613. protected _meshes: Array<Nullable<AbstractMesh>>;
  104614. /** @hidden */
  104615. protected _scene: Nullable<Scene>;
  104616. /** @hidden */
  104617. protected _numMeshes: number;
  104618. /** @hidden */
  104619. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  104620. private _renderFunction;
  104621. private _utilityLayer;
  104622. private _debugBoxMesh;
  104623. private _debugSphereMesh;
  104624. private _debugCylinderMesh;
  104625. private _debugMaterial;
  104626. private _debugMeshMeshes;
  104627. /**
  104628. * Creates a new PhysicsViewer
  104629. * @param scene defines the hosting scene
  104630. */
  104631. constructor(scene: Scene);
  104632. /** @hidden */
  104633. protected _updateDebugMeshes(): void;
  104634. /**
  104635. * Renders a specified physic impostor
  104636. * @param impostor defines the impostor to render
  104637. * @param targetMesh defines the mesh represented by the impostor
  104638. * @returns the new debug mesh used to render the impostor
  104639. */
  104640. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  104641. /**
  104642. * Hides a specified physic impostor
  104643. * @param impostor defines the impostor to hide
  104644. */
  104645. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  104646. private _getDebugMaterial;
  104647. private _getDebugBoxMesh;
  104648. private _getDebugSphereMesh;
  104649. private _getDebugCylinderMesh;
  104650. private _getDebugMeshMesh;
  104651. private _getDebugMesh;
  104652. /** Releases all resources */
  104653. dispose(): void;
  104654. }
  104655. }
  104656. declare module BABYLON {
  104657. /**
  104658. * Class containing static functions to help procedurally build meshes
  104659. */
  104660. export class LinesBuilder {
  104661. /**
  104662. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  104663. * * 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
  104664. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  104665. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  104666. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  104667. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  104668. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  104669. * * 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
  104670. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  104671. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104672. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  104673. * @param name defines the name of the new line system
  104674. * @param options defines the options used to create the line system
  104675. * @param scene defines the hosting scene
  104676. * @returns a new line system mesh
  104677. */
  104678. static CreateLineSystem(name: string, options: {
  104679. lines: Vector3[][];
  104680. updatable?: boolean;
  104681. instance?: Nullable<LinesMesh>;
  104682. colors?: Nullable<Color4[][]>;
  104683. useVertexAlpha?: boolean;
  104684. }, scene: Nullable<Scene>): LinesMesh;
  104685. /**
  104686. * Creates a line mesh
  104687. * 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
  104688. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  104689. * * The parameter `points` is an array successive Vector3
  104690. * * 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
  104691. * * The optional parameter `colors` is an array of successive Color4, one per line point
  104692. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  104693. * * When updating an instance, remember that only point positions can change, not the number of points
  104694. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104695. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  104696. * @param name defines the name of the new line system
  104697. * @param options defines the options used to create the line system
  104698. * @param scene defines the hosting scene
  104699. * @returns a new line mesh
  104700. */
  104701. static CreateLines(name: string, options: {
  104702. points: Vector3[];
  104703. updatable?: boolean;
  104704. instance?: Nullable<LinesMesh>;
  104705. colors?: Color4[];
  104706. useVertexAlpha?: boolean;
  104707. }, scene?: Nullable<Scene>): LinesMesh;
  104708. /**
  104709. * Creates a dashed line mesh
  104710. * * 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
  104711. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  104712. * * The parameter `points` is an array successive Vector3
  104713. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  104714. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  104715. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  104716. * * 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
  104717. * * When updating an instance, remember that only point positions can change, not the number of points
  104718. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104719. * @param name defines the name of the mesh
  104720. * @param options defines the options used to create the mesh
  104721. * @param scene defines the hosting scene
  104722. * @returns the dashed line mesh
  104723. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  104724. */
  104725. static CreateDashedLines(name: string, options: {
  104726. points: Vector3[];
  104727. dashSize?: number;
  104728. gapSize?: number;
  104729. dashNb?: number;
  104730. updatable?: boolean;
  104731. instance?: LinesMesh;
  104732. }, scene?: Nullable<Scene>): LinesMesh;
  104733. }
  104734. }
  104735. declare module BABYLON {
  104736. /**
  104737. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  104738. * in order to better appreciate the issue one might have.
  104739. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  104740. */
  104741. export class RayHelper {
  104742. /**
  104743. * Defines the ray we are currently tryin to visualize.
  104744. */
  104745. ray: Nullable<Ray>;
  104746. private _renderPoints;
  104747. private _renderLine;
  104748. private _renderFunction;
  104749. private _scene;
  104750. private _updateToMeshFunction;
  104751. private _attachedToMesh;
  104752. private _meshSpaceDirection;
  104753. private _meshSpaceOrigin;
  104754. /**
  104755. * Helper function to create a colored helper in a scene in one line.
  104756. * @param ray Defines the ray we are currently tryin to visualize
  104757. * @param scene Defines the scene the ray is used in
  104758. * @param color Defines the color we want to see the ray in
  104759. * @returns The newly created ray helper.
  104760. */
  104761. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  104762. /**
  104763. * Instantiate a new ray helper.
  104764. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  104765. * in order to better appreciate the issue one might have.
  104766. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  104767. * @param ray Defines the ray we are currently tryin to visualize
  104768. */
  104769. constructor(ray: Ray);
  104770. /**
  104771. * Shows the ray we are willing to debug.
  104772. * @param scene Defines the scene the ray needs to be rendered in
  104773. * @param color Defines the color the ray needs to be rendered in
  104774. */
  104775. show(scene: Scene, color?: Color3): void;
  104776. /**
  104777. * Hides the ray we are debugging.
  104778. */
  104779. hide(): void;
  104780. private _render;
  104781. /**
  104782. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  104783. * @param mesh Defines the mesh we want the helper attached to
  104784. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  104785. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  104786. * @param length Defines the length of the ray
  104787. */
  104788. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  104789. /**
  104790. * Detach the ray helper from the mesh it has previously been attached to.
  104791. */
  104792. detachFromMesh(): void;
  104793. private _updateToMesh;
  104794. /**
  104795. * Dispose the helper and release its associated resources.
  104796. */
  104797. dispose(): void;
  104798. }
  104799. }
  104800. declare module BABYLON.Debug {
  104801. /**
  104802. * Class used to render a debug view of a given skeleton
  104803. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  104804. */
  104805. export class SkeletonViewer {
  104806. /** defines the skeleton to render */
  104807. skeleton: Skeleton;
  104808. /** defines the mesh attached to the skeleton */
  104809. mesh: AbstractMesh;
  104810. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  104811. autoUpdateBonesMatrices: boolean;
  104812. /** defines the rendering group id to use with the viewer */
  104813. renderingGroupId: number;
  104814. /** Gets or sets the color used to render the skeleton */
  104815. color: Color3;
  104816. private _scene;
  104817. private _debugLines;
  104818. private _debugMesh;
  104819. private _isEnabled;
  104820. private _renderFunction;
  104821. private _utilityLayer;
  104822. /**
  104823. * Returns the mesh used to render the bones
  104824. */
  104825. readonly debugMesh: Nullable<LinesMesh>;
  104826. /**
  104827. * Creates a new SkeletonViewer
  104828. * @param skeleton defines the skeleton to render
  104829. * @param mesh defines the mesh attached to the skeleton
  104830. * @param scene defines the hosting scene
  104831. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  104832. * @param renderingGroupId defines the rendering group id to use with the viewer
  104833. */
  104834. constructor(
  104835. /** defines the skeleton to render */
  104836. skeleton: Skeleton,
  104837. /** defines the mesh attached to the skeleton */
  104838. mesh: AbstractMesh, scene: Scene,
  104839. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  104840. autoUpdateBonesMatrices?: boolean,
  104841. /** defines the rendering group id to use with the viewer */
  104842. renderingGroupId?: number);
  104843. /** Gets or sets a boolean indicating if the viewer is enabled */
  104844. isEnabled: boolean;
  104845. private _getBonePosition;
  104846. private _getLinesForBonesWithLength;
  104847. private _getLinesForBonesNoLength;
  104848. /** Update the viewer to sync with current skeleton state */
  104849. update(): void;
  104850. /** Release associated resources */
  104851. dispose(): void;
  104852. }
  104853. }
  104854. declare module BABYLON {
  104855. /**
  104856. * Options to create the null engine
  104857. */
  104858. export class NullEngineOptions {
  104859. /**
  104860. * Render width (Default: 512)
  104861. */
  104862. renderWidth: number;
  104863. /**
  104864. * Render height (Default: 256)
  104865. */
  104866. renderHeight: number;
  104867. /**
  104868. * Texture size (Default: 512)
  104869. */
  104870. textureSize: number;
  104871. /**
  104872. * If delta time between frames should be constant
  104873. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104874. */
  104875. deterministicLockstep: boolean;
  104876. /**
  104877. * Maximum about of steps between frames (Default: 4)
  104878. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104879. */
  104880. lockstepMaxSteps: number;
  104881. }
  104882. /**
  104883. * The null engine class provides support for headless version of babylon.js.
  104884. * This can be used in server side scenario or for testing purposes
  104885. */
  104886. export class NullEngine extends Engine {
  104887. private _options;
  104888. /**
  104889. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104890. */
  104891. isDeterministicLockStep(): boolean;
  104892. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  104893. getLockstepMaxSteps(): number;
  104894. /**
  104895. * Sets hardware scaling, used to save performance if needed
  104896. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  104897. */
  104898. getHardwareScalingLevel(): number;
  104899. constructor(options?: NullEngineOptions);
  104900. createVertexBuffer(vertices: FloatArray): DataBuffer;
  104901. createIndexBuffer(indices: IndicesArray): DataBuffer;
  104902. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  104903. getRenderWidth(useScreen?: boolean): number;
  104904. getRenderHeight(useScreen?: boolean): number;
  104905. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  104906. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  104907. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  104908. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  104909. bindSamplers(effect: Effect): void;
  104910. enableEffect(effect: Effect): void;
  104911. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  104912. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  104913. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  104914. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  104915. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  104916. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  104917. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  104918. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  104919. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  104920. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  104921. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  104922. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  104923. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  104924. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  104925. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  104926. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  104927. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  104928. setFloat(uniform: WebGLUniformLocation, value: number): void;
  104929. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  104930. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  104931. setBool(uniform: WebGLUniformLocation, bool: number): void;
  104932. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  104933. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  104934. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  104935. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  104936. bindBuffers(vertexBuffers: {
  104937. [key: string]: VertexBuffer;
  104938. }, indexBuffer: DataBuffer, effect: Effect): void;
  104939. wipeCaches(bruteForce?: boolean): void;
  104940. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  104941. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  104942. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  104943. /** @hidden */
  104944. _createTexture(): WebGLTexture;
  104945. /** @hidden */
  104946. _releaseTexture(texture: InternalTexture): void;
  104947. 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;
  104948. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  104949. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  104950. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  104951. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  104952. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  104953. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  104954. areAllEffectsReady(): boolean;
  104955. /**
  104956. * @hidden
  104957. * Get the current error code of the webGL context
  104958. * @returns the error code
  104959. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  104960. */
  104961. getError(): number;
  104962. /** @hidden */
  104963. _getUnpackAlignement(): number;
  104964. /** @hidden */
  104965. _unpackFlipY(value: boolean): void;
  104966. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  104967. /**
  104968. * Updates a dynamic vertex buffer.
  104969. * @param vertexBuffer the vertex buffer to update
  104970. * @param data the data used to update the vertex buffer
  104971. * @param byteOffset the byte offset of the data (optional)
  104972. * @param byteLength the byte length of the data (optional)
  104973. */
  104974. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  104975. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  104976. /** @hidden */
  104977. _bindTexture(channel: number, texture: InternalTexture): void;
  104978. /** @hidden */
  104979. _releaseBuffer(buffer: DataBuffer): boolean;
  104980. releaseEffects(): void;
  104981. displayLoadingUI(): void;
  104982. hideLoadingUI(): void;
  104983. /** @hidden */
  104984. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  104985. /** @hidden */
  104986. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  104987. /** @hidden */
  104988. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  104989. /** @hidden */
  104990. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  104991. }
  104992. }
  104993. declare module BABYLON {
  104994. /** @hidden */
  104995. export class _OcclusionDataStorage {
  104996. /** @hidden */
  104997. occlusionInternalRetryCounter: number;
  104998. /** @hidden */
  104999. isOcclusionQueryInProgress: boolean;
  105000. /** @hidden */
  105001. isOccluded: boolean;
  105002. /** @hidden */
  105003. occlusionRetryCount: number;
  105004. /** @hidden */
  105005. occlusionType: number;
  105006. /** @hidden */
  105007. occlusionQueryAlgorithmType: number;
  105008. }
  105009. interface Engine {
  105010. /**
  105011. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  105012. * @return the new query
  105013. */
  105014. createQuery(): WebGLQuery;
  105015. /**
  105016. * Delete and release a webGL query
  105017. * @param query defines the query to delete
  105018. * @return the current engine
  105019. */
  105020. deleteQuery(query: WebGLQuery): Engine;
  105021. /**
  105022. * Check if a given query has resolved and got its value
  105023. * @param query defines the query to check
  105024. * @returns true if the query got its value
  105025. */
  105026. isQueryResultAvailable(query: WebGLQuery): boolean;
  105027. /**
  105028. * Gets the value of a given query
  105029. * @param query defines the query to check
  105030. * @returns the value of the query
  105031. */
  105032. getQueryResult(query: WebGLQuery): number;
  105033. /**
  105034. * Initiates an occlusion query
  105035. * @param algorithmType defines the algorithm to use
  105036. * @param query defines the query to use
  105037. * @returns the current engine
  105038. * @see http://doc.babylonjs.com/features/occlusionquery
  105039. */
  105040. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  105041. /**
  105042. * Ends an occlusion query
  105043. * @see http://doc.babylonjs.com/features/occlusionquery
  105044. * @param algorithmType defines the algorithm to use
  105045. * @returns the current engine
  105046. */
  105047. endOcclusionQuery(algorithmType: number): Engine;
  105048. /**
  105049. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  105050. * Please note that only one query can be issued at a time
  105051. * @returns a time token used to track the time span
  105052. */
  105053. startTimeQuery(): Nullable<_TimeToken>;
  105054. /**
  105055. * Ends a time query
  105056. * @param token defines the token used to measure the time span
  105057. * @returns the time spent (in ns)
  105058. */
  105059. endTimeQuery(token: _TimeToken): int;
  105060. /** @hidden */
  105061. _currentNonTimestampToken: Nullable<_TimeToken>;
  105062. /** @hidden */
  105063. _createTimeQuery(): WebGLQuery;
  105064. /** @hidden */
  105065. _deleteTimeQuery(query: WebGLQuery): void;
  105066. /** @hidden */
  105067. _getGlAlgorithmType(algorithmType: number): number;
  105068. /** @hidden */
  105069. _getTimeQueryResult(query: WebGLQuery): any;
  105070. /** @hidden */
  105071. _getTimeQueryAvailability(query: WebGLQuery): any;
  105072. }
  105073. interface AbstractMesh {
  105074. /**
  105075. * Backing filed
  105076. * @hidden
  105077. */
  105078. __occlusionDataStorage: _OcclusionDataStorage;
  105079. /**
  105080. * Access property
  105081. * @hidden
  105082. */
  105083. _occlusionDataStorage: _OcclusionDataStorage;
  105084. /**
  105085. * 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.
  105086. * The default value is -1 which means don't break the query and wait till the result
  105087. * @see http://doc.babylonjs.com/features/occlusionquery
  105088. */
  105089. occlusionRetryCount: number;
  105090. /**
  105091. * 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:
  105092. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  105093. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  105094. * * 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.
  105095. * @see http://doc.babylonjs.com/features/occlusionquery
  105096. */
  105097. occlusionType: number;
  105098. /**
  105099. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  105100. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  105101. * * 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.
  105102. * @see http://doc.babylonjs.com/features/occlusionquery
  105103. */
  105104. occlusionQueryAlgorithmType: number;
  105105. /**
  105106. * 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
  105107. * @see http://doc.babylonjs.com/features/occlusionquery
  105108. */
  105109. isOccluded: boolean;
  105110. /**
  105111. * Flag to check the progress status of the query
  105112. * @see http://doc.babylonjs.com/features/occlusionquery
  105113. */
  105114. isOcclusionQueryInProgress: boolean;
  105115. }
  105116. }
  105117. declare module BABYLON {
  105118. /** @hidden */
  105119. export var _forceTransformFeedbackToBundle: boolean;
  105120. interface Engine {
  105121. /**
  105122. * Creates a webGL transform feedback object
  105123. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  105124. * @returns the webGL transform feedback object
  105125. */
  105126. createTransformFeedback(): WebGLTransformFeedback;
  105127. /**
  105128. * Delete a webGL transform feedback object
  105129. * @param value defines the webGL transform feedback object to delete
  105130. */
  105131. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  105132. /**
  105133. * Bind a webGL transform feedback object to the webgl context
  105134. * @param value defines the webGL transform feedback object to bind
  105135. */
  105136. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  105137. /**
  105138. * Begins a transform feedback operation
  105139. * @param usePoints defines if points or triangles must be used
  105140. */
  105141. beginTransformFeedback(usePoints: boolean): void;
  105142. /**
  105143. * Ends a transform feedback operation
  105144. */
  105145. endTransformFeedback(): void;
  105146. /**
  105147. * Specify the varyings to use with transform feedback
  105148. * @param program defines the associated webGL program
  105149. * @param value defines the list of strings representing the varying names
  105150. */
  105151. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  105152. /**
  105153. * Bind a webGL buffer for a transform feedback operation
  105154. * @param value defines the webGL buffer to bind
  105155. */
  105156. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  105157. }
  105158. }
  105159. declare module BABYLON {
  105160. /**
  105161. * Creation options of the multi render target texture.
  105162. */
  105163. export interface IMultiRenderTargetOptions {
  105164. /**
  105165. * Define if the texture needs to create mip maps after render.
  105166. */
  105167. generateMipMaps?: boolean;
  105168. /**
  105169. * Define the types of all the draw buffers we want to create
  105170. */
  105171. types?: number[];
  105172. /**
  105173. * Define the sampling modes of all the draw buffers we want to create
  105174. */
  105175. samplingModes?: number[];
  105176. /**
  105177. * Define if a depth buffer is required
  105178. */
  105179. generateDepthBuffer?: boolean;
  105180. /**
  105181. * Define if a stencil buffer is required
  105182. */
  105183. generateStencilBuffer?: boolean;
  105184. /**
  105185. * Define if a depth texture is required instead of a depth buffer
  105186. */
  105187. generateDepthTexture?: boolean;
  105188. /**
  105189. * Define the number of desired draw buffers
  105190. */
  105191. textureCount?: number;
  105192. /**
  105193. * Define if aspect ratio should be adapted to the texture or stay the scene one
  105194. */
  105195. doNotChangeAspectRatio?: boolean;
  105196. /**
  105197. * Define the default type of the buffers we are creating
  105198. */
  105199. defaultType?: number;
  105200. }
  105201. /**
  105202. * A multi render target, like a render target provides the ability to render to a texture.
  105203. * Unlike the render target, it can render to several draw buffers in one draw.
  105204. * This is specially interesting in deferred rendering or for any effects requiring more than
  105205. * just one color from a single pass.
  105206. */
  105207. export class MultiRenderTarget extends RenderTargetTexture {
  105208. private _internalTextures;
  105209. private _textures;
  105210. private _multiRenderTargetOptions;
  105211. /**
  105212. * Get if draw buffers are currently supported by the used hardware and browser.
  105213. */
  105214. readonly isSupported: boolean;
  105215. /**
  105216. * Get the list of textures generated by the multi render target.
  105217. */
  105218. readonly textures: Texture[];
  105219. /**
  105220. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  105221. */
  105222. readonly depthTexture: Texture;
  105223. /**
  105224. * Set the wrapping mode on U of all the textures we are rendering to.
  105225. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  105226. */
  105227. wrapU: number;
  105228. /**
  105229. * Set the wrapping mode on V of all the textures we are rendering to.
  105230. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  105231. */
  105232. wrapV: number;
  105233. /**
  105234. * Instantiate a new multi render target texture.
  105235. * A multi render target, like a render target provides the ability to render to a texture.
  105236. * Unlike the render target, it can render to several draw buffers in one draw.
  105237. * This is specially interesting in deferred rendering or for any effects requiring more than
  105238. * just one color from a single pass.
  105239. * @param name Define the name of the texture
  105240. * @param size Define the size of the buffers to render to
  105241. * @param count Define the number of target we are rendering into
  105242. * @param scene Define the scene the texture belongs to
  105243. * @param options Define the options used to create the multi render target
  105244. */
  105245. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  105246. /** @hidden */
  105247. _rebuild(): void;
  105248. private _createInternalTextures;
  105249. private _createTextures;
  105250. /**
  105251. * Define the number of samples used if MSAA is enabled.
  105252. */
  105253. samples: number;
  105254. /**
  105255. * Resize all the textures in the multi render target.
  105256. * Be carrefull as it will recreate all the data in the new texture.
  105257. * @param size Define the new size
  105258. */
  105259. resize(size: any): void;
  105260. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  105261. /**
  105262. * Dispose the render targets and their associated resources
  105263. */
  105264. dispose(): void;
  105265. /**
  105266. * Release all the underlying texture used as draw buffers.
  105267. */
  105268. releaseInternalTextures(): void;
  105269. }
  105270. }
  105271. declare module BABYLON {
  105272. interface Engine {
  105273. /**
  105274. * Unbind a list of render target textures from the webGL context
  105275. * This is used only when drawBuffer extension or webGL2 are active
  105276. * @param textures defines the render target textures to unbind
  105277. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  105278. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  105279. */
  105280. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  105281. /**
  105282. * Create a multi render target texture
  105283. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  105284. * @param size defines the size of the texture
  105285. * @param options defines the creation options
  105286. * @returns the cube texture as an InternalTexture
  105287. */
  105288. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  105289. /**
  105290. * Update the sample count for a given multiple render target texture
  105291. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  105292. * @param textures defines the textures to update
  105293. * @param samples defines the sample count to set
  105294. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  105295. */
  105296. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  105297. }
  105298. }
  105299. declare module BABYLON {
  105300. /**
  105301. * Gather the list of clipboard event types as constants.
  105302. */
  105303. export class ClipboardEventTypes {
  105304. /**
  105305. * The clipboard event is fired when a copy command is active (pressed).
  105306. */
  105307. static readonly COPY: number;
  105308. /**
  105309. * The clipboard event is fired when a cut command is active (pressed).
  105310. */
  105311. static readonly CUT: number;
  105312. /**
  105313. * The clipboard event is fired when a paste command is active (pressed).
  105314. */
  105315. static readonly PASTE: number;
  105316. }
  105317. /**
  105318. * This class is used to store clipboard related info for the onClipboardObservable event.
  105319. */
  105320. export class ClipboardInfo {
  105321. /**
  105322. * Defines the type of event (BABYLON.ClipboardEventTypes)
  105323. */
  105324. type: number;
  105325. /**
  105326. * Defines the related dom event
  105327. */
  105328. event: ClipboardEvent;
  105329. /**
  105330. *Creates an instance of ClipboardInfo.
  105331. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  105332. * @param event Defines the related dom event
  105333. */
  105334. constructor(
  105335. /**
  105336. * Defines the type of event (BABYLON.ClipboardEventTypes)
  105337. */
  105338. type: number,
  105339. /**
  105340. * Defines the related dom event
  105341. */
  105342. event: ClipboardEvent);
  105343. /**
  105344. * Get the clipboard event's type from the keycode.
  105345. * @param keyCode Defines the keyCode for the current keyboard event.
  105346. * @return {number}
  105347. */
  105348. static GetTypeFromCharacter(keyCode: number): number;
  105349. }
  105350. }
  105351. declare module BABYLON {
  105352. /**
  105353. * Class used to represent data loading progression
  105354. */
  105355. export class SceneLoaderProgressEvent {
  105356. /** defines if data length to load can be evaluated */
  105357. readonly lengthComputable: boolean;
  105358. /** defines the loaded data length */
  105359. readonly loaded: number;
  105360. /** defines the data length to load */
  105361. readonly total: number;
  105362. /**
  105363. * Create a new progress event
  105364. * @param lengthComputable defines if data length to load can be evaluated
  105365. * @param loaded defines the loaded data length
  105366. * @param total defines the data length to load
  105367. */
  105368. constructor(
  105369. /** defines if data length to load can be evaluated */
  105370. lengthComputable: boolean,
  105371. /** defines the loaded data length */
  105372. loaded: number,
  105373. /** defines the data length to load */
  105374. total: number);
  105375. /**
  105376. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  105377. * @param event defines the source event
  105378. * @returns a new SceneLoaderProgressEvent
  105379. */
  105380. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  105381. }
  105382. /**
  105383. * Interface used by SceneLoader plugins to define supported file extensions
  105384. */
  105385. export interface ISceneLoaderPluginExtensions {
  105386. /**
  105387. * Defines the list of supported extensions
  105388. */
  105389. [extension: string]: {
  105390. isBinary: boolean;
  105391. };
  105392. }
  105393. /**
  105394. * Interface used by SceneLoader plugin factory
  105395. */
  105396. export interface ISceneLoaderPluginFactory {
  105397. /**
  105398. * Defines the name of the factory
  105399. */
  105400. name: string;
  105401. /**
  105402. * Function called to create a new plugin
  105403. * @return the new plugin
  105404. */
  105405. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  105406. /**
  105407. * Boolean indicating if the plugin can direct load specific data
  105408. */
  105409. canDirectLoad?: (data: string) => boolean;
  105410. }
  105411. /**
  105412. * Interface used to define a SceneLoader plugin
  105413. */
  105414. export interface ISceneLoaderPlugin {
  105415. /**
  105416. * The friendly name of this plugin.
  105417. */
  105418. name: string;
  105419. /**
  105420. * The file extensions supported by this plugin.
  105421. */
  105422. extensions: string | ISceneLoaderPluginExtensions;
  105423. /**
  105424. * Import meshes into a scene.
  105425. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  105426. * @param scene The scene to import into
  105427. * @param data The data to import
  105428. * @param rootUrl The root url for scene and resources
  105429. * @param meshes The meshes array to import into
  105430. * @param particleSystems The particle systems array to import into
  105431. * @param skeletons The skeletons array to import into
  105432. * @param onError The callback when import fails
  105433. * @returns True if successful or false otherwise
  105434. */
  105435. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  105436. /**
  105437. * Load into a scene.
  105438. * @param scene The scene to load into
  105439. * @param data The data to import
  105440. * @param rootUrl The root url for scene and resources
  105441. * @param onError The callback when import fails
  105442. * @returns true if successful or false otherwise
  105443. */
  105444. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  105445. /**
  105446. * The callback that returns true if the data can be directly loaded.
  105447. */
  105448. canDirectLoad?: (data: string) => boolean;
  105449. /**
  105450. * The callback that allows custom handling of the root url based on the response url.
  105451. */
  105452. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  105453. /**
  105454. * Load into an asset container.
  105455. * @param scene The scene to load into
  105456. * @param data The data to import
  105457. * @param rootUrl The root url for scene and resources
  105458. * @param onError The callback when import fails
  105459. * @returns The loaded asset container
  105460. */
  105461. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  105462. }
  105463. /**
  105464. * Interface used to define an async SceneLoader plugin
  105465. */
  105466. export interface ISceneLoaderPluginAsync {
  105467. /**
  105468. * The friendly name of this plugin.
  105469. */
  105470. name: string;
  105471. /**
  105472. * The file extensions supported by this plugin.
  105473. */
  105474. extensions: string | ISceneLoaderPluginExtensions;
  105475. /**
  105476. * Import meshes into a scene.
  105477. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  105478. * @param scene The scene to import into
  105479. * @param data The data to import
  105480. * @param rootUrl The root url for scene and resources
  105481. * @param onProgress The callback when the load progresses
  105482. * @param fileName Defines the name of the file to load
  105483. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  105484. */
  105485. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  105486. meshes: AbstractMesh[];
  105487. particleSystems: IParticleSystem[];
  105488. skeletons: Skeleton[];
  105489. animationGroups: AnimationGroup[];
  105490. }>;
  105491. /**
  105492. * Load into a scene.
  105493. * @param scene The scene to load into
  105494. * @param data The data to import
  105495. * @param rootUrl The root url for scene and resources
  105496. * @param onProgress The callback when the load progresses
  105497. * @param fileName Defines the name of the file to load
  105498. * @returns Nothing
  105499. */
  105500. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  105501. /**
  105502. * The callback that returns true if the data can be directly loaded.
  105503. */
  105504. canDirectLoad?: (data: string) => boolean;
  105505. /**
  105506. * The callback that allows custom handling of the root url based on the response url.
  105507. */
  105508. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  105509. /**
  105510. * Load into an asset container.
  105511. * @param scene The scene to load into
  105512. * @param data The data to import
  105513. * @param rootUrl The root url for scene and resources
  105514. * @param onProgress The callback when the load progresses
  105515. * @param fileName Defines the name of the file to load
  105516. * @returns The loaded asset container
  105517. */
  105518. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  105519. }
  105520. /**
  105521. * Class used to load scene from various file formats using registered plugins
  105522. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  105523. */
  105524. export class SceneLoader {
  105525. /**
  105526. * No logging while loading
  105527. */
  105528. static readonly NO_LOGGING: number;
  105529. /**
  105530. * Minimal logging while loading
  105531. */
  105532. static readonly MINIMAL_LOGGING: number;
  105533. /**
  105534. * Summary logging while loading
  105535. */
  105536. static readonly SUMMARY_LOGGING: number;
  105537. /**
  105538. * Detailled logging while loading
  105539. */
  105540. static readonly DETAILED_LOGGING: number;
  105541. /**
  105542. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  105543. */
  105544. static ForceFullSceneLoadingForIncremental: boolean;
  105545. /**
  105546. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  105547. */
  105548. static ShowLoadingScreen: boolean;
  105549. /**
  105550. * Defines the current logging level (while loading the scene)
  105551. * @ignorenaming
  105552. */
  105553. static loggingLevel: number;
  105554. /**
  105555. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  105556. */
  105557. static CleanBoneMatrixWeights: boolean;
  105558. /**
  105559. * Event raised when a plugin is used to load a scene
  105560. */
  105561. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  105562. private static _registeredPlugins;
  105563. private static _getDefaultPlugin;
  105564. private static _getPluginForExtension;
  105565. private static _getPluginForDirectLoad;
  105566. private static _getPluginForFilename;
  105567. private static _getDirectLoad;
  105568. private static _loadData;
  105569. private static _getFileInfo;
  105570. /**
  105571. * Gets a plugin that can load the given extension
  105572. * @param extension defines the extension to load
  105573. * @returns a plugin or null if none works
  105574. */
  105575. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  105576. /**
  105577. * Gets a boolean indicating that the given extension can be loaded
  105578. * @param extension defines the extension to load
  105579. * @returns true if the extension is supported
  105580. */
  105581. static IsPluginForExtensionAvailable(extension: string): boolean;
  105582. /**
  105583. * Adds a new plugin to the list of registered plugins
  105584. * @param plugin defines the plugin to add
  105585. */
  105586. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  105587. /**
  105588. * Import meshes into a scene
  105589. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  105590. * @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)
  105591. * @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)
  105592. * @param scene the instance of BABYLON.Scene to append to
  105593. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  105594. * @param onProgress a callback with a progress event for each file being loaded
  105595. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  105596. * @param pluginExtension the extension used to determine the plugin
  105597. * @returns The loaded plugin
  105598. */
  105599. 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>;
  105600. /**
  105601. * Import meshes into a scene
  105602. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  105603. * @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)
  105604. * @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)
  105605. * @param scene the instance of BABYLON.Scene to append to
  105606. * @param onProgress a callback with a progress event for each file being loaded
  105607. * @param pluginExtension the extension used to determine the plugin
  105608. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  105609. */
  105610. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  105611. meshes: AbstractMesh[];
  105612. particleSystems: IParticleSystem[];
  105613. skeletons: Skeleton[];
  105614. animationGroups: AnimationGroup[];
  105615. }>;
  105616. /**
  105617. * Load a scene
  105618. * @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)
  105619. * @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)
  105620. * @param engine is the instance of BABYLON.Engine to use to create the scene
  105621. * @param onSuccess a callback with the scene when import succeeds
  105622. * @param onProgress a callback with a progress event for each file being loaded
  105623. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  105624. * @param pluginExtension the extension used to determine the plugin
  105625. * @returns The loaded plugin
  105626. */
  105627. 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>;
  105628. /**
  105629. * Load a scene
  105630. * @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)
  105631. * @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)
  105632. * @param engine is the instance of BABYLON.Engine to use to create the scene
  105633. * @param onProgress a callback with a progress event for each file being loaded
  105634. * @param pluginExtension the extension used to determine the plugin
  105635. * @returns The loaded scene
  105636. */
  105637. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  105638. /**
  105639. * Append a scene
  105640. * @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)
  105641. * @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)
  105642. * @param scene is the instance of BABYLON.Scene to append to
  105643. * @param onSuccess a callback with the scene when import succeeds
  105644. * @param onProgress a callback with a progress event for each file being loaded
  105645. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  105646. * @param pluginExtension the extension used to determine the plugin
  105647. * @returns The loaded plugin
  105648. */
  105649. 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>;
  105650. /**
  105651. * Append a scene
  105652. * @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)
  105653. * @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)
  105654. * @param scene is the instance of BABYLON.Scene to append to
  105655. * @param onProgress a callback with a progress event for each file being loaded
  105656. * @param pluginExtension the extension used to determine the plugin
  105657. * @returns The given scene
  105658. */
  105659. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  105660. /**
  105661. * Load a scene into an asset container
  105662. * @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)
  105663. * @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)
  105664. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  105665. * @param onSuccess a callback with the scene when import succeeds
  105666. * @param onProgress a callback with a progress event for each file being loaded
  105667. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  105668. * @param pluginExtension the extension used to determine the plugin
  105669. * @returns The loaded plugin
  105670. */
  105671. 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>;
  105672. /**
  105673. * Load a scene into an asset container
  105674. * @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)
  105675. * @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)
  105676. * @param scene is the instance of Scene to append to
  105677. * @param onProgress a callback with a progress event for each file being loaded
  105678. * @param pluginExtension the extension used to determine the plugin
  105679. * @returns The loaded asset container
  105680. */
  105681. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  105682. }
  105683. }
  105684. declare module BABYLON {
  105685. /**
  105686. * Google Daydream controller
  105687. */
  105688. export class DaydreamController extends WebVRController {
  105689. /**
  105690. * Base Url for the controller model.
  105691. */
  105692. static MODEL_BASE_URL: string;
  105693. /**
  105694. * File name for the controller model.
  105695. */
  105696. static MODEL_FILENAME: string;
  105697. /**
  105698. * Gamepad Id prefix used to identify Daydream Controller.
  105699. */
  105700. static readonly GAMEPAD_ID_PREFIX: string;
  105701. /**
  105702. * Creates a new DaydreamController from a gamepad
  105703. * @param vrGamepad the gamepad that the controller should be created from
  105704. */
  105705. constructor(vrGamepad: any);
  105706. /**
  105707. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105708. * @param scene scene in which to add meshes
  105709. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105710. */
  105711. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105712. /**
  105713. * Called once for each button that changed state since the last frame
  105714. * @param buttonIdx Which button index changed
  105715. * @param state New state of the button
  105716. * @param changes Which properties on the state changed since last frame
  105717. */
  105718. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105719. }
  105720. }
  105721. declare module BABYLON {
  105722. /**
  105723. * Gear VR Controller
  105724. */
  105725. export class GearVRController extends WebVRController {
  105726. /**
  105727. * Base Url for the controller model.
  105728. */
  105729. static MODEL_BASE_URL: string;
  105730. /**
  105731. * File name for the controller model.
  105732. */
  105733. static MODEL_FILENAME: string;
  105734. /**
  105735. * Gamepad Id prefix used to identify this controller.
  105736. */
  105737. static readonly GAMEPAD_ID_PREFIX: string;
  105738. private readonly _buttonIndexToObservableNameMap;
  105739. /**
  105740. * Creates a new GearVRController from a gamepad
  105741. * @param vrGamepad the gamepad that the controller should be created from
  105742. */
  105743. constructor(vrGamepad: any);
  105744. /**
  105745. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105746. * @param scene scene in which to add meshes
  105747. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105748. */
  105749. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105750. /**
  105751. * Called once for each button that changed state since the last frame
  105752. * @param buttonIdx Which button index changed
  105753. * @param state New state of the button
  105754. * @param changes Which properties on the state changed since last frame
  105755. */
  105756. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105757. }
  105758. }
  105759. declare module BABYLON {
  105760. /**
  105761. * Generic Controller
  105762. */
  105763. export class GenericController extends WebVRController {
  105764. /**
  105765. * Base Url for the controller model.
  105766. */
  105767. static readonly MODEL_BASE_URL: string;
  105768. /**
  105769. * File name for the controller model.
  105770. */
  105771. static readonly MODEL_FILENAME: string;
  105772. /**
  105773. * Creates a new GenericController from a gamepad
  105774. * @param vrGamepad the gamepad that the controller should be created from
  105775. */
  105776. constructor(vrGamepad: any);
  105777. /**
  105778. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105779. * @param scene scene in which to add meshes
  105780. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105781. */
  105782. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105783. /**
  105784. * Called once for each button that changed state since the last frame
  105785. * @param buttonIdx Which button index changed
  105786. * @param state New state of the button
  105787. * @param changes Which properties on the state changed since last frame
  105788. */
  105789. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105790. }
  105791. }
  105792. declare module BABYLON {
  105793. /**
  105794. * Oculus Touch Controller
  105795. */
  105796. export class OculusTouchController extends WebVRController {
  105797. /**
  105798. * Base Url for the controller model.
  105799. */
  105800. static MODEL_BASE_URL: string;
  105801. /**
  105802. * File name for the left controller model.
  105803. */
  105804. static MODEL_LEFT_FILENAME: string;
  105805. /**
  105806. * File name for the right controller model.
  105807. */
  105808. static MODEL_RIGHT_FILENAME: string;
  105809. /**
  105810. * Base Url for the Quest controller model.
  105811. */
  105812. static QUEST_MODEL_BASE_URL: string;
  105813. /**
  105814. * @hidden
  105815. * If the controllers are running on a device that needs the updated Quest controller models
  105816. */
  105817. static _IsQuest: boolean;
  105818. /**
  105819. * Fired when the secondary trigger on this controller is modified
  105820. */
  105821. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  105822. /**
  105823. * Fired when the thumb rest on this controller is modified
  105824. */
  105825. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  105826. /**
  105827. * Creates a new OculusTouchController from a gamepad
  105828. * @param vrGamepad the gamepad that the controller should be created from
  105829. */
  105830. constructor(vrGamepad: any);
  105831. /**
  105832. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105833. * @param scene scene in which to add meshes
  105834. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105835. */
  105836. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105837. /**
  105838. * Fired when the A button on this controller is modified
  105839. */
  105840. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105841. /**
  105842. * Fired when the B button on this controller is modified
  105843. */
  105844. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105845. /**
  105846. * Fired when the X button on this controller is modified
  105847. */
  105848. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105849. /**
  105850. * Fired when the Y button on this controller is modified
  105851. */
  105852. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105853. /**
  105854. * Called once for each button that changed state since the last frame
  105855. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  105856. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  105857. * 2) secondary trigger (same)
  105858. * 3) A (right) X (left), touch, pressed = value
  105859. * 4) B / Y
  105860. * 5) thumb rest
  105861. * @param buttonIdx Which button index changed
  105862. * @param state New state of the button
  105863. * @param changes Which properties on the state changed since last frame
  105864. */
  105865. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105866. }
  105867. }
  105868. declare module BABYLON {
  105869. /**
  105870. * Vive Controller
  105871. */
  105872. export class ViveController extends WebVRController {
  105873. /**
  105874. * Base Url for the controller model.
  105875. */
  105876. static MODEL_BASE_URL: string;
  105877. /**
  105878. * File name for the controller model.
  105879. */
  105880. static MODEL_FILENAME: string;
  105881. /**
  105882. * Creates a new ViveController from a gamepad
  105883. * @param vrGamepad the gamepad that the controller should be created from
  105884. */
  105885. constructor(vrGamepad: any);
  105886. /**
  105887. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105888. * @param scene scene in which to add meshes
  105889. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105890. */
  105891. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105892. /**
  105893. * Fired when the left button on this controller is modified
  105894. */
  105895. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105896. /**
  105897. * Fired when the right button on this controller is modified
  105898. */
  105899. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105900. /**
  105901. * Fired when the menu button on this controller is modified
  105902. */
  105903. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105904. /**
  105905. * Called once for each button that changed state since the last frame
  105906. * Vive mapping:
  105907. * 0: touchpad
  105908. * 1: trigger
  105909. * 2: left AND right buttons
  105910. * 3: menu button
  105911. * @param buttonIdx Which button index changed
  105912. * @param state New state of the button
  105913. * @param changes Which properties on the state changed since last frame
  105914. */
  105915. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105916. }
  105917. }
  105918. declare module BABYLON {
  105919. /**
  105920. * Defines the WindowsMotionController object that the state of the windows motion controller
  105921. */
  105922. export class WindowsMotionController extends WebVRController {
  105923. /**
  105924. * The base url used to load the left and right controller models
  105925. */
  105926. static MODEL_BASE_URL: string;
  105927. /**
  105928. * The name of the left controller model file
  105929. */
  105930. static MODEL_LEFT_FILENAME: string;
  105931. /**
  105932. * The name of the right controller model file
  105933. */
  105934. static MODEL_RIGHT_FILENAME: string;
  105935. /**
  105936. * The controller name prefix for this controller type
  105937. */
  105938. static readonly GAMEPAD_ID_PREFIX: string;
  105939. /**
  105940. * The controller id pattern for this controller type
  105941. */
  105942. private static readonly GAMEPAD_ID_PATTERN;
  105943. private _loadedMeshInfo;
  105944. private readonly _mapping;
  105945. /**
  105946. * Fired when the trackpad on this controller is clicked
  105947. */
  105948. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  105949. /**
  105950. * Fired when the trackpad on this controller is modified
  105951. */
  105952. onTrackpadValuesChangedObservable: Observable<StickValues>;
  105953. /**
  105954. * The current x and y values of this controller's trackpad
  105955. */
  105956. trackpad: StickValues;
  105957. /**
  105958. * Creates a new WindowsMotionController from a gamepad
  105959. * @param vrGamepad the gamepad that the controller should be created from
  105960. */
  105961. constructor(vrGamepad: any);
  105962. /**
  105963. * Fired when the trigger on this controller is modified
  105964. */
  105965. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105966. /**
  105967. * Fired when the menu button on this controller is modified
  105968. */
  105969. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105970. /**
  105971. * Fired when the grip button on this controller is modified
  105972. */
  105973. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105974. /**
  105975. * Fired when the thumbstick button on this controller is modified
  105976. */
  105977. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105978. /**
  105979. * Fired when the touchpad button on this controller is modified
  105980. */
  105981. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105982. /**
  105983. * Fired when the touchpad values on this controller are modified
  105984. */
  105985. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  105986. private _updateTrackpad;
  105987. /**
  105988. * Called once per frame by the engine.
  105989. */
  105990. update(): void;
  105991. /**
  105992. * Called once for each button that changed state since the last frame
  105993. * @param buttonIdx Which button index changed
  105994. * @param state New state of the button
  105995. * @param changes Which properties on the state changed since last frame
  105996. */
  105997. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105998. /**
  105999. * Moves the buttons on the controller mesh based on their current state
  106000. * @param buttonName the name of the button to move
  106001. * @param buttonValue the value of the button which determines the buttons new position
  106002. */
  106003. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  106004. /**
  106005. * Moves the axis on the controller mesh based on its current state
  106006. * @param axis the index of the axis
  106007. * @param axisValue the value of the axis which determines the meshes new position
  106008. * @hidden
  106009. */
  106010. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  106011. /**
  106012. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  106013. * @param scene scene in which to add meshes
  106014. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  106015. */
  106016. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  106017. /**
  106018. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  106019. * can be transformed by button presses and axes values, based on this._mapping.
  106020. *
  106021. * @param scene scene in which the meshes exist
  106022. * @param meshes list of meshes that make up the controller model to process
  106023. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  106024. */
  106025. private processModel;
  106026. private createMeshInfo;
  106027. /**
  106028. * Gets the ray of the controller in the direction the controller is pointing
  106029. * @param length the length the resulting ray should be
  106030. * @returns a ray in the direction the controller is pointing
  106031. */
  106032. getForwardRay(length?: number): Ray;
  106033. /**
  106034. * Disposes of the controller
  106035. */
  106036. dispose(): void;
  106037. }
  106038. }
  106039. declare module BABYLON {
  106040. /**
  106041. * Class containing static functions to help procedurally build meshes
  106042. */
  106043. export class PolyhedronBuilder {
  106044. /**
  106045. * Creates a polyhedron mesh
  106046. * * 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
  106047. * * The parameter `size` (positive float, default 1) sets the polygon size
  106048. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  106049. * * 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`
  106050. * * 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
  106051. * * 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)`)
  106052. * * 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
  106053. * * 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
  106054. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106055. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106056. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106057. * @param name defines the name of the mesh
  106058. * @param options defines the options used to create the mesh
  106059. * @param scene defines the hosting scene
  106060. * @returns the polyhedron mesh
  106061. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  106062. */
  106063. static CreatePolyhedron(name: string, options: {
  106064. type?: number;
  106065. size?: number;
  106066. sizeX?: number;
  106067. sizeY?: number;
  106068. sizeZ?: number;
  106069. custom?: any;
  106070. faceUV?: Vector4[];
  106071. faceColors?: Color4[];
  106072. flat?: boolean;
  106073. updatable?: boolean;
  106074. sideOrientation?: number;
  106075. frontUVs?: Vector4;
  106076. backUVs?: Vector4;
  106077. }, scene?: Nullable<Scene>): Mesh;
  106078. }
  106079. }
  106080. declare module BABYLON {
  106081. /**
  106082. * Gizmo that enables scaling a mesh along 3 axis
  106083. */
  106084. export class ScaleGizmo extends Gizmo {
  106085. /**
  106086. * Internal gizmo used for interactions on the x axis
  106087. */
  106088. xGizmo: AxisScaleGizmo;
  106089. /**
  106090. * Internal gizmo used for interactions on the y axis
  106091. */
  106092. yGizmo: AxisScaleGizmo;
  106093. /**
  106094. * Internal gizmo used for interactions on the z axis
  106095. */
  106096. zGizmo: AxisScaleGizmo;
  106097. /**
  106098. * Internal gizmo used to scale all axis equally
  106099. */
  106100. uniformScaleGizmo: AxisScaleGizmo;
  106101. private _meshAttached;
  106102. private _updateGizmoRotationToMatchAttachedMesh;
  106103. private _snapDistance;
  106104. private _scaleRatio;
  106105. private _uniformScalingMesh;
  106106. private _octahedron;
  106107. /** Fires an event when any of it's sub gizmos are dragged */
  106108. onDragStartObservable: Observable<unknown>;
  106109. /** Fires an event when any of it's sub gizmos are released from dragging */
  106110. onDragEndObservable: Observable<unknown>;
  106111. attachedMesh: Nullable<AbstractMesh>;
  106112. /**
  106113. * Creates a ScaleGizmo
  106114. * @param gizmoLayer The utility layer the gizmo will be added to
  106115. */
  106116. constructor(gizmoLayer?: UtilityLayerRenderer);
  106117. updateGizmoRotationToMatchAttachedMesh: boolean;
  106118. /**
  106119. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  106120. */
  106121. snapDistance: number;
  106122. /**
  106123. * Ratio for the scale of the gizmo (Default: 1)
  106124. */
  106125. scaleRatio: number;
  106126. /**
  106127. * Disposes of the gizmo
  106128. */
  106129. dispose(): void;
  106130. }
  106131. }
  106132. declare module BABYLON {
  106133. /**
  106134. * Single axis scale gizmo
  106135. */
  106136. export class AxisScaleGizmo extends Gizmo {
  106137. /**
  106138. * Drag behavior responsible for the gizmos dragging interactions
  106139. */
  106140. dragBehavior: PointerDragBehavior;
  106141. private _pointerObserver;
  106142. /**
  106143. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  106144. */
  106145. snapDistance: number;
  106146. /**
  106147. * Event that fires each time the gizmo snaps to a new location.
  106148. * * snapDistance is the the change in distance
  106149. */
  106150. onSnapObservable: Observable<{
  106151. snapDistance: number;
  106152. }>;
  106153. /**
  106154. * If the scaling operation should be done on all axis (default: false)
  106155. */
  106156. uniformScaling: boolean;
  106157. private _isEnabled;
  106158. private _parent;
  106159. private _arrow;
  106160. private _coloredMaterial;
  106161. private _hoverMaterial;
  106162. /**
  106163. * Creates an AxisScaleGizmo
  106164. * @param gizmoLayer The utility layer the gizmo will be added to
  106165. * @param dragAxis The axis which the gizmo will be able to scale on
  106166. * @param color The color of the gizmo
  106167. */
  106168. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  106169. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  106170. /**
  106171. * If the gizmo is enabled
  106172. */
  106173. isEnabled: boolean;
  106174. /**
  106175. * Disposes of the gizmo
  106176. */
  106177. dispose(): void;
  106178. /**
  106179. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  106180. * @param mesh The mesh to replace the default mesh of the gizmo
  106181. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  106182. */
  106183. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  106184. }
  106185. }
  106186. declare module BABYLON {
  106187. /**
  106188. * Bounding box gizmo
  106189. */
  106190. export class BoundingBoxGizmo extends Gizmo {
  106191. private _lineBoundingBox;
  106192. private _rotateSpheresParent;
  106193. private _scaleBoxesParent;
  106194. private _boundingDimensions;
  106195. private _renderObserver;
  106196. private _pointerObserver;
  106197. private _scaleDragSpeed;
  106198. private _tmpQuaternion;
  106199. private _tmpVector;
  106200. private _tmpRotationMatrix;
  106201. /**
  106202. * 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)
  106203. */
  106204. ignoreChildren: boolean;
  106205. /**
  106206. * 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)
  106207. */
  106208. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  106209. /**
  106210. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  106211. */
  106212. rotationSphereSize: number;
  106213. /**
  106214. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  106215. */
  106216. scaleBoxSize: number;
  106217. /**
  106218. * 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)
  106219. */
  106220. fixedDragMeshScreenSize: boolean;
  106221. /**
  106222. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  106223. */
  106224. fixedDragMeshScreenSizeDistanceFactor: number;
  106225. /**
  106226. * Fired when a rotation sphere or scale box is dragged
  106227. */
  106228. onDragStartObservable: Observable<{}>;
  106229. /**
  106230. * Fired when a scale box is dragged
  106231. */
  106232. onScaleBoxDragObservable: Observable<{}>;
  106233. /**
  106234. * Fired when a scale box drag is ended
  106235. */
  106236. onScaleBoxDragEndObservable: Observable<{}>;
  106237. /**
  106238. * Fired when a rotation sphere is dragged
  106239. */
  106240. onRotationSphereDragObservable: Observable<{}>;
  106241. /**
  106242. * Fired when a rotation sphere drag is ended
  106243. */
  106244. onRotationSphereDragEndObservable: Observable<{}>;
  106245. /**
  106246. * 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)
  106247. */
  106248. scalePivot: Nullable<Vector3>;
  106249. /**
  106250. * Mesh used as a pivot to rotate the attached mesh
  106251. */
  106252. private _anchorMesh;
  106253. private _existingMeshScale;
  106254. private _dragMesh;
  106255. private pointerDragBehavior;
  106256. private coloredMaterial;
  106257. private hoverColoredMaterial;
  106258. /**
  106259. * Sets the color of the bounding box gizmo
  106260. * @param color the color to set
  106261. */
  106262. setColor(color: Color3): void;
  106263. /**
  106264. * Creates an BoundingBoxGizmo
  106265. * @param gizmoLayer The utility layer the gizmo will be added to
  106266. * @param color The color of the gizmo
  106267. */
  106268. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  106269. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  106270. private _selectNode;
  106271. /**
  106272. * Updates the bounding box information for the Gizmo
  106273. */
  106274. updateBoundingBox(): void;
  106275. private _updateRotationSpheres;
  106276. private _updateScaleBoxes;
  106277. /**
  106278. * Enables rotation on the specified axis and disables rotation on the others
  106279. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  106280. */
  106281. setEnabledRotationAxis(axis: string): void;
  106282. /**
  106283. * Enables/disables scaling
  106284. * @param enable if scaling should be enabled
  106285. */
  106286. setEnabledScaling(enable: boolean): void;
  106287. private _updateDummy;
  106288. /**
  106289. * Enables a pointer drag behavior on the bounding box of the gizmo
  106290. */
  106291. enableDragBehavior(): void;
  106292. /**
  106293. * Disposes of the gizmo
  106294. */
  106295. dispose(): void;
  106296. /**
  106297. * 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)
  106298. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  106299. * @returns the bounding box mesh with the passed in mesh as a child
  106300. */
  106301. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  106302. /**
  106303. * CustomMeshes are not supported by this gizmo
  106304. * @param mesh The mesh to replace the default mesh of the gizmo
  106305. */
  106306. setCustomMesh(mesh: Mesh): void;
  106307. }
  106308. }
  106309. declare module BABYLON {
  106310. /**
  106311. * Single plane rotation gizmo
  106312. */
  106313. export class PlaneRotationGizmo extends Gizmo {
  106314. /**
  106315. * Drag behavior responsible for the gizmos dragging interactions
  106316. */
  106317. dragBehavior: PointerDragBehavior;
  106318. private _pointerObserver;
  106319. /**
  106320. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  106321. */
  106322. snapDistance: number;
  106323. /**
  106324. * Event that fires each time the gizmo snaps to a new location.
  106325. * * snapDistance is the the change in distance
  106326. */
  106327. onSnapObservable: Observable<{
  106328. snapDistance: number;
  106329. }>;
  106330. private _isEnabled;
  106331. private _parent;
  106332. /**
  106333. * Creates a PlaneRotationGizmo
  106334. * @param gizmoLayer The utility layer the gizmo will be added to
  106335. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  106336. * @param color The color of the gizmo
  106337. * @param tessellation Amount of tessellation to be used when creating rotation circles
  106338. */
  106339. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>);
  106340. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  106341. /**
  106342. * If the gizmo is enabled
  106343. */
  106344. isEnabled: boolean;
  106345. /**
  106346. * Disposes of the gizmo
  106347. */
  106348. dispose(): void;
  106349. }
  106350. }
  106351. declare module BABYLON {
  106352. /**
  106353. * Gizmo that enables rotating a mesh along 3 axis
  106354. */
  106355. export class RotationGizmo extends Gizmo {
  106356. /**
  106357. * Internal gizmo used for interactions on the x axis
  106358. */
  106359. xGizmo: PlaneRotationGizmo;
  106360. /**
  106361. * Internal gizmo used for interactions on the y axis
  106362. */
  106363. yGizmo: PlaneRotationGizmo;
  106364. /**
  106365. * Internal gizmo used for interactions on the z axis
  106366. */
  106367. zGizmo: PlaneRotationGizmo;
  106368. /** Fires an event when any of it's sub gizmos are dragged */
  106369. onDragStartObservable: Observable<unknown>;
  106370. /** Fires an event when any of it's sub gizmos are released from dragging */
  106371. onDragEndObservable: Observable<unknown>;
  106372. private _meshAttached;
  106373. attachedMesh: Nullable<AbstractMesh>;
  106374. /**
  106375. * Creates a RotationGizmo
  106376. * @param gizmoLayer The utility layer the gizmo will be added to
  106377. * @param tessellation Amount of tessellation to be used when creating rotation circles
  106378. */
  106379. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  106380. updateGizmoRotationToMatchAttachedMesh: boolean;
  106381. /**
  106382. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  106383. */
  106384. snapDistance: number;
  106385. /**
  106386. * Ratio for the scale of the gizmo (Default: 1)
  106387. */
  106388. scaleRatio: number;
  106389. /**
  106390. * Disposes of the gizmo
  106391. */
  106392. dispose(): void;
  106393. /**
  106394. * CustomMeshes are not supported by this gizmo
  106395. * @param mesh The mesh to replace the default mesh of the gizmo
  106396. */
  106397. setCustomMesh(mesh: Mesh): void;
  106398. }
  106399. }
  106400. declare module BABYLON {
  106401. /**
  106402. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  106403. */
  106404. export class GizmoManager implements IDisposable {
  106405. private scene;
  106406. /**
  106407. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  106408. */
  106409. gizmos: {
  106410. positionGizmo: Nullable<PositionGizmo>;
  106411. rotationGizmo: Nullable<RotationGizmo>;
  106412. scaleGizmo: Nullable<ScaleGizmo>;
  106413. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  106414. };
  106415. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  106416. clearGizmoOnEmptyPointerEvent: boolean;
  106417. /** Fires an event when the manager is attached to a mesh */
  106418. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  106419. private _gizmosEnabled;
  106420. private _pointerObserver;
  106421. private _attachedMesh;
  106422. private _boundingBoxColor;
  106423. private _defaultUtilityLayer;
  106424. private _defaultKeepDepthUtilityLayer;
  106425. /**
  106426. * When bounding box gizmo is enabled, this can be used to track drag/end events
  106427. */
  106428. boundingBoxDragBehavior: SixDofDragBehavior;
  106429. /**
  106430. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  106431. */
  106432. attachableMeshes: Nullable<Array<AbstractMesh>>;
  106433. /**
  106434. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  106435. */
  106436. usePointerToAttachGizmos: boolean;
  106437. /**
  106438. * Utility layer that the bounding box gizmo belongs to
  106439. */
  106440. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  106441. /**
  106442. * Utility layer that all gizmos besides bounding box belong to
  106443. */
  106444. readonly utilityLayer: UtilityLayerRenderer;
  106445. /**
  106446. * Instatiates a gizmo manager
  106447. * @param scene the scene to overlay the gizmos on top of
  106448. */
  106449. constructor(scene: Scene);
  106450. /**
  106451. * Attaches a set of gizmos to the specified mesh
  106452. * @param mesh The mesh the gizmo's should be attached to
  106453. */
  106454. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  106455. /**
  106456. * If the position gizmo is enabled
  106457. */
  106458. positionGizmoEnabled: boolean;
  106459. /**
  106460. * If the rotation gizmo is enabled
  106461. */
  106462. rotationGizmoEnabled: boolean;
  106463. /**
  106464. * If the scale gizmo is enabled
  106465. */
  106466. scaleGizmoEnabled: boolean;
  106467. /**
  106468. * If the boundingBox gizmo is enabled
  106469. */
  106470. boundingBoxGizmoEnabled: boolean;
  106471. /**
  106472. * Disposes of the gizmo manager
  106473. */
  106474. dispose(): void;
  106475. }
  106476. }
  106477. declare module BABYLON {
  106478. /**
  106479. * A directional light is defined by a direction (what a surprise!).
  106480. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  106481. * 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.
  106482. * Documentation: https://doc.babylonjs.com/babylon101/lights
  106483. */
  106484. export class DirectionalLight extends ShadowLight {
  106485. private _shadowFrustumSize;
  106486. /**
  106487. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  106488. */
  106489. /**
  106490. * Specifies a fix frustum size for the shadow generation.
  106491. */
  106492. shadowFrustumSize: number;
  106493. private _shadowOrthoScale;
  106494. /**
  106495. * Gets the shadow projection scale against the optimal computed one.
  106496. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  106497. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  106498. */
  106499. /**
  106500. * Sets the shadow projection scale against the optimal computed one.
  106501. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  106502. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  106503. */
  106504. shadowOrthoScale: number;
  106505. /**
  106506. * Automatically compute the projection matrix to best fit (including all the casters)
  106507. * on each frame.
  106508. */
  106509. autoUpdateExtends: boolean;
  106510. private _orthoLeft;
  106511. private _orthoRight;
  106512. private _orthoTop;
  106513. private _orthoBottom;
  106514. /**
  106515. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  106516. * The directional light is emitted from everywhere in the given direction.
  106517. * It can cast shadows.
  106518. * Documentation : https://doc.babylonjs.com/babylon101/lights
  106519. * @param name The friendly name of the light
  106520. * @param direction The direction of the light
  106521. * @param scene The scene the light belongs to
  106522. */
  106523. constructor(name: string, direction: Vector3, scene: Scene);
  106524. /**
  106525. * Returns the string "DirectionalLight".
  106526. * @return The class name
  106527. */
  106528. getClassName(): string;
  106529. /**
  106530. * Returns the integer 1.
  106531. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  106532. */
  106533. getTypeID(): number;
  106534. /**
  106535. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  106536. * Returns the DirectionalLight Shadow projection matrix.
  106537. */
  106538. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  106539. /**
  106540. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  106541. * Returns the DirectionalLight Shadow projection matrix.
  106542. */
  106543. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  106544. /**
  106545. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  106546. * Returns the DirectionalLight Shadow projection matrix.
  106547. */
  106548. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  106549. protected _buildUniformLayout(): void;
  106550. /**
  106551. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  106552. * @param effect The effect to update
  106553. * @param lightIndex The index of the light in the effect to update
  106554. * @returns The directional light
  106555. */
  106556. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  106557. /**
  106558. * Gets the minZ used for shadow according to both the scene and the light.
  106559. *
  106560. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  106561. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  106562. * @param activeCamera The camera we are returning the min for
  106563. * @returns the depth min z
  106564. */
  106565. getDepthMinZ(activeCamera: Camera): number;
  106566. /**
  106567. * Gets the maxZ used for shadow according to both the scene and the light.
  106568. *
  106569. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  106570. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  106571. * @param activeCamera The camera we are returning the max for
  106572. * @returns the depth max z
  106573. */
  106574. getDepthMaxZ(activeCamera: Camera): number;
  106575. /**
  106576. * Prepares the list of defines specific to the light type.
  106577. * @param defines the list of defines
  106578. * @param lightIndex defines the index of the light for the effect
  106579. */
  106580. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  106581. }
  106582. }
  106583. declare module BABYLON {
  106584. /**
  106585. * Class containing static functions to help procedurally build meshes
  106586. */
  106587. export class HemisphereBuilder {
  106588. /**
  106589. * Creates a hemisphere mesh
  106590. * @param name defines the name of the mesh
  106591. * @param options defines the options used to create the mesh
  106592. * @param scene defines the hosting scene
  106593. * @returns the hemisphere mesh
  106594. */
  106595. static CreateHemisphere(name: string, options: {
  106596. segments?: number;
  106597. diameter?: number;
  106598. sideOrientation?: number;
  106599. }, scene: any): Mesh;
  106600. }
  106601. }
  106602. declare module BABYLON {
  106603. /**
  106604. * A spot light is defined by a position, a direction, an angle, and an exponent.
  106605. * These values define a cone of light starting from the position, emitting toward the direction.
  106606. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  106607. * and the exponent defines the speed of the decay of the light with distance (reach).
  106608. * Documentation: https://doc.babylonjs.com/babylon101/lights
  106609. */
  106610. export class SpotLight extends ShadowLight {
  106611. private _angle;
  106612. private _innerAngle;
  106613. private _cosHalfAngle;
  106614. private _lightAngleScale;
  106615. private _lightAngleOffset;
  106616. /**
  106617. * Gets the cone angle of the spot light in Radians.
  106618. */
  106619. /**
  106620. * Sets the cone angle of the spot light in Radians.
  106621. */
  106622. angle: number;
  106623. /**
  106624. * Only used in gltf falloff mode, this defines the angle where
  106625. * the directional falloff will start before cutting at angle which could be seen
  106626. * as outer angle.
  106627. */
  106628. /**
  106629. * Only used in gltf falloff mode, this defines the angle where
  106630. * the directional falloff will start before cutting at angle which could be seen
  106631. * as outer angle.
  106632. */
  106633. innerAngle: number;
  106634. private _shadowAngleScale;
  106635. /**
  106636. * Allows scaling the angle of the light for shadow generation only.
  106637. */
  106638. /**
  106639. * Allows scaling the angle of the light for shadow generation only.
  106640. */
  106641. shadowAngleScale: number;
  106642. /**
  106643. * The light decay speed with the distance from the emission spot.
  106644. */
  106645. exponent: number;
  106646. private _projectionTextureMatrix;
  106647. /**
  106648. * Allows reading the projecton texture
  106649. */
  106650. readonly projectionTextureMatrix: Matrix;
  106651. protected _projectionTextureLightNear: number;
  106652. /**
  106653. * Gets the near clip of the Spotlight for texture projection.
  106654. */
  106655. /**
  106656. * Sets the near clip of the Spotlight for texture projection.
  106657. */
  106658. projectionTextureLightNear: number;
  106659. protected _projectionTextureLightFar: number;
  106660. /**
  106661. * Gets the far clip of the Spotlight for texture projection.
  106662. */
  106663. /**
  106664. * Sets the far clip of the Spotlight for texture projection.
  106665. */
  106666. projectionTextureLightFar: number;
  106667. protected _projectionTextureUpDirection: Vector3;
  106668. /**
  106669. * Gets the Up vector of the Spotlight for texture projection.
  106670. */
  106671. /**
  106672. * Sets the Up vector of the Spotlight for texture projection.
  106673. */
  106674. projectionTextureUpDirection: Vector3;
  106675. private _projectionTexture;
  106676. /**
  106677. * Gets the projection texture of the light.
  106678. */
  106679. /**
  106680. * Sets the projection texture of the light.
  106681. */
  106682. projectionTexture: Nullable<BaseTexture>;
  106683. private _projectionTextureViewLightDirty;
  106684. private _projectionTextureProjectionLightDirty;
  106685. private _projectionTextureDirty;
  106686. private _projectionTextureViewTargetVector;
  106687. private _projectionTextureViewLightMatrix;
  106688. private _projectionTextureProjectionLightMatrix;
  106689. private _projectionTextureScalingMatrix;
  106690. /**
  106691. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  106692. * It can cast shadows.
  106693. * Documentation : https://doc.babylonjs.com/babylon101/lights
  106694. * @param name The light friendly name
  106695. * @param position The position of the spot light in the scene
  106696. * @param direction The direction of the light in the scene
  106697. * @param angle The cone angle of the light in Radians
  106698. * @param exponent The light decay speed with the distance from the emission spot
  106699. * @param scene The scene the lights belongs to
  106700. */
  106701. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  106702. /**
  106703. * Returns the string "SpotLight".
  106704. * @returns the class name
  106705. */
  106706. getClassName(): string;
  106707. /**
  106708. * Returns the integer 2.
  106709. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  106710. */
  106711. getTypeID(): number;
  106712. /**
  106713. * Overrides the direction setter to recompute the projection texture view light Matrix.
  106714. */
  106715. protected _setDirection(value: Vector3): void;
  106716. /**
  106717. * Overrides the position setter to recompute the projection texture view light Matrix.
  106718. */
  106719. protected _setPosition(value: Vector3): void;
  106720. /**
  106721. * 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.
  106722. * Returns the SpotLight.
  106723. */
  106724. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  106725. protected _computeProjectionTextureViewLightMatrix(): void;
  106726. protected _computeProjectionTextureProjectionLightMatrix(): void;
  106727. /**
  106728. * Main function for light texture projection matrix computing.
  106729. */
  106730. protected _computeProjectionTextureMatrix(): void;
  106731. protected _buildUniformLayout(): void;
  106732. private _computeAngleValues;
  106733. /**
  106734. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  106735. * @param effect The effect to update
  106736. * @param lightIndex The index of the light in the effect to update
  106737. * @returns The spot light
  106738. */
  106739. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  106740. /**
  106741. * Disposes the light and the associated resources.
  106742. */
  106743. dispose(): void;
  106744. /**
  106745. * Prepares the list of defines specific to the light type.
  106746. * @param defines the list of defines
  106747. * @param lightIndex defines the index of the light for the effect
  106748. */
  106749. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  106750. }
  106751. }
  106752. declare module BABYLON {
  106753. /**
  106754. * Gizmo that enables viewing a light
  106755. */
  106756. export class LightGizmo extends Gizmo {
  106757. private _lightMesh;
  106758. private _material;
  106759. private cachedPosition;
  106760. private cachedForward;
  106761. /**
  106762. * Creates a LightGizmo
  106763. * @param gizmoLayer The utility layer the gizmo will be added to
  106764. */
  106765. constructor(gizmoLayer?: UtilityLayerRenderer);
  106766. private _light;
  106767. /**
  106768. * The light that the gizmo is attached to
  106769. */
  106770. light: Nullable<Light>;
  106771. /**
  106772. * @hidden
  106773. * Updates the gizmo to match the attached mesh's position/rotation
  106774. */
  106775. protected _update(): void;
  106776. private static _Scale;
  106777. /**
  106778. * Creates the lines for a light mesh
  106779. */
  106780. private static _createLightLines;
  106781. /**
  106782. * Disposes of the light gizmo
  106783. */
  106784. dispose(): void;
  106785. private static _CreateHemisphericLightMesh;
  106786. private static _CreatePointLightMesh;
  106787. private static _CreateSpotLightMesh;
  106788. private static _CreateDirectionalLightMesh;
  106789. }
  106790. }
  106791. declare module BABYLON {
  106792. /** @hidden */
  106793. export var backgroundFragmentDeclaration: {
  106794. name: string;
  106795. shader: string;
  106796. };
  106797. }
  106798. declare module BABYLON {
  106799. /** @hidden */
  106800. export var backgroundUboDeclaration: {
  106801. name: string;
  106802. shader: string;
  106803. };
  106804. }
  106805. declare module BABYLON {
  106806. /** @hidden */
  106807. export var backgroundPixelShader: {
  106808. name: string;
  106809. shader: string;
  106810. };
  106811. }
  106812. declare module BABYLON {
  106813. /** @hidden */
  106814. export var backgroundVertexDeclaration: {
  106815. name: string;
  106816. shader: string;
  106817. };
  106818. }
  106819. declare module BABYLON {
  106820. /** @hidden */
  106821. export var backgroundVertexShader: {
  106822. name: string;
  106823. shader: string;
  106824. };
  106825. }
  106826. declare module BABYLON {
  106827. /**
  106828. * Background material used to create an efficient environement around your scene.
  106829. */
  106830. export class BackgroundMaterial extends PushMaterial {
  106831. /**
  106832. * Standard reflectance value at parallel view angle.
  106833. */
  106834. static StandardReflectance0: number;
  106835. /**
  106836. * Standard reflectance value at grazing angle.
  106837. */
  106838. static StandardReflectance90: number;
  106839. protected _primaryColor: Color3;
  106840. /**
  106841. * Key light Color (multiply against the environement texture)
  106842. */
  106843. primaryColor: Color3;
  106844. protected __perceptualColor: Nullable<Color3>;
  106845. /**
  106846. * Experimental Internal Use Only.
  106847. *
  106848. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  106849. * This acts as a helper to set the primary color to a more "human friendly" value.
  106850. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  106851. * output color as close as possible from the chosen value.
  106852. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  106853. * part of lighting setup.)
  106854. */
  106855. _perceptualColor: Nullable<Color3>;
  106856. protected _primaryColorShadowLevel: float;
  106857. /**
  106858. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  106859. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  106860. */
  106861. primaryColorShadowLevel: float;
  106862. protected _primaryColorHighlightLevel: float;
  106863. /**
  106864. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  106865. * The primary color is used at the level chosen to define what the white area would look.
  106866. */
  106867. primaryColorHighlightLevel: float;
  106868. protected _reflectionTexture: Nullable<BaseTexture>;
  106869. /**
  106870. * Reflection Texture used in the material.
  106871. * Should be author in a specific way for the best result (refer to the documentation).
  106872. */
  106873. reflectionTexture: Nullable<BaseTexture>;
  106874. protected _reflectionBlur: float;
  106875. /**
  106876. * Reflection Texture level of blur.
  106877. *
  106878. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  106879. * texture twice.
  106880. */
  106881. reflectionBlur: float;
  106882. protected _diffuseTexture: Nullable<BaseTexture>;
  106883. /**
  106884. * Diffuse Texture used in the material.
  106885. * Should be author in a specific way for the best result (refer to the documentation).
  106886. */
  106887. diffuseTexture: Nullable<BaseTexture>;
  106888. protected _shadowLights: Nullable<IShadowLight[]>;
  106889. /**
  106890. * Specify the list of lights casting shadow on the material.
  106891. * All scene shadow lights will be included if null.
  106892. */
  106893. shadowLights: Nullable<IShadowLight[]>;
  106894. protected _shadowLevel: float;
  106895. /**
  106896. * Helps adjusting the shadow to a softer level if required.
  106897. * 0 means black shadows and 1 means no shadows.
  106898. */
  106899. shadowLevel: float;
  106900. protected _sceneCenter: Vector3;
  106901. /**
  106902. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  106903. * It is usually zero but might be interesting to modify according to your setup.
  106904. */
  106905. sceneCenter: Vector3;
  106906. protected _opacityFresnel: boolean;
  106907. /**
  106908. * This helps specifying that the material is falling off to the sky box at grazing angle.
  106909. * This helps ensuring a nice transition when the camera goes under the ground.
  106910. */
  106911. opacityFresnel: boolean;
  106912. protected _reflectionFresnel: boolean;
  106913. /**
  106914. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  106915. * This helps adding a mirror texture on the ground.
  106916. */
  106917. reflectionFresnel: boolean;
  106918. protected _reflectionFalloffDistance: number;
  106919. /**
  106920. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  106921. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  106922. */
  106923. reflectionFalloffDistance: number;
  106924. protected _reflectionAmount: number;
  106925. /**
  106926. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  106927. */
  106928. reflectionAmount: number;
  106929. protected _reflectionReflectance0: number;
  106930. /**
  106931. * This specifies the weight of the reflection at grazing angle.
  106932. */
  106933. reflectionReflectance0: number;
  106934. protected _reflectionReflectance90: number;
  106935. /**
  106936. * This specifies the weight of the reflection at a perpendicular point of view.
  106937. */
  106938. reflectionReflectance90: number;
  106939. /**
  106940. * Sets the reflection reflectance fresnel values according to the default standard
  106941. * empirically know to work well :-)
  106942. */
  106943. reflectionStandardFresnelWeight: number;
  106944. protected _useRGBColor: boolean;
  106945. /**
  106946. * Helps to directly use the maps channels instead of their level.
  106947. */
  106948. useRGBColor: boolean;
  106949. protected _enableNoise: boolean;
  106950. /**
  106951. * This helps reducing the banding effect that could occur on the background.
  106952. */
  106953. enableNoise: boolean;
  106954. /**
  106955. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  106956. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  106957. * Recommended to be keep at 1.0 except for special cases.
  106958. */
  106959. fovMultiplier: number;
  106960. private _fovMultiplier;
  106961. /**
  106962. * Enable the FOV adjustment feature controlled by fovMultiplier.
  106963. */
  106964. useEquirectangularFOV: boolean;
  106965. private _maxSimultaneousLights;
  106966. /**
  106967. * Number of Simultaneous lights allowed on the material.
  106968. */
  106969. maxSimultaneousLights: int;
  106970. /**
  106971. * Default configuration related to image processing available in the Background Material.
  106972. */
  106973. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  106974. /**
  106975. * Keep track of the image processing observer to allow dispose and replace.
  106976. */
  106977. private _imageProcessingObserver;
  106978. /**
  106979. * Attaches a new image processing configuration to the PBR Material.
  106980. * @param configuration (if null the scene configuration will be use)
  106981. */
  106982. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  106983. /**
  106984. * Gets the image processing configuration used either in this material.
  106985. */
  106986. /**
  106987. * Sets the Default image processing configuration used either in the this material.
  106988. *
  106989. * If sets to null, the scene one is in use.
  106990. */
  106991. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  106992. /**
  106993. * Gets wether the color curves effect is enabled.
  106994. */
  106995. /**
  106996. * Sets wether the color curves effect is enabled.
  106997. */
  106998. cameraColorCurvesEnabled: boolean;
  106999. /**
  107000. * Gets wether the color grading effect is enabled.
  107001. */
  107002. /**
  107003. * Gets wether the color grading effect is enabled.
  107004. */
  107005. cameraColorGradingEnabled: boolean;
  107006. /**
  107007. * Gets wether tonemapping is enabled or not.
  107008. */
  107009. /**
  107010. * Sets wether tonemapping is enabled or not
  107011. */
  107012. cameraToneMappingEnabled: boolean;
  107013. /**
  107014. * The camera exposure used on this material.
  107015. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  107016. * This corresponds to a photographic exposure.
  107017. */
  107018. /**
  107019. * The camera exposure used on this material.
  107020. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  107021. * This corresponds to a photographic exposure.
  107022. */
  107023. cameraExposure: float;
  107024. /**
  107025. * Gets The camera contrast used on this material.
  107026. */
  107027. /**
  107028. * Sets The camera contrast used on this material.
  107029. */
  107030. cameraContrast: float;
  107031. /**
  107032. * Gets the Color Grading 2D Lookup Texture.
  107033. */
  107034. /**
  107035. * Sets the Color Grading 2D Lookup Texture.
  107036. */
  107037. cameraColorGradingTexture: Nullable<BaseTexture>;
  107038. /**
  107039. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  107040. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  107041. * 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;
  107042. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  107043. */
  107044. /**
  107045. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  107046. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  107047. * 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;
  107048. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  107049. */
  107050. cameraColorCurves: Nullable<ColorCurves>;
  107051. /**
  107052. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  107053. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  107054. */
  107055. switchToBGR: boolean;
  107056. private _renderTargets;
  107057. private _reflectionControls;
  107058. private _white;
  107059. private _primaryShadowColor;
  107060. private _primaryHighlightColor;
  107061. /**
  107062. * Instantiates a Background Material in the given scene
  107063. * @param name The friendly name of the material
  107064. * @param scene The scene to add the material to
  107065. */
  107066. constructor(name: string, scene: Scene);
  107067. /**
  107068. * Gets a boolean indicating that current material needs to register RTT
  107069. */
  107070. readonly hasRenderTargetTextures: boolean;
  107071. /**
  107072. * The entire material has been created in order to prevent overdraw.
  107073. * @returns false
  107074. */
  107075. needAlphaTesting(): boolean;
  107076. /**
  107077. * The entire material has been created in order to prevent overdraw.
  107078. * @returns true if blending is enable
  107079. */
  107080. needAlphaBlending(): boolean;
  107081. /**
  107082. * Checks wether the material is ready to be rendered for a given mesh.
  107083. * @param mesh The mesh to render
  107084. * @param subMesh The submesh to check against
  107085. * @param useInstances Specify wether or not the material is used with instances
  107086. * @returns true if all the dependencies are ready (Textures, Effects...)
  107087. */
  107088. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  107089. /**
  107090. * Compute the primary color according to the chosen perceptual color.
  107091. */
  107092. private _computePrimaryColorFromPerceptualColor;
  107093. /**
  107094. * Compute the highlights and shadow colors according to their chosen levels.
  107095. */
  107096. private _computePrimaryColors;
  107097. /**
  107098. * Build the uniform buffer used in the material.
  107099. */
  107100. buildUniformLayout(): void;
  107101. /**
  107102. * Unbind the material.
  107103. */
  107104. unbind(): void;
  107105. /**
  107106. * Bind only the world matrix to the material.
  107107. * @param world The world matrix to bind.
  107108. */
  107109. bindOnlyWorldMatrix(world: Matrix): void;
  107110. /**
  107111. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  107112. * @param world The world matrix to bind.
  107113. * @param subMesh The submesh to bind for.
  107114. */
  107115. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  107116. /**
  107117. * Dispose the material.
  107118. * @param forceDisposeEffect Force disposal of the associated effect.
  107119. * @param forceDisposeTextures Force disposal of the associated textures.
  107120. */
  107121. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  107122. /**
  107123. * Clones the material.
  107124. * @param name The cloned name.
  107125. * @returns The cloned material.
  107126. */
  107127. clone(name: string): BackgroundMaterial;
  107128. /**
  107129. * Serializes the current material to its JSON representation.
  107130. * @returns The JSON representation.
  107131. */
  107132. serialize(): any;
  107133. /**
  107134. * Gets the class name of the material
  107135. * @returns "BackgroundMaterial"
  107136. */
  107137. getClassName(): string;
  107138. /**
  107139. * Parse a JSON input to create back a background material.
  107140. * @param source The JSON data to parse
  107141. * @param scene The scene to create the parsed material in
  107142. * @param rootUrl The root url of the assets the material depends upon
  107143. * @returns the instantiated BackgroundMaterial.
  107144. */
  107145. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  107146. }
  107147. }
  107148. declare module BABYLON {
  107149. /**
  107150. * Represents the different options available during the creation of
  107151. * a Environment helper.
  107152. *
  107153. * This can control the default ground, skybox and image processing setup of your scene.
  107154. */
  107155. export interface IEnvironmentHelperOptions {
  107156. /**
  107157. * Specifies wether or not to create a ground.
  107158. * True by default.
  107159. */
  107160. createGround: boolean;
  107161. /**
  107162. * Specifies the ground size.
  107163. * 15 by default.
  107164. */
  107165. groundSize: number;
  107166. /**
  107167. * The texture used on the ground for the main color.
  107168. * Comes from the BabylonJS CDN by default.
  107169. *
  107170. * Remarks: Can be either a texture or a url.
  107171. */
  107172. groundTexture: string | BaseTexture;
  107173. /**
  107174. * The color mixed in the ground texture by default.
  107175. * BabylonJS clearColor by default.
  107176. */
  107177. groundColor: Color3;
  107178. /**
  107179. * Specifies the ground opacity.
  107180. * 1 by default.
  107181. */
  107182. groundOpacity: number;
  107183. /**
  107184. * Enables the ground to receive shadows.
  107185. * True by default.
  107186. */
  107187. enableGroundShadow: boolean;
  107188. /**
  107189. * Helps preventing the shadow to be fully black on the ground.
  107190. * 0.5 by default.
  107191. */
  107192. groundShadowLevel: number;
  107193. /**
  107194. * Creates a mirror texture attach to the ground.
  107195. * false by default.
  107196. */
  107197. enableGroundMirror: boolean;
  107198. /**
  107199. * Specifies the ground mirror size ratio.
  107200. * 0.3 by default as the default kernel is 64.
  107201. */
  107202. groundMirrorSizeRatio: number;
  107203. /**
  107204. * Specifies the ground mirror blur kernel size.
  107205. * 64 by default.
  107206. */
  107207. groundMirrorBlurKernel: number;
  107208. /**
  107209. * Specifies the ground mirror visibility amount.
  107210. * 1 by default
  107211. */
  107212. groundMirrorAmount: number;
  107213. /**
  107214. * Specifies the ground mirror reflectance weight.
  107215. * This uses the standard weight of the background material to setup the fresnel effect
  107216. * of the mirror.
  107217. * 1 by default.
  107218. */
  107219. groundMirrorFresnelWeight: number;
  107220. /**
  107221. * Specifies the ground mirror Falloff distance.
  107222. * This can helps reducing the size of the reflection.
  107223. * 0 by Default.
  107224. */
  107225. groundMirrorFallOffDistance: number;
  107226. /**
  107227. * Specifies the ground mirror texture type.
  107228. * Unsigned Int by Default.
  107229. */
  107230. groundMirrorTextureType: number;
  107231. /**
  107232. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  107233. * the shown objects.
  107234. */
  107235. groundYBias: number;
  107236. /**
  107237. * Specifies wether or not to create a skybox.
  107238. * True by default.
  107239. */
  107240. createSkybox: boolean;
  107241. /**
  107242. * Specifies the skybox size.
  107243. * 20 by default.
  107244. */
  107245. skyboxSize: number;
  107246. /**
  107247. * The texture used on the skybox for the main color.
  107248. * Comes from the BabylonJS CDN by default.
  107249. *
  107250. * Remarks: Can be either a texture or a url.
  107251. */
  107252. skyboxTexture: string | BaseTexture;
  107253. /**
  107254. * The color mixed in the skybox texture by default.
  107255. * BabylonJS clearColor by default.
  107256. */
  107257. skyboxColor: Color3;
  107258. /**
  107259. * The background rotation around the Y axis of the scene.
  107260. * This helps aligning the key lights of your scene with the background.
  107261. * 0 by default.
  107262. */
  107263. backgroundYRotation: number;
  107264. /**
  107265. * Compute automatically the size of the elements to best fit with the scene.
  107266. */
  107267. sizeAuto: boolean;
  107268. /**
  107269. * Default position of the rootMesh if autoSize is not true.
  107270. */
  107271. rootPosition: Vector3;
  107272. /**
  107273. * Sets up the image processing in the scene.
  107274. * true by default.
  107275. */
  107276. setupImageProcessing: boolean;
  107277. /**
  107278. * The texture used as your environment texture in the scene.
  107279. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  107280. *
  107281. * Remarks: Can be either a texture or a url.
  107282. */
  107283. environmentTexture: string | BaseTexture;
  107284. /**
  107285. * The value of the exposure to apply to the scene.
  107286. * 0.6 by default if setupImageProcessing is true.
  107287. */
  107288. cameraExposure: number;
  107289. /**
  107290. * The value of the contrast to apply to the scene.
  107291. * 1.6 by default if setupImageProcessing is true.
  107292. */
  107293. cameraContrast: number;
  107294. /**
  107295. * Specifies wether or not tonemapping should be enabled in the scene.
  107296. * true by default if setupImageProcessing is true.
  107297. */
  107298. toneMappingEnabled: boolean;
  107299. }
  107300. /**
  107301. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  107302. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  107303. * It also helps with the default setup of your imageProcessing configuration.
  107304. */
  107305. export class EnvironmentHelper {
  107306. /**
  107307. * Default ground texture URL.
  107308. */
  107309. private static _groundTextureCDNUrl;
  107310. /**
  107311. * Default skybox texture URL.
  107312. */
  107313. private static _skyboxTextureCDNUrl;
  107314. /**
  107315. * Default environment texture URL.
  107316. */
  107317. private static _environmentTextureCDNUrl;
  107318. /**
  107319. * Creates the default options for the helper.
  107320. */
  107321. private static _getDefaultOptions;
  107322. private _rootMesh;
  107323. /**
  107324. * Gets the root mesh created by the helper.
  107325. */
  107326. readonly rootMesh: Mesh;
  107327. private _skybox;
  107328. /**
  107329. * Gets the skybox created by the helper.
  107330. */
  107331. readonly skybox: Nullable<Mesh>;
  107332. private _skyboxTexture;
  107333. /**
  107334. * Gets the skybox texture created by the helper.
  107335. */
  107336. readonly skyboxTexture: Nullable<BaseTexture>;
  107337. private _skyboxMaterial;
  107338. /**
  107339. * Gets the skybox material created by the helper.
  107340. */
  107341. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  107342. private _ground;
  107343. /**
  107344. * Gets the ground mesh created by the helper.
  107345. */
  107346. readonly ground: Nullable<Mesh>;
  107347. private _groundTexture;
  107348. /**
  107349. * Gets the ground texture created by the helper.
  107350. */
  107351. readonly groundTexture: Nullable<BaseTexture>;
  107352. private _groundMirror;
  107353. /**
  107354. * Gets the ground mirror created by the helper.
  107355. */
  107356. readonly groundMirror: Nullable<MirrorTexture>;
  107357. /**
  107358. * Gets the ground mirror render list to helps pushing the meshes
  107359. * you wish in the ground reflection.
  107360. */
  107361. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  107362. private _groundMaterial;
  107363. /**
  107364. * Gets the ground material created by the helper.
  107365. */
  107366. readonly groundMaterial: Nullable<BackgroundMaterial>;
  107367. /**
  107368. * Stores the creation options.
  107369. */
  107370. private readonly _scene;
  107371. private _options;
  107372. /**
  107373. * This observable will be notified with any error during the creation of the environment,
  107374. * mainly texture creation errors.
  107375. */
  107376. onErrorObservable: Observable<{
  107377. message?: string;
  107378. exception?: any;
  107379. }>;
  107380. /**
  107381. * constructor
  107382. * @param options Defines the options we want to customize the helper
  107383. * @param scene The scene to add the material to
  107384. */
  107385. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  107386. /**
  107387. * Updates the background according to the new options
  107388. * @param options
  107389. */
  107390. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  107391. /**
  107392. * Sets the primary color of all the available elements.
  107393. * @param color the main color to affect to the ground and the background
  107394. */
  107395. setMainColor(color: Color3): void;
  107396. /**
  107397. * Setup the image processing according to the specified options.
  107398. */
  107399. private _setupImageProcessing;
  107400. /**
  107401. * Setup the environment texture according to the specified options.
  107402. */
  107403. private _setupEnvironmentTexture;
  107404. /**
  107405. * Setup the background according to the specified options.
  107406. */
  107407. private _setupBackground;
  107408. /**
  107409. * Get the scene sizes according to the setup.
  107410. */
  107411. private _getSceneSize;
  107412. /**
  107413. * Setup the ground according to the specified options.
  107414. */
  107415. private _setupGround;
  107416. /**
  107417. * Setup the ground material according to the specified options.
  107418. */
  107419. private _setupGroundMaterial;
  107420. /**
  107421. * Setup the ground diffuse texture according to the specified options.
  107422. */
  107423. private _setupGroundDiffuseTexture;
  107424. /**
  107425. * Setup the ground mirror texture according to the specified options.
  107426. */
  107427. private _setupGroundMirrorTexture;
  107428. /**
  107429. * Setup the ground to receive the mirror texture.
  107430. */
  107431. private _setupMirrorInGroundMaterial;
  107432. /**
  107433. * Setup the skybox according to the specified options.
  107434. */
  107435. private _setupSkybox;
  107436. /**
  107437. * Setup the skybox material according to the specified options.
  107438. */
  107439. private _setupSkyboxMaterial;
  107440. /**
  107441. * Setup the skybox reflection texture according to the specified options.
  107442. */
  107443. private _setupSkyboxReflectionTexture;
  107444. private _errorHandler;
  107445. /**
  107446. * Dispose all the elements created by the Helper.
  107447. */
  107448. dispose(): void;
  107449. }
  107450. }
  107451. declare module BABYLON {
  107452. /**
  107453. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  107454. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  107455. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  107456. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  107457. */
  107458. export class PhotoDome extends TransformNode {
  107459. /**
  107460. * Define the image as a Monoscopic panoramic 360 image.
  107461. */
  107462. static readonly MODE_MONOSCOPIC: number;
  107463. /**
  107464. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  107465. */
  107466. static readonly MODE_TOPBOTTOM: number;
  107467. /**
  107468. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  107469. */
  107470. static readonly MODE_SIDEBYSIDE: number;
  107471. private _useDirectMapping;
  107472. /**
  107473. * The texture being displayed on the sphere
  107474. */
  107475. protected _photoTexture: Texture;
  107476. /**
  107477. * Gets or sets the texture being displayed on the sphere
  107478. */
  107479. photoTexture: Texture;
  107480. /**
  107481. * Observable raised when an error occured while loading the 360 image
  107482. */
  107483. onLoadErrorObservable: Observable<string>;
  107484. /**
  107485. * The skybox material
  107486. */
  107487. protected _material: BackgroundMaterial;
  107488. /**
  107489. * The surface used for the skybox
  107490. */
  107491. protected _mesh: Mesh;
  107492. /**
  107493. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  107494. * Also see the options.resolution property.
  107495. */
  107496. fovMultiplier: number;
  107497. private _imageMode;
  107498. /**
  107499. * Gets or set the current video mode for the video. It can be:
  107500. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  107501. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  107502. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  107503. */
  107504. imageMode: number;
  107505. /**
  107506. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  107507. * @param name Element's name, child elements will append suffixes for their own names.
  107508. * @param urlsOfPhoto defines the url of the photo to display
  107509. * @param options defines an object containing optional or exposed sub element properties
  107510. * @param onError defines a callback called when an error occured while loading the texture
  107511. */
  107512. constructor(name: string, urlOfPhoto: string, options: {
  107513. resolution?: number;
  107514. size?: number;
  107515. useDirectMapping?: boolean;
  107516. faceForward?: boolean;
  107517. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  107518. private _onBeforeCameraRenderObserver;
  107519. private _changeImageMode;
  107520. /**
  107521. * Releases resources associated with this node.
  107522. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  107523. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  107524. */
  107525. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  107526. }
  107527. }
  107528. declare module BABYLON {
  107529. /** @hidden */
  107530. export var rgbdDecodePixelShader: {
  107531. name: string;
  107532. shader: string;
  107533. };
  107534. }
  107535. declare module BABYLON {
  107536. /**
  107537. * Class used to host texture specific utilities
  107538. */
  107539. export class BRDFTextureTools {
  107540. /**
  107541. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  107542. * @param texture the texture to expand.
  107543. */
  107544. private static _ExpandDefaultBRDFTexture;
  107545. /**
  107546. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  107547. * @param scene defines the hosting scene
  107548. * @returns the environment BRDF texture
  107549. */
  107550. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  107551. private static _environmentBRDFBase64Texture;
  107552. }
  107553. }
  107554. declare module BABYLON {
  107555. /**
  107556. * @hidden
  107557. */
  107558. export interface IMaterialClearCoatDefines {
  107559. CLEARCOAT: boolean;
  107560. CLEARCOAT_DEFAULTIOR: boolean;
  107561. CLEARCOAT_TEXTURE: boolean;
  107562. CLEARCOAT_TEXTUREDIRECTUV: number;
  107563. CLEARCOAT_BUMP: boolean;
  107564. CLEARCOAT_BUMPDIRECTUV: number;
  107565. CLEARCOAT_TINT: boolean;
  107566. CLEARCOAT_TINT_TEXTURE: boolean;
  107567. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  107568. /** @hidden */
  107569. _areTexturesDirty: boolean;
  107570. }
  107571. /**
  107572. * Define the code related to the clear coat parameters of the pbr material.
  107573. */
  107574. export class PBRClearCoatConfiguration {
  107575. /**
  107576. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  107577. * The default fits with a polyurethane material.
  107578. */
  107579. private static readonly _DefaultIndexOfRefraction;
  107580. private _isEnabled;
  107581. /**
  107582. * Defines if the clear coat is enabled in the material.
  107583. */
  107584. isEnabled: boolean;
  107585. /**
  107586. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  107587. */
  107588. intensity: number;
  107589. /**
  107590. * Defines the clear coat layer roughness.
  107591. */
  107592. roughness: number;
  107593. private _indexOfRefraction;
  107594. /**
  107595. * Defines the index of refraction of the clear coat.
  107596. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  107597. * The default fits with a polyurethane material.
  107598. * Changing the default value is more performance intensive.
  107599. */
  107600. indexOfRefraction: number;
  107601. private _texture;
  107602. /**
  107603. * Stores the clear coat values in a texture.
  107604. */
  107605. texture: Nullable<BaseTexture>;
  107606. private _bumpTexture;
  107607. /**
  107608. * Define the clear coat specific bump texture.
  107609. */
  107610. bumpTexture: Nullable<BaseTexture>;
  107611. private _isTintEnabled;
  107612. /**
  107613. * Defines if the clear coat tint is enabled in the material.
  107614. */
  107615. isTintEnabled: boolean;
  107616. /**
  107617. * Defines the clear coat tint of the material.
  107618. * This is only use if tint is enabled
  107619. */
  107620. tintColor: Color3;
  107621. /**
  107622. * Defines the distance at which the tint color should be found in the
  107623. * clear coat media.
  107624. * This is only use if tint is enabled
  107625. */
  107626. tintColorAtDistance: number;
  107627. /**
  107628. * Defines the clear coat layer thickness.
  107629. * This is only use if tint is enabled
  107630. */
  107631. tintThickness: number;
  107632. private _tintTexture;
  107633. /**
  107634. * Stores the clear tint values in a texture.
  107635. * rgb is tint
  107636. * a is a thickness factor
  107637. */
  107638. tintTexture: Nullable<BaseTexture>;
  107639. /** @hidden */
  107640. private _internalMarkAllSubMeshesAsTexturesDirty;
  107641. /** @hidden */
  107642. _markAllSubMeshesAsTexturesDirty(): void;
  107643. /**
  107644. * Instantiate a new istance of clear coat configuration.
  107645. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  107646. */
  107647. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  107648. /**
  107649. * Gets wehter the submesh is ready to be used or not.
  107650. * @param defines the list of "defines" to update.
  107651. * @param scene defines the scene the material belongs to.
  107652. * @param engine defines the engine the material belongs to.
  107653. * @param disableBumpMap defines wether the material disables bump or not.
  107654. * @returns - boolean indicating that the submesh is ready or not.
  107655. */
  107656. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  107657. /**
  107658. * Checks to see if a texture is used in the material.
  107659. * @param defines the list of "defines" to update.
  107660. * @param scene defines the scene to the material belongs to.
  107661. */
  107662. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  107663. /**
  107664. * Binds the material data.
  107665. * @param uniformBuffer defines the Uniform buffer to fill in.
  107666. * @param scene defines the scene the material belongs to.
  107667. * @param engine defines the engine the material belongs to.
  107668. * @param disableBumpMap defines wether the material disables bump or not.
  107669. * @param isFrozen defines wether the material is frozen or not.
  107670. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  107671. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  107672. */
  107673. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  107674. /**
  107675. * Checks to see if a texture is used in the material.
  107676. * @param texture - Base texture to use.
  107677. * @returns - Boolean specifying if a texture is used in the material.
  107678. */
  107679. hasTexture(texture: BaseTexture): boolean;
  107680. /**
  107681. * Returns an array of the actively used textures.
  107682. * @param activeTextures Array of BaseTextures
  107683. */
  107684. getActiveTextures(activeTextures: BaseTexture[]): void;
  107685. /**
  107686. * Returns the animatable textures.
  107687. * @param animatables Array of animatable textures.
  107688. */
  107689. getAnimatables(animatables: IAnimatable[]): void;
  107690. /**
  107691. * Disposes the resources of the material.
  107692. * @param forceDisposeTextures - Forces the disposal of all textures.
  107693. */
  107694. dispose(forceDisposeTextures?: boolean): void;
  107695. /**
  107696. * Get the current class name of the texture useful for serialization or dynamic coding.
  107697. * @returns "PBRClearCoatConfiguration"
  107698. */
  107699. getClassName(): string;
  107700. /**
  107701. * Add fallbacks to the effect fallbacks list.
  107702. * @param defines defines the Base texture to use.
  107703. * @param fallbacks defines the current fallback list.
  107704. * @param currentRank defines the current fallback rank.
  107705. * @returns the new fallback rank.
  107706. */
  107707. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  107708. /**
  107709. * Add the required uniforms to the current list.
  107710. * @param uniforms defines the current uniform list.
  107711. */
  107712. static AddUniforms(uniforms: string[]): void;
  107713. /**
  107714. * Add the required samplers to the current list.
  107715. * @param samplers defines the current sampler list.
  107716. */
  107717. static AddSamplers(samplers: string[]): void;
  107718. /**
  107719. * Add the required uniforms to the current buffer.
  107720. * @param uniformBuffer defines the current uniform buffer.
  107721. */
  107722. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  107723. /**
  107724. * Makes a duplicate of the current configuration into another one.
  107725. * @param clearCoatConfiguration define the config where to copy the info
  107726. */
  107727. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  107728. /**
  107729. * Serializes this clear coat configuration.
  107730. * @returns - An object with the serialized config.
  107731. */
  107732. serialize(): any;
  107733. /**
  107734. * Parses a anisotropy Configuration from a serialized object.
  107735. * @param source - Serialized object.
  107736. * @param scene Defines the scene we are parsing for
  107737. * @param rootUrl Defines the rootUrl to load from
  107738. */
  107739. parse(source: any, scene: Scene, rootUrl: string): void;
  107740. }
  107741. }
  107742. declare module BABYLON {
  107743. /**
  107744. * @hidden
  107745. */
  107746. export interface IMaterialAnisotropicDefines {
  107747. ANISOTROPIC: boolean;
  107748. ANISOTROPIC_TEXTURE: boolean;
  107749. ANISOTROPIC_TEXTUREDIRECTUV: number;
  107750. MAINUV1: boolean;
  107751. _areTexturesDirty: boolean;
  107752. _needUVs: boolean;
  107753. }
  107754. /**
  107755. * Define the code related to the anisotropic parameters of the pbr material.
  107756. */
  107757. export class PBRAnisotropicConfiguration {
  107758. private _isEnabled;
  107759. /**
  107760. * Defines if the anisotropy is enabled in the material.
  107761. */
  107762. isEnabled: boolean;
  107763. /**
  107764. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  107765. */
  107766. intensity: number;
  107767. /**
  107768. * Defines if the effect is along the tangents, bitangents or in between.
  107769. * By default, the effect is "strectching" the highlights along the tangents.
  107770. */
  107771. direction: Vector2;
  107772. private _texture;
  107773. /**
  107774. * Stores the anisotropy values in a texture.
  107775. * rg is direction (like normal from -1 to 1)
  107776. * b is a intensity
  107777. */
  107778. texture: Nullable<BaseTexture>;
  107779. /** @hidden */
  107780. private _internalMarkAllSubMeshesAsTexturesDirty;
  107781. /** @hidden */
  107782. _markAllSubMeshesAsTexturesDirty(): void;
  107783. /**
  107784. * Instantiate a new istance of anisotropy configuration.
  107785. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  107786. */
  107787. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  107788. /**
  107789. * Specifies that the submesh is ready to be used.
  107790. * @param defines the list of "defines" to update.
  107791. * @param scene defines the scene the material belongs to.
  107792. * @returns - boolean indicating that the submesh is ready or not.
  107793. */
  107794. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  107795. /**
  107796. * Checks to see if a texture is used in the material.
  107797. * @param defines the list of "defines" to update.
  107798. * @param mesh the mesh we are preparing the defines for.
  107799. * @param scene defines the scene the material belongs to.
  107800. */
  107801. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  107802. /**
  107803. * Binds the material data.
  107804. * @param uniformBuffer defines the Uniform buffer to fill in.
  107805. * @param scene defines the scene the material belongs to.
  107806. * @param isFrozen defines wether the material is frozen or not.
  107807. */
  107808. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  107809. /**
  107810. * Checks to see if a texture is used in the material.
  107811. * @param texture - Base texture to use.
  107812. * @returns - Boolean specifying if a texture is used in the material.
  107813. */
  107814. hasTexture(texture: BaseTexture): boolean;
  107815. /**
  107816. * Returns an array of the actively used textures.
  107817. * @param activeTextures Array of BaseTextures
  107818. */
  107819. getActiveTextures(activeTextures: BaseTexture[]): void;
  107820. /**
  107821. * Returns the animatable textures.
  107822. * @param animatables Array of animatable textures.
  107823. */
  107824. getAnimatables(animatables: IAnimatable[]): void;
  107825. /**
  107826. * Disposes the resources of the material.
  107827. * @param forceDisposeTextures - Forces the disposal of all textures.
  107828. */
  107829. dispose(forceDisposeTextures?: boolean): void;
  107830. /**
  107831. * Get the current class name of the texture useful for serialization or dynamic coding.
  107832. * @returns "PBRAnisotropicConfiguration"
  107833. */
  107834. getClassName(): string;
  107835. /**
  107836. * Add fallbacks to the effect fallbacks list.
  107837. * @param defines defines the Base texture to use.
  107838. * @param fallbacks defines the current fallback list.
  107839. * @param currentRank defines the current fallback rank.
  107840. * @returns the new fallback rank.
  107841. */
  107842. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  107843. /**
  107844. * Add the required uniforms to the current list.
  107845. * @param uniforms defines the current uniform list.
  107846. */
  107847. static AddUniforms(uniforms: string[]): void;
  107848. /**
  107849. * Add the required uniforms to the current buffer.
  107850. * @param uniformBuffer defines the current uniform buffer.
  107851. */
  107852. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  107853. /**
  107854. * Add the required samplers to the current list.
  107855. * @param samplers defines the current sampler list.
  107856. */
  107857. static AddSamplers(samplers: string[]): void;
  107858. /**
  107859. * Makes a duplicate of the current configuration into another one.
  107860. * @param anisotropicConfiguration define the config where to copy the info
  107861. */
  107862. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  107863. /**
  107864. * Serializes this anisotropy configuration.
  107865. * @returns - An object with the serialized config.
  107866. */
  107867. serialize(): any;
  107868. /**
  107869. * Parses a anisotropy Configuration from a serialized object.
  107870. * @param source - Serialized object.
  107871. * @param scene Defines the scene we are parsing for
  107872. * @param rootUrl Defines the rootUrl to load from
  107873. */
  107874. parse(source: any, scene: Scene, rootUrl: string): void;
  107875. }
  107876. }
  107877. declare module BABYLON {
  107878. /**
  107879. * @hidden
  107880. */
  107881. export interface IMaterialBRDFDefines {
  107882. BRDF_V_HEIGHT_CORRELATED: boolean;
  107883. MS_BRDF_ENERGY_CONSERVATION: boolean;
  107884. SPHERICAL_HARMONICS: boolean;
  107885. /** @hidden */
  107886. _areMiscDirty: boolean;
  107887. }
  107888. /**
  107889. * Define the code related to the BRDF parameters of the pbr material.
  107890. */
  107891. export class PBRBRDFConfiguration {
  107892. /**
  107893. * Default value used for the energy conservation.
  107894. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  107895. */
  107896. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  107897. /**
  107898. * Default value used for the Smith Visibility Height Correlated mode.
  107899. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  107900. */
  107901. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  107902. /**
  107903. * Default value used for the IBL diffuse part.
  107904. * This can help switching back to the polynomials mode globally which is a tiny bit
  107905. * less GPU intensive at the drawback of a lower quality.
  107906. */
  107907. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  107908. private _useEnergyConservation;
  107909. /**
  107910. * Defines if the material uses energy conservation.
  107911. */
  107912. useEnergyConservation: boolean;
  107913. private _useSmithVisibilityHeightCorrelated;
  107914. /**
  107915. * LEGACY Mode set to false
  107916. * Defines if the material uses height smith correlated visibility term.
  107917. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  107918. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  107919. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  107920. * Not relying on height correlated will also disable energy conservation.
  107921. */
  107922. useSmithVisibilityHeightCorrelated: boolean;
  107923. private _useSphericalHarmonics;
  107924. /**
  107925. * LEGACY Mode set to false
  107926. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  107927. * diffuse part of the IBL.
  107928. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  107929. * to the ground truth.
  107930. */
  107931. useSphericalHarmonics: boolean;
  107932. /** @hidden */
  107933. private _internalMarkAllSubMeshesAsMiscDirty;
  107934. /** @hidden */
  107935. _markAllSubMeshesAsMiscDirty(): void;
  107936. /**
  107937. * Instantiate a new istance of clear coat configuration.
  107938. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  107939. */
  107940. constructor(markAllSubMeshesAsMiscDirty: () => void);
  107941. /**
  107942. * Checks to see if a texture is used in the material.
  107943. * @param defines the list of "defines" to update.
  107944. */
  107945. prepareDefines(defines: IMaterialBRDFDefines): void;
  107946. /**
  107947. * Get the current class name of the texture useful for serialization or dynamic coding.
  107948. * @returns "PBRClearCoatConfiguration"
  107949. */
  107950. getClassName(): string;
  107951. /**
  107952. * Makes a duplicate of the current configuration into another one.
  107953. * @param brdfConfiguration define the config where to copy the info
  107954. */
  107955. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  107956. /**
  107957. * Serializes this BRDF configuration.
  107958. * @returns - An object with the serialized config.
  107959. */
  107960. serialize(): any;
  107961. /**
  107962. * Parses a anisotropy Configuration from a serialized object.
  107963. * @param source - Serialized object.
  107964. * @param scene Defines the scene we are parsing for
  107965. * @param rootUrl Defines the rootUrl to load from
  107966. */
  107967. parse(source: any, scene: Scene, rootUrl: string): void;
  107968. }
  107969. }
  107970. declare module BABYLON {
  107971. /**
  107972. * @hidden
  107973. */
  107974. export interface IMaterialSheenDefines {
  107975. SHEEN: boolean;
  107976. SHEEN_TEXTURE: boolean;
  107977. SHEEN_TEXTUREDIRECTUV: number;
  107978. SHEEN_LINKWITHALBEDO: boolean;
  107979. /** @hidden */
  107980. _areTexturesDirty: boolean;
  107981. }
  107982. /**
  107983. * Define the code related to the Sheen parameters of the pbr material.
  107984. */
  107985. export class PBRSheenConfiguration {
  107986. private _isEnabled;
  107987. /**
  107988. * Defines if the material uses sheen.
  107989. */
  107990. isEnabled: boolean;
  107991. private _linkSheenWithAlbedo;
  107992. /**
  107993. * Defines if the sheen is linked to the sheen color.
  107994. */
  107995. linkSheenWithAlbedo: boolean;
  107996. /**
  107997. * Defines the sheen intensity.
  107998. */
  107999. intensity: number;
  108000. /**
  108001. * Defines the sheen color.
  108002. */
  108003. color: Color3;
  108004. private _texture;
  108005. /**
  108006. * Stores the sheen tint values in a texture.
  108007. * rgb is tint
  108008. * a is a intensity
  108009. */
  108010. texture: Nullable<BaseTexture>;
  108011. /** @hidden */
  108012. private _internalMarkAllSubMeshesAsTexturesDirty;
  108013. /** @hidden */
  108014. _markAllSubMeshesAsTexturesDirty(): void;
  108015. /**
  108016. * Instantiate a new istance of clear coat configuration.
  108017. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  108018. */
  108019. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  108020. /**
  108021. * Specifies that the submesh is ready to be used.
  108022. * @param defines the list of "defines" to update.
  108023. * @param scene defines the scene the material belongs to.
  108024. * @returns - boolean indicating that the submesh is ready or not.
  108025. */
  108026. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  108027. /**
  108028. * Checks to see if a texture is used in the material.
  108029. * @param defines the list of "defines" to update.
  108030. * @param scene defines the scene the material belongs to.
  108031. */
  108032. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  108033. /**
  108034. * Binds the material data.
  108035. * @param uniformBuffer defines the Uniform buffer to fill in.
  108036. * @param scene defines the scene the material belongs to.
  108037. * @param isFrozen defines wether the material is frozen or not.
  108038. */
  108039. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  108040. /**
  108041. * Checks to see if a texture is used in the material.
  108042. * @param texture - Base texture to use.
  108043. * @returns - Boolean specifying if a texture is used in the material.
  108044. */
  108045. hasTexture(texture: BaseTexture): boolean;
  108046. /**
  108047. * Returns an array of the actively used textures.
  108048. * @param activeTextures Array of BaseTextures
  108049. */
  108050. getActiveTextures(activeTextures: BaseTexture[]): void;
  108051. /**
  108052. * Returns the animatable textures.
  108053. * @param animatables Array of animatable textures.
  108054. */
  108055. getAnimatables(animatables: IAnimatable[]): void;
  108056. /**
  108057. * Disposes the resources of the material.
  108058. * @param forceDisposeTextures - Forces the disposal of all textures.
  108059. */
  108060. dispose(forceDisposeTextures?: boolean): void;
  108061. /**
  108062. * Get the current class name of the texture useful for serialization or dynamic coding.
  108063. * @returns "PBRSheenConfiguration"
  108064. */
  108065. getClassName(): string;
  108066. /**
  108067. * Add fallbacks to the effect fallbacks list.
  108068. * @param defines defines the Base texture to use.
  108069. * @param fallbacks defines the current fallback list.
  108070. * @param currentRank defines the current fallback rank.
  108071. * @returns the new fallback rank.
  108072. */
  108073. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  108074. /**
  108075. * Add the required uniforms to the current list.
  108076. * @param uniforms defines the current uniform list.
  108077. */
  108078. static AddUniforms(uniforms: string[]): void;
  108079. /**
  108080. * Add the required uniforms to the current buffer.
  108081. * @param uniformBuffer defines the current uniform buffer.
  108082. */
  108083. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  108084. /**
  108085. * Add the required samplers to the current list.
  108086. * @param samplers defines the current sampler list.
  108087. */
  108088. static AddSamplers(samplers: string[]): void;
  108089. /**
  108090. * Makes a duplicate of the current configuration into another one.
  108091. * @param sheenConfiguration define the config where to copy the info
  108092. */
  108093. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  108094. /**
  108095. * Serializes this BRDF configuration.
  108096. * @returns - An object with the serialized config.
  108097. */
  108098. serialize(): any;
  108099. /**
  108100. * Parses a anisotropy Configuration from a serialized object.
  108101. * @param source - Serialized object.
  108102. * @param scene Defines the scene we are parsing for
  108103. * @param rootUrl Defines the rootUrl to load from
  108104. */
  108105. parse(source: any, scene: Scene, rootUrl: string): void;
  108106. }
  108107. }
  108108. declare module BABYLON {
  108109. /**
  108110. * @hidden
  108111. */
  108112. export interface IMaterialSubSurfaceDefines {
  108113. SUBSURFACE: boolean;
  108114. SS_REFRACTION: boolean;
  108115. SS_TRANSLUCENCY: boolean;
  108116. SS_SCATERRING: boolean;
  108117. SS_THICKNESSANDMASK_TEXTURE: boolean;
  108118. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  108119. SS_REFRACTIONMAP_3D: boolean;
  108120. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  108121. SS_LODINREFRACTIONALPHA: boolean;
  108122. SS_GAMMAREFRACTION: boolean;
  108123. SS_RGBDREFRACTION: boolean;
  108124. SS_LINEARSPECULARREFRACTION: boolean;
  108125. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  108126. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  108127. /** @hidden */
  108128. _areTexturesDirty: boolean;
  108129. }
  108130. /**
  108131. * Define the code related to the sub surface parameters of the pbr material.
  108132. */
  108133. export class PBRSubSurfaceConfiguration {
  108134. private _isRefractionEnabled;
  108135. /**
  108136. * Defines if the refraction is enabled in the material.
  108137. */
  108138. isRefractionEnabled: boolean;
  108139. private _isTranslucencyEnabled;
  108140. /**
  108141. * Defines if the translucency is enabled in the material.
  108142. */
  108143. isTranslucencyEnabled: boolean;
  108144. private _isScatteringEnabled;
  108145. /**
  108146. * Defines the refraction intensity of the material.
  108147. * The refraction when enabled replaces the Diffuse part of the material.
  108148. * The intensity helps transitionning between diffuse and refraction.
  108149. */
  108150. refractionIntensity: number;
  108151. /**
  108152. * Defines the translucency intensity of the material.
  108153. * When translucency has been enabled, this defines how much of the "translucency"
  108154. * is addded to the diffuse part of the material.
  108155. */
  108156. translucencyIntensity: number;
  108157. /**
  108158. * Defines the scattering intensity of the material.
  108159. * When scattering has been enabled, this defines how much of the "scattered light"
  108160. * is addded to the diffuse part of the material.
  108161. */
  108162. scatteringIntensity: number;
  108163. private _thicknessTexture;
  108164. /**
  108165. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  108166. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  108167. * 0 would mean minimumThickness
  108168. * 1 would mean maximumThickness
  108169. * The other channels might be use as a mask to vary the different effects intensity.
  108170. */
  108171. thicknessTexture: Nullable<BaseTexture>;
  108172. private _refractionTexture;
  108173. /**
  108174. * Defines the texture to use for refraction.
  108175. */
  108176. refractionTexture: Nullable<BaseTexture>;
  108177. private _indexOfRefraction;
  108178. /**
  108179. * Defines the index of refraction used in the material.
  108180. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  108181. */
  108182. indexOfRefraction: number;
  108183. private _invertRefractionY;
  108184. /**
  108185. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  108186. */
  108187. invertRefractionY: boolean;
  108188. private _linkRefractionWithTransparency;
  108189. /**
  108190. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  108191. * Materials half opaque for instance using refraction could benefit from this control.
  108192. */
  108193. linkRefractionWithTransparency: boolean;
  108194. /**
  108195. * Defines the minimum thickness stored in the thickness map.
  108196. * If no thickness map is defined, this value will be used to simulate thickness.
  108197. */
  108198. minimumThickness: number;
  108199. /**
  108200. * Defines the maximum thickness stored in the thickness map.
  108201. */
  108202. maximumThickness: number;
  108203. /**
  108204. * Defines the volume tint of the material.
  108205. * This is used for both translucency and scattering.
  108206. */
  108207. tintColor: Color3;
  108208. /**
  108209. * Defines the distance at which the tint color should be found in the media.
  108210. * This is used for refraction only.
  108211. */
  108212. tintColorAtDistance: number;
  108213. /**
  108214. * Defines how far each channel transmit through the media.
  108215. * It is defined as a color to simplify it selection.
  108216. */
  108217. diffusionDistance: Color3;
  108218. private _useMaskFromThicknessTexture;
  108219. /**
  108220. * Stores the intensity of the different subsurface effects in the thickness texture.
  108221. * * the green channel is the translucency intensity.
  108222. * * the blue channel is the scattering intensity.
  108223. * * the alpha channel is the refraction intensity.
  108224. */
  108225. useMaskFromThicknessTexture: boolean;
  108226. /** @hidden */
  108227. private _internalMarkAllSubMeshesAsTexturesDirty;
  108228. /** @hidden */
  108229. _markAllSubMeshesAsTexturesDirty(): void;
  108230. /**
  108231. * Instantiate a new istance of sub surface configuration.
  108232. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  108233. */
  108234. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  108235. /**
  108236. * Gets wehter the submesh is ready to be used or not.
  108237. * @param defines the list of "defines" to update.
  108238. * @param scene defines the scene the material belongs to.
  108239. * @returns - boolean indicating that the submesh is ready or not.
  108240. */
  108241. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  108242. /**
  108243. * Checks to see if a texture is used in the material.
  108244. * @param defines the list of "defines" to update.
  108245. * @param scene defines the scene to the material belongs to.
  108246. */
  108247. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  108248. /**
  108249. * Binds the material data.
  108250. * @param uniformBuffer defines the Uniform buffer to fill in.
  108251. * @param scene defines the scene the material belongs to.
  108252. * @param engine defines the engine the material belongs to.
  108253. * @param isFrozen defines wether the material is frozen or not.
  108254. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  108255. */
  108256. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  108257. /**
  108258. * Unbinds the material from the mesh.
  108259. * @param activeEffect defines the effect that should be unbound from.
  108260. * @returns true if unbound, otherwise false
  108261. */
  108262. unbind(activeEffect: Effect): boolean;
  108263. /**
  108264. * Returns the texture used for refraction or null if none is used.
  108265. * @param scene defines the scene the material belongs to.
  108266. * @returns - Refraction texture if present. If no refraction texture and refraction
  108267. * is linked with transparency, returns environment texture. Otherwise, returns null.
  108268. */
  108269. private _getRefractionTexture;
  108270. /**
  108271. * Returns true if alpha blending should be disabled.
  108272. */
  108273. readonly disableAlphaBlending: boolean;
  108274. /**
  108275. * Fills the list of render target textures.
  108276. * @param renderTargets the list of render targets to update
  108277. */
  108278. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  108279. /**
  108280. * Checks to see if a texture is used in the material.
  108281. * @param texture - Base texture to use.
  108282. * @returns - Boolean specifying if a texture is used in the material.
  108283. */
  108284. hasTexture(texture: BaseTexture): boolean;
  108285. /**
  108286. * Gets a boolean indicating that current material needs to register RTT
  108287. * @returns true if this uses a render target otherwise false.
  108288. */
  108289. hasRenderTargetTextures(): boolean;
  108290. /**
  108291. * Returns an array of the actively used textures.
  108292. * @param activeTextures Array of BaseTextures
  108293. */
  108294. getActiveTextures(activeTextures: BaseTexture[]): void;
  108295. /**
  108296. * Returns the animatable textures.
  108297. * @param animatables Array of animatable textures.
  108298. */
  108299. getAnimatables(animatables: IAnimatable[]): void;
  108300. /**
  108301. * Disposes the resources of the material.
  108302. * @param forceDisposeTextures - Forces the disposal of all textures.
  108303. */
  108304. dispose(forceDisposeTextures?: boolean): void;
  108305. /**
  108306. * Get the current class name of the texture useful for serialization or dynamic coding.
  108307. * @returns "PBRSubSurfaceConfiguration"
  108308. */
  108309. getClassName(): string;
  108310. /**
  108311. * Add fallbacks to the effect fallbacks list.
  108312. * @param defines defines the Base texture to use.
  108313. * @param fallbacks defines the current fallback list.
  108314. * @param currentRank defines the current fallback rank.
  108315. * @returns the new fallback rank.
  108316. */
  108317. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  108318. /**
  108319. * Add the required uniforms to the current list.
  108320. * @param uniforms defines the current uniform list.
  108321. */
  108322. static AddUniforms(uniforms: string[]): void;
  108323. /**
  108324. * Add the required samplers to the current list.
  108325. * @param samplers defines the current sampler list.
  108326. */
  108327. static AddSamplers(samplers: string[]): void;
  108328. /**
  108329. * Add the required uniforms to the current buffer.
  108330. * @param uniformBuffer defines the current uniform buffer.
  108331. */
  108332. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  108333. /**
  108334. * Makes a duplicate of the current configuration into another one.
  108335. * @param configuration define the config where to copy the info
  108336. */
  108337. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  108338. /**
  108339. * Serializes this Sub Surface configuration.
  108340. * @returns - An object with the serialized config.
  108341. */
  108342. serialize(): any;
  108343. /**
  108344. * Parses a anisotropy Configuration from a serialized object.
  108345. * @param source - Serialized object.
  108346. * @param scene Defines the scene we are parsing for
  108347. * @param rootUrl Defines the rootUrl to load from
  108348. */
  108349. parse(source: any, scene: Scene, rootUrl: string): void;
  108350. }
  108351. }
  108352. declare module BABYLON {
  108353. /** @hidden */
  108354. export var pbrFragmentDeclaration: {
  108355. name: string;
  108356. shader: string;
  108357. };
  108358. }
  108359. declare module BABYLON {
  108360. /** @hidden */
  108361. export var pbrUboDeclaration: {
  108362. name: string;
  108363. shader: string;
  108364. };
  108365. }
  108366. declare module BABYLON {
  108367. /** @hidden */
  108368. export var pbrFragmentExtraDeclaration: {
  108369. name: string;
  108370. shader: string;
  108371. };
  108372. }
  108373. declare module BABYLON {
  108374. /** @hidden */
  108375. export var pbrFragmentSamplersDeclaration: {
  108376. name: string;
  108377. shader: string;
  108378. };
  108379. }
  108380. declare module BABYLON {
  108381. /** @hidden */
  108382. export var pbrHelperFunctions: {
  108383. name: string;
  108384. shader: string;
  108385. };
  108386. }
  108387. declare module BABYLON {
  108388. /** @hidden */
  108389. export var harmonicsFunctions: {
  108390. name: string;
  108391. shader: string;
  108392. };
  108393. }
  108394. declare module BABYLON {
  108395. /** @hidden */
  108396. export var pbrDirectLightingSetupFunctions: {
  108397. name: string;
  108398. shader: string;
  108399. };
  108400. }
  108401. declare module BABYLON {
  108402. /** @hidden */
  108403. export var pbrDirectLightingFalloffFunctions: {
  108404. name: string;
  108405. shader: string;
  108406. };
  108407. }
  108408. declare module BABYLON {
  108409. /** @hidden */
  108410. export var pbrBRDFFunctions: {
  108411. name: string;
  108412. shader: string;
  108413. };
  108414. }
  108415. declare module BABYLON {
  108416. /** @hidden */
  108417. export var pbrDirectLightingFunctions: {
  108418. name: string;
  108419. shader: string;
  108420. };
  108421. }
  108422. declare module BABYLON {
  108423. /** @hidden */
  108424. export var pbrIBLFunctions: {
  108425. name: string;
  108426. shader: string;
  108427. };
  108428. }
  108429. declare module BABYLON {
  108430. /** @hidden */
  108431. export var pbrDebug: {
  108432. name: string;
  108433. shader: string;
  108434. };
  108435. }
  108436. declare module BABYLON {
  108437. /** @hidden */
  108438. export var pbrPixelShader: {
  108439. name: string;
  108440. shader: string;
  108441. };
  108442. }
  108443. declare module BABYLON {
  108444. /** @hidden */
  108445. export var pbrVertexDeclaration: {
  108446. name: string;
  108447. shader: string;
  108448. };
  108449. }
  108450. declare module BABYLON {
  108451. /** @hidden */
  108452. export var pbrVertexShader: {
  108453. name: string;
  108454. shader: string;
  108455. };
  108456. }
  108457. declare module BABYLON {
  108458. /**
  108459. * Manages the defines for the PBR Material.
  108460. * @hidden
  108461. */
  108462. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  108463. PBR: boolean;
  108464. MAINUV1: boolean;
  108465. MAINUV2: boolean;
  108466. UV1: boolean;
  108467. UV2: boolean;
  108468. ALBEDO: boolean;
  108469. ALBEDODIRECTUV: number;
  108470. VERTEXCOLOR: boolean;
  108471. AMBIENT: boolean;
  108472. AMBIENTDIRECTUV: number;
  108473. AMBIENTINGRAYSCALE: boolean;
  108474. OPACITY: boolean;
  108475. VERTEXALPHA: boolean;
  108476. OPACITYDIRECTUV: number;
  108477. OPACITYRGB: boolean;
  108478. ALPHATEST: boolean;
  108479. DEPTHPREPASS: boolean;
  108480. ALPHABLEND: boolean;
  108481. ALPHAFROMALBEDO: boolean;
  108482. ALPHATESTVALUE: string;
  108483. SPECULAROVERALPHA: boolean;
  108484. RADIANCEOVERALPHA: boolean;
  108485. ALPHAFRESNEL: boolean;
  108486. LINEARALPHAFRESNEL: boolean;
  108487. PREMULTIPLYALPHA: boolean;
  108488. EMISSIVE: boolean;
  108489. EMISSIVEDIRECTUV: number;
  108490. REFLECTIVITY: boolean;
  108491. REFLECTIVITYDIRECTUV: number;
  108492. SPECULARTERM: boolean;
  108493. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  108494. MICROSURFACEAUTOMATIC: boolean;
  108495. LODBASEDMICROSFURACE: boolean;
  108496. MICROSURFACEMAP: boolean;
  108497. MICROSURFACEMAPDIRECTUV: number;
  108498. METALLICWORKFLOW: boolean;
  108499. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  108500. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  108501. METALLNESSSTOREINMETALMAPBLUE: boolean;
  108502. AOSTOREINMETALMAPRED: boolean;
  108503. ENVIRONMENTBRDF: boolean;
  108504. ENVIRONMENTBRDF_RGBD: boolean;
  108505. NORMAL: boolean;
  108506. TANGENT: boolean;
  108507. BUMP: boolean;
  108508. BUMPDIRECTUV: number;
  108509. OBJECTSPACE_NORMALMAP: boolean;
  108510. PARALLAX: boolean;
  108511. PARALLAXOCCLUSION: boolean;
  108512. NORMALXYSCALE: boolean;
  108513. LIGHTMAP: boolean;
  108514. LIGHTMAPDIRECTUV: number;
  108515. USELIGHTMAPASSHADOWMAP: boolean;
  108516. GAMMALIGHTMAP: boolean;
  108517. REFLECTION: boolean;
  108518. REFLECTIONMAP_3D: boolean;
  108519. REFLECTIONMAP_SPHERICAL: boolean;
  108520. REFLECTIONMAP_PLANAR: boolean;
  108521. REFLECTIONMAP_CUBIC: boolean;
  108522. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  108523. REFLECTIONMAP_PROJECTION: boolean;
  108524. REFLECTIONMAP_SKYBOX: boolean;
  108525. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  108526. REFLECTIONMAP_EXPLICIT: boolean;
  108527. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  108528. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  108529. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  108530. INVERTCUBICMAP: boolean;
  108531. USESPHERICALFROMREFLECTIONMAP: boolean;
  108532. USEIRRADIANCEMAP: boolean;
  108533. SPHERICAL_HARMONICS: boolean;
  108534. USESPHERICALINVERTEX: boolean;
  108535. REFLECTIONMAP_OPPOSITEZ: boolean;
  108536. LODINREFLECTIONALPHA: boolean;
  108537. GAMMAREFLECTION: boolean;
  108538. RGBDREFLECTION: boolean;
  108539. LINEARSPECULARREFLECTION: boolean;
  108540. RADIANCEOCCLUSION: boolean;
  108541. HORIZONOCCLUSION: boolean;
  108542. INSTANCES: boolean;
  108543. NUM_BONE_INFLUENCERS: number;
  108544. BonesPerMesh: number;
  108545. BONETEXTURE: boolean;
  108546. NONUNIFORMSCALING: boolean;
  108547. MORPHTARGETS: boolean;
  108548. MORPHTARGETS_NORMAL: boolean;
  108549. MORPHTARGETS_TANGENT: boolean;
  108550. MORPHTARGETS_UV: boolean;
  108551. NUM_MORPH_INFLUENCERS: number;
  108552. IMAGEPROCESSING: boolean;
  108553. VIGNETTE: boolean;
  108554. VIGNETTEBLENDMODEMULTIPLY: boolean;
  108555. VIGNETTEBLENDMODEOPAQUE: boolean;
  108556. TONEMAPPING: boolean;
  108557. TONEMAPPING_ACES: boolean;
  108558. CONTRAST: boolean;
  108559. COLORCURVES: boolean;
  108560. COLORGRADING: boolean;
  108561. COLORGRADING3D: boolean;
  108562. SAMPLER3DGREENDEPTH: boolean;
  108563. SAMPLER3DBGRMAP: boolean;
  108564. IMAGEPROCESSINGPOSTPROCESS: boolean;
  108565. EXPOSURE: boolean;
  108566. MULTIVIEW: boolean;
  108567. USEPHYSICALLIGHTFALLOFF: boolean;
  108568. USEGLTFLIGHTFALLOFF: boolean;
  108569. TWOSIDEDLIGHTING: boolean;
  108570. SHADOWFLOAT: boolean;
  108571. CLIPPLANE: boolean;
  108572. CLIPPLANE2: boolean;
  108573. CLIPPLANE3: boolean;
  108574. CLIPPLANE4: boolean;
  108575. POINTSIZE: boolean;
  108576. FOG: boolean;
  108577. LOGARITHMICDEPTH: boolean;
  108578. FORCENORMALFORWARD: boolean;
  108579. SPECULARAA: boolean;
  108580. CLEARCOAT: boolean;
  108581. CLEARCOAT_DEFAULTIOR: boolean;
  108582. CLEARCOAT_TEXTURE: boolean;
  108583. CLEARCOAT_TEXTUREDIRECTUV: number;
  108584. CLEARCOAT_BUMP: boolean;
  108585. CLEARCOAT_BUMPDIRECTUV: number;
  108586. CLEARCOAT_TINT: boolean;
  108587. CLEARCOAT_TINT_TEXTURE: boolean;
  108588. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  108589. ANISOTROPIC: boolean;
  108590. ANISOTROPIC_TEXTURE: boolean;
  108591. ANISOTROPIC_TEXTUREDIRECTUV: number;
  108592. BRDF_V_HEIGHT_CORRELATED: boolean;
  108593. MS_BRDF_ENERGY_CONSERVATION: boolean;
  108594. SHEEN: boolean;
  108595. SHEEN_TEXTURE: boolean;
  108596. SHEEN_TEXTUREDIRECTUV: number;
  108597. SHEEN_LINKWITHALBEDO: boolean;
  108598. SUBSURFACE: boolean;
  108599. SS_REFRACTION: boolean;
  108600. SS_TRANSLUCENCY: boolean;
  108601. SS_SCATERRING: boolean;
  108602. SS_THICKNESSANDMASK_TEXTURE: boolean;
  108603. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  108604. SS_REFRACTIONMAP_3D: boolean;
  108605. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  108606. SS_LODINREFRACTIONALPHA: boolean;
  108607. SS_GAMMAREFRACTION: boolean;
  108608. SS_RGBDREFRACTION: boolean;
  108609. SS_LINEARSPECULARREFRACTION: boolean;
  108610. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  108611. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  108612. UNLIT: boolean;
  108613. DEBUGMODE: number;
  108614. /**
  108615. * Initializes the PBR Material defines.
  108616. */
  108617. constructor();
  108618. /**
  108619. * Resets the PBR Material defines.
  108620. */
  108621. reset(): void;
  108622. }
  108623. /**
  108624. * The Physically based material base class of BJS.
  108625. *
  108626. * This offers the main features of a standard PBR material.
  108627. * For more information, please refer to the documentation :
  108628. * https://doc.babylonjs.com/how_to/physically_based_rendering
  108629. */
  108630. export abstract class PBRBaseMaterial extends PushMaterial {
  108631. /**
  108632. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  108633. */
  108634. static readonly PBRMATERIAL_OPAQUE: number;
  108635. /**
  108636. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  108637. */
  108638. static readonly PBRMATERIAL_ALPHATEST: number;
  108639. /**
  108640. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  108641. */
  108642. static readonly PBRMATERIAL_ALPHABLEND: number;
  108643. /**
  108644. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  108645. * They are also discarded below the alpha cutoff threshold to improve performances.
  108646. */
  108647. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  108648. /**
  108649. * Defines the default value of how much AO map is occluding the analytical lights
  108650. * (point spot...).
  108651. */
  108652. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  108653. /**
  108654. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  108655. */
  108656. static readonly LIGHTFALLOFF_PHYSICAL: number;
  108657. /**
  108658. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  108659. * to enhance interoperability with other engines.
  108660. */
  108661. static readonly LIGHTFALLOFF_GLTF: number;
  108662. /**
  108663. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  108664. * to enhance interoperability with other materials.
  108665. */
  108666. static readonly LIGHTFALLOFF_STANDARD: number;
  108667. /**
  108668. * Intensity of the direct lights e.g. the four lights available in your scene.
  108669. * This impacts both the direct diffuse and specular highlights.
  108670. */
  108671. protected _directIntensity: number;
  108672. /**
  108673. * Intensity of the emissive part of the material.
  108674. * This helps controlling the emissive effect without modifying the emissive color.
  108675. */
  108676. protected _emissiveIntensity: number;
  108677. /**
  108678. * Intensity of the environment e.g. how much the environment will light the object
  108679. * either through harmonics for rough material or through the refelction for shiny ones.
  108680. */
  108681. protected _environmentIntensity: number;
  108682. /**
  108683. * This is a special control allowing the reduction of the specular highlights coming from the
  108684. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  108685. */
  108686. protected _specularIntensity: number;
  108687. /**
  108688. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  108689. */
  108690. private _lightingInfos;
  108691. /**
  108692. * Debug Control allowing disabling the bump map on this material.
  108693. */
  108694. protected _disableBumpMap: boolean;
  108695. /**
  108696. * AKA Diffuse Texture in standard nomenclature.
  108697. */
  108698. protected _albedoTexture: Nullable<BaseTexture>;
  108699. /**
  108700. * AKA Occlusion Texture in other nomenclature.
  108701. */
  108702. protected _ambientTexture: Nullable<BaseTexture>;
  108703. /**
  108704. * AKA Occlusion Texture Intensity in other nomenclature.
  108705. */
  108706. protected _ambientTextureStrength: number;
  108707. /**
  108708. * Defines how much the AO map is occluding the analytical lights (point spot...).
  108709. * 1 means it completely occludes it
  108710. * 0 mean it has no impact
  108711. */
  108712. protected _ambientTextureImpactOnAnalyticalLights: number;
  108713. /**
  108714. * Stores the alpha values in a texture.
  108715. */
  108716. protected _opacityTexture: Nullable<BaseTexture>;
  108717. /**
  108718. * Stores the reflection values in a texture.
  108719. */
  108720. protected _reflectionTexture: Nullable<BaseTexture>;
  108721. /**
  108722. * Stores the emissive values in a texture.
  108723. */
  108724. protected _emissiveTexture: Nullable<BaseTexture>;
  108725. /**
  108726. * AKA Specular texture in other nomenclature.
  108727. */
  108728. protected _reflectivityTexture: Nullable<BaseTexture>;
  108729. /**
  108730. * Used to switch from specular/glossiness to metallic/roughness workflow.
  108731. */
  108732. protected _metallicTexture: Nullable<BaseTexture>;
  108733. /**
  108734. * Specifies the metallic scalar of the metallic/roughness workflow.
  108735. * Can also be used to scale the metalness values of the metallic texture.
  108736. */
  108737. protected _metallic: Nullable<number>;
  108738. /**
  108739. * Specifies the roughness scalar of the metallic/roughness workflow.
  108740. * Can also be used to scale the roughness values of the metallic texture.
  108741. */
  108742. protected _roughness: Nullable<number>;
  108743. /**
  108744. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  108745. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  108746. */
  108747. protected _microSurfaceTexture: Nullable<BaseTexture>;
  108748. /**
  108749. * Stores surface normal data used to displace a mesh in a texture.
  108750. */
  108751. protected _bumpTexture: Nullable<BaseTexture>;
  108752. /**
  108753. * Stores the pre-calculated light information of a mesh in a texture.
  108754. */
  108755. protected _lightmapTexture: Nullable<BaseTexture>;
  108756. /**
  108757. * The color of a material in ambient lighting.
  108758. */
  108759. protected _ambientColor: Color3;
  108760. /**
  108761. * AKA Diffuse Color in other nomenclature.
  108762. */
  108763. protected _albedoColor: Color3;
  108764. /**
  108765. * AKA Specular Color in other nomenclature.
  108766. */
  108767. protected _reflectivityColor: Color3;
  108768. /**
  108769. * The color applied when light is reflected from a material.
  108770. */
  108771. protected _reflectionColor: Color3;
  108772. /**
  108773. * The color applied when light is emitted from a material.
  108774. */
  108775. protected _emissiveColor: Color3;
  108776. /**
  108777. * AKA Glossiness in other nomenclature.
  108778. */
  108779. protected _microSurface: number;
  108780. /**
  108781. * Specifies that the material will use the light map as a show map.
  108782. */
  108783. protected _useLightmapAsShadowmap: boolean;
  108784. /**
  108785. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  108786. * makes the reflect vector face the model (under horizon).
  108787. */
  108788. protected _useHorizonOcclusion: boolean;
  108789. /**
  108790. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  108791. * too much the area relying on ambient texture to define their ambient occlusion.
  108792. */
  108793. protected _useRadianceOcclusion: boolean;
  108794. /**
  108795. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  108796. */
  108797. protected _useAlphaFromAlbedoTexture: boolean;
  108798. /**
  108799. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  108800. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  108801. */
  108802. protected _useSpecularOverAlpha: boolean;
  108803. /**
  108804. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  108805. */
  108806. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  108807. /**
  108808. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  108809. */
  108810. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  108811. /**
  108812. * Specifies if the metallic texture contains the roughness information in its green channel.
  108813. */
  108814. protected _useRoughnessFromMetallicTextureGreen: boolean;
  108815. /**
  108816. * Specifies if the metallic texture contains the metallness information in its blue channel.
  108817. */
  108818. protected _useMetallnessFromMetallicTextureBlue: boolean;
  108819. /**
  108820. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  108821. */
  108822. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  108823. /**
  108824. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  108825. */
  108826. protected _useAmbientInGrayScale: boolean;
  108827. /**
  108828. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  108829. * The material will try to infer what glossiness each pixel should be.
  108830. */
  108831. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  108832. /**
  108833. * Defines the falloff type used in this material.
  108834. * It by default is Physical.
  108835. */
  108836. protected _lightFalloff: number;
  108837. /**
  108838. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  108839. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  108840. */
  108841. protected _useRadianceOverAlpha: boolean;
  108842. /**
  108843. * Allows using an object space normal map (instead of tangent space).
  108844. */
  108845. protected _useObjectSpaceNormalMap: boolean;
  108846. /**
  108847. * Allows using the bump map in parallax mode.
  108848. */
  108849. protected _useParallax: boolean;
  108850. /**
  108851. * Allows using the bump map in parallax occlusion mode.
  108852. */
  108853. protected _useParallaxOcclusion: boolean;
  108854. /**
  108855. * Controls the scale bias of the parallax mode.
  108856. */
  108857. protected _parallaxScaleBias: number;
  108858. /**
  108859. * If sets to true, disables all the lights affecting the material.
  108860. */
  108861. protected _disableLighting: boolean;
  108862. /**
  108863. * Number of Simultaneous lights allowed on the material.
  108864. */
  108865. protected _maxSimultaneousLights: number;
  108866. /**
  108867. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  108868. */
  108869. protected _invertNormalMapX: boolean;
  108870. /**
  108871. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  108872. */
  108873. protected _invertNormalMapY: boolean;
  108874. /**
  108875. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  108876. */
  108877. protected _twoSidedLighting: boolean;
  108878. /**
  108879. * Defines the alpha limits in alpha test mode.
  108880. */
  108881. protected _alphaCutOff: number;
  108882. /**
  108883. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  108884. */
  108885. protected _forceAlphaTest: boolean;
  108886. /**
  108887. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  108888. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  108889. */
  108890. protected _useAlphaFresnel: boolean;
  108891. /**
  108892. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  108893. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  108894. */
  108895. protected _useLinearAlphaFresnel: boolean;
  108896. /**
  108897. * The transparency mode of the material.
  108898. */
  108899. protected _transparencyMode: Nullable<number>;
  108900. /**
  108901. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  108902. * from cos thetav and roughness:
  108903. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  108904. */
  108905. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  108906. /**
  108907. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  108908. */
  108909. protected _forceIrradianceInFragment: boolean;
  108910. /**
  108911. * Force normal to face away from face.
  108912. */
  108913. protected _forceNormalForward: boolean;
  108914. /**
  108915. * Enables specular anti aliasing in the PBR shader.
  108916. * It will both interacts on the Geometry for analytical and IBL lighting.
  108917. * It also prefilter the roughness map based on the bump values.
  108918. */
  108919. protected _enableSpecularAntiAliasing: boolean;
  108920. /**
  108921. * Default configuration related to image processing available in the PBR Material.
  108922. */
  108923. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  108924. /**
  108925. * Keep track of the image processing observer to allow dispose and replace.
  108926. */
  108927. private _imageProcessingObserver;
  108928. /**
  108929. * Attaches a new image processing configuration to the PBR Material.
  108930. * @param configuration
  108931. */
  108932. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  108933. /**
  108934. * Stores the available render targets.
  108935. */
  108936. private _renderTargets;
  108937. /**
  108938. * Sets the global ambient color for the material used in lighting calculations.
  108939. */
  108940. private _globalAmbientColor;
  108941. /**
  108942. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  108943. */
  108944. private _useLogarithmicDepth;
  108945. /**
  108946. * If set to true, no lighting calculations will be applied.
  108947. */
  108948. private _unlit;
  108949. private _debugMode;
  108950. /**
  108951. * @hidden
  108952. * This is reserved for the inspector.
  108953. * Defines the material debug mode.
  108954. * It helps seeing only some components of the material while troubleshooting.
  108955. */
  108956. debugMode: number;
  108957. /**
  108958. * @hidden
  108959. * This is reserved for the inspector.
  108960. * Specify from where on screen the debug mode should start.
  108961. * The value goes from -1 (full screen) to 1 (not visible)
  108962. * It helps with side by side comparison against the final render
  108963. * This defaults to -1
  108964. */
  108965. private debugLimit;
  108966. /**
  108967. * @hidden
  108968. * This is reserved for the inspector.
  108969. * As the default viewing range might not be enough (if the ambient is really small for instance)
  108970. * You can use the factor to better multiply the final value.
  108971. */
  108972. private debugFactor;
  108973. /**
  108974. * Defines the clear coat layer parameters for the material.
  108975. */
  108976. readonly clearCoat: PBRClearCoatConfiguration;
  108977. /**
  108978. * Defines the anisotropic parameters for the material.
  108979. */
  108980. readonly anisotropy: PBRAnisotropicConfiguration;
  108981. /**
  108982. * Defines the BRDF parameters for the material.
  108983. */
  108984. readonly brdf: PBRBRDFConfiguration;
  108985. /**
  108986. * Defines the Sheen parameters for the material.
  108987. */
  108988. readonly sheen: PBRSheenConfiguration;
  108989. /**
  108990. * Defines the SubSurface parameters for the material.
  108991. */
  108992. readonly subSurface: PBRSubSurfaceConfiguration;
  108993. /**
  108994. * Custom callback helping to override the default shader used in the material.
  108995. */
  108996. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  108997. /**
  108998. * Instantiates a new PBRMaterial instance.
  108999. *
  109000. * @param name The material name
  109001. * @param scene The scene the material will be use in.
  109002. */
  109003. constructor(name: string, scene: Scene);
  109004. /**
  109005. * Gets a boolean indicating that current material needs to register RTT
  109006. */
  109007. readonly hasRenderTargetTextures: boolean;
  109008. /**
  109009. * Gets the name of the material class.
  109010. */
  109011. getClassName(): string;
  109012. /**
  109013. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  109014. */
  109015. /**
  109016. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  109017. */
  109018. useLogarithmicDepth: boolean;
  109019. /**
  109020. * Gets the current transparency mode.
  109021. */
  109022. /**
  109023. * Sets the transparency mode of the material.
  109024. *
  109025. * | Value | Type | Description |
  109026. * | ----- | ----------------------------------- | ----------- |
  109027. * | 0 | OPAQUE | |
  109028. * | 1 | ALPHATEST | |
  109029. * | 2 | ALPHABLEND | |
  109030. * | 3 | ALPHATESTANDBLEND | |
  109031. *
  109032. */
  109033. transparencyMode: Nullable<number>;
  109034. /**
  109035. * Returns true if alpha blending should be disabled.
  109036. */
  109037. private readonly _disableAlphaBlending;
  109038. /**
  109039. * Specifies whether or not this material should be rendered in alpha blend mode.
  109040. */
  109041. needAlphaBlending(): boolean;
  109042. /**
  109043. * Specifies if the mesh will require alpha blending.
  109044. * @param mesh - BJS mesh.
  109045. */
  109046. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  109047. /**
  109048. * Specifies whether or not this material should be rendered in alpha test mode.
  109049. */
  109050. needAlphaTesting(): boolean;
  109051. /**
  109052. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  109053. */
  109054. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  109055. /**
  109056. * Gets the texture used for the alpha test.
  109057. */
  109058. getAlphaTestTexture(): Nullable<BaseTexture>;
  109059. /**
  109060. * Specifies that the submesh is ready to be used.
  109061. * @param mesh - BJS mesh.
  109062. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  109063. * @param useInstances - Specifies that instances should be used.
  109064. * @returns - boolean indicating that the submesh is ready or not.
  109065. */
  109066. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  109067. /**
  109068. * Specifies if the material uses metallic roughness workflow.
  109069. * @returns boolean specifiying if the material uses metallic roughness workflow.
  109070. */
  109071. isMetallicWorkflow(): boolean;
  109072. private _prepareEffect;
  109073. private _prepareDefines;
  109074. /**
  109075. * Force shader compilation
  109076. */
  109077. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  109078. clipPlane: boolean;
  109079. }>): void;
  109080. /**
  109081. * Initializes the uniform buffer layout for the shader.
  109082. */
  109083. buildUniformLayout(): void;
  109084. /**
  109085. * Unbinds the material from the mesh
  109086. */
  109087. unbind(): void;
  109088. /**
  109089. * Binds the submesh data.
  109090. * @param world - The world matrix.
  109091. * @param mesh - The BJS mesh.
  109092. * @param subMesh - A submesh of the BJS mesh.
  109093. */
  109094. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  109095. /**
  109096. * Returns the animatable textures.
  109097. * @returns - Array of animatable textures.
  109098. */
  109099. getAnimatables(): IAnimatable[];
  109100. /**
  109101. * Returns the texture used for reflections.
  109102. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  109103. */
  109104. private _getReflectionTexture;
  109105. /**
  109106. * Returns an array of the actively used textures.
  109107. * @returns - Array of BaseTextures
  109108. */
  109109. getActiveTextures(): BaseTexture[];
  109110. /**
  109111. * Checks to see if a texture is used in the material.
  109112. * @param texture - Base texture to use.
  109113. * @returns - Boolean specifying if a texture is used in the material.
  109114. */
  109115. hasTexture(texture: BaseTexture): boolean;
  109116. /**
  109117. * Disposes the resources of the material.
  109118. * @param forceDisposeEffect - Forces the disposal of effects.
  109119. * @param forceDisposeTextures - Forces the disposal of all textures.
  109120. */
  109121. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  109122. }
  109123. }
  109124. declare module BABYLON {
  109125. /**
  109126. * The Physically based material of BJS.
  109127. *
  109128. * This offers the main features of a standard PBR material.
  109129. * For more information, please refer to the documentation :
  109130. * https://doc.babylonjs.com/how_to/physically_based_rendering
  109131. */
  109132. export class PBRMaterial extends PBRBaseMaterial {
  109133. /**
  109134. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  109135. */
  109136. static readonly PBRMATERIAL_OPAQUE: number;
  109137. /**
  109138. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  109139. */
  109140. static readonly PBRMATERIAL_ALPHATEST: number;
  109141. /**
  109142. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  109143. */
  109144. static readonly PBRMATERIAL_ALPHABLEND: number;
  109145. /**
  109146. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  109147. * They are also discarded below the alpha cutoff threshold to improve performances.
  109148. */
  109149. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  109150. /**
  109151. * Defines the default value of how much AO map is occluding the analytical lights
  109152. * (point spot...).
  109153. */
  109154. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  109155. /**
  109156. * Intensity of the direct lights e.g. the four lights available in your scene.
  109157. * This impacts both the direct diffuse and specular highlights.
  109158. */
  109159. directIntensity: number;
  109160. /**
  109161. * Intensity of the emissive part of the material.
  109162. * This helps controlling the emissive effect without modifying the emissive color.
  109163. */
  109164. emissiveIntensity: number;
  109165. /**
  109166. * Intensity of the environment e.g. how much the environment will light the object
  109167. * either through harmonics for rough material or through the refelction for shiny ones.
  109168. */
  109169. environmentIntensity: number;
  109170. /**
  109171. * This is a special control allowing the reduction of the specular highlights coming from the
  109172. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  109173. */
  109174. specularIntensity: number;
  109175. /**
  109176. * Debug Control allowing disabling the bump map on this material.
  109177. */
  109178. disableBumpMap: boolean;
  109179. /**
  109180. * AKA Diffuse Texture in standard nomenclature.
  109181. */
  109182. albedoTexture: BaseTexture;
  109183. /**
  109184. * AKA Occlusion Texture in other nomenclature.
  109185. */
  109186. ambientTexture: BaseTexture;
  109187. /**
  109188. * AKA Occlusion Texture Intensity in other nomenclature.
  109189. */
  109190. ambientTextureStrength: number;
  109191. /**
  109192. * Defines how much the AO map is occluding the analytical lights (point spot...).
  109193. * 1 means it completely occludes it
  109194. * 0 mean it has no impact
  109195. */
  109196. ambientTextureImpactOnAnalyticalLights: number;
  109197. /**
  109198. * Stores the alpha values in a texture.
  109199. */
  109200. opacityTexture: BaseTexture;
  109201. /**
  109202. * Stores the reflection values in a texture.
  109203. */
  109204. reflectionTexture: Nullable<BaseTexture>;
  109205. /**
  109206. * Stores the emissive values in a texture.
  109207. */
  109208. emissiveTexture: BaseTexture;
  109209. /**
  109210. * AKA Specular texture in other nomenclature.
  109211. */
  109212. reflectivityTexture: BaseTexture;
  109213. /**
  109214. * Used to switch from specular/glossiness to metallic/roughness workflow.
  109215. */
  109216. metallicTexture: BaseTexture;
  109217. /**
  109218. * Specifies the metallic scalar of the metallic/roughness workflow.
  109219. * Can also be used to scale the metalness values of the metallic texture.
  109220. */
  109221. metallic: Nullable<number>;
  109222. /**
  109223. * Specifies the roughness scalar of the metallic/roughness workflow.
  109224. * Can also be used to scale the roughness values of the metallic texture.
  109225. */
  109226. roughness: Nullable<number>;
  109227. /**
  109228. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  109229. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  109230. */
  109231. microSurfaceTexture: BaseTexture;
  109232. /**
  109233. * Stores surface normal data used to displace a mesh in a texture.
  109234. */
  109235. bumpTexture: BaseTexture;
  109236. /**
  109237. * Stores the pre-calculated light information of a mesh in a texture.
  109238. */
  109239. lightmapTexture: BaseTexture;
  109240. /**
  109241. * Stores the refracted light information in a texture.
  109242. */
  109243. refractionTexture: Nullable<BaseTexture>;
  109244. /**
  109245. * The color of a material in ambient lighting.
  109246. */
  109247. ambientColor: Color3;
  109248. /**
  109249. * AKA Diffuse Color in other nomenclature.
  109250. */
  109251. albedoColor: Color3;
  109252. /**
  109253. * AKA Specular Color in other nomenclature.
  109254. */
  109255. reflectivityColor: Color3;
  109256. /**
  109257. * The color reflected from the material.
  109258. */
  109259. reflectionColor: Color3;
  109260. /**
  109261. * The color emitted from the material.
  109262. */
  109263. emissiveColor: Color3;
  109264. /**
  109265. * AKA Glossiness in other nomenclature.
  109266. */
  109267. microSurface: number;
  109268. /**
  109269. * source material index of refraction (IOR)' / 'destination material IOR.
  109270. */
  109271. indexOfRefraction: number;
  109272. /**
  109273. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  109274. */
  109275. invertRefractionY: boolean;
  109276. /**
  109277. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  109278. * Materials half opaque for instance using refraction could benefit from this control.
  109279. */
  109280. linkRefractionWithTransparency: boolean;
  109281. /**
  109282. * If true, the light map contains occlusion information instead of lighting info.
  109283. */
  109284. useLightmapAsShadowmap: boolean;
  109285. /**
  109286. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  109287. */
  109288. useAlphaFromAlbedoTexture: boolean;
  109289. /**
  109290. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  109291. */
  109292. forceAlphaTest: boolean;
  109293. /**
  109294. * Defines the alpha limits in alpha test mode.
  109295. */
  109296. alphaCutOff: number;
  109297. /**
  109298. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  109299. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  109300. */
  109301. useSpecularOverAlpha: boolean;
  109302. /**
  109303. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  109304. */
  109305. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  109306. /**
  109307. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  109308. */
  109309. useRoughnessFromMetallicTextureAlpha: boolean;
  109310. /**
  109311. * Specifies if the metallic texture contains the roughness information in its green channel.
  109312. */
  109313. useRoughnessFromMetallicTextureGreen: boolean;
  109314. /**
  109315. * Specifies if the metallic texture contains the metallness information in its blue channel.
  109316. */
  109317. useMetallnessFromMetallicTextureBlue: boolean;
  109318. /**
  109319. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  109320. */
  109321. useAmbientOcclusionFromMetallicTextureRed: boolean;
  109322. /**
  109323. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  109324. */
  109325. useAmbientInGrayScale: boolean;
  109326. /**
  109327. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  109328. * The material will try to infer what glossiness each pixel should be.
  109329. */
  109330. useAutoMicroSurfaceFromReflectivityMap: boolean;
  109331. /**
  109332. * BJS is using an harcoded light falloff based on a manually sets up range.
  109333. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  109334. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  109335. */
  109336. /**
  109337. * BJS is using an harcoded light falloff based on a manually sets up range.
  109338. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  109339. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  109340. */
  109341. usePhysicalLightFalloff: boolean;
  109342. /**
  109343. * In order to support the falloff compatibility with gltf, a special mode has been added
  109344. * to reproduce the gltf light falloff.
  109345. */
  109346. /**
  109347. * In order to support the falloff compatibility with gltf, a special mode has been added
  109348. * to reproduce the gltf light falloff.
  109349. */
  109350. useGLTFLightFalloff: boolean;
  109351. /**
  109352. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  109353. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  109354. */
  109355. useRadianceOverAlpha: boolean;
  109356. /**
  109357. * Allows using an object space normal map (instead of tangent space).
  109358. */
  109359. useObjectSpaceNormalMap: boolean;
  109360. /**
  109361. * Allows using the bump map in parallax mode.
  109362. */
  109363. useParallax: boolean;
  109364. /**
  109365. * Allows using the bump map in parallax occlusion mode.
  109366. */
  109367. useParallaxOcclusion: boolean;
  109368. /**
  109369. * Controls the scale bias of the parallax mode.
  109370. */
  109371. parallaxScaleBias: number;
  109372. /**
  109373. * If sets to true, disables all the lights affecting the material.
  109374. */
  109375. disableLighting: boolean;
  109376. /**
  109377. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  109378. */
  109379. forceIrradianceInFragment: boolean;
  109380. /**
  109381. * Number of Simultaneous lights allowed on the material.
  109382. */
  109383. maxSimultaneousLights: number;
  109384. /**
  109385. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  109386. */
  109387. invertNormalMapX: boolean;
  109388. /**
  109389. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  109390. */
  109391. invertNormalMapY: boolean;
  109392. /**
  109393. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  109394. */
  109395. twoSidedLighting: boolean;
  109396. /**
  109397. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  109398. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  109399. */
  109400. useAlphaFresnel: boolean;
  109401. /**
  109402. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  109403. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  109404. */
  109405. useLinearAlphaFresnel: boolean;
  109406. /**
  109407. * Let user defines the brdf lookup texture used for IBL.
  109408. * A default 8bit version is embedded but you could point at :
  109409. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  109410. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  109411. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  109412. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  109413. */
  109414. environmentBRDFTexture: Nullable<BaseTexture>;
  109415. /**
  109416. * Force normal to face away from face.
  109417. */
  109418. forceNormalForward: boolean;
  109419. /**
  109420. * Enables specular anti aliasing in the PBR shader.
  109421. * It will both interacts on the Geometry for analytical and IBL lighting.
  109422. * It also prefilter the roughness map based on the bump values.
  109423. */
  109424. enableSpecularAntiAliasing: boolean;
  109425. /**
  109426. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  109427. * makes the reflect vector face the model (under horizon).
  109428. */
  109429. useHorizonOcclusion: boolean;
  109430. /**
  109431. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  109432. * too much the area relying on ambient texture to define their ambient occlusion.
  109433. */
  109434. useRadianceOcclusion: boolean;
  109435. /**
  109436. * If set to true, no lighting calculations will be applied.
  109437. */
  109438. unlit: boolean;
  109439. /**
  109440. * Gets the image processing configuration used either in this material.
  109441. */
  109442. /**
  109443. * Sets the Default image processing configuration used either in the this material.
  109444. *
  109445. * If sets to null, the scene one is in use.
  109446. */
  109447. imageProcessingConfiguration: ImageProcessingConfiguration;
  109448. /**
  109449. * Gets wether the color curves effect is enabled.
  109450. */
  109451. /**
  109452. * Sets wether the color curves effect is enabled.
  109453. */
  109454. cameraColorCurvesEnabled: boolean;
  109455. /**
  109456. * Gets wether the color grading effect is enabled.
  109457. */
  109458. /**
  109459. * Gets wether the color grading effect is enabled.
  109460. */
  109461. cameraColorGradingEnabled: boolean;
  109462. /**
  109463. * Gets wether tonemapping is enabled or not.
  109464. */
  109465. /**
  109466. * Sets wether tonemapping is enabled or not
  109467. */
  109468. cameraToneMappingEnabled: boolean;
  109469. /**
  109470. * The camera exposure used on this material.
  109471. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  109472. * This corresponds to a photographic exposure.
  109473. */
  109474. /**
  109475. * The camera exposure used on this material.
  109476. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  109477. * This corresponds to a photographic exposure.
  109478. */
  109479. cameraExposure: number;
  109480. /**
  109481. * Gets The camera contrast used on this material.
  109482. */
  109483. /**
  109484. * Sets The camera contrast used on this material.
  109485. */
  109486. cameraContrast: number;
  109487. /**
  109488. * Gets the Color Grading 2D Lookup Texture.
  109489. */
  109490. /**
  109491. * Sets the Color Grading 2D Lookup Texture.
  109492. */
  109493. cameraColorGradingTexture: Nullable<BaseTexture>;
  109494. /**
  109495. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  109496. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  109497. * 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;
  109498. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  109499. */
  109500. /**
  109501. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  109502. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  109503. * 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;
  109504. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  109505. */
  109506. cameraColorCurves: Nullable<ColorCurves>;
  109507. /**
  109508. * Instantiates a new PBRMaterial instance.
  109509. *
  109510. * @param name The material name
  109511. * @param scene The scene the material will be use in.
  109512. */
  109513. constructor(name: string, scene: Scene);
  109514. /**
  109515. * Returns the name of this material class.
  109516. */
  109517. getClassName(): string;
  109518. /**
  109519. * Makes a duplicate of the current material.
  109520. * @param name - name to use for the new material.
  109521. */
  109522. clone(name: string): PBRMaterial;
  109523. /**
  109524. * Serializes this PBR Material.
  109525. * @returns - An object with the serialized material.
  109526. */
  109527. serialize(): any;
  109528. /**
  109529. * Parses a PBR Material from a serialized object.
  109530. * @param source - Serialized object.
  109531. * @param scene - BJS scene instance.
  109532. * @param rootUrl - url for the scene object
  109533. * @returns - PBRMaterial
  109534. */
  109535. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  109536. }
  109537. }
  109538. declare module BABYLON {
  109539. /**
  109540. * Direct draw surface info
  109541. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  109542. */
  109543. export interface DDSInfo {
  109544. /**
  109545. * Width of the texture
  109546. */
  109547. width: number;
  109548. /**
  109549. * Width of the texture
  109550. */
  109551. height: number;
  109552. /**
  109553. * Number of Mipmaps for the texture
  109554. * @see https://en.wikipedia.org/wiki/Mipmap
  109555. */
  109556. mipmapCount: number;
  109557. /**
  109558. * If the textures format is a known fourCC format
  109559. * @see https://www.fourcc.org/
  109560. */
  109561. isFourCC: boolean;
  109562. /**
  109563. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  109564. */
  109565. isRGB: boolean;
  109566. /**
  109567. * If the texture is a lumincance format
  109568. */
  109569. isLuminance: boolean;
  109570. /**
  109571. * If this is a cube texture
  109572. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  109573. */
  109574. isCube: boolean;
  109575. /**
  109576. * If the texture is a compressed format eg. FOURCC_DXT1
  109577. */
  109578. isCompressed: boolean;
  109579. /**
  109580. * The dxgiFormat of the texture
  109581. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  109582. */
  109583. dxgiFormat: number;
  109584. /**
  109585. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  109586. */
  109587. textureType: number;
  109588. /**
  109589. * Sphericle polynomial created for the dds texture
  109590. */
  109591. sphericalPolynomial?: SphericalPolynomial;
  109592. }
  109593. /**
  109594. * Class used to provide DDS decompression tools
  109595. */
  109596. export class DDSTools {
  109597. /**
  109598. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  109599. */
  109600. static StoreLODInAlphaChannel: boolean;
  109601. /**
  109602. * Gets DDS information from an array buffer
  109603. * @param arrayBuffer defines the array buffer to read data from
  109604. * @returns the DDS information
  109605. */
  109606. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  109607. private static _FloatView;
  109608. private static _Int32View;
  109609. private static _ToHalfFloat;
  109610. private static _FromHalfFloat;
  109611. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  109612. private static _GetHalfFloatRGBAArrayBuffer;
  109613. private static _GetFloatRGBAArrayBuffer;
  109614. private static _GetFloatAsUIntRGBAArrayBuffer;
  109615. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  109616. private static _GetRGBAArrayBuffer;
  109617. private static _ExtractLongWordOrder;
  109618. private static _GetRGBArrayBuffer;
  109619. private static _GetLuminanceArrayBuffer;
  109620. /**
  109621. * Uploads DDS Levels to a Babylon Texture
  109622. * @hidden
  109623. */
  109624. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  109625. }
  109626. interface Engine {
  109627. /**
  109628. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  109629. * @param rootUrl defines the url where the file to load is located
  109630. * @param scene defines the current scene
  109631. * @param lodScale defines scale to apply to the mip map selection
  109632. * @param lodOffset defines offset to apply to the mip map selection
  109633. * @param onLoad defines an optional callback raised when the texture is loaded
  109634. * @param onError defines an optional callback raised if there is an issue to load the texture
  109635. * @param format defines the format of the data
  109636. * @param forcedExtension defines the extension to use to pick the right loader
  109637. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  109638. * @returns the cube texture as an InternalTexture
  109639. */
  109640. 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;
  109641. }
  109642. }
  109643. declare module BABYLON {
  109644. /**
  109645. * Implementation of the DDS Texture Loader.
  109646. * @hidden
  109647. */
  109648. export class _DDSTextureLoader implements IInternalTextureLoader {
  109649. /**
  109650. * Defines wether the loader supports cascade loading the different faces.
  109651. */
  109652. readonly supportCascades: boolean;
  109653. /**
  109654. * This returns if the loader support the current file information.
  109655. * @param extension defines the file extension of the file being loaded
  109656. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109657. * @param fallback defines the fallback internal texture if any
  109658. * @param isBase64 defines whether the texture is encoded as a base64
  109659. * @param isBuffer defines whether the texture data are stored as a buffer
  109660. * @returns true if the loader can load the specified file
  109661. */
  109662. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  109663. /**
  109664. * Transform the url before loading if required.
  109665. * @param rootUrl the url of the texture
  109666. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109667. * @returns the transformed texture
  109668. */
  109669. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  109670. /**
  109671. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  109672. * @param rootUrl the url of the texture
  109673. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109674. * @returns the fallback texture
  109675. */
  109676. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  109677. /**
  109678. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  109679. * @param data contains the texture data
  109680. * @param texture defines the BabylonJS internal texture
  109681. * @param createPolynomials will be true if polynomials have been requested
  109682. * @param onLoad defines the callback to trigger once the texture is ready
  109683. * @param onError defines the callback to trigger in case of error
  109684. */
  109685. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  109686. /**
  109687. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  109688. * @param data contains the texture data
  109689. * @param texture defines the BabylonJS internal texture
  109690. * @param callback defines the method to call once ready to upload
  109691. */
  109692. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  109693. }
  109694. }
  109695. declare module BABYLON {
  109696. /** @hidden */
  109697. export var rgbdEncodePixelShader: {
  109698. name: string;
  109699. shader: string;
  109700. };
  109701. }
  109702. declare module BABYLON {
  109703. /**
  109704. * Raw texture data and descriptor sufficient for WebGL texture upload
  109705. */
  109706. export interface EnvironmentTextureInfo {
  109707. /**
  109708. * Version of the environment map
  109709. */
  109710. version: number;
  109711. /**
  109712. * Width of image
  109713. */
  109714. width: number;
  109715. /**
  109716. * Irradiance information stored in the file.
  109717. */
  109718. irradiance: any;
  109719. /**
  109720. * Specular information stored in the file.
  109721. */
  109722. specular: any;
  109723. }
  109724. /**
  109725. * Sets of helpers addressing the serialization and deserialization of environment texture
  109726. * stored in a BabylonJS env file.
  109727. * Those files are usually stored as .env files.
  109728. */
  109729. export class EnvironmentTextureTools {
  109730. /**
  109731. * Magic number identifying the env file.
  109732. */
  109733. private static _MagicBytes;
  109734. /**
  109735. * Gets the environment info from an env file.
  109736. * @param data The array buffer containing the .env bytes.
  109737. * @returns the environment file info (the json header) if successfully parsed.
  109738. */
  109739. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  109740. /**
  109741. * Creates an environment texture from a loaded cube texture.
  109742. * @param texture defines the cube texture to convert in env file
  109743. * @return a promise containing the environment data if succesfull.
  109744. */
  109745. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  109746. /**
  109747. * Creates a JSON representation of the spherical data.
  109748. * @param texture defines the texture containing the polynomials
  109749. * @return the JSON representation of the spherical info
  109750. */
  109751. private static _CreateEnvTextureIrradiance;
  109752. /**
  109753. * Uploads the texture info contained in the env file to the GPU.
  109754. * @param texture defines the internal texture to upload to
  109755. * @param arrayBuffer defines the buffer cotaining the data to load
  109756. * @param info defines the texture info retrieved through the GetEnvInfo method
  109757. * @returns a promise
  109758. */
  109759. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  109760. /**
  109761. * Uploads the levels of image data to the GPU.
  109762. * @param texture defines the internal texture to upload to
  109763. * @param imageData defines the array buffer views of image data [mipmap][face]
  109764. * @returns a promise
  109765. */
  109766. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  109767. /**
  109768. * Uploads spherical polynomials information to the texture.
  109769. * @param texture defines the texture we are trying to upload the information to
  109770. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  109771. */
  109772. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  109773. /** @hidden */
  109774. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  109775. }
  109776. }
  109777. declare module BABYLON {
  109778. /**
  109779. * Implementation of the ENV Texture Loader.
  109780. * @hidden
  109781. */
  109782. export class _ENVTextureLoader implements IInternalTextureLoader {
  109783. /**
  109784. * Defines wether the loader supports cascade loading the different faces.
  109785. */
  109786. readonly supportCascades: boolean;
  109787. /**
  109788. * This returns if the loader support the current file information.
  109789. * @param extension defines the file extension of the file being loaded
  109790. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109791. * @param fallback defines the fallback internal texture if any
  109792. * @param isBase64 defines whether the texture is encoded as a base64
  109793. * @param isBuffer defines whether the texture data are stored as a buffer
  109794. * @returns true if the loader can load the specified file
  109795. */
  109796. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  109797. /**
  109798. * Transform the url before loading if required.
  109799. * @param rootUrl the url of the texture
  109800. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109801. * @returns the transformed texture
  109802. */
  109803. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  109804. /**
  109805. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  109806. * @param rootUrl the url of the texture
  109807. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109808. * @returns the fallback texture
  109809. */
  109810. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  109811. /**
  109812. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  109813. * @param data contains the texture data
  109814. * @param texture defines the BabylonJS internal texture
  109815. * @param createPolynomials will be true if polynomials have been requested
  109816. * @param onLoad defines the callback to trigger once the texture is ready
  109817. * @param onError defines the callback to trigger in case of error
  109818. */
  109819. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  109820. /**
  109821. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  109822. * @param data contains the texture data
  109823. * @param texture defines the BabylonJS internal texture
  109824. * @param callback defines the method to call once ready to upload
  109825. */
  109826. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  109827. }
  109828. }
  109829. declare module BABYLON {
  109830. /**
  109831. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  109832. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  109833. */
  109834. export class KhronosTextureContainer {
  109835. /** contents of the KTX container file */
  109836. arrayBuffer: any;
  109837. private static HEADER_LEN;
  109838. private static COMPRESSED_2D;
  109839. private static COMPRESSED_3D;
  109840. private static TEX_2D;
  109841. private static TEX_3D;
  109842. /**
  109843. * Gets the openGL type
  109844. */
  109845. glType: number;
  109846. /**
  109847. * Gets the openGL type size
  109848. */
  109849. glTypeSize: number;
  109850. /**
  109851. * Gets the openGL format
  109852. */
  109853. glFormat: number;
  109854. /**
  109855. * Gets the openGL internal format
  109856. */
  109857. glInternalFormat: number;
  109858. /**
  109859. * Gets the base internal format
  109860. */
  109861. glBaseInternalFormat: number;
  109862. /**
  109863. * Gets image width in pixel
  109864. */
  109865. pixelWidth: number;
  109866. /**
  109867. * Gets image height in pixel
  109868. */
  109869. pixelHeight: number;
  109870. /**
  109871. * Gets image depth in pixels
  109872. */
  109873. pixelDepth: number;
  109874. /**
  109875. * Gets the number of array elements
  109876. */
  109877. numberOfArrayElements: number;
  109878. /**
  109879. * Gets the number of faces
  109880. */
  109881. numberOfFaces: number;
  109882. /**
  109883. * Gets the number of mipmap levels
  109884. */
  109885. numberOfMipmapLevels: number;
  109886. /**
  109887. * Gets the bytes of key value data
  109888. */
  109889. bytesOfKeyValueData: number;
  109890. /**
  109891. * Gets the load type
  109892. */
  109893. loadType: number;
  109894. /**
  109895. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  109896. */
  109897. isInvalid: boolean;
  109898. /**
  109899. * Creates a new KhronosTextureContainer
  109900. * @param arrayBuffer contents of the KTX container file
  109901. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  109902. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  109903. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  109904. */
  109905. constructor(
  109906. /** contents of the KTX container file */
  109907. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  109908. /**
  109909. * Uploads KTX content to a Babylon Texture.
  109910. * It is assumed that the texture has already been created & is currently bound
  109911. * @hidden
  109912. */
  109913. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  109914. private _upload2DCompressedLevels;
  109915. }
  109916. }
  109917. declare module BABYLON {
  109918. /**
  109919. * Implementation of the KTX Texture Loader.
  109920. * @hidden
  109921. */
  109922. export class _KTXTextureLoader implements IInternalTextureLoader {
  109923. /**
  109924. * Defines wether the loader supports cascade loading the different faces.
  109925. */
  109926. readonly supportCascades: boolean;
  109927. /**
  109928. * This returns if the loader support the current file information.
  109929. * @param extension defines the file extension of the file being loaded
  109930. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109931. * @param fallback defines the fallback internal texture if any
  109932. * @param isBase64 defines whether the texture is encoded as a base64
  109933. * @param isBuffer defines whether the texture data are stored as a buffer
  109934. * @returns true if the loader can load the specified file
  109935. */
  109936. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  109937. /**
  109938. * Transform the url before loading if required.
  109939. * @param rootUrl the url of the texture
  109940. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109941. * @returns the transformed texture
  109942. */
  109943. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  109944. /**
  109945. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  109946. * @param rootUrl the url of the texture
  109947. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109948. * @returns the fallback texture
  109949. */
  109950. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  109951. /**
  109952. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  109953. * @param data contains the texture data
  109954. * @param texture defines the BabylonJS internal texture
  109955. * @param createPolynomials will be true if polynomials have been requested
  109956. * @param onLoad defines the callback to trigger once the texture is ready
  109957. * @param onError defines the callback to trigger in case of error
  109958. */
  109959. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  109960. /**
  109961. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  109962. * @param data contains the texture data
  109963. * @param texture defines the BabylonJS internal texture
  109964. * @param callback defines the method to call once ready to upload
  109965. */
  109966. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  109967. }
  109968. }
  109969. declare module BABYLON {
  109970. /** @hidden */
  109971. export var _forceSceneHelpersToBundle: boolean;
  109972. interface Scene {
  109973. /**
  109974. * Creates a default light for the scene.
  109975. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  109976. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  109977. */
  109978. createDefaultLight(replace?: boolean): void;
  109979. /**
  109980. * Creates a default camera for the scene.
  109981. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  109982. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  109983. * @param replace has default false, when true replaces the active camera in the scene
  109984. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  109985. */
  109986. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  109987. /**
  109988. * Creates a default camera and a default light.
  109989. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  109990. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  109991. * @param replace has the default false, when true replaces the active camera/light in the scene
  109992. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  109993. */
  109994. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  109995. /**
  109996. * Creates a new sky box
  109997. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  109998. * @param environmentTexture defines the texture to use as environment texture
  109999. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  110000. * @param scale defines the overall scale of the skybox
  110001. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  110002. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  110003. * @returns a new mesh holding the sky box
  110004. */
  110005. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  110006. /**
  110007. * Creates a new environment
  110008. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  110009. * @param options defines the options you can use to configure the environment
  110010. * @returns the new EnvironmentHelper
  110011. */
  110012. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  110013. /**
  110014. * Creates a new VREXperienceHelper
  110015. * @see http://doc.babylonjs.com/how_to/webvr_helper
  110016. * @param webVROptions defines the options used to create the new VREXperienceHelper
  110017. * @returns a new VREXperienceHelper
  110018. */
  110019. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  110020. /**
  110021. * Creates a new XREXperienceHelper
  110022. * @see http://doc.babylonjs.com/how_to/webxr
  110023. * @returns a promise for a new XREXperienceHelper
  110024. */
  110025. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  110026. }
  110027. }
  110028. declare module BABYLON {
  110029. /**
  110030. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  110031. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  110032. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  110033. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  110034. */
  110035. export class VideoDome extends TransformNode {
  110036. /**
  110037. * Define the video source as a Monoscopic panoramic 360 video.
  110038. */
  110039. static readonly MODE_MONOSCOPIC: number;
  110040. /**
  110041. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  110042. */
  110043. static readonly MODE_TOPBOTTOM: number;
  110044. /**
  110045. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  110046. */
  110047. static readonly MODE_SIDEBYSIDE: number;
  110048. private _useDirectMapping;
  110049. /**
  110050. * The video texture being displayed on the sphere
  110051. */
  110052. protected _videoTexture: VideoTexture;
  110053. /**
  110054. * Gets the video texture being displayed on the sphere
  110055. */
  110056. readonly videoTexture: VideoTexture;
  110057. /**
  110058. * The skybox material
  110059. */
  110060. protected _material: BackgroundMaterial;
  110061. /**
  110062. * The surface used for the skybox
  110063. */
  110064. protected _mesh: Mesh;
  110065. /**
  110066. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  110067. * Also see the options.resolution property.
  110068. */
  110069. fovMultiplier: number;
  110070. private _videoMode;
  110071. /**
  110072. * Gets or set the current video mode for the video. It can be:
  110073. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  110074. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  110075. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  110076. */
  110077. videoMode: number;
  110078. /**
  110079. * Oberserver used in Stereoscopic VR Mode.
  110080. */
  110081. private _onBeforeCameraRenderObserver;
  110082. /**
  110083. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  110084. * @param name Element's name, child elements will append suffixes for their own names.
  110085. * @param urlsOrVideo defines the url(s) or the video element to use
  110086. * @param options An object containing optional or exposed sub element properties
  110087. */
  110088. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  110089. resolution?: number;
  110090. clickToPlay?: boolean;
  110091. autoPlay?: boolean;
  110092. loop?: boolean;
  110093. size?: number;
  110094. poster?: string;
  110095. faceForward?: boolean;
  110096. useDirectMapping?: boolean;
  110097. }, scene: Scene);
  110098. private _changeVideoMode;
  110099. /**
  110100. * Releases resources associated with this node.
  110101. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  110102. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  110103. */
  110104. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  110105. }
  110106. }
  110107. declare module BABYLON {
  110108. /**
  110109. * This class can be used to get instrumentation data from a Babylon engine
  110110. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  110111. */
  110112. export class EngineInstrumentation implements IDisposable {
  110113. /**
  110114. * Define the instrumented engine.
  110115. */
  110116. engine: Engine;
  110117. private _captureGPUFrameTime;
  110118. private _gpuFrameTimeToken;
  110119. private _gpuFrameTime;
  110120. private _captureShaderCompilationTime;
  110121. private _shaderCompilationTime;
  110122. private _onBeginFrameObserver;
  110123. private _onEndFrameObserver;
  110124. private _onBeforeShaderCompilationObserver;
  110125. private _onAfterShaderCompilationObserver;
  110126. /**
  110127. * Gets the perf counter used for GPU frame time
  110128. */
  110129. readonly gpuFrameTimeCounter: PerfCounter;
  110130. /**
  110131. * Gets the GPU frame time capture status
  110132. */
  110133. /**
  110134. * Enable or disable the GPU frame time capture
  110135. */
  110136. captureGPUFrameTime: boolean;
  110137. /**
  110138. * Gets the perf counter used for shader compilation time
  110139. */
  110140. readonly shaderCompilationTimeCounter: PerfCounter;
  110141. /**
  110142. * Gets the shader compilation time capture status
  110143. */
  110144. /**
  110145. * Enable or disable the shader compilation time capture
  110146. */
  110147. captureShaderCompilationTime: boolean;
  110148. /**
  110149. * Instantiates a new engine instrumentation.
  110150. * This class can be used to get instrumentation data from a Babylon engine
  110151. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  110152. * @param engine Defines the engine to instrument
  110153. */
  110154. constructor(
  110155. /**
  110156. * Define the instrumented engine.
  110157. */
  110158. engine: Engine);
  110159. /**
  110160. * Dispose and release associated resources.
  110161. */
  110162. dispose(): void;
  110163. }
  110164. }
  110165. declare module BABYLON {
  110166. /**
  110167. * This class can be used to get instrumentation data from a Babylon engine
  110168. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  110169. */
  110170. export class SceneInstrumentation implements IDisposable {
  110171. /**
  110172. * Defines the scene to instrument
  110173. */
  110174. scene: Scene;
  110175. private _captureActiveMeshesEvaluationTime;
  110176. private _activeMeshesEvaluationTime;
  110177. private _captureRenderTargetsRenderTime;
  110178. private _renderTargetsRenderTime;
  110179. private _captureFrameTime;
  110180. private _frameTime;
  110181. private _captureRenderTime;
  110182. private _renderTime;
  110183. private _captureInterFrameTime;
  110184. private _interFrameTime;
  110185. private _captureParticlesRenderTime;
  110186. private _particlesRenderTime;
  110187. private _captureSpritesRenderTime;
  110188. private _spritesRenderTime;
  110189. private _capturePhysicsTime;
  110190. private _physicsTime;
  110191. private _captureAnimationsTime;
  110192. private _animationsTime;
  110193. private _captureCameraRenderTime;
  110194. private _cameraRenderTime;
  110195. private _onBeforeActiveMeshesEvaluationObserver;
  110196. private _onAfterActiveMeshesEvaluationObserver;
  110197. private _onBeforeRenderTargetsRenderObserver;
  110198. private _onAfterRenderTargetsRenderObserver;
  110199. private _onAfterRenderObserver;
  110200. private _onBeforeDrawPhaseObserver;
  110201. private _onAfterDrawPhaseObserver;
  110202. private _onBeforeAnimationsObserver;
  110203. private _onBeforeParticlesRenderingObserver;
  110204. private _onAfterParticlesRenderingObserver;
  110205. private _onBeforeSpritesRenderingObserver;
  110206. private _onAfterSpritesRenderingObserver;
  110207. private _onBeforePhysicsObserver;
  110208. private _onAfterPhysicsObserver;
  110209. private _onAfterAnimationsObserver;
  110210. private _onBeforeCameraRenderObserver;
  110211. private _onAfterCameraRenderObserver;
  110212. /**
  110213. * Gets the perf counter used for active meshes evaluation time
  110214. */
  110215. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  110216. /**
  110217. * Gets the active meshes evaluation time capture status
  110218. */
  110219. /**
  110220. * Enable or disable the active meshes evaluation time capture
  110221. */
  110222. captureActiveMeshesEvaluationTime: boolean;
  110223. /**
  110224. * Gets the perf counter used for render targets render time
  110225. */
  110226. readonly renderTargetsRenderTimeCounter: PerfCounter;
  110227. /**
  110228. * Gets the render targets render time capture status
  110229. */
  110230. /**
  110231. * Enable or disable the render targets render time capture
  110232. */
  110233. captureRenderTargetsRenderTime: boolean;
  110234. /**
  110235. * Gets the perf counter used for particles render time
  110236. */
  110237. readonly particlesRenderTimeCounter: PerfCounter;
  110238. /**
  110239. * Gets the particles render time capture status
  110240. */
  110241. /**
  110242. * Enable or disable the particles render time capture
  110243. */
  110244. captureParticlesRenderTime: boolean;
  110245. /**
  110246. * Gets the perf counter used for sprites render time
  110247. */
  110248. readonly spritesRenderTimeCounter: PerfCounter;
  110249. /**
  110250. * Gets the sprites render time capture status
  110251. */
  110252. /**
  110253. * Enable or disable the sprites render time capture
  110254. */
  110255. captureSpritesRenderTime: boolean;
  110256. /**
  110257. * Gets the perf counter used for physics time
  110258. */
  110259. readonly physicsTimeCounter: PerfCounter;
  110260. /**
  110261. * Gets the physics time capture status
  110262. */
  110263. /**
  110264. * Enable or disable the physics time capture
  110265. */
  110266. capturePhysicsTime: boolean;
  110267. /**
  110268. * Gets the perf counter used for animations time
  110269. */
  110270. readonly animationsTimeCounter: PerfCounter;
  110271. /**
  110272. * Gets the animations time capture status
  110273. */
  110274. /**
  110275. * Enable or disable the animations time capture
  110276. */
  110277. captureAnimationsTime: boolean;
  110278. /**
  110279. * Gets the perf counter used for frame time capture
  110280. */
  110281. readonly frameTimeCounter: PerfCounter;
  110282. /**
  110283. * Gets the frame time capture status
  110284. */
  110285. /**
  110286. * Enable or disable the frame time capture
  110287. */
  110288. captureFrameTime: boolean;
  110289. /**
  110290. * Gets the perf counter used for inter-frames time capture
  110291. */
  110292. readonly interFrameTimeCounter: PerfCounter;
  110293. /**
  110294. * Gets the inter-frames time capture status
  110295. */
  110296. /**
  110297. * Enable or disable the inter-frames time capture
  110298. */
  110299. captureInterFrameTime: boolean;
  110300. /**
  110301. * Gets the perf counter used for render time capture
  110302. */
  110303. readonly renderTimeCounter: PerfCounter;
  110304. /**
  110305. * Gets the render time capture status
  110306. */
  110307. /**
  110308. * Enable or disable the render time capture
  110309. */
  110310. captureRenderTime: boolean;
  110311. /**
  110312. * Gets the perf counter used for camera render time capture
  110313. */
  110314. readonly cameraRenderTimeCounter: PerfCounter;
  110315. /**
  110316. * Gets the camera render time capture status
  110317. */
  110318. /**
  110319. * Enable or disable the camera render time capture
  110320. */
  110321. captureCameraRenderTime: boolean;
  110322. /**
  110323. * Gets the perf counter used for draw calls
  110324. */
  110325. readonly drawCallsCounter: PerfCounter;
  110326. /**
  110327. * Instantiates a new scene instrumentation.
  110328. * This class can be used to get instrumentation data from a Babylon engine
  110329. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  110330. * @param scene Defines the scene to instrument
  110331. */
  110332. constructor(
  110333. /**
  110334. * Defines the scene to instrument
  110335. */
  110336. scene: Scene);
  110337. /**
  110338. * Dispose and release associated resources.
  110339. */
  110340. dispose(): void;
  110341. }
  110342. }
  110343. declare module BABYLON {
  110344. /** @hidden */
  110345. export var glowMapGenerationPixelShader: {
  110346. name: string;
  110347. shader: string;
  110348. };
  110349. }
  110350. declare module BABYLON {
  110351. /** @hidden */
  110352. export var glowMapGenerationVertexShader: {
  110353. name: string;
  110354. shader: string;
  110355. };
  110356. }
  110357. declare module BABYLON {
  110358. /**
  110359. * Effect layer options. This helps customizing the behaviour
  110360. * of the effect layer.
  110361. */
  110362. export interface IEffectLayerOptions {
  110363. /**
  110364. * Multiplication factor apply to the canvas size to compute the render target size
  110365. * used to generated the objects (the smaller the faster).
  110366. */
  110367. mainTextureRatio: number;
  110368. /**
  110369. * Enforces a fixed size texture to ensure effect stability across devices.
  110370. */
  110371. mainTextureFixedSize?: number;
  110372. /**
  110373. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  110374. */
  110375. alphaBlendingMode: number;
  110376. /**
  110377. * The camera attached to the layer.
  110378. */
  110379. camera: Nullable<Camera>;
  110380. /**
  110381. * The rendering group to draw the layer in.
  110382. */
  110383. renderingGroupId: number;
  110384. }
  110385. /**
  110386. * The effect layer Helps adding post process effect blended with the main pass.
  110387. *
  110388. * This can be for instance use to generate glow or higlight effects on the scene.
  110389. *
  110390. * The effect layer class can not be used directly and is intented to inherited from to be
  110391. * customized per effects.
  110392. */
  110393. export abstract class EffectLayer {
  110394. private _vertexBuffers;
  110395. private _indexBuffer;
  110396. private _cachedDefines;
  110397. private _effectLayerMapGenerationEffect;
  110398. private _effectLayerOptions;
  110399. private _mergeEffect;
  110400. protected _scene: Scene;
  110401. protected _engine: Engine;
  110402. protected _maxSize: number;
  110403. protected _mainTextureDesiredSize: ISize;
  110404. protected _mainTexture: RenderTargetTexture;
  110405. protected _shouldRender: boolean;
  110406. protected _postProcesses: PostProcess[];
  110407. protected _textures: BaseTexture[];
  110408. protected _emissiveTextureAndColor: {
  110409. texture: Nullable<BaseTexture>;
  110410. color: Color4;
  110411. };
  110412. /**
  110413. * The name of the layer
  110414. */
  110415. name: string;
  110416. /**
  110417. * The clear color of the texture used to generate the glow map.
  110418. */
  110419. neutralColor: Color4;
  110420. /**
  110421. * Specifies wether the highlight layer is enabled or not.
  110422. */
  110423. isEnabled: boolean;
  110424. /**
  110425. * Gets the camera attached to the layer.
  110426. */
  110427. readonly camera: Nullable<Camera>;
  110428. /**
  110429. * Gets the rendering group id the layer should render in.
  110430. */
  110431. readonly renderingGroupId: number;
  110432. /**
  110433. * An event triggered when the effect layer has been disposed.
  110434. */
  110435. onDisposeObservable: Observable<EffectLayer>;
  110436. /**
  110437. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  110438. */
  110439. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  110440. /**
  110441. * An event triggered when the generated texture is being merged in the scene.
  110442. */
  110443. onBeforeComposeObservable: Observable<EffectLayer>;
  110444. /**
  110445. * An event triggered when the generated texture has been merged in the scene.
  110446. */
  110447. onAfterComposeObservable: Observable<EffectLayer>;
  110448. /**
  110449. * An event triggered when the efffect layer changes its size.
  110450. */
  110451. onSizeChangedObservable: Observable<EffectLayer>;
  110452. /** @hidden */
  110453. static _SceneComponentInitialization: (scene: Scene) => void;
  110454. /**
  110455. * Instantiates a new effect Layer and references it in the scene.
  110456. * @param name The name of the layer
  110457. * @param scene The scene to use the layer in
  110458. */
  110459. constructor(
  110460. /** The Friendly of the effect in the scene */
  110461. name: string, scene: Scene);
  110462. /**
  110463. * Get the effect name of the layer.
  110464. * @return The effect name
  110465. */
  110466. abstract getEffectName(): string;
  110467. /**
  110468. * Checks for the readiness of the element composing the layer.
  110469. * @param subMesh the mesh to check for
  110470. * @param useInstances specify wether or not to use instances to render the mesh
  110471. * @return true if ready otherwise, false
  110472. */
  110473. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  110474. /**
  110475. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  110476. * @returns true if the effect requires stencil during the main canvas render pass.
  110477. */
  110478. abstract needStencil(): boolean;
  110479. /**
  110480. * Create the merge effect. This is the shader use to blit the information back
  110481. * to the main canvas at the end of the scene rendering.
  110482. * @returns The effect containing the shader used to merge the effect on the main canvas
  110483. */
  110484. protected abstract _createMergeEffect(): Effect;
  110485. /**
  110486. * Creates the render target textures and post processes used in the effect layer.
  110487. */
  110488. protected abstract _createTextureAndPostProcesses(): void;
  110489. /**
  110490. * Implementation specific of rendering the generating effect on the main canvas.
  110491. * @param effect The effect used to render through
  110492. */
  110493. protected abstract _internalRender(effect: Effect): void;
  110494. /**
  110495. * Sets the required values for both the emissive texture and and the main color.
  110496. */
  110497. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  110498. /**
  110499. * Free any resources and references associated to a mesh.
  110500. * Internal use
  110501. * @param mesh The mesh to free.
  110502. */
  110503. abstract _disposeMesh(mesh: Mesh): void;
  110504. /**
  110505. * Serializes this layer (Glow or Highlight for example)
  110506. * @returns a serialized layer object
  110507. */
  110508. abstract serialize?(): any;
  110509. /**
  110510. * Initializes the effect layer with the required options.
  110511. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  110512. */
  110513. protected _init(options: Partial<IEffectLayerOptions>): void;
  110514. /**
  110515. * Generates the index buffer of the full screen quad blending to the main canvas.
  110516. */
  110517. private _generateIndexBuffer;
  110518. /**
  110519. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  110520. */
  110521. private _generateVertexBuffer;
  110522. /**
  110523. * Sets the main texture desired size which is the closest power of two
  110524. * of the engine canvas size.
  110525. */
  110526. private _setMainTextureSize;
  110527. /**
  110528. * Creates the main texture for the effect layer.
  110529. */
  110530. protected _createMainTexture(): void;
  110531. /**
  110532. * Adds specific effects defines.
  110533. * @param defines The defines to add specifics to.
  110534. */
  110535. protected _addCustomEffectDefines(defines: string[]): void;
  110536. /**
  110537. * Checks for the readiness of the element composing the layer.
  110538. * @param subMesh the mesh to check for
  110539. * @param useInstances specify wether or not to use instances to render the mesh
  110540. * @param emissiveTexture the associated emissive texture used to generate the glow
  110541. * @return true if ready otherwise, false
  110542. */
  110543. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  110544. /**
  110545. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  110546. */
  110547. render(): void;
  110548. /**
  110549. * Determine if a given mesh will be used in the current effect.
  110550. * @param mesh mesh to test
  110551. * @returns true if the mesh will be used
  110552. */
  110553. hasMesh(mesh: AbstractMesh): boolean;
  110554. /**
  110555. * Returns true if the layer contains information to display, otherwise false.
  110556. * @returns true if the glow layer should be rendered
  110557. */
  110558. shouldRender(): boolean;
  110559. /**
  110560. * Returns true if the mesh should render, otherwise false.
  110561. * @param mesh The mesh to render
  110562. * @returns true if it should render otherwise false
  110563. */
  110564. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  110565. /**
  110566. * Returns true if the mesh can be rendered, otherwise false.
  110567. * @param mesh The mesh to render
  110568. * @param material The material used on the mesh
  110569. * @returns true if it can be rendered otherwise false
  110570. */
  110571. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  110572. /**
  110573. * Returns true if the mesh should render, otherwise false.
  110574. * @param mesh The mesh to render
  110575. * @returns true if it should render otherwise false
  110576. */
  110577. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  110578. /**
  110579. * Renders the submesh passed in parameter to the generation map.
  110580. */
  110581. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  110582. /**
  110583. * Rebuild the required buffers.
  110584. * @hidden Internal use only.
  110585. */
  110586. _rebuild(): void;
  110587. /**
  110588. * Dispose only the render target textures and post process.
  110589. */
  110590. private _disposeTextureAndPostProcesses;
  110591. /**
  110592. * Dispose the highlight layer and free resources.
  110593. */
  110594. dispose(): void;
  110595. /**
  110596. * Gets the class name of the effect layer
  110597. * @returns the string with the class name of the effect layer
  110598. */
  110599. getClassName(): string;
  110600. /**
  110601. * Creates an effect layer from parsed effect layer data
  110602. * @param parsedEffectLayer defines effect layer data
  110603. * @param scene defines the current scene
  110604. * @param rootUrl defines the root URL containing the effect layer information
  110605. * @returns a parsed effect Layer
  110606. */
  110607. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  110608. }
  110609. }
  110610. declare module BABYLON {
  110611. interface AbstractScene {
  110612. /**
  110613. * The list of effect layers (highlights/glow) added to the scene
  110614. * @see http://doc.babylonjs.com/how_to/highlight_layer
  110615. * @see http://doc.babylonjs.com/how_to/glow_layer
  110616. */
  110617. effectLayers: Array<EffectLayer>;
  110618. /**
  110619. * Removes the given effect layer from this scene.
  110620. * @param toRemove defines the effect layer to remove
  110621. * @returns the index of the removed effect layer
  110622. */
  110623. removeEffectLayer(toRemove: EffectLayer): number;
  110624. /**
  110625. * Adds the given effect layer to this scene
  110626. * @param newEffectLayer defines the effect layer to add
  110627. */
  110628. addEffectLayer(newEffectLayer: EffectLayer): void;
  110629. }
  110630. /**
  110631. * Defines the layer scene component responsible to manage any effect layers
  110632. * in a given scene.
  110633. */
  110634. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  110635. /**
  110636. * The component name helpfull to identify the component in the list of scene components.
  110637. */
  110638. readonly name: string;
  110639. /**
  110640. * The scene the component belongs to.
  110641. */
  110642. scene: Scene;
  110643. private _engine;
  110644. private _renderEffects;
  110645. private _needStencil;
  110646. private _previousStencilState;
  110647. /**
  110648. * Creates a new instance of the component for the given scene
  110649. * @param scene Defines the scene to register the component in
  110650. */
  110651. constructor(scene: Scene);
  110652. /**
  110653. * Registers the component in a given scene
  110654. */
  110655. register(): void;
  110656. /**
  110657. * Rebuilds the elements related to this component in case of
  110658. * context lost for instance.
  110659. */
  110660. rebuild(): void;
  110661. /**
  110662. * Serializes the component data to the specified json object
  110663. * @param serializationObject The object to serialize to
  110664. */
  110665. serialize(serializationObject: any): void;
  110666. /**
  110667. * Adds all the elements from the container to the scene
  110668. * @param container the container holding the elements
  110669. */
  110670. addFromContainer(container: AbstractScene): void;
  110671. /**
  110672. * Removes all the elements in the container from the scene
  110673. * @param container contains the elements to remove
  110674. * @param dispose if the removed element should be disposed (default: false)
  110675. */
  110676. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  110677. /**
  110678. * Disposes the component and the associated ressources.
  110679. */
  110680. dispose(): void;
  110681. private _isReadyForMesh;
  110682. private _renderMainTexture;
  110683. private _setStencil;
  110684. private _setStencilBack;
  110685. private _draw;
  110686. private _drawCamera;
  110687. private _drawRenderingGroup;
  110688. }
  110689. }
  110690. declare module BABYLON {
  110691. /** @hidden */
  110692. export var glowMapMergePixelShader: {
  110693. name: string;
  110694. shader: string;
  110695. };
  110696. }
  110697. declare module BABYLON {
  110698. /** @hidden */
  110699. export var glowMapMergeVertexShader: {
  110700. name: string;
  110701. shader: string;
  110702. };
  110703. }
  110704. declare module BABYLON {
  110705. interface AbstractScene {
  110706. /**
  110707. * Return a the first highlight layer of the scene with a given name.
  110708. * @param name The name of the highlight layer to look for.
  110709. * @return The highlight layer if found otherwise null.
  110710. */
  110711. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  110712. }
  110713. /**
  110714. * Glow layer options. This helps customizing the behaviour
  110715. * of the glow layer.
  110716. */
  110717. export interface IGlowLayerOptions {
  110718. /**
  110719. * Multiplication factor apply to the canvas size to compute the render target size
  110720. * used to generated the glowing objects (the smaller the faster).
  110721. */
  110722. mainTextureRatio: number;
  110723. /**
  110724. * Enforces a fixed size texture to ensure resize independant blur.
  110725. */
  110726. mainTextureFixedSize?: number;
  110727. /**
  110728. * How big is the kernel of the blur texture.
  110729. */
  110730. blurKernelSize: number;
  110731. /**
  110732. * The camera attached to the layer.
  110733. */
  110734. camera: Nullable<Camera>;
  110735. /**
  110736. * Enable MSAA by chosing the number of samples.
  110737. */
  110738. mainTextureSamples?: number;
  110739. /**
  110740. * The rendering group to draw the layer in.
  110741. */
  110742. renderingGroupId: number;
  110743. }
  110744. /**
  110745. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  110746. *
  110747. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  110748. * glowy meshes to your scene.
  110749. *
  110750. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  110751. */
  110752. export class GlowLayer extends EffectLayer {
  110753. /**
  110754. * Effect Name of the layer.
  110755. */
  110756. static readonly EffectName: string;
  110757. /**
  110758. * The default blur kernel size used for the glow.
  110759. */
  110760. static DefaultBlurKernelSize: number;
  110761. /**
  110762. * The default texture size ratio used for the glow.
  110763. */
  110764. static DefaultTextureRatio: number;
  110765. /**
  110766. * Sets the kernel size of the blur.
  110767. */
  110768. /**
  110769. * Gets the kernel size of the blur.
  110770. */
  110771. blurKernelSize: number;
  110772. /**
  110773. * Sets the glow intensity.
  110774. */
  110775. /**
  110776. * Gets the glow intensity.
  110777. */
  110778. intensity: number;
  110779. private _options;
  110780. private _intensity;
  110781. private _horizontalBlurPostprocess1;
  110782. private _verticalBlurPostprocess1;
  110783. private _horizontalBlurPostprocess2;
  110784. private _verticalBlurPostprocess2;
  110785. private _blurTexture1;
  110786. private _blurTexture2;
  110787. private _postProcesses1;
  110788. private _postProcesses2;
  110789. private _includedOnlyMeshes;
  110790. private _excludedMeshes;
  110791. /**
  110792. * Callback used to let the user override the color selection on a per mesh basis
  110793. */
  110794. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  110795. /**
  110796. * Callback used to let the user override the texture selection on a per mesh basis
  110797. */
  110798. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  110799. /**
  110800. * Instantiates a new glow Layer and references it to the scene.
  110801. * @param name The name of the layer
  110802. * @param scene The scene to use the layer in
  110803. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  110804. */
  110805. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  110806. /**
  110807. * Get the effect name of the layer.
  110808. * @return The effect name
  110809. */
  110810. getEffectName(): string;
  110811. /**
  110812. * Create the merge effect. This is the shader use to blit the information back
  110813. * to the main canvas at the end of the scene rendering.
  110814. */
  110815. protected _createMergeEffect(): Effect;
  110816. /**
  110817. * Creates the render target textures and post processes used in the glow layer.
  110818. */
  110819. protected _createTextureAndPostProcesses(): void;
  110820. /**
  110821. * Checks for the readiness of the element composing the layer.
  110822. * @param subMesh the mesh to check for
  110823. * @param useInstances specify wether or not to use instances to render the mesh
  110824. * @param emissiveTexture the associated emissive texture used to generate the glow
  110825. * @return true if ready otherwise, false
  110826. */
  110827. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  110828. /**
  110829. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  110830. */
  110831. needStencil(): boolean;
  110832. /**
  110833. * Returns true if the mesh can be rendered, otherwise false.
  110834. * @param mesh The mesh to render
  110835. * @param material The material used on the mesh
  110836. * @returns true if it can be rendered otherwise false
  110837. */
  110838. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  110839. /**
  110840. * Implementation specific of rendering the generating effect on the main canvas.
  110841. * @param effect The effect used to render through
  110842. */
  110843. protected _internalRender(effect: Effect): void;
  110844. /**
  110845. * Sets the required values for both the emissive texture and and the main color.
  110846. */
  110847. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  110848. /**
  110849. * Returns true if the mesh should render, otherwise false.
  110850. * @param mesh The mesh to render
  110851. * @returns true if it should render otherwise false
  110852. */
  110853. protected _shouldRenderMesh(mesh: Mesh): boolean;
  110854. /**
  110855. * Adds specific effects defines.
  110856. * @param defines The defines to add specifics to.
  110857. */
  110858. protected _addCustomEffectDefines(defines: string[]): void;
  110859. /**
  110860. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  110861. * @param mesh The mesh to exclude from the glow layer
  110862. */
  110863. addExcludedMesh(mesh: Mesh): void;
  110864. /**
  110865. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  110866. * @param mesh The mesh to remove
  110867. */
  110868. removeExcludedMesh(mesh: Mesh): void;
  110869. /**
  110870. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  110871. * @param mesh The mesh to include in the glow layer
  110872. */
  110873. addIncludedOnlyMesh(mesh: Mesh): void;
  110874. /**
  110875. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  110876. * @param mesh The mesh to remove
  110877. */
  110878. removeIncludedOnlyMesh(mesh: Mesh): void;
  110879. /**
  110880. * Determine if a given mesh will be used in the glow layer
  110881. * @param mesh The mesh to test
  110882. * @returns true if the mesh will be highlighted by the current glow layer
  110883. */
  110884. hasMesh(mesh: AbstractMesh): boolean;
  110885. /**
  110886. * Free any resources and references associated to a mesh.
  110887. * Internal use
  110888. * @param mesh The mesh to free.
  110889. * @hidden
  110890. */
  110891. _disposeMesh(mesh: Mesh): void;
  110892. /**
  110893. * Gets the class name of the effect layer
  110894. * @returns the string with the class name of the effect layer
  110895. */
  110896. getClassName(): string;
  110897. /**
  110898. * Serializes this glow layer
  110899. * @returns a serialized glow layer object
  110900. */
  110901. serialize(): any;
  110902. /**
  110903. * Creates a Glow Layer from parsed glow layer data
  110904. * @param parsedGlowLayer defines glow layer data
  110905. * @param scene defines the current scene
  110906. * @param rootUrl defines the root URL containing the glow layer information
  110907. * @returns a parsed Glow Layer
  110908. */
  110909. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  110910. }
  110911. }
  110912. declare module BABYLON {
  110913. /** @hidden */
  110914. export var glowBlurPostProcessPixelShader: {
  110915. name: string;
  110916. shader: string;
  110917. };
  110918. }
  110919. declare module BABYLON {
  110920. interface AbstractScene {
  110921. /**
  110922. * Return a the first highlight layer of the scene with a given name.
  110923. * @param name The name of the highlight layer to look for.
  110924. * @return The highlight layer if found otherwise null.
  110925. */
  110926. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  110927. }
  110928. /**
  110929. * Highlight layer options. This helps customizing the behaviour
  110930. * of the highlight layer.
  110931. */
  110932. export interface IHighlightLayerOptions {
  110933. /**
  110934. * Multiplication factor apply to the canvas size to compute the render target size
  110935. * used to generated the glowing objects (the smaller the faster).
  110936. */
  110937. mainTextureRatio: number;
  110938. /**
  110939. * Enforces a fixed size texture to ensure resize independant blur.
  110940. */
  110941. mainTextureFixedSize?: number;
  110942. /**
  110943. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  110944. * of the picture to blur (the smaller the faster).
  110945. */
  110946. blurTextureSizeRatio: number;
  110947. /**
  110948. * How big in texel of the blur texture is the vertical blur.
  110949. */
  110950. blurVerticalSize: number;
  110951. /**
  110952. * How big in texel of the blur texture is the horizontal blur.
  110953. */
  110954. blurHorizontalSize: number;
  110955. /**
  110956. * Alpha blending mode used to apply the blur. Default is combine.
  110957. */
  110958. alphaBlendingMode: number;
  110959. /**
  110960. * The camera attached to the layer.
  110961. */
  110962. camera: Nullable<Camera>;
  110963. /**
  110964. * Should we display highlight as a solid stroke?
  110965. */
  110966. isStroke?: boolean;
  110967. /**
  110968. * The rendering group to draw the layer in.
  110969. */
  110970. renderingGroupId: number;
  110971. }
  110972. /**
  110973. * The highlight layer Helps adding a glow effect around a mesh.
  110974. *
  110975. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  110976. * glowy meshes to your scene.
  110977. *
  110978. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  110979. */
  110980. export class HighlightLayer extends EffectLayer {
  110981. name: string;
  110982. /**
  110983. * Effect Name of the highlight layer.
  110984. */
  110985. static readonly EffectName: string;
  110986. /**
  110987. * The neutral color used during the preparation of the glow effect.
  110988. * This is black by default as the blend operation is a blend operation.
  110989. */
  110990. static NeutralColor: Color4;
  110991. /**
  110992. * Stencil value used for glowing meshes.
  110993. */
  110994. static GlowingMeshStencilReference: number;
  110995. /**
  110996. * Stencil value used for the other meshes in the scene.
  110997. */
  110998. static NormalMeshStencilReference: number;
  110999. /**
  111000. * Specifies whether or not the inner glow is ACTIVE in the layer.
  111001. */
  111002. innerGlow: boolean;
  111003. /**
  111004. * Specifies whether or not the outer glow is ACTIVE in the layer.
  111005. */
  111006. outerGlow: boolean;
  111007. /**
  111008. * Specifies the horizontal size of the blur.
  111009. */
  111010. /**
  111011. * Gets the horizontal size of the blur.
  111012. */
  111013. blurHorizontalSize: number;
  111014. /**
  111015. * Specifies the vertical size of the blur.
  111016. */
  111017. /**
  111018. * Gets the vertical size of the blur.
  111019. */
  111020. blurVerticalSize: number;
  111021. /**
  111022. * An event triggered when the highlight layer is being blurred.
  111023. */
  111024. onBeforeBlurObservable: Observable<HighlightLayer>;
  111025. /**
  111026. * An event triggered when the highlight layer has been blurred.
  111027. */
  111028. onAfterBlurObservable: Observable<HighlightLayer>;
  111029. private _instanceGlowingMeshStencilReference;
  111030. private _options;
  111031. private _downSamplePostprocess;
  111032. private _horizontalBlurPostprocess;
  111033. private _verticalBlurPostprocess;
  111034. private _blurTexture;
  111035. private _meshes;
  111036. private _excludedMeshes;
  111037. /**
  111038. * Instantiates a new highlight Layer and references it to the scene..
  111039. * @param name The name of the layer
  111040. * @param scene The scene to use the layer in
  111041. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  111042. */
  111043. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  111044. /**
  111045. * Get the effect name of the layer.
  111046. * @return The effect name
  111047. */
  111048. getEffectName(): string;
  111049. /**
  111050. * Create the merge effect. This is the shader use to blit the information back
  111051. * to the main canvas at the end of the scene rendering.
  111052. */
  111053. protected _createMergeEffect(): Effect;
  111054. /**
  111055. * Creates the render target textures and post processes used in the highlight layer.
  111056. */
  111057. protected _createTextureAndPostProcesses(): void;
  111058. /**
  111059. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  111060. */
  111061. needStencil(): boolean;
  111062. /**
  111063. * Checks for the readiness of the element composing the layer.
  111064. * @param subMesh the mesh to check for
  111065. * @param useInstances specify wether or not to use instances to render the mesh
  111066. * @param emissiveTexture the associated emissive texture used to generate the glow
  111067. * @return true if ready otherwise, false
  111068. */
  111069. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  111070. /**
  111071. * Implementation specific of rendering the generating effect on the main canvas.
  111072. * @param effect The effect used to render through
  111073. */
  111074. protected _internalRender(effect: Effect): void;
  111075. /**
  111076. * Returns true if the layer contains information to display, otherwise false.
  111077. */
  111078. shouldRender(): boolean;
  111079. /**
  111080. * Returns true if the mesh should render, otherwise false.
  111081. * @param mesh The mesh to render
  111082. * @returns true if it should render otherwise false
  111083. */
  111084. protected _shouldRenderMesh(mesh: Mesh): boolean;
  111085. /**
  111086. * Sets the required values for both the emissive texture and and the main color.
  111087. */
  111088. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  111089. /**
  111090. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  111091. * @param mesh The mesh to exclude from the highlight layer
  111092. */
  111093. addExcludedMesh(mesh: Mesh): void;
  111094. /**
  111095. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  111096. * @param mesh The mesh to highlight
  111097. */
  111098. removeExcludedMesh(mesh: Mesh): void;
  111099. /**
  111100. * Determine if a given mesh will be highlighted by the current HighlightLayer
  111101. * @param mesh mesh to test
  111102. * @returns true if the mesh will be highlighted by the current HighlightLayer
  111103. */
  111104. hasMesh(mesh: AbstractMesh): boolean;
  111105. /**
  111106. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  111107. * @param mesh The mesh to highlight
  111108. * @param color The color of the highlight
  111109. * @param glowEmissiveOnly Extract the glow from the emissive texture
  111110. */
  111111. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  111112. /**
  111113. * Remove a mesh from the highlight layer in order to make it stop glowing.
  111114. * @param mesh The mesh to highlight
  111115. */
  111116. removeMesh(mesh: Mesh): void;
  111117. /**
  111118. * Force the stencil to the normal expected value for none glowing parts
  111119. */
  111120. private _defaultStencilReference;
  111121. /**
  111122. * Free any resources and references associated to a mesh.
  111123. * Internal use
  111124. * @param mesh The mesh to free.
  111125. * @hidden
  111126. */
  111127. _disposeMesh(mesh: Mesh): void;
  111128. /**
  111129. * Dispose the highlight layer and free resources.
  111130. */
  111131. dispose(): void;
  111132. /**
  111133. * Gets the class name of the effect layer
  111134. * @returns the string with the class name of the effect layer
  111135. */
  111136. getClassName(): string;
  111137. /**
  111138. * Serializes this Highlight layer
  111139. * @returns a serialized Highlight layer object
  111140. */
  111141. serialize(): any;
  111142. /**
  111143. * Creates a Highlight layer from parsed Highlight layer data
  111144. * @param parsedHightlightLayer defines the Highlight layer data
  111145. * @param scene defines the current scene
  111146. * @param rootUrl defines the root URL containing the Highlight layer information
  111147. * @returns a parsed Highlight layer
  111148. */
  111149. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  111150. }
  111151. }
  111152. declare module BABYLON {
  111153. interface AbstractScene {
  111154. /**
  111155. * The list of layers (background and foreground) of the scene
  111156. */
  111157. layers: Array<Layer>;
  111158. }
  111159. /**
  111160. * Defines the layer scene component responsible to manage any layers
  111161. * in a given scene.
  111162. */
  111163. export class LayerSceneComponent implements ISceneComponent {
  111164. /**
  111165. * The component name helpfull to identify the component in the list of scene components.
  111166. */
  111167. readonly name: string;
  111168. /**
  111169. * The scene the component belongs to.
  111170. */
  111171. scene: Scene;
  111172. private _engine;
  111173. /**
  111174. * Creates a new instance of the component for the given scene
  111175. * @param scene Defines the scene to register the component in
  111176. */
  111177. constructor(scene: Scene);
  111178. /**
  111179. * Registers the component in a given scene
  111180. */
  111181. register(): void;
  111182. /**
  111183. * Rebuilds the elements related to this component in case of
  111184. * context lost for instance.
  111185. */
  111186. rebuild(): void;
  111187. /**
  111188. * Disposes the component and the associated ressources.
  111189. */
  111190. dispose(): void;
  111191. private _draw;
  111192. private _drawCameraPredicate;
  111193. private _drawCameraBackground;
  111194. private _drawCameraForeground;
  111195. private _drawRenderTargetPredicate;
  111196. private _drawRenderTargetBackground;
  111197. private _drawRenderTargetForeground;
  111198. /**
  111199. * Adds all the elements from the container to the scene
  111200. * @param container the container holding the elements
  111201. */
  111202. addFromContainer(container: AbstractScene): void;
  111203. /**
  111204. * Removes all the elements in the container from the scene
  111205. * @param container contains the elements to remove
  111206. * @param dispose if the removed element should be disposed (default: false)
  111207. */
  111208. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  111209. }
  111210. }
  111211. declare module BABYLON {
  111212. /** @hidden */
  111213. export var layerPixelShader: {
  111214. name: string;
  111215. shader: string;
  111216. };
  111217. }
  111218. declare module BABYLON {
  111219. /** @hidden */
  111220. export var layerVertexShader: {
  111221. name: string;
  111222. shader: string;
  111223. };
  111224. }
  111225. declare module BABYLON {
  111226. /**
  111227. * This represents a full screen 2d layer.
  111228. * This can be useful to display a picture in the background of your scene for instance.
  111229. * @see https://www.babylonjs-playground.com/#08A2BS#1
  111230. */
  111231. export class Layer {
  111232. /**
  111233. * Define the name of the layer.
  111234. */
  111235. name: string;
  111236. /**
  111237. * Define the texture the layer should display.
  111238. */
  111239. texture: Nullable<Texture>;
  111240. /**
  111241. * Is the layer in background or foreground.
  111242. */
  111243. isBackground: boolean;
  111244. /**
  111245. * Define the color of the layer (instead of texture).
  111246. */
  111247. color: Color4;
  111248. /**
  111249. * Define the scale of the layer in order to zoom in out of the texture.
  111250. */
  111251. scale: Vector2;
  111252. /**
  111253. * Define an offset for the layer in order to shift the texture.
  111254. */
  111255. offset: Vector2;
  111256. /**
  111257. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  111258. */
  111259. alphaBlendingMode: number;
  111260. /**
  111261. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  111262. * Alpha test will not mix with the background color in case of transparency.
  111263. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  111264. */
  111265. alphaTest: boolean;
  111266. /**
  111267. * Define a mask to restrict the layer to only some of the scene cameras.
  111268. */
  111269. layerMask: number;
  111270. /**
  111271. * Define the list of render target the layer is visible into.
  111272. */
  111273. renderTargetTextures: RenderTargetTexture[];
  111274. /**
  111275. * Define if the layer is only used in renderTarget or if it also
  111276. * renders in the main frame buffer of the canvas.
  111277. */
  111278. renderOnlyInRenderTargetTextures: boolean;
  111279. private _scene;
  111280. private _vertexBuffers;
  111281. private _indexBuffer;
  111282. private _effect;
  111283. private _alphaTestEffect;
  111284. /**
  111285. * An event triggered when the layer is disposed.
  111286. */
  111287. onDisposeObservable: Observable<Layer>;
  111288. private _onDisposeObserver;
  111289. /**
  111290. * Back compatibility with callback before the onDisposeObservable existed.
  111291. * The set callback will be triggered when the layer has been disposed.
  111292. */
  111293. onDispose: () => void;
  111294. /**
  111295. * An event triggered before rendering the scene
  111296. */
  111297. onBeforeRenderObservable: Observable<Layer>;
  111298. private _onBeforeRenderObserver;
  111299. /**
  111300. * Back compatibility with callback before the onBeforeRenderObservable existed.
  111301. * The set callback will be triggered just before rendering the layer.
  111302. */
  111303. onBeforeRender: () => void;
  111304. /**
  111305. * An event triggered after rendering the scene
  111306. */
  111307. onAfterRenderObservable: Observable<Layer>;
  111308. private _onAfterRenderObserver;
  111309. /**
  111310. * Back compatibility with callback before the onAfterRenderObservable existed.
  111311. * The set callback will be triggered just after rendering the layer.
  111312. */
  111313. onAfterRender: () => void;
  111314. /**
  111315. * Instantiates a new layer.
  111316. * This represents a full screen 2d layer.
  111317. * This can be useful to display a picture in the background of your scene for instance.
  111318. * @see https://www.babylonjs-playground.com/#08A2BS#1
  111319. * @param name Define the name of the layer in the scene
  111320. * @param imgUrl Define the url of the texture to display in the layer
  111321. * @param scene Define the scene the layer belongs to
  111322. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  111323. * @param color Defines a color for the layer
  111324. */
  111325. constructor(
  111326. /**
  111327. * Define the name of the layer.
  111328. */
  111329. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  111330. private _createIndexBuffer;
  111331. /** @hidden */
  111332. _rebuild(): void;
  111333. /**
  111334. * Renders the layer in the scene.
  111335. */
  111336. render(): void;
  111337. /**
  111338. * Disposes and releases the associated ressources.
  111339. */
  111340. dispose(): void;
  111341. }
  111342. }
  111343. declare module BABYLON {
  111344. /** @hidden */
  111345. export var lensFlarePixelShader: {
  111346. name: string;
  111347. shader: string;
  111348. };
  111349. }
  111350. declare module BABYLON {
  111351. /** @hidden */
  111352. export var lensFlareVertexShader: {
  111353. name: string;
  111354. shader: string;
  111355. };
  111356. }
  111357. declare module BABYLON {
  111358. /**
  111359. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  111360. * It is usually composed of several `lensFlare`.
  111361. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  111362. */
  111363. export class LensFlareSystem {
  111364. /**
  111365. * Define the name of the lens flare system
  111366. */
  111367. name: string;
  111368. /**
  111369. * List of lens flares used in this system.
  111370. */
  111371. lensFlares: LensFlare[];
  111372. /**
  111373. * Define a limit from the border the lens flare can be visible.
  111374. */
  111375. borderLimit: number;
  111376. /**
  111377. * Define a viewport border we do not want to see the lens flare in.
  111378. */
  111379. viewportBorder: number;
  111380. /**
  111381. * Define a predicate which could limit the list of meshes able to occlude the effect.
  111382. */
  111383. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  111384. /**
  111385. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  111386. */
  111387. layerMask: number;
  111388. /**
  111389. * Define the id of the lens flare system in the scene.
  111390. * (equal to name by default)
  111391. */
  111392. id: string;
  111393. private _scene;
  111394. private _emitter;
  111395. private _vertexBuffers;
  111396. private _indexBuffer;
  111397. private _effect;
  111398. private _positionX;
  111399. private _positionY;
  111400. private _isEnabled;
  111401. /** @hidden */
  111402. static _SceneComponentInitialization: (scene: Scene) => void;
  111403. /**
  111404. * Instantiates a lens flare system.
  111405. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  111406. * It is usually composed of several `lensFlare`.
  111407. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  111408. * @param name Define the name of the lens flare system in the scene
  111409. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  111410. * @param scene Define the scene the lens flare system belongs to
  111411. */
  111412. constructor(
  111413. /**
  111414. * Define the name of the lens flare system
  111415. */
  111416. name: string, emitter: any, scene: Scene);
  111417. /**
  111418. * Define if the lens flare system is enabled.
  111419. */
  111420. isEnabled: boolean;
  111421. /**
  111422. * Get the scene the effects belongs to.
  111423. * @returns the scene holding the lens flare system
  111424. */
  111425. getScene(): Scene;
  111426. /**
  111427. * Get the emitter of the lens flare system.
  111428. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  111429. * @returns the emitter of the lens flare system
  111430. */
  111431. getEmitter(): any;
  111432. /**
  111433. * Set the emitter of the lens flare system.
  111434. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  111435. * @param newEmitter Define the new emitter of the system
  111436. */
  111437. setEmitter(newEmitter: any): void;
  111438. /**
  111439. * Get the lens flare system emitter position.
  111440. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  111441. * @returns the position
  111442. */
  111443. getEmitterPosition(): Vector3;
  111444. /**
  111445. * @hidden
  111446. */
  111447. computeEffectivePosition(globalViewport: Viewport): boolean;
  111448. /** @hidden */
  111449. _isVisible(): boolean;
  111450. /**
  111451. * @hidden
  111452. */
  111453. render(): boolean;
  111454. /**
  111455. * Dispose and release the lens flare with its associated resources.
  111456. */
  111457. dispose(): void;
  111458. /**
  111459. * Parse a lens flare system from a JSON repressentation
  111460. * @param parsedLensFlareSystem Define the JSON to parse
  111461. * @param scene Define the scene the parsed system should be instantiated in
  111462. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  111463. * @returns the parsed system
  111464. */
  111465. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  111466. /**
  111467. * Serialize the current Lens Flare System into a JSON representation.
  111468. * @returns the serialized JSON
  111469. */
  111470. serialize(): any;
  111471. }
  111472. }
  111473. declare module BABYLON {
  111474. /**
  111475. * This represents one of the lens effect in a `lensFlareSystem`.
  111476. * It controls one of the indiviual texture used in the effect.
  111477. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  111478. */
  111479. export class LensFlare {
  111480. /**
  111481. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  111482. */
  111483. size: number;
  111484. /**
  111485. * 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.
  111486. */
  111487. position: number;
  111488. /**
  111489. * Define the lens color.
  111490. */
  111491. color: Color3;
  111492. /**
  111493. * Define the lens texture.
  111494. */
  111495. texture: Nullable<Texture>;
  111496. /**
  111497. * Define the alpha mode to render this particular lens.
  111498. */
  111499. alphaMode: number;
  111500. private _system;
  111501. /**
  111502. * Creates a new Lens Flare.
  111503. * This represents one of the lens effect in a `lensFlareSystem`.
  111504. * It controls one of the indiviual texture used in the effect.
  111505. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  111506. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  111507. * @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.
  111508. * @param color Define the lens color
  111509. * @param imgUrl Define the lens texture url
  111510. * @param system Define the `lensFlareSystem` this flare is part of
  111511. * @returns The newly created Lens Flare
  111512. */
  111513. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  111514. /**
  111515. * Instantiates a new Lens Flare.
  111516. * This represents one of the lens effect in a `lensFlareSystem`.
  111517. * It controls one of the indiviual texture used in the effect.
  111518. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  111519. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  111520. * @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.
  111521. * @param color Define the lens color
  111522. * @param imgUrl Define the lens texture url
  111523. * @param system Define the `lensFlareSystem` this flare is part of
  111524. */
  111525. constructor(
  111526. /**
  111527. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  111528. */
  111529. size: number,
  111530. /**
  111531. * 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.
  111532. */
  111533. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  111534. /**
  111535. * Dispose and release the lens flare with its associated resources.
  111536. */
  111537. dispose(): void;
  111538. }
  111539. }
  111540. declare module BABYLON {
  111541. interface AbstractScene {
  111542. /**
  111543. * The list of lens flare system added to the scene
  111544. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  111545. */
  111546. lensFlareSystems: Array<LensFlareSystem>;
  111547. /**
  111548. * Removes the given lens flare system from this scene.
  111549. * @param toRemove The lens flare system to remove
  111550. * @returns The index of the removed lens flare system
  111551. */
  111552. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  111553. /**
  111554. * Adds the given lens flare system to this scene
  111555. * @param newLensFlareSystem The lens flare system to add
  111556. */
  111557. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  111558. /**
  111559. * Gets a lens flare system using its name
  111560. * @param name defines the name to look for
  111561. * @returns the lens flare system or null if not found
  111562. */
  111563. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  111564. /**
  111565. * Gets a lens flare system using its id
  111566. * @param id defines the id to look for
  111567. * @returns the lens flare system or null if not found
  111568. */
  111569. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  111570. }
  111571. /**
  111572. * Defines the lens flare scene component responsible to manage any lens flares
  111573. * in a given scene.
  111574. */
  111575. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  111576. /**
  111577. * The component name helpfull to identify the component in the list of scene components.
  111578. */
  111579. readonly name: string;
  111580. /**
  111581. * The scene the component belongs to.
  111582. */
  111583. scene: Scene;
  111584. /**
  111585. * Creates a new instance of the component for the given scene
  111586. * @param scene Defines the scene to register the component in
  111587. */
  111588. constructor(scene: Scene);
  111589. /**
  111590. * Registers the component in a given scene
  111591. */
  111592. register(): void;
  111593. /**
  111594. * Rebuilds the elements related to this component in case of
  111595. * context lost for instance.
  111596. */
  111597. rebuild(): void;
  111598. /**
  111599. * Adds all the elements from the container to the scene
  111600. * @param container the container holding the elements
  111601. */
  111602. addFromContainer(container: AbstractScene): void;
  111603. /**
  111604. * Removes all the elements in the container from the scene
  111605. * @param container contains the elements to remove
  111606. * @param dispose if the removed element should be disposed (default: false)
  111607. */
  111608. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  111609. /**
  111610. * Serializes the component data to the specified json object
  111611. * @param serializationObject The object to serialize to
  111612. */
  111613. serialize(serializationObject: any): void;
  111614. /**
  111615. * Disposes the component and the associated ressources.
  111616. */
  111617. dispose(): void;
  111618. private _draw;
  111619. }
  111620. }
  111621. declare module BABYLON {
  111622. /**
  111623. * Defines the shadow generator component responsible to manage any shadow generators
  111624. * in a given scene.
  111625. */
  111626. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  111627. /**
  111628. * The component name helpfull to identify the component in the list of scene components.
  111629. */
  111630. readonly name: string;
  111631. /**
  111632. * The scene the component belongs to.
  111633. */
  111634. scene: Scene;
  111635. /**
  111636. * Creates a new instance of the component for the given scene
  111637. * @param scene Defines the scene to register the component in
  111638. */
  111639. constructor(scene: Scene);
  111640. /**
  111641. * Registers the component in a given scene
  111642. */
  111643. register(): void;
  111644. /**
  111645. * Rebuilds the elements related to this component in case of
  111646. * context lost for instance.
  111647. */
  111648. rebuild(): void;
  111649. /**
  111650. * Serializes the component data to the specified json object
  111651. * @param serializationObject The object to serialize to
  111652. */
  111653. serialize(serializationObject: any): void;
  111654. /**
  111655. * Adds all the elements from the container to the scene
  111656. * @param container the container holding the elements
  111657. */
  111658. addFromContainer(container: AbstractScene): void;
  111659. /**
  111660. * Removes all the elements in the container from the scene
  111661. * @param container contains the elements to remove
  111662. * @param dispose if the removed element should be disposed (default: false)
  111663. */
  111664. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  111665. /**
  111666. * Rebuilds the elements related to this component in case of
  111667. * context lost for instance.
  111668. */
  111669. dispose(): void;
  111670. private _gatherRenderTargets;
  111671. }
  111672. }
  111673. declare module BABYLON {
  111674. /**
  111675. * A point light is a light defined by an unique point in world space.
  111676. * The light is emitted in every direction from this point.
  111677. * A good example of a point light is a standard light bulb.
  111678. * Documentation: https://doc.babylonjs.com/babylon101/lights
  111679. */
  111680. export class PointLight extends ShadowLight {
  111681. private _shadowAngle;
  111682. /**
  111683. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  111684. * This specifies what angle the shadow will use to be created.
  111685. *
  111686. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  111687. */
  111688. /**
  111689. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  111690. * This specifies what angle the shadow will use to be created.
  111691. *
  111692. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  111693. */
  111694. shadowAngle: number;
  111695. /**
  111696. * Gets the direction if it has been set.
  111697. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  111698. */
  111699. /**
  111700. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  111701. */
  111702. direction: Vector3;
  111703. /**
  111704. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  111705. * A PointLight emits the light in every direction.
  111706. * It can cast shadows.
  111707. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  111708. * ```javascript
  111709. * var pointLight = new PointLight("pl", camera.position, scene);
  111710. * ```
  111711. * Documentation : https://doc.babylonjs.com/babylon101/lights
  111712. * @param name The light friendly name
  111713. * @param position The position of the point light in the scene
  111714. * @param scene The scene the lights belongs to
  111715. */
  111716. constructor(name: string, position: Vector3, scene: Scene);
  111717. /**
  111718. * Returns the string "PointLight"
  111719. * @returns the class name
  111720. */
  111721. getClassName(): string;
  111722. /**
  111723. * Returns the integer 0.
  111724. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  111725. */
  111726. getTypeID(): number;
  111727. /**
  111728. * Specifies wether or not the shadowmap should be a cube texture.
  111729. * @returns true if the shadowmap needs to be a cube texture.
  111730. */
  111731. needCube(): boolean;
  111732. /**
  111733. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  111734. * @param faceIndex The index of the face we are computed the direction to generate shadow
  111735. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  111736. */
  111737. getShadowDirection(faceIndex?: number): Vector3;
  111738. /**
  111739. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  111740. * - fov = PI / 2
  111741. * - aspect ratio : 1.0
  111742. * - z-near and far equal to the active camera minZ and maxZ.
  111743. * Returns the PointLight.
  111744. */
  111745. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  111746. protected _buildUniformLayout(): void;
  111747. /**
  111748. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  111749. * @param effect The effect to update
  111750. * @param lightIndex The index of the light in the effect to update
  111751. * @returns The point light
  111752. */
  111753. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  111754. /**
  111755. * Prepares the list of defines specific to the light type.
  111756. * @param defines the list of defines
  111757. * @param lightIndex defines the index of the light for the effect
  111758. */
  111759. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  111760. }
  111761. }
  111762. declare module BABYLON {
  111763. /**
  111764. * Header information of HDR texture files.
  111765. */
  111766. export interface HDRInfo {
  111767. /**
  111768. * The height of the texture in pixels.
  111769. */
  111770. height: number;
  111771. /**
  111772. * The width of the texture in pixels.
  111773. */
  111774. width: number;
  111775. /**
  111776. * The index of the beginning of the data in the binary file.
  111777. */
  111778. dataPosition: number;
  111779. }
  111780. /**
  111781. * This groups tools to convert HDR texture to native colors array.
  111782. */
  111783. export class HDRTools {
  111784. private static Ldexp;
  111785. private static Rgbe2float;
  111786. private static readStringLine;
  111787. /**
  111788. * Reads header information from an RGBE texture stored in a native array.
  111789. * More information on this format are available here:
  111790. * https://en.wikipedia.org/wiki/RGBE_image_format
  111791. *
  111792. * @param uint8array The binary file stored in native array.
  111793. * @return The header information.
  111794. */
  111795. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  111796. /**
  111797. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  111798. * This RGBE texture needs to store the information as a panorama.
  111799. *
  111800. * More information on this format are available here:
  111801. * https://en.wikipedia.org/wiki/RGBE_image_format
  111802. *
  111803. * @param buffer The binary file stored in an array buffer.
  111804. * @param size The expected size of the extracted cubemap.
  111805. * @return The Cube Map information.
  111806. */
  111807. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  111808. /**
  111809. * Returns the pixels data extracted from an RGBE texture.
  111810. * This pixels will be stored left to right up to down in the R G B order in one array.
  111811. *
  111812. * More information on this format are available here:
  111813. * https://en.wikipedia.org/wiki/RGBE_image_format
  111814. *
  111815. * @param uint8array The binary file stored in an array buffer.
  111816. * @param hdrInfo The header information of the file.
  111817. * @return The pixels data in RGB right to left up to down order.
  111818. */
  111819. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  111820. private static RGBE_ReadPixels_RLE;
  111821. }
  111822. }
  111823. declare module BABYLON {
  111824. /**
  111825. * This represents a texture coming from an HDR input.
  111826. *
  111827. * The only supported format is currently panorama picture stored in RGBE format.
  111828. * Example of such files can be found on HDRLib: http://hdrlib.com/
  111829. */
  111830. export class HDRCubeTexture extends BaseTexture {
  111831. private static _facesMapping;
  111832. private _generateHarmonics;
  111833. private _noMipmap;
  111834. private _textureMatrix;
  111835. private _size;
  111836. private _onLoad;
  111837. private _onError;
  111838. /**
  111839. * The texture URL.
  111840. */
  111841. url: string;
  111842. /**
  111843. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  111844. */
  111845. coordinatesMode: number;
  111846. protected _isBlocking: boolean;
  111847. /**
  111848. * Sets wether or not the texture is blocking during loading.
  111849. */
  111850. /**
  111851. * Gets wether or not the texture is blocking during loading.
  111852. */
  111853. isBlocking: boolean;
  111854. protected _rotationY: number;
  111855. /**
  111856. * Sets texture matrix rotation angle around Y axis in radians.
  111857. */
  111858. /**
  111859. * Gets texture matrix rotation angle around Y axis radians.
  111860. */
  111861. rotationY: number;
  111862. /**
  111863. * Gets or sets the center of the bounding box associated with the cube texture
  111864. * It must define where the camera used to render the texture was set
  111865. */
  111866. boundingBoxPosition: Vector3;
  111867. private _boundingBoxSize;
  111868. /**
  111869. * Gets or sets the size of the bounding box associated with the cube texture
  111870. * When defined, the cubemap will switch to local mode
  111871. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  111872. * @example https://www.babylonjs-playground.com/#RNASML
  111873. */
  111874. boundingBoxSize: Vector3;
  111875. /**
  111876. * Instantiates an HDRTexture from the following parameters.
  111877. *
  111878. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  111879. * @param scene The scene the texture will be used in
  111880. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  111881. * @param noMipmap Forces to not generate the mipmap if true
  111882. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  111883. * @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)
  111884. * @param reserved Reserved flag for internal use.
  111885. */
  111886. 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>);
  111887. /**
  111888. * Get the current class name of the texture useful for serialization or dynamic coding.
  111889. * @returns "HDRCubeTexture"
  111890. */
  111891. getClassName(): string;
  111892. /**
  111893. * Occurs when the file is raw .hdr file.
  111894. */
  111895. private loadTexture;
  111896. clone(): HDRCubeTexture;
  111897. delayLoad(): void;
  111898. /**
  111899. * Get the texture reflection matrix used to rotate/transform the reflection.
  111900. * @returns the reflection matrix
  111901. */
  111902. getReflectionTextureMatrix(): Matrix;
  111903. /**
  111904. * Set the texture reflection matrix used to rotate/transform the reflection.
  111905. * @param value Define the reflection matrix to set
  111906. */
  111907. setReflectionTextureMatrix(value: Matrix): void;
  111908. /**
  111909. * Parses a JSON representation of an HDR Texture in order to create the texture
  111910. * @param parsedTexture Define the JSON representation
  111911. * @param scene Define the scene the texture should be created in
  111912. * @param rootUrl Define the root url in case we need to load relative dependencies
  111913. * @returns the newly created texture after parsing
  111914. */
  111915. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  111916. serialize(): any;
  111917. }
  111918. }
  111919. declare module BABYLON {
  111920. /**
  111921. * Class used to control physics engine
  111922. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  111923. */
  111924. export class PhysicsEngine implements IPhysicsEngine {
  111925. private _physicsPlugin;
  111926. /**
  111927. * Global value used to control the smallest number supported by the simulation
  111928. */
  111929. static Epsilon: number;
  111930. private _impostors;
  111931. private _joints;
  111932. /**
  111933. * Gets the gravity vector used by the simulation
  111934. */
  111935. gravity: Vector3;
  111936. /**
  111937. * Factory used to create the default physics plugin.
  111938. * @returns The default physics plugin
  111939. */
  111940. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  111941. /**
  111942. * Creates a new Physics Engine
  111943. * @param gravity defines the gravity vector used by the simulation
  111944. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  111945. */
  111946. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  111947. /**
  111948. * Sets the gravity vector used by the simulation
  111949. * @param gravity defines the gravity vector to use
  111950. */
  111951. setGravity(gravity: Vector3): void;
  111952. /**
  111953. * Set the time step of the physics engine.
  111954. * Default is 1/60.
  111955. * To slow it down, enter 1/600 for example.
  111956. * To speed it up, 1/30
  111957. * @param newTimeStep defines the new timestep to apply to this world.
  111958. */
  111959. setTimeStep(newTimeStep?: number): void;
  111960. /**
  111961. * Get the time step of the physics engine.
  111962. * @returns the current time step
  111963. */
  111964. getTimeStep(): number;
  111965. /**
  111966. * Release all resources
  111967. */
  111968. dispose(): void;
  111969. /**
  111970. * Gets the name of the current physics plugin
  111971. * @returns the name of the plugin
  111972. */
  111973. getPhysicsPluginName(): string;
  111974. /**
  111975. * Adding a new impostor for the impostor tracking.
  111976. * This will be done by the impostor itself.
  111977. * @param impostor the impostor to add
  111978. */
  111979. addImpostor(impostor: PhysicsImpostor): void;
  111980. /**
  111981. * Remove an impostor from the engine.
  111982. * This impostor and its mesh will not longer be updated by the physics engine.
  111983. * @param impostor the impostor to remove
  111984. */
  111985. removeImpostor(impostor: PhysicsImpostor): void;
  111986. /**
  111987. * Add a joint to the physics engine
  111988. * @param mainImpostor defines the main impostor to which the joint is added.
  111989. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  111990. * @param joint defines the joint that will connect both impostors.
  111991. */
  111992. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  111993. /**
  111994. * Removes a joint from the simulation
  111995. * @param mainImpostor defines the impostor used with the joint
  111996. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  111997. * @param joint defines the joint to remove
  111998. */
  111999. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  112000. /**
  112001. * Called by the scene. No need to call it.
  112002. * @param delta defines the timespam between frames
  112003. */
  112004. _step(delta: number): void;
  112005. /**
  112006. * Gets the current plugin used to run the simulation
  112007. * @returns current plugin
  112008. */
  112009. getPhysicsPlugin(): IPhysicsEnginePlugin;
  112010. /**
  112011. * Gets the list of physic impostors
  112012. * @returns an array of PhysicsImpostor
  112013. */
  112014. getImpostors(): Array<PhysicsImpostor>;
  112015. /**
  112016. * Gets the impostor for a physics enabled object
  112017. * @param object defines the object impersonated by the impostor
  112018. * @returns the PhysicsImpostor or null if not found
  112019. */
  112020. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  112021. /**
  112022. * Gets the impostor for a physics body object
  112023. * @param body defines physics body used by the impostor
  112024. * @returns the PhysicsImpostor or null if not found
  112025. */
  112026. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  112027. /**
  112028. * Does a raycast in the physics world
  112029. * @param from when should the ray start?
  112030. * @param to when should the ray end?
  112031. * @returns PhysicsRaycastResult
  112032. */
  112033. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  112034. }
  112035. }
  112036. declare module BABYLON {
  112037. /** @hidden */
  112038. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  112039. private _useDeltaForWorldStep;
  112040. world: any;
  112041. name: string;
  112042. private _physicsMaterials;
  112043. private _fixedTimeStep;
  112044. private _cannonRaycastResult;
  112045. private _raycastResult;
  112046. private _physicsBodysToRemoveAfterStep;
  112047. BJSCANNON: any;
  112048. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  112049. setGravity(gravity: Vector3): void;
  112050. setTimeStep(timeStep: number): void;
  112051. getTimeStep(): number;
  112052. executeStep(delta: number): void;
  112053. private _removeMarkedPhysicsBodiesFromWorld;
  112054. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  112055. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  112056. generatePhysicsBody(impostor: PhysicsImpostor): void;
  112057. private _processChildMeshes;
  112058. removePhysicsBody(impostor: PhysicsImpostor): void;
  112059. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  112060. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  112061. private _addMaterial;
  112062. private _checkWithEpsilon;
  112063. private _createShape;
  112064. private _createHeightmap;
  112065. private _minus90X;
  112066. private _plus90X;
  112067. private _tmpPosition;
  112068. private _tmpDeltaPosition;
  112069. private _tmpUnityRotation;
  112070. private _updatePhysicsBodyTransformation;
  112071. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  112072. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  112073. isSupported(): boolean;
  112074. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  112075. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  112076. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  112077. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  112078. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  112079. getBodyMass(impostor: PhysicsImpostor): number;
  112080. getBodyFriction(impostor: PhysicsImpostor): number;
  112081. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  112082. getBodyRestitution(impostor: PhysicsImpostor): number;
  112083. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  112084. sleepBody(impostor: PhysicsImpostor): void;
  112085. wakeUpBody(impostor: PhysicsImpostor): void;
  112086. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  112087. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  112088. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  112089. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  112090. getRadius(impostor: PhysicsImpostor): number;
  112091. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  112092. dispose(): void;
  112093. private _extendNamespace;
  112094. /**
  112095. * Does a raycast in the physics world
  112096. * @param from when should the ray start?
  112097. * @param to when should the ray end?
  112098. * @returns PhysicsRaycastResult
  112099. */
  112100. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  112101. }
  112102. }
  112103. declare module BABYLON {
  112104. /** @hidden */
  112105. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  112106. world: any;
  112107. name: string;
  112108. BJSOIMO: any;
  112109. private _raycastResult;
  112110. constructor(iterations?: number, oimoInjection?: any);
  112111. setGravity(gravity: Vector3): void;
  112112. setTimeStep(timeStep: number): void;
  112113. getTimeStep(): number;
  112114. private _tmpImpostorsArray;
  112115. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  112116. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  112117. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  112118. generatePhysicsBody(impostor: PhysicsImpostor): void;
  112119. private _tmpPositionVector;
  112120. removePhysicsBody(impostor: PhysicsImpostor): void;
  112121. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  112122. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  112123. isSupported(): boolean;
  112124. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  112125. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  112126. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  112127. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  112128. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  112129. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  112130. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  112131. getBodyMass(impostor: PhysicsImpostor): number;
  112132. getBodyFriction(impostor: PhysicsImpostor): number;
  112133. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  112134. getBodyRestitution(impostor: PhysicsImpostor): number;
  112135. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  112136. sleepBody(impostor: PhysicsImpostor): void;
  112137. wakeUpBody(impostor: PhysicsImpostor): void;
  112138. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  112139. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  112140. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  112141. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  112142. getRadius(impostor: PhysicsImpostor): number;
  112143. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  112144. dispose(): void;
  112145. /**
  112146. * Does a raycast in the physics world
  112147. * @param from when should the ray start?
  112148. * @param to when should the ray end?
  112149. * @returns PhysicsRaycastResult
  112150. */
  112151. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  112152. }
  112153. }
  112154. declare module BABYLON {
  112155. /**
  112156. * Class containing static functions to help procedurally build meshes
  112157. */
  112158. export class RibbonBuilder {
  112159. /**
  112160. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  112161. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  112162. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  112163. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  112164. * * 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
  112165. * * 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
  112166. * * 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
  112167. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  112168. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  112169. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  112170. * * 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
  112171. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  112172. * * 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
  112173. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  112174. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112175. * @param name defines the name of the mesh
  112176. * @param options defines the options used to create the mesh
  112177. * @param scene defines the hosting scene
  112178. * @returns the ribbon mesh
  112179. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  112180. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  112181. */
  112182. static CreateRibbon(name: string, options: {
  112183. pathArray: Vector3[][];
  112184. closeArray?: boolean;
  112185. closePath?: boolean;
  112186. offset?: number;
  112187. updatable?: boolean;
  112188. sideOrientation?: number;
  112189. frontUVs?: Vector4;
  112190. backUVs?: Vector4;
  112191. instance?: Mesh;
  112192. invertUV?: boolean;
  112193. uvs?: Vector2[];
  112194. colors?: Color4[];
  112195. }, scene?: Nullable<Scene>): Mesh;
  112196. }
  112197. }
  112198. declare module BABYLON {
  112199. /**
  112200. * Class containing static functions to help procedurally build meshes
  112201. */
  112202. export class ShapeBuilder {
  112203. /**
  112204. * 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.
  112205. * * 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.
  112206. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  112207. * * 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.
  112208. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  112209. * * 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
  112210. * * 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
  112211. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  112212. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  112213. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  112214. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  112215. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  112216. * @param name defines the name of the mesh
  112217. * @param options defines the options used to create the mesh
  112218. * @param scene defines the hosting scene
  112219. * @returns the extruded shape mesh
  112220. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  112221. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  112222. */
  112223. static ExtrudeShape(name: string, options: {
  112224. shape: Vector3[];
  112225. path: Vector3[];
  112226. scale?: number;
  112227. rotation?: number;
  112228. cap?: number;
  112229. updatable?: boolean;
  112230. sideOrientation?: number;
  112231. frontUVs?: Vector4;
  112232. backUVs?: Vector4;
  112233. instance?: Mesh;
  112234. invertUV?: boolean;
  112235. }, scene?: Nullable<Scene>): Mesh;
  112236. /**
  112237. * Creates an custom extruded shape mesh.
  112238. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  112239. * * 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.
  112240. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  112241. * * 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
  112242. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  112243. * * 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
  112244. * * It must returns a float value that will be the scale value applied to the shape on each path point
  112245. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  112246. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  112247. * * 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
  112248. * * 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
  112249. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  112250. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  112251. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  112252. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  112253. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112254. * @param name defines the name of the mesh
  112255. * @param options defines the options used to create the mesh
  112256. * @param scene defines the hosting scene
  112257. * @returns the custom extruded shape mesh
  112258. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  112259. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  112260. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  112261. */
  112262. static ExtrudeShapeCustom(name: string, options: {
  112263. shape: Vector3[];
  112264. path: Vector3[];
  112265. scaleFunction?: any;
  112266. rotationFunction?: any;
  112267. ribbonCloseArray?: boolean;
  112268. ribbonClosePath?: boolean;
  112269. cap?: number;
  112270. updatable?: boolean;
  112271. sideOrientation?: number;
  112272. frontUVs?: Vector4;
  112273. backUVs?: Vector4;
  112274. instance?: Mesh;
  112275. invertUV?: boolean;
  112276. }, scene?: Nullable<Scene>): Mesh;
  112277. private static _ExtrudeShapeGeneric;
  112278. }
  112279. }
  112280. declare module BABYLON {
  112281. /**
  112282. * AmmoJS Physics plugin
  112283. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112284. * @see https://github.com/kripken/ammo.js/
  112285. */
  112286. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  112287. private _useDeltaForWorldStep;
  112288. /**
  112289. * Reference to the Ammo library
  112290. */
  112291. bjsAMMO: any;
  112292. /**
  112293. * Created ammoJS world which physics bodies are added to
  112294. */
  112295. world: any;
  112296. /**
  112297. * Name of the plugin
  112298. */
  112299. name: string;
  112300. private _timeStep;
  112301. private _fixedTimeStep;
  112302. private _maxSteps;
  112303. private _tmpQuaternion;
  112304. private _tmpAmmoTransform;
  112305. private _tmpAmmoQuaternion;
  112306. private _tmpAmmoConcreteContactResultCallback;
  112307. private _collisionConfiguration;
  112308. private _dispatcher;
  112309. private _overlappingPairCache;
  112310. private _solver;
  112311. private _softBodySolver;
  112312. private _tmpAmmoVectorA;
  112313. private _tmpAmmoVectorB;
  112314. private _tmpAmmoVectorC;
  112315. private _tmpAmmoVectorD;
  112316. private _tmpContactCallbackResult;
  112317. private _tmpAmmoVectorRCA;
  112318. private _tmpAmmoVectorRCB;
  112319. private _raycastResult;
  112320. private static readonly DISABLE_COLLISION_FLAG;
  112321. private static readonly KINEMATIC_FLAG;
  112322. private static readonly DISABLE_DEACTIVATION_FLAG;
  112323. /**
  112324. * Initializes the ammoJS plugin
  112325. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  112326. * @param ammoInjection can be used to inject your own ammo reference
  112327. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  112328. */
  112329. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  112330. /**
  112331. * Sets the gravity of the physics world (m/(s^2))
  112332. * @param gravity Gravity to set
  112333. */
  112334. setGravity(gravity: Vector3): void;
  112335. /**
  112336. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  112337. * @param timeStep timestep to use in seconds
  112338. */
  112339. setTimeStep(timeStep: number): void;
  112340. /**
  112341. * 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)
  112342. * @param fixedTimeStep fixedTimeStep to use in seconds
  112343. */
  112344. setFixedTimeStep(fixedTimeStep: number): void;
  112345. /**
  112346. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  112347. * @param maxSteps the maximum number of steps by the physics engine per frame
  112348. */
  112349. setMaxSteps(maxSteps: number): void;
  112350. /**
  112351. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  112352. * @returns the current timestep in seconds
  112353. */
  112354. getTimeStep(): number;
  112355. private _isImpostorInContact;
  112356. private _isImpostorPairInContact;
  112357. private _stepSimulation;
  112358. /**
  112359. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  112360. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  112361. * After the step the babylon meshes are set to the position of the physics imposters
  112362. * @param delta amount of time to step forward
  112363. * @param impostors array of imposters to update before/after the step
  112364. */
  112365. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  112366. /**
  112367. * Update babylon mesh to match physics world object
  112368. * @param impostor imposter to match
  112369. */
  112370. private _afterSoftStep;
  112371. /**
  112372. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  112373. * @param impostor imposter to match
  112374. */
  112375. private _ropeStep;
  112376. /**
  112377. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  112378. * @param impostor imposter to match
  112379. */
  112380. private _softbodyOrClothStep;
  112381. private _tmpVector;
  112382. private _tmpMatrix;
  112383. /**
  112384. * Applies an impulse on the imposter
  112385. * @param impostor imposter to apply impulse to
  112386. * @param force amount of force to be applied to the imposter
  112387. * @param contactPoint the location to apply the impulse on the imposter
  112388. */
  112389. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  112390. /**
  112391. * Applies a force on the imposter
  112392. * @param impostor imposter to apply force
  112393. * @param force amount of force to be applied to the imposter
  112394. * @param contactPoint the location to apply the force on the imposter
  112395. */
  112396. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  112397. /**
  112398. * Creates a physics body using the plugin
  112399. * @param impostor the imposter to create the physics body on
  112400. */
  112401. generatePhysicsBody(impostor: PhysicsImpostor): void;
  112402. /**
  112403. * Removes the physics body from the imposter and disposes of the body's memory
  112404. * @param impostor imposter to remove the physics body from
  112405. */
  112406. removePhysicsBody(impostor: PhysicsImpostor): void;
  112407. /**
  112408. * Generates a joint
  112409. * @param impostorJoint the imposter joint to create the joint with
  112410. */
  112411. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  112412. /**
  112413. * Removes a joint
  112414. * @param impostorJoint the imposter joint to remove the joint from
  112415. */
  112416. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  112417. private _addMeshVerts;
  112418. /**
  112419. * Initialise the soft body vertices to match its object's (mesh) vertices
  112420. * Softbody vertices (nodes) are in world space and to match this
  112421. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  112422. * @param impostor to create the softbody for
  112423. */
  112424. private _softVertexData;
  112425. /**
  112426. * Create an impostor's soft body
  112427. * @param impostor to create the softbody for
  112428. */
  112429. private _createSoftbody;
  112430. /**
  112431. * Create cloth for an impostor
  112432. * @param impostor to create the softbody for
  112433. */
  112434. private _createCloth;
  112435. /**
  112436. * Create rope for an impostor
  112437. * @param impostor to create the softbody for
  112438. */
  112439. private _createRope;
  112440. private _addHullVerts;
  112441. private _createShape;
  112442. /**
  112443. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  112444. * @param impostor imposter containing the physics body and babylon object
  112445. */
  112446. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  112447. /**
  112448. * Sets the babylon object's position/rotation from the physics body's position/rotation
  112449. * @param impostor imposter containing the physics body and babylon object
  112450. * @param newPosition new position
  112451. * @param newRotation new rotation
  112452. */
  112453. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  112454. /**
  112455. * If this plugin is supported
  112456. * @returns true if its supported
  112457. */
  112458. isSupported(): boolean;
  112459. /**
  112460. * Sets the linear velocity of the physics body
  112461. * @param impostor imposter to set the velocity on
  112462. * @param velocity velocity to set
  112463. */
  112464. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  112465. /**
  112466. * Sets the angular velocity of the physics body
  112467. * @param impostor imposter to set the velocity on
  112468. * @param velocity velocity to set
  112469. */
  112470. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  112471. /**
  112472. * gets the linear velocity
  112473. * @param impostor imposter to get linear velocity from
  112474. * @returns linear velocity
  112475. */
  112476. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  112477. /**
  112478. * gets the angular velocity
  112479. * @param impostor imposter to get angular velocity from
  112480. * @returns angular velocity
  112481. */
  112482. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  112483. /**
  112484. * Sets the mass of physics body
  112485. * @param impostor imposter to set the mass on
  112486. * @param mass mass to set
  112487. */
  112488. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  112489. /**
  112490. * Gets the mass of the physics body
  112491. * @param impostor imposter to get the mass from
  112492. * @returns mass
  112493. */
  112494. getBodyMass(impostor: PhysicsImpostor): number;
  112495. /**
  112496. * Gets friction of the impostor
  112497. * @param impostor impostor to get friction from
  112498. * @returns friction value
  112499. */
  112500. getBodyFriction(impostor: PhysicsImpostor): number;
  112501. /**
  112502. * Sets friction of the impostor
  112503. * @param impostor impostor to set friction on
  112504. * @param friction friction value
  112505. */
  112506. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  112507. /**
  112508. * Gets restitution of the impostor
  112509. * @param impostor impostor to get restitution from
  112510. * @returns restitution value
  112511. */
  112512. getBodyRestitution(impostor: PhysicsImpostor): number;
  112513. /**
  112514. * Sets resitution of the impostor
  112515. * @param impostor impostor to set resitution on
  112516. * @param restitution resitution value
  112517. */
  112518. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  112519. /**
  112520. * Gets pressure inside the impostor
  112521. * @param impostor impostor to get pressure from
  112522. * @returns pressure value
  112523. */
  112524. getBodyPressure(impostor: PhysicsImpostor): number;
  112525. /**
  112526. * Sets pressure inside a soft body impostor
  112527. * Cloth and rope must remain 0 pressure
  112528. * @param impostor impostor to set pressure on
  112529. * @param pressure pressure value
  112530. */
  112531. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  112532. /**
  112533. * Gets stiffness of the impostor
  112534. * @param impostor impostor to get stiffness from
  112535. * @returns pressure value
  112536. */
  112537. getBodyStiffness(impostor: PhysicsImpostor): number;
  112538. /**
  112539. * Sets stiffness of the impostor
  112540. * @param impostor impostor to set stiffness on
  112541. * @param stiffness stiffness value from 0 to 1
  112542. */
  112543. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  112544. /**
  112545. * Gets velocityIterations of the impostor
  112546. * @param impostor impostor to get velocity iterations from
  112547. * @returns velocityIterations value
  112548. */
  112549. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  112550. /**
  112551. * Sets velocityIterations of the impostor
  112552. * @param impostor impostor to set velocity iterations on
  112553. * @param velocityIterations velocityIterations value
  112554. */
  112555. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  112556. /**
  112557. * Gets positionIterations of the impostor
  112558. * @param impostor impostor to get position iterations from
  112559. * @returns positionIterations value
  112560. */
  112561. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  112562. /**
  112563. * Sets positionIterations of the impostor
  112564. * @param impostor impostor to set position on
  112565. * @param positionIterations positionIterations value
  112566. */
  112567. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  112568. /**
  112569. * Append an anchor to a cloth object
  112570. * @param impostor is the cloth impostor to add anchor to
  112571. * @param otherImpostor is the rigid impostor to anchor to
  112572. * @param width ratio across width from 0 to 1
  112573. * @param height ratio up height from 0 to 1
  112574. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  112575. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  112576. */
  112577. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  112578. /**
  112579. * Append an hook to a rope object
  112580. * @param impostor is the rope impostor to add hook to
  112581. * @param otherImpostor is the rigid impostor to hook to
  112582. * @param length ratio along the rope from 0 to 1
  112583. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  112584. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  112585. */
  112586. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  112587. /**
  112588. * Sleeps the physics body and stops it from being active
  112589. * @param impostor impostor to sleep
  112590. */
  112591. sleepBody(impostor: PhysicsImpostor): void;
  112592. /**
  112593. * Activates the physics body
  112594. * @param impostor impostor to activate
  112595. */
  112596. wakeUpBody(impostor: PhysicsImpostor): void;
  112597. /**
  112598. * Updates the distance parameters of the joint
  112599. * @param joint joint to update
  112600. * @param maxDistance maximum distance of the joint
  112601. * @param minDistance minimum distance of the joint
  112602. */
  112603. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  112604. /**
  112605. * Sets a motor on the joint
  112606. * @param joint joint to set motor on
  112607. * @param speed speed of the motor
  112608. * @param maxForce maximum force of the motor
  112609. * @param motorIndex index of the motor
  112610. */
  112611. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  112612. /**
  112613. * Sets the motors limit
  112614. * @param joint joint to set limit on
  112615. * @param upperLimit upper limit
  112616. * @param lowerLimit lower limit
  112617. */
  112618. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  112619. /**
  112620. * Syncs the position and rotation of a mesh with the impostor
  112621. * @param mesh mesh to sync
  112622. * @param impostor impostor to update the mesh with
  112623. */
  112624. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  112625. /**
  112626. * Gets the radius of the impostor
  112627. * @param impostor impostor to get radius from
  112628. * @returns the radius
  112629. */
  112630. getRadius(impostor: PhysicsImpostor): number;
  112631. /**
  112632. * Gets the box size of the impostor
  112633. * @param impostor impostor to get box size from
  112634. * @param result the resulting box size
  112635. */
  112636. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  112637. /**
  112638. * Disposes of the impostor
  112639. */
  112640. dispose(): void;
  112641. /**
  112642. * Does a raycast in the physics world
  112643. * @param from when should the ray start?
  112644. * @param to when should the ray end?
  112645. * @returns PhysicsRaycastResult
  112646. */
  112647. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  112648. }
  112649. }
  112650. declare module BABYLON {
  112651. interface AbstractScene {
  112652. /**
  112653. * The list of reflection probes added to the scene
  112654. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  112655. */
  112656. reflectionProbes: Array<ReflectionProbe>;
  112657. /**
  112658. * Removes the given reflection probe from this scene.
  112659. * @param toRemove The reflection probe to remove
  112660. * @returns The index of the removed reflection probe
  112661. */
  112662. removeReflectionProbe(toRemove: ReflectionProbe): number;
  112663. /**
  112664. * Adds the given reflection probe to this scene.
  112665. * @param newReflectionProbe The reflection probe to add
  112666. */
  112667. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  112668. }
  112669. /**
  112670. * Class used to generate realtime reflection / refraction cube textures
  112671. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  112672. */
  112673. export class ReflectionProbe {
  112674. /** defines the name of the probe */
  112675. name: string;
  112676. private _scene;
  112677. private _renderTargetTexture;
  112678. private _projectionMatrix;
  112679. private _viewMatrix;
  112680. private _target;
  112681. private _add;
  112682. private _attachedMesh;
  112683. private _invertYAxis;
  112684. /** Gets or sets probe position (center of the cube map) */
  112685. position: Vector3;
  112686. /**
  112687. * Creates a new reflection probe
  112688. * @param name defines the name of the probe
  112689. * @param size defines the texture resolution (for each face)
  112690. * @param scene defines the hosting scene
  112691. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  112692. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  112693. */
  112694. constructor(
  112695. /** defines the name of the probe */
  112696. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  112697. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  112698. samples: number;
  112699. /** Gets or sets the refresh rate to use (on every frame by default) */
  112700. refreshRate: number;
  112701. /**
  112702. * Gets the hosting scene
  112703. * @returns a Scene
  112704. */
  112705. getScene(): Scene;
  112706. /** Gets the internal CubeTexture used to render to */
  112707. readonly cubeTexture: RenderTargetTexture;
  112708. /** Gets the list of meshes to render */
  112709. readonly renderList: Nullable<AbstractMesh[]>;
  112710. /**
  112711. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  112712. * @param mesh defines the mesh to attach to
  112713. */
  112714. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  112715. /**
  112716. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  112717. * @param renderingGroupId The rendering group id corresponding to its index
  112718. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  112719. */
  112720. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  112721. /**
  112722. * Clean all associated resources
  112723. */
  112724. dispose(): void;
  112725. /**
  112726. * Converts the reflection probe information to a readable string for debug purpose.
  112727. * @param fullDetails Supports for multiple levels of logging within scene loading
  112728. * @returns the human readable reflection probe info
  112729. */
  112730. toString(fullDetails?: boolean): string;
  112731. /**
  112732. * Get the class name of the relfection probe.
  112733. * @returns "ReflectionProbe"
  112734. */
  112735. getClassName(): string;
  112736. /**
  112737. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  112738. * @returns The JSON representation of the texture
  112739. */
  112740. serialize(): any;
  112741. /**
  112742. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  112743. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  112744. * @param scene Define the scene the parsed reflection probe should be instantiated in
  112745. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  112746. * @returns The parsed reflection probe if successful
  112747. */
  112748. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  112749. }
  112750. }
  112751. declare module BABYLON {
  112752. /** @hidden */
  112753. export var _BabylonLoaderRegistered: boolean;
  112754. }
  112755. declare module BABYLON {
  112756. /**
  112757. * The Physically based simple base material of BJS.
  112758. *
  112759. * This enables better naming and convention enforcements on top of the pbrMaterial.
  112760. * It is used as the base class for both the specGloss and metalRough conventions.
  112761. */
  112762. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  112763. /**
  112764. * Number of Simultaneous lights allowed on the material.
  112765. */
  112766. maxSimultaneousLights: number;
  112767. /**
  112768. * If sets to true, disables all the lights affecting the material.
  112769. */
  112770. disableLighting: boolean;
  112771. /**
  112772. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  112773. */
  112774. environmentTexture: BaseTexture;
  112775. /**
  112776. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  112777. */
  112778. invertNormalMapX: boolean;
  112779. /**
  112780. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  112781. */
  112782. invertNormalMapY: boolean;
  112783. /**
  112784. * Normal map used in the model.
  112785. */
  112786. normalTexture: BaseTexture;
  112787. /**
  112788. * Emissivie color used to self-illuminate the model.
  112789. */
  112790. emissiveColor: Color3;
  112791. /**
  112792. * Emissivie texture used to self-illuminate the model.
  112793. */
  112794. emissiveTexture: BaseTexture;
  112795. /**
  112796. * Occlusion Channel Strenght.
  112797. */
  112798. occlusionStrength: number;
  112799. /**
  112800. * Occlusion Texture of the material (adding extra occlusion effects).
  112801. */
  112802. occlusionTexture: BaseTexture;
  112803. /**
  112804. * Defines the alpha limits in alpha test mode.
  112805. */
  112806. alphaCutOff: number;
  112807. /**
  112808. * Gets the current double sided mode.
  112809. */
  112810. /**
  112811. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  112812. */
  112813. doubleSided: boolean;
  112814. /**
  112815. * Stores the pre-calculated light information of a mesh in a texture.
  112816. */
  112817. lightmapTexture: BaseTexture;
  112818. /**
  112819. * If true, the light map contains occlusion information instead of lighting info.
  112820. */
  112821. useLightmapAsShadowmap: boolean;
  112822. /**
  112823. * Instantiates a new PBRMaterial instance.
  112824. *
  112825. * @param name The material name
  112826. * @param scene The scene the material will be use in.
  112827. */
  112828. constructor(name: string, scene: Scene);
  112829. getClassName(): string;
  112830. }
  112831. }
  112832. declare module BABYLON {
  112833. /**
  112834. * The PBR material of BJS following the metal roughness convention.
  112835. *
  112836. * This fits to the PBR convention in the GLTF definition:
  112837. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  112838. */
  112839. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  112840. /**
  112841. * The base color has two different interpretations depending on the value of metalness.
  112842. * When the material is a metal, the base color is the specific measured reflectance value
  112843. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  112844. * of the material.
  112845. */
  112846. baseColor: Color3;
  112847. /**
  112848. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  112849. * well as opacity information in the alpha channel.
  112850. */
  112851. baseTexture: BaseTexture;
  112852. /**
  112853. * Specifies the metallic scalar value of the material.
  112854. * Can also be used to scale the metalness values of the metallic texture.
  112855. */
  112856. metallic: number;
  112857. /**
  112858. * Specifies the roughness scalar value of the material.
  112859. * Can also be used to scale the roughness values of the metallic texture.
  112860. */
  112861. roughness: number;
  112862. /**
  112863. * Texture containing both the metallic value in the B channel and the
  112864. * roughness value in the G channel to keep better precision.
  112865. */
  112866. metallicRoughnessTexture: BaseTexture;
  112867. /**
  112868. * Instantiates a new PBRMetalRoughnessMaterial instance.
  112869. *
  112870. * @param name The material name
  112871. * @param scene The scene the material will be use in.
  112872. */
  112873. constructor(name: string, scene: Scene);
  112874. /**
  112875. * Return the currrent class name of the material.
  112876. */
  112877. getClassName(): string;
  112878. /**
  112879. * Makes a duplicate of the current material.
  112880. * @param name - name to use for the new material.
  112881. */
  112882. clone(name: string): PBRMetallicRoughnessMaterial;
  112883. /**
  112884. * Serialize the material to a parsable JSON object.
  112885. */
  112886. serialize(): any;
  112887. /**
  112888. * Parses a JSON object correponding to the serialize function.
  112889. */
  112890. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  112891. }
  112892. }
  112893. declare module BABYLON {
  112894. /**
  112895. * The PBR material of BJS following the specular glossiness convention.
  112896. *
  112897. * This fits to the PBR convention in the GLTF definition:
  112898. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  112899. */
  112900. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  112901. /**
  112902. * Specifies the diffuse color of the material.
  112903. */
  112904. diffuseColor: Color3;
  112905. /**
  112906. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  112907. * channel.
  112908. */
  112909. diffuseTexture: BaseTexture;
  112910. /**
  112911. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  112912. */
  112913. specularColor: Color3;
  112914. /**
  112915. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  112916. */
  112917. glossiness: number;
  112918. /**
  112919. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  112920. */
  112921. specularGlossinessTexture: BaseTexture;
  112922. /**
  112923. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  112924. *
  112925. * @param name The material name
  112926. * @param scene The scene the material will be use in.
  112927. */
  112928. constructor(name: string, scene: Scene);
  112929. /**
  112930. * Return the currrent class name of the material.
  112931. */
  112932. getClassName(): string;
  112933. /**
  112934. * Makes a duplicate of the current material.
  112935. * @param name - name to use for the new material.
  112936. */
  112937. clone(name: string): PBRSpecularGlossinessMaterial;
  112938. /**
  112939. * Serialize the material to a parsable JSON object.
  112940. */
  112941. serialize(): any;
  112942. /**
  112943. * Parses a JSON object correponding to the serialize function.
  112944. */
  112945. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  112946. }
  112947. }
  112948. declare module BABYLON {
  112949. /**
  112950. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  112951. * It can help converting any input color in a desired output one. This can then be used to create effects
  112952. * from sepia, black and white to sixties or futuristic rendering...
  112953. *
  112954. * The only supported format is currently 3dl.
  112955. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  112956. */
  112957. export class ColorGradingTexture extends BaseTexture {
  112958. /**
  112959. * The current texture matrix. (will always be identity in color grading texture)
  112960. */
  112961. private _textureMatrix;
  112962. /**
  112963. * The texture URL.
  112964. */
  112965. url: string;
  112966. /**
  112967. * Empty line regex stored for GC.
  112968. */
  112969. private static _noneEmptyLineRegex;
  112970. private _engine;
  112971. /**
  112972. * Instantiates a ColorGradingTexture from the following parameters.
  112973. *
  112974. * @param url The location of the color gradind data (currently only supporting 3dl)
  112975. * @param scene The scene the texture will be used in
  112976. */
  112977. constructor(url: string, scene: Scene);
  112978. /**
  112979. * Returns the texture matrix used in most of the material.
  112980. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  112981. */
  112982. getTextureMatrix(): Matrix;
  112983. /**
  112984. * Occurs when the file being loaded is a .3dl LUT file.
  112985. */
  112986. private load3dlTexture;
  112987. /**
  112988. * Starts the loading process of the texture.
  112989. */
  112990. private loadTexture;
  112991. /**
  112992. * Clones the color gradind texture.
  112993. */
  112994. clone(): ColorGradingTexture;
  112995. /**
  112996. * Called during delayed load for textures.
  112997. */
  112998. delayLoad(): void;
  112999. /**
  113000. * Parses a color grading texture serialized by Babylon.
  113001. * @param parsedTexture The texture information being parsedTexture
  113002. * @param scene The scene to load the texture in
  113003. * @param rootUrl The root url of the data assets to load
  113004. * @return A color gradind texture
  113005. */
  113006. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  113007. /**
  113008. * Serializes the LUT texture to json format.
  113009. */
  113010. serialize(): any;
  113011. }
  113012. }
  113013. declare module BABYLON {
  113014. /**
  113015. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  113016. */
  113017. export class EquiRectangularCubeTexture extends BaseTexture {
  113018. /** The six faces of the cube. */
  113019. private static _FacesMapping;
  113020. private _noMipmap;
  113021. private _onLoad;
  113022. private _onError;
  113023. /** The size of the cubemap. */
  113024. private _size;
  113025. /** The buffer of the image. */
  113026. private _buffer;
  113027. /** The width of the input image. */
  113028. private _width;
  113029. /** The height of the input image. */
  113030. private _height;
  113031. /** The URL to the image. */
  113032. url: string;
  113033. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  113034. coordinatesMode: number;
  113035. /**
  113036. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  113037. * @param url The location of the image
  113038. * @param scene The scene the texture will be used in
  113039. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  113040. * @param noMipmap Forces to not generate the mipmap if true
  113041. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  113042. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  113043. * @param onLoad — defines a callback called when texture is loaded
  113044. * @param onError — defines a callback called if there is an error
  113045. */
  113046. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  113047. /**
  113048. * Load the image data, by putting the image on a canvas and extracting its buffer.
  113049. */
  113050. private loadImage;
  113051. /**
  113052. * Convert the image buffer into a cubemap and create a CubeTexture.
  113053. */
  113054. private loadTexture;
  113055. /**
  113056. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  113057. * @param buffer The ArrayBuffer that should be converted.
  113058. * @returns The buffer as Float32Array.
  113059. */
  113060. private getFloat32ArrayFromArrayBuffer;
  113061. /**
  113062. * Get the current class name of the texture useful for serialization or dynamic coding.
  113063. * @returns "EquiRectangularCubeTexture"
  113064. */
  113065. getClassName(): string;
  113066. /**
  113067. * Create a clone of the current EquiRectangularCubeTexture and return it.
  113068. * @returns A clone of the current EquiRectangularCubeTexture.
  113069. */
  113070. clone(): EquiRectangularCubeTexture;
  113071. }
  113072. }
  113073. declare module BABYLON {
  113074. /**
  113075. * Based on jsTGALoader - Javascript loader for TGA file
  113076. * By Vincent Thibault
  113077. * @see http://blog.robrowser.com/javascript-tga-loader.html
  113078. */
  113079. export class TGATools {
  113080. private static _TYPE_INDEXED;
  113081. private static _TYPE_RGB;
  113082. private static _TYPE_GREY;
  113083. private static _TYPE_RLE_INDEXED;
  113084. private static _TYPE_RLE_RGB;
  113085. private static _TYPE_RLE_GREY;
  113086. private static _ORIGIN_MASK;
  113087. private static _ORIGIN_SHIFT;
  113088. private static _ORIGIN_BL;
  113089. private static _ORIGIN_BR;
  113090. private static _ORIGIN_UL;
  113091. private static _ORIGIN_UR;
  113092. /**
  113093. * Gets the header of a TGA file
  113094. * @param data defines the TGA data
  113095. * @returns the header
  113096. */
  113097. static GetTGAHeader(data: Uint8Array): any;
  113098. /**
  113099. * Uploads TGA content to a Babylon Texture
  113100. * @hidden
  113101. */
  113102. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  113103. /** @hidden */
  113104. 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;
  113105. /** @hidden */
  113106. 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;
  113107. /** @hidden */
  113108. 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;
  113109. /** @hidden */
  113110. 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;
  113111. /** @hidden */
  113112. 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;
  113113. /** @hidden */
  113114. 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;
  113115. }
  113116. }
  113117. declare module BABYLON {
  113118. /**
  113119. * Implementation of the TGA Texture Loader.
  113120. * @hidden
  113121. */
  113122. export class _TGATextureLoader implements IInternalTextureLoader {
  113123. /**
  113124. * Defines wether the loader supports cascade loading the different faces.
  113125. */
  113126. readonly supportCascades: boolean;
  113127. /**
  113128. * This returns if the loader support the current file information.
  113129. * @param extension defines the file extension of the file being loaded
  113130. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113131. * @param fallback defines the fallback internal texture if any
  113132. * @param isBase64 defines whether the texture is encoded as a base64
  113133. * @param isBuffer defines whether the texture data are stored as a buffer
  113134. * @returns true if the loader can load the specified file
  113135. */
  113136. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  113137. /**
  113138. * Transform the url before loading if required.
  113139. * @param rootUrl the url of the texture
  113140. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113141. * @returns the transformed texture
  113142. */
  113143. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  113144. /**
  113145. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  113146. * @param rootUrl the url of the texture
  113147. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113148. * @returns the fallback texture
  113149. */
  113150. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  113151. /**
  113152. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  113153. * @param data contains the texture data
  113154. * @param texture defines the BabylonJS internal texture
  113155. * @param createPolynomials will be true if polynomials have been requested
  113156. * @param onLoad defines the callback to trigger once the texture is ready
  113157. * @param onError defines the callback to trigger in case of error
  113158. */
  113159. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  113160. /**
  113161. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  113162. * @param data contains the texture data
  113163. * @param texture defines the BabylonJS internal texture
  113164. * @param callback defines the method to call once ready to upload
  113165. */
  113166. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  113167. }
  113168. }
  113169. declare module BABYLON {
  113170. /**
  113171. * Info about the .basis files
  113172. */
  113173. class BasisFileInfo {
  113174. /**
  113175. * If the file has alpha
  113176. */
  113177. hasAlpha: boolean;
  113178. /**
  113179. * Info about each image of the basis file
  113180. */
  113181. images: Array<{
  113182. levels: Array<{
  113183. width: number;
  113184. height: number;
  113185. transcodedPixels: ArrayBufferView;
  113186. }>;
  113187. }>;
  113188. }
  113189. /**
  113190. * Result of transcoding a basis file
  113191. */
  113192. class TranscodeResult {
  113193. /**
  113194. * Info about the .basis file
  113195. */
  113196. fileInfo: BasisFileInfo;
  113197. /**
  113198. * Format to use when loading the file
  113199. */
  113200. format: number;
  113201. }
  113202. /**
  113203. * Configuration options for the Basis transcoder
  113204. */
  113205. export class BasisTranscodeConfiguration {
  113206. /**
  113207. * Supported compression formats used to determine the supported output format of the transcoder
  113208. */
  113209. supportedCompressionFormats?: {
  113210. /**
  113211. * etc1 compression format
  113212. */
  113213. etc1?: boolean;
  113214. /**
  113215. * s3tc compression format
  113216. */
  113217. s3tc?: boolean;
  113218. /**
  113219. * pvrtc compression format
  113220. */
  113221. pvrtc?: boolean;
  113222. /**
  113223. * etc2 compression format
  113224. */
  113225. etc2?: boolean;
  113226. };
  113227. /**
  113228. * If mipmap levels should be loaded for transcoded images (Default: true)
  113229. */
  113230. loadMipmapLevels?: boolean;
  113231. /**
  113232. * Index of a single image to load (Default: all images)
  113233. */
  113234. loadSingleImage?: number;
  113235. }
  113236. /**
  113237. * Used to load .Basis files
  113238. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  113239. */
  113240. export class BasisTools {
  113241. private static _IgnoreSupportedFormats;
  113242. /**
  113243. * URL to use when loading the basis transcoder
  113244. */
  113245. static JSModuleURL: string;
  113246. /**
  113247. * URL to use when loading the wasm module for the transcoder
  113248. */
  113249. static WasmModuleURL: string;
  113250. /**
  113251. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  113252. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  113253. * @returns internal format corresponding to the Basis format
  113254. */
  113255. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  113256. private static _WorkerPromise;
  113257. private static _Worker;
  113258. private static _actionId;
  113259. private static _CreateWorkerAsync;
  113260. /**
  113261. * Transcodes a loaded image file to compressed pixel data
  113262. * @param imageData image data to transcode
  113263. * @param config configuration options for the transcoding
  113264. * @returns a promise resulting in the transcoded image
  113265. */
  113266. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  113267. /**
  113268. * Loads a texture from the transcode result
  113269. * @param texture texture load to
  113270. * @param transcodeResult the result of transcoding the basis file to load from
  113271. */
  113272. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  113273. }
  113274. }
  113275. declare module BABYLON {
  113276. /**
  113277. * Loader for .basis file format
  113278. */
  113279. export class _BasisTextureLoader implements IInternalTextureLoader {
  113280. /**
  113281. * Defines whether the loader supports cascade loading the different faces.
  113282. */
  113283. readonly supportCascades: boolean;
  113284. /**
  113285. * This returns if the loader support the current file information.
  113286. * @param extension defines the file extension of the file being loaded
  113287. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113288. * @param fallback defines the fallback internal texture if any
  113289. * @param isBase64 defines whether the texture is encoded as a base64
  113290. * @param isBuffer defines whether the texture data are stored as a buffer
  113291. * @returns true if the loader can load the specified file
  113292. */
  113293. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  113294. /**
  113295. * Transform the url before loading if required.
  113296. * @param rootUrl the url of the texture
  113297. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113298. * @returns the transformed texture
  113299. */
  113300. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  113301. /**
  113302. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  113303. * @param rootUrl the url of the texture
  113304. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113305. * @returns the fallback texture
  113306. */
  113307. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  113308. /**
  113309. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  113310. * @param data contains the texture data
  113311. * @param texture defines the BabylonJS internal texture
  113312. * @param createPolynomials will be true if polynomials have been requested
  113313. * @param onLoad defines the callback to trigger once the texture is ready
  113314. * @param onError defines the callback to trigger in case of error
  113315. */
  113316. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  113317. /**
  113318. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  113319. * @param data contains the texture data
  113320. * @param texture defines the BabylonJS internal texture
  113321. * @param callback defines the method to call once ready to upload
  113322. */
  113323. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  113324. }
  113325. }
  113326. declare module BABYLON {
  113327. /**
  113328. * 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.
  113329. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  113330. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  113331. */
  113332. export class CustomProceduralTexture extends ProceduralTexture {
  113333. private _animate;
  113334. private _time;
  113335. private _config;
  113336. private _texturePath;
  113337. /**
  113338. * Instantiates a new Custom Procedural Texture.
  113339. * 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.
  113340. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  113341. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  113342. * @param name Define the name of the texture
  113343. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  113344. * @param size Define the size of the texture to create
  113345. * @param scene Define the scene the texture belongs to
  113346. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  113347. * @param generateMipMaps Define if the texture should creates mip maps or not
  113348. */
  113349. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  113350. private _loadJson;
  113351. /**
  113352. * Is the texture ready to be used ? (rendered at least once)
  113353. * @returns true if ready, otherwise, false.
  113354. */
  113355. isReady(): boolean;
  113356. /**
  113357. * Render the texture to its associated render target.
  113358. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  113359. */
  113360. render(useCameraPostProcess?: boolean): void;
  113361. /**
  113362. * Update the list of dependant textures samplers in the shader.
  113363. */
  113364. updateTextures(): void;
  113365. /**
  113366. * Update the uniform values of the procedural texture in the shader.
  113367. */
  113368. updateShaderUniforms(): void;
  113369. /**
  113370. * Define if the texture animates or not.
  113371. */
  113372. animate: boolean;
  113373. }
  113374. }
  113375. declare module BABYLON {
  113376. /** @hidden */
  113377. export var noisePixelShader: {
  113378. name: string;
  113379. shader: string;
  113380. };
  113381. }
  113382. declare module BABYLON {
  113383. /**
  113384. * Class used to generate noise procedural textures
  113385. */
  113386. export class NoiseProceduralTexture extends ProceduralTexture {
  113387. private _time;
  113388. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  113389. brightness: number;
  113390. /** Defines the number of octaves to process */
  113391. octaves: number;
  113392. /** Defines the level of persistence (0.8 by default) */
  113393. persistence: number;
  113394. /** Gets or sets animation speed factor (default is 1) */
  113395. animationSpeedFactor: number;
  113396. /**
  113397. * Creates a new NoiseProceduralTexture
  113398. * @param name defines the name fo the texture
  113399. * @param size defines the size of the texture (default is 256)
  113400. * @param scene defines the hosting scene
  113401. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  113402. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  113403. */
  113404. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  113405. private _updateShaderUniforms;
  113406. protected _getDefines(): string;
  113407. /** Generate the current state of the procedural texture */
  113408. render(useCameraPostProcess?: boolean): void;
  113409. /**
  113410. * Serializes this noise procedural texture
  113411. * @returns a serialized noise procedural texture object
  113412. */
  113413. serialize(): any;
  113414. /**
  113415. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  113416. * @param parsedTexture defines parsed texture data
  113417. * @param scene defines the current scene
  113418. * @param rootUrl defines the root URL containing noise procedural texture information
  113419. * @returns a parsed NoiseProceduralTexture
  113420. */
  113421. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  113422. }
  113423. }
  113424. declare module BABYLON {
  113425. /**
  113426. * Raw cube texture where the raw buffers are passed in
  113427. */
  113428. export class RawCubeTexture extends CubeTexture {
  113429. /**
  113430. * Creates a cube texture where the raw buffers are passed in.
  113431. * @param scene defines the scene the texture is attached to
  113432. * @param data defines the array of data to use to create each face
  113433. * @param size defines the size of the textures
  113434. * @param format defines the format of the data
  113435. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  113436. * @param generateMipMaps defines if the engine should generate the mip levels
  113437. * @param invertY defines if data must be stored with Y axis inverted
  113438. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  113439. * @param compression defines the compression used (null by default)
  113440. */
  113441. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  113442. /**
  113443. * Updates the raw cube texture.
  113444. * @param data defines the data to store
  113445. * @param format defines the data format
  113446. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  113447. * @param invertY defines if data must be stored with Y axis inverted
  113448. * @param compression defines the compression used (null by default)
  113449. * @param level defines which level of the texture to update
  113450. */
  113451. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  113452. /**
  113453. * Updates a raw cube texture with RGBD encoded data.
  113454. * @param data defines the array of data [mipmap][face] to use to create each face
  113455. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  113456. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  113457. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  113458. * @returns a promsie that resolves when the operation is complete
  113459. */
  113460. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  113461. /**
  113462. * Clones the raw cube texture.
  113463. * @return a new cube texture
  113464. */
  113465. clone(): CubeTexture;
  113466. /** @hidden */
  113467. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  113468. }
  113469. }
  113470. declare module BABYLON {
  113471. /**
  113472. * Class used to store 3D textures containing user data
  113473. */
  113474. export class RawTexture3D extends Texture {
  113475. /** Gets or sets the texture format to use */
  113476. format: number;
  113477. private _engine;
  113478. /**
  113479. * Create a new RawTexture3D
  113480. * @param data defines the data of the texture
  113481. * @param width defines the width of the texture
  113482. * @param height defines the height of the texture
  113483. * @param depth defines the depth of the texture
  113484. * @param format defines the texture format to use
  113485. * @param scene defines the hosting scene
  113486. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  113487. * @param invertY defines if texture must be stored with Y axis inverted
  113488. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  113489. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  113490. */
  113491. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  113492. /** Gets or sets the texture format to use */
  113493. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  113494. /**
  113495. * Update the texture with new data
  113496. * @param data defines the data to store in the texture
  113497. */
  113498. update(data: ArrayBufferView): void;
  113499. }
  113500. }
  113501. declare module BABYLON {
  113502. /**
  113503. * Creates a refraction texture used by refraction channel of the standard material.
  113504. * It is like a mirror but to see through a material.
  113505. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  113506. */
  113507. export class RefractionTexture extends RenderTargetTexture {
  113508. /**
  113509. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  113510. * 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.
  113511. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  113512. */
  113513. refractionPlane: Plane;
  113514. /**
  113515. * Define how deep under the surface we should see.
  113516. */
  113517. depth: number;
  113518. /**
  113519. * Creates a refraction texture used by refraction channel of the standard material.
  113520. * It is like a mirror but to see through a material.
  113521. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  113522. * @param name Define the texture name
  113523. * @param size Define the size of the underlying texture
  113524. * @param scene Define the scene the refraction belongs to
  113525. * @param generateMipMaps Define if we need to generate mips level for the refraction
  113526. */
  113527. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  113528. /**
  113529. * Clone the refraction texture.
  113530. * @returns the cloned texture
  113531. */
  113532. clone(): RefractionTexture;
  113533. /**
  113534. * Serialize the texture to a JSON representation you could use in Parse later on
  113535. * @returns the serialized JSON representation
  113536. */
  113537. serialize(): any;
  113538. }
  113539. }
  113540. declare module BABYLON {
  113541. /**
  113542. * Defines the options related to the creation of an HtmlElementTexture
  113543. */
  113544. export interface IHtmlElementTextureOptions {
  113545. /**
  113546. * Defines wether mip maps should be created or not.
  113547. */
  113548. generateMipMaps?: boolean;
  113549. /**
  113550. * Defines the sampling mode of the texture.
  113551. */
  113552. samplingMode?: number;
  113553. /**
  113554. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  113555. */
  113556. engine: Nullable<Engine>;
  113557. /**
  113558. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  113559. */
  113560. scene: Nullable<Scene>;
  113561. }
  113562. /**
  113563. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  113564. * To be as efficient as possible depending on your constraints nothing aside the first upload
  113565. * is automatically managed.
  113566. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  113567. * in your application.
  113568. *
  113569. * As the update is not automatic, you need to call them manually.
  113570. */
  113571. export class HtmlElementTexture extends BaseTexture {
  113572. /**
  113573. * The texture URL.
  113574. */
  113575. element: HTMLVideoElement | HTMLCanvasElement;
  113576. private static readonly DefaultOptions;
  113577. private _textureMatrix;
  113578. private _engine;
  113579. private _isVideo;
  113580. private _generateMipMaps;
  113581. private _samplingMode;
  113582. /**
  113583. * Instantiates a HtmlElementTexture from the following parameters.
  113584. *
  113585. * @param name Defines the name of the texture
  113586. * @param element Defines the video or canvas the texture is filled with
  113587. * @param options Defines the other none mandatory texture creation options
  113588. */
  113589. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  113590. private _createInternalTexture;
  113591. /**
  113592. * Returns the texture matrix used in most of the material.
  113593. */
  113594. getTextureMatrix(): Matrix;
  113595. /**
  113596. * Updates the content of the texture.
  113597. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  113598. */
  113599. update(invertY?: Nullable<boolean>): void;
  113600. }
  113601. }
  113602. declare module BABYLON {
  113603. /**
  113604. * Enum used to define the target of a block
  113605. */
  113606. export enum NodeMaterialBlockTargets {
  113607. /** Vertex shader */
  113608. Vertex = 1,
  113609. /** Fragment shader */
  113610. Fragment = 2,
  113611. /** Vertex and Fragment */
  113612. VertexAndFragment = 3
  113613. }
  113614. }
  113615. declare module BABYLON {
  113616. /**
  113617. * Defines the kind of connection point for node based material
  113618. */
  113619. export enum NodeMaterialBlockConnectionPointTypes {
  113620. /** Float */
  113621. Float = 1,
  113622. /** Int */
  113623. Int = 2,
  113624. /** Vector2 */
  113625. Vector2 = 4,
  113626. /** Vector3 */
  113627. Vector3 = 8,
  113628. /** Vector4 */
  113629. Vector4 = 16,
  113630. /** Color3 */
  113631. Color3 = 32,
  113632. /** Color4 */
  113633. Color4 = 64,
  113634. /** Matrix */
  113635. Matrix = 128,
  113636. /** Texture */
  113637. Texture = 256,
  113638. /** Texture3D */
  113639. Texture3D = 512,
  113640. /** Vector3 or Color3 */
  113641. Vector3OrColor3 = 40,
  113642. /** Vector3 or Vector4 */
  113643. Vector3OrVector4 = 24,
  113644. /** Vector4 or Color4 */
  113645. Vector4OrColor4 = 80,
  113646. /** Color3 or Color4 */
  113647. Color3OrColor4 = 96,
  113648. /** Vector3 or Color3 */
  113649. Vector3OrColor3OrVector4OrColor4 = 120,
  113650. /** Detect type based on connection */
  113651. AutoDetect = 1024,
  113652. /** Output type that will be defined by input type */
  113653. BasedOnInput = 2048,
  113654. /** Light */
  113655. Light = 4096
  113656. }
  113657. }
  113658. declare module BABYLON {
  113659. /**
  113660. * Enum used to define well known values e.g. values automatically provided by the system
  113661. */
  113662. export enum NodeMaterialWellKnownValues {
  113663. /** World */
  113664. World = 1,
  113665. /** View */
  113666. View = 2,
  113667. /** Projection */
  113668. Projection = 3,
  113669. /** ViewProjection */
  113670. ViewProjection = 4,
  113671. /** WorldView */
  113672. WorldView = 5,
  113673. /** WorldViewProjection */
  113674. WorldViewProjection = 6,
  113675. /** CameraPosition */
  113676. CameraPosition = 7,
  113677. /** Will be filled by the block itself */
  113678. Automatic = 8
  113679. }
  113680. }
  113681. declare module BABYLON {
  113682. /**
  113683. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  113684. */
  113685. export enum NodeMaterialBlockConnectionPointMode {
  113686. /** Value is an uniform */
  113687. Uniform = 0,
  113688. /** Value is a mesh attribute */
  113689. Attribute = 1,
  113690. /** Value is a varying between vertex and fragment shaders */
  113691. Varying = 2,
  113692. /** Mode is undefined */
  113693. Undefined = 3
  113694. }
  113695. }
  113696. declare module BABYLON {
  113697. /**
  113698. * Class used to store shared data between 2 NodeMaterialBuildState
  113699. */
  113700. export class NodeMaterialBuildStateSharedData {
  113701. /**
  113702. * Gets the list of emitted varyings
  113703. */
  113704. varyings: string[];
  113705. /**
  113706. * Gets the varying declaration string
  113707. */
  113708. varyingDeclaration: string;
  113709. /**
  113710. * Uniform connection points
  113711. */
  113712. uniformConnectionPoints: NodeMaterialConnectionPoint[];
  113713. /**
  113714. * Bindable blocks (Blocks that need to set data to the effect)
  113715. */
  113716. bindableBlocks: NodeMaterialBlock[];
  113717. /**
  113718. * List of blocks that can provide a compilation fallback
  113719. */
  113720. blocksWithFallbacks: NodeMaterialBlock[];
  113721. /**
  113722. * List of blocks that can provide a define update
  113723. */
  113724. blocksWithDefines: NodeMaterialBlock[];
  113725. /**
  113726. * List of blocks that can provide a repeatable content
  113727. */
  113728. repeatableContentBlocks: NodeMaterialBlock[];
  113729. /**
  113730. * List of blocks that can block the isReady function for the material
  113731. */
  113732. blockingBlocks: NodeMaterialBlock[];
  113733. /**
  113734. * Build Id used to avoid multiple recompilations
  113735. */
  113736. buildId: number;
  113737. /** List of emitted variables */
  113738. variableNames: {
  113739. [key: string]: number;
  113740. };
  113741. /** List of emitted defines */
  113742. defineNames: {
  113743. [key: string]: number;
  113744. };
  113745. /** Should emit comments? */
  113746. emitComments: boolean;
  113747. /** Emit build activity */
  113748. verbose: boolean;
  113749. /**
  113750. * Gets the compilation hints emitted at compilation time
  113751. */
  113752. hints: {
  113753. needWorldViewMatrix: boolean;
  113754. needWorldViewProjectionMatrix: boolean;
  113755. needAlphaBlending: boolean;
  113756. needAlphaTesting: boolean;
  113757. };
  113758. /**
  113759. * List of compilation checks
  113760. */
  113761. checks: {
  113762. emitVertex: boolean;
  113763. emitFragment: boolean;
  113764. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  113765. };
  113766. /** Creates a new shared data */
  113767. constructor();
  113768. /**
  113769. * Emits console errors and exceptions if there is a failing check
  113770. */
  113771. emitErrors(): void;
  113772. }
  113773. }
  113774. declare module BABYLON {
  113775. /**
  113776. * Class used to store node based material build state
  113777. */
  113778. export class NodeMaterialBuildState {
  113779. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  113780. supportUniformBuffers: boolean;
  113781. /**
  113782. * Gets the list of emitted attributes
  113783. */
  113784. attributes: string[];
  113785. /**
  113786. * Gets the list of emitted uniforms
  113787. */
  113788. uniforms: string[];
  113789. /**
  113790. * Gets the list of emitted uniform buffers
  113791. */
  113792. uniformBuffers: string[];
  113793. /**
  113794. * Gets the list of emitted samplers
  113795. */
  113796. samplers: string[];
  113797. /**
  113798. * Gets the list of emitted functions
  113799. */
  113800. functions: {
  113801. [key: string]: string;
  113802. };
  113803. /**
  113804. * Gets the target of the compilation state
  113805. */
  113806. target: NodeMaterialBlockTargets;
  113807. /**
  113808. * Gets the list of emitted counters
  113809. */
  113810. counters: {
  113811. [key: string]: number;
  113812. };
  113813. /**
  113814. * Shared data between multiple NodeMaterialBuildState instances
  113815. */
  113816. sharedData: NodeMaterialBuildStateSharedData;
  113817. /** @hidden */
  113818. _vertexState: NodeMaterialBuildState;
  113819. private _attributeDeclaration;
  113820. private _uniformDeclaration;
  113821. private _samplerDeclaration;
  113822. private _varyingTransfer;
  113823. private _repeatableContentAnchorIndex;
  113824. /** @hidden */
  113825. _builtCompilationString: string;
  113826. /**
  113827. * Gets the emitted compilation strings
  113828. */
  113829. compilationString: string;
  113830. /**
  113831. * Finalize the compilation strings
  113832. * @param state defines the current compilation state
  113833. */
  113834. finalize(state: NodeMaterialBuildState): void;
  113835. /** @hidden */
  113836. readonly _repeatableContentAnchor: string;
  113837. /** @hidden */
  113838. _getFreeVariableName(prefix: string): string;
  113839. /** @hidden */
  113840. _getFreeDefineName(prefix: string): string;
  113841. /** @hidden */
  113842. _excludeVariableName(name: string): void;
  113843. /** @hidden */
  113844. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  113845. /** @hidden */
  113846. _emitFunction(name: string, code: string, comments: string): void;
  113847. /** @hidden */
  113848. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  113849. replaceStrings?: {
  113850. search: RegExp;
  113851. replace: string;
  113852. }[];
  113853. }): string;
  113854. /** @hidden */
  113855. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  113856. repeatKey?: string;
  113857. removeAttributes?: boolean;
  113858. removeUniforms?: boolean;
  113859. removeVaryings?: boolean;
  113860. removeIfDef?: boolean;
  113861. replaceStrings?: {
  113862. search: RegExp;
  113863. replace: string;
  113864. }[];
  113865. }, storeKey?: string): void;
  113866. /** @hidden */
  113867. _emitVaryings(point: NodeMaterialConnectionPoint, define?: string, force?: boolean, fromFragment?: boolean, replacementName?: string, type?: Nullable<NodeMaterialBlockConnectionPointTypes>): void;
  113868. private _emitDefine;
  113869. /** @hidden */
  113870. _emitUniformOrAttributes(point: NodeMaterialConnectionPoint, define?: string): void;
  113871. }
  113872. }
  113873. declare module BABYLON {
  113874. /**
  113875. * Root class for all node material optimizers
  113876. */
  113877. export class NodeMaterialOptimizer {
  113878. /**
  113879. * Function used to optimize a NodeMaterial graph
  113880. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  113881. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  113882. */
  113883. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  113884. }
  113885. }
  113886. declare module BABYLON {
  113887. /**
  113888. * Block used to transform a vector4 with a matrix
  113889. */
  113890. export class Vector4TransformBlock extends NodeMaterialBlock {
  113891. /**
  113892. * Defines the value to use to complement Vector3 to transform it to a Vector4
  113893. */
  113894. complementW: number;
  113895. /**
  113896. * Creates a new Vector4TransformBlock
  113897. * @param name defines the block name
  113898. */
  113899. constructor(name: string);
  113900. /**
  113901. * Gets the current class name
  113902. * @returns the class name
  113903. */
  113904. getClassName(): string;
  113905. /**
  113906. * Gets the vector input
  113907. */
  113908. readonly vector: NodeMaterialConnectionPoint;
  113909. /**
  113910. * Gets the output component
  113911. */
  113912. readonly output: NodeMaterialConnectionPoint;
  113913. /**
  113914. * Gets the matrix transform input
  113915. */
  113916. readonly transform: NodeMaterialConnectionPoint;
  113917. protected _buildBlock(state: NodeMaterialBuildState): this;
  113918. }
  113919. }
  113920. declare module BABYLON {
  113921. /**
  113922. * Block used to output the vertex position
  113923. */
  113924. export class VertexOutputBlock extends NodeMaterialBlock {
  113925. /**
  113926. * Creates a new VertexOutputBlock
  113927. * @param name defines the block name
  113928. */
  113929. constructor(name: string);
  113930. /**
  113931. * Gets the current class name
  113932. * @returns the class name
  113933. */
  113934. getClassName(): string;
  113935. /**
  113936. * Gets the vector input component
  113937. */
  113938. readonly vector: NodeMaterialConnectionPoint;
  113939. protected _buildBlock(state: NodeMaterialBuildState): this;
  113940. }
  113941. }
  113942. declare module BABYLON {
  113943. /**
  113944. * Block used to output the final color
  113945. */
  113946. export class FragmentOutputBlock extends NodeMaterialBlock {
  113947. /**
  113948. * Gets or sets a boolean indicating if this block will output an alpha value
  113949. */
  113950. alphaBlendingEnabled: boolean;
  113951. /**
  113952. * Create a new FragmentOutputBlock
  113953. * @param name defines the block name
  113954. */
  113955. constructor(name: string);
  113956. /**
  113957. * Gets the current class name
  113958. * @returns the class name
  113959. */
  113960. getClassName(): string;
  113961. /**
  113962. * Gets the color input component
  113963. */
  113964. readonly color: NodeMaterialConnectionPoint;
  113965. protected _buildBlock(state: NodeMaterialBuildState): this;
  113966. }
  113967. }
  113968. declare module BABYLON {
  113969. /**
  113970. * Interface used to configure the node material editor
  113971. */
  113972. export interface INodeMaterialEditorOptions {
  113973. /** Define the URl to load node editor script */
  113974. editorURL?: string;
  113975. }
  113976. /** @hidden */
  113977. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  113978. /** BONES */
  113979. NUM_BONE_INFLUENCERS: number;
  113980. BonesPerMesh: number;
  113981. BONETEXTURE: boolean;
  113982. /** MORPH TARGETS */
  113983. MORPHTARGETS: boolean;
  113984. MORPHTARGETS_NORMAL: boolean;
  113985. MORPHTARGETS_TANGENT: boolean;
  113986. MORPHTARGETS_UV: boolean;
  113987. NUM_MORPH_INFLUENCERS: number;
  113988. /** IMAGE PROCESSING */
  113989. IMAGEPROCESSING: boolean;
  113990. VIGNETTE: boolean;
  113991. VIGNETTEBLENDMODEMULTIPLY: boolean;
  113992. VIGNETTEBLENDMODEOPAQUE: boolean;
  113993. TONEMAPPING: boolean;
  113994. TONEMAPPING_ACES: boolean;
  113995. CONTRAST: boolean;
  113996. EXPOSURE: boolean;
  113997. COLORCURVES: boolean;
  113998. COLORGRADING: boolean;
  113999. COLORGRADING3D: boolean;
  114000. SAMPLER3DGREENDEPTH: boolean;
  114001. SAMPLER3DBGRMAP: boolean;
  114002. IMAGEPROCESSINGPOSTPROCESS: boolean;
  114003. constructor();
  114004. setValue(name: string, value: boolean): void;
  114005. }
  114006. /**
  114007. * Class used to configure NodeMaterial
  114008. */
  114009. export interface INodeMaterialOptions {
  114010. /**
  114011. * Defines if blocks should emit comments
  114012. */
  114013. emitComments: boolean;
  114014. }
  114015. /**
  114016. * Class used to create a node based material built by assembling shader blocks
  114017. */
  114018. export class NodeMaterial extends PushMaterial {
  114019. private _options;
  114020. private _vertexCompilationState;
  114021. private _fragmentCompilationState;
  114022. private _sharedData;
  114023. private _buildId;
  114024. private _buildWasSuccessful;
  114025. private _cachedWorldViewMatrix;
  114026. private _cachedWorldViewProjectionMatrix;
  114027. private _textureConnectionPoints;
  114028. private _optimizers;
  114029. /** Define the URl to load node editor script */
  114030. static EditorURL: string;
  114031. private BJSNODEMATERIALEDITOR;
  114032. /** Get the inspector from bundle or global */
  114033. private _getGlobalNodeMaterialEditor;
  114034. /**
  114035. * Defines the maximum number of lights that can be used in the material
  114036. */
  114037. maxSimultaneousLights: number;
  114038. /**
  114039. * Observable raised when the material is built
  114040. */
  114041. onBuildObservable: Observable<NodeMaterial>;
  114042. /**
  114043. * Gets or sets the root nodes of the material vertex shader
  114044. */
  114045. _vertexOutputNodes: NodeMaterialBlock[];
  114046. /**
  114047. * Gets or sets the root nodes of the material fragment (pixel) shader
  114048. */
  114049. _fragmentOutputNodes: NodeMaterialBlock[];
  114050. /** Gets or sets options to control the node material overall behavior */
  114051. options: INodeMaterialOptions;
  114052. /**
  114053. * Default configuration related to image processing available in the standard Material.
  114054. */
  114055. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  114056. /**
  114057. * Gets the image processing configuration used either in this material.
  114058. */
  114059. /**
  114060. * Sets the Default image processing configuration used either in the this material.
  114061. *
  114062. * If sets to null, the scene one is in use.
  114063. */
  114064. imageProcessingConfiguration: ImageProcessingConfiguration;
  114065. /**
  114066. * Create a new node based material
  114067. * @param name defines the material name
  114068. * @param scene defines the hosting scene
  114069. * @param options defines creation option
  114070. */
  114071. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  114072. /**
  114073. * Gets the current class name of the material e.g. "NodeMaterial"
  114074. * @returns the class name
  114075. */
  114076. getClassName(): string;
  114077. /**
  114078. * Keep track of the image processing observer to allow dispose and replace.
  114079. */
  114080. private _imageProcessingObserver;
  114081. /**
  114082. * Attaches a new image processing configuration to the Standard Material.
  114083. * @param configuration
  114084. */
  114085. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  114086. /**
  114087. * Adds a new optimizer to the list of optimizers
  114088. * @param optimizer defines the optimizers to add
  114089. * @returns the current material
  114090. */
  114091. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  114092. /**
  114093. * Remove an optimizer from the list of optimizers
  114094. * @param optimizer defines the optimizers to remove
  114095. * @returns the current material
  114096. */
  114097. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  114098. /**
  114099. * Add a new block to the list of output nodes
  114100. * @param node defines the node to add
  114101. * @returns the current material
  114102. */
  114103. addOutputNode(node: NodeMaterialBlock): this;
  114104. /**
  114105. * Remove a block from the list of root nodes
  114106. * @param node defines the node to remove
  114107. * @returns the current material
  114108. */
  114109. removeOutputNode(node: NodeMaterialBlock): this;
  114110. private _addVertexOutputNode;
  114111. private _removeVertexOutputNode;
  114112. private _addFragmentOutputNode;
  114113. private _removeFragmentOutputNode;
  114114. /**
  114115. * Specifies if the material will require alpha blending
  114116. * @returns a boolean specifying if alpha blending is needed
  114117. */
  114118. needAlphaBlending(): boolean;
  114119. /**
  114120. * Specifies if this material should be rendered in alpha test mode
  114121. * @returns a boolean specifying if an alpha test is needed.
  114122. */
  114123. needAlphaTesting(): boolean;
  114124. private _initializeBlock;
  114125. private _resetDualBlocks;
  114126. /**
  114127. * Build the material and generates the inner effect
  114128. * @param verbose defines if the build should log activity
  114129. */
  114130. build(verbose?: boolean): void;
  114131. /**
  114132. * Runs an otpimization phase to try to improve the shader code
  114133. */
  114134. optimize(): void;
  114135. private _prepareDefinesForAttributes;
  114136. /**
  114137. * Get if the submesh is ready to be used and all its information available.
  114138. * Child classes can use it to update shaders
  114139. * @param mesh defines the mesh to check
  114140. * @param subMesh defines which submesh to check
  114141. * @param useInstances specifies that instances should be used
  114142. * @returns a boolean indicating that the submesh is ready or not
  114143. */
  114144. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  114145. /**
  114146. * Binds the world matrix to the material
  114147. * @param world defines the world transformation matrix
  114148. */
  114149. bindOnlyWorldMatrix(world: Matrix): void;
  114150. /**
  114151. * Binds the submesh to this material by preparing the effect and shader to draw
  114152. * @param world defines the world transformation matrix
  114153. * @param mesh defines the mesh containing the submesh
  114154. * @param subMesh defines the submesh to bind the material to
  114155. */
  114156. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  114157. /**
  114158. * Gets the active textures from the material
  114159. * @returns an array of textures
  114160. */
  114161. getActiveTextures(): BaseTexture[];
  114162. /**
  114163. * Specifies if the material uses a texture
  114164. * @param texture defines the texture to check against the material
  114165. * @returns a boolean specifying if the material uses the texture
  114166. */
  114167. hasTexture(texture: BaseTexture): boolean;
  114168. /**
  114169. * Disposes the material
  114170. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  114171. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  114172. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  114173. */
  114174. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  114175. /** Creates the node editor window. */
  114176. private _createNodeEditor;
  114177. /**
  114178. * Launch the node material editor
  114179. * @param config Define the configuration of the editor
  114180. * @return a promise fulfilled when the node editor is visible
  114181. */
  114182. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  114183. /**
  114184. * Clear the current material
  114185. */
  114186. clear(): void;
  114187. /**
  114188. * Clear the current material and set it to a default state
  114189. */
  114190. setToDefault(): void;
  114191. }
  114192. }
  114193. declare module BABYLON {
  114194. /**
  114195. * Defines a block that can be used inside a node based material
  114196. */
  114197. export class NodeMaterialBlock {
  114198. private _buildId;
  114199. private _target;
  114200. private _isFinalMerger;
  114201. /** @hidden */
  114202. _inputs: NodeMaterialConnectionPoint[];
  114203. /** @hidden */
  114204. _outputs: NodeMaterialConnectionPoint[];
  114205. /**
  114206. * Gets or sets the name of the block
  114207. */
  114208. name: string;
  114209. /**
  114210. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  114211. */
  114212. readonly isFinalMerger: boolean;
  114213. /**
  114214. * Gets or sets the build Id
  114215. */
  114216. buildId: number;
  114217. /**
  114218. * Gets or sets the target of the block
  114219. */
  114220. target: NodeMaterialBlockTargets;
  114221. /**
  114222. * Gets the list of input points
  114223. */
  114224. readonly inputs: NodeMaterialConnectionPoint[];
  114225. /** Gets the list of output points */
  114226. readonly outputs: NodeMaterialConnectionPoint[];
  114227. /**
  114228. * Find an input by its name
  114229. * @param name defines the name of the input to look for
  114230. * @returns the input or null if not found
  114231. */
  114232. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  114233. /**
  114234. * Find an output by its name
  114235. * @param name defines the name of the outputto look for
  114236. * @returns the output or null if not found
  114237. */
  114238. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  114239. /**
  114240. * Creates a new NodeMaterialBlock
  114241. * @param name defines the block name
  114242. * @param target defines the target of that block (Vertex by default)
  114243. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  114244. */
  114245. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean);
  114246. /**
  114247. * Initialize the block and prepare the context for build
  114248. * @param state defines the state that will be used for the build
  114249. */
  114250. initialize(state: NodeMaterialBuildState): void;
  114251. /**
  114252. * Bind data to effect. Will only be called for blocks with isBindable === true
  114253. * @param effect defines the effect to bind data to
  114254. * @param nodeMaterial defines the hosting NodeMaterial
  114255. * @param mesh defines the mesh that will be rendered
  114256. */
  114257. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  114258. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  114259. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  114260. protected _writeFloat(value: number): string;
  114261. /**
  114262. * Gets the current class name e.g. "NodeMaterialBlock"
  114263. * @returns the class name
  114264. */
  114265. getClassName(): string;
  114266. /**
  114267. * Register a new input. Must be called inside a block constructor
  114268. * @param name defines the connection point name
  114269. * @param type defines the connection point type
  114270. * @param isOptional defines a boolean indicating that this input can be omitted
  114271. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  114272. * @returns the current block
  114273. */
  114274. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  114275. /**
  114276. * Register a new output. Must be called inside a block constructor
  114277. * @param name defines the connection point name
  114278. * @param type defines the connection point type
  114279. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  114280. * @returns the current block
  114281. */
  114282. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  114283. /**
  114284. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  114285. * @param forOutput defines an optional connection point to check compatibility with
  114286. * @returns the first available input or null
  114287. */
  114288. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  114289. /**
  114290. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  114291. * @param forBlock defines an optional block to check compatibility with
  114292. * @returns the first available input or null
  114293. */
  114294. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  114295. /**
  114296. * Connect current block with another block
  114297. * @param other defines the block to connect with
  114298. * @param options define the various options to help pick the right connections
  114299. * @returns the current block
  114300. */
  114301. connectTo(other: NodeMaterialBlock, options?: {
  114302. input?: string;
  114303. output?: string;
  114304. outputSwizzle?: string;
  114305. }): this | undefined;
  114306. protected _buildBlock(state: NodeMaterialBuildState): void;
  114307. /**
  114308. * Add potential fallbacks if shader compilation fails
  114309. * @param mesh defines the mesh to be rendered
  114310. * @param fallbacks defines the current prioritized list of fallbacks
  114311. */
  114312. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  114313. /**
  114314. * Update defines for shader compilation
  114315. * @param mesh defines the mesh to be rendered
  114316. * @param nodeMaterial defines the node material requesting the update
  114317. * @param defines defines the material defines to update
  114318. * @param useInstances specifies that instances should be used
  114319. */
  114320. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  114321. /**
  114322. * Lets the block try to connect some inputs automatically
  114323. */
  114324. autoConfigure(): void;
  114325. /**
  114326. * Function called when a block is declared as repeatable content generator
  114327. * @param vertexShaderState defines the current compilation state for the vertex shader
  114328. * @param fragmentShaderState defines the current compilation state for the fragment shader
  114329. * @param mesh defines the mesh to be rendered
  114330. * @param defines defines the material defines to update
  114331. */
  114332. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  114333. /**
  114334. * Checks if the block is ready
  114335. * @param mesh defines the mesh to be rendered
  114336. * @param nodeMaterial defines the node material requesting the update
  114337. * @param defines defines the material defines to update
  114338. * @param useInstances specifies that instances should be used
  114339. * @returns true if the block is ready
  114340. */
  114341. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  114342. /**
  114343. * Compile the current node and generate the shader code
  114344. * @param state defines the current compilation state (uniforms, samplers, current string)
  114345. * @returns the current block
  114346. */
  114347. build(state: NodeMaterialBuildState): this | undefined;
  114348. }
  114349. }
  114350. declare module BABYLON {
  114351. /**
  114352. * Defines a connection point for a block
  114353. */
  114354. export class NodeMaterialConnectionPoint {
  114355. /** @hidden */
  114356. _ownerBlock: NodeMaterialBlock;
  114357. /** @hidden */
  114358. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  114359. private _associatedVariableName;
  114360. private _endpoints;
  114361. private _storedValue;
  114362. private _valueCallback;
  114363. private _mode;
  114364. /** @hidden */
  114365. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  114366. /** @hidden */
  114367. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  114368. /** @hidden */
  114369. _needToEmitVarying: boolean;
  114370. /** @hidden */
  114371. _forceUniformInVertexShaderOnly: boolean;
  114372. private _type;
  114373. /**
  114374. * Gets or sets the connection point type (default is float)
  114375. */
  114376. type: NodeMaterialBlockConnectionPointTypes;
  114377. /**
  114378. * Gets or sets the connection point name
  114379. */
  114380. name: string;
  114381. /**
  114382. * Gets or sets the swizzle to apply to this connection point when reading or writing
  114383. */
  114384. swizzle: string;
  114385. /**
  114386. * Gets or sets a boolean indicating that this connection point can be omitted
  114387. */
  114388. isOptional: boolean;
  114389. /**
  114390. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  114391. */
  114392. define: string;
  114393. /** Gets or sets the target of that connection point */
  114394. target: NodeMaterialBlockTargets;
  114395. /**
  114396. * Gets or sets the value of that point.
  114397. * Please note that this value will be ignored if valueCallback is defined
  114398. */
  114399. value: any;
  114400. /**
  114401. * Gets or sets a callback used to get the value of that point.
  114402. * Please note that setting this value will force the connection point to ignore the value property
  114403. */
  114404. valueCallback: () => any;
  114405. /**
  114406. * Gets or sets the associated variable name in the shader
  114407. */
  114408. associatedVariableName: string;
  114409. /**
  114410. * Gets a boolean indicating that this connection point not defined yet
  114411. */
  114412. readonly isUndefined: boolean;
  114413. /**
  114414. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  114415. * In this case the connection point name must be the name of the uniform to use.
  114416. * Can only be set on inputs
  114417. */
  114418. isUniform: boolean;
  114419. /**
  114420. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  114421. * In this case the connection point name must be the name of the attribute to use
  114422. * Can only be set on inputs
  114423. */
  114424. isAttribute: boolean;
  114425. /**
  114426. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  114427. * Can only be set on exit points
  114428. */
  114429. isVarying: boolean;
  114430. /** Get the other side of the connection (if any) */
  114431. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  114432. /** Get the block that owns this connection point */
  114433. readonly ownerBlock: NodeMaterialBlock;
  114434. /** Get the block connected on the other side of this connection (if any) */
  114435. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  114436. /** Get the block connected on the endpoints of this connection (if any) */
  114437. readonly connectedBlocks: Array<NodeMaterialBlock>;
  114438. /**
  114439. * Creates a new connection point
  114440. * @param name defines the connection point name
  114441. * @param ownerBlock defines the block hosting this connection point
  114442. */
  114443. constructor(name: string, ownerBlock: NodeMaterialBlock);
  114444. /**
  114445. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  114446. * @returns the class name
  114447. */
  114448. getClassName(): string;
  114449. /**
  114450. * Set the source of this connection point to a vertex attribute
  114451. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  114452. * @returns the current connection point
  114453. */
  114454. setAsAttribute(attributeName?: string): NodeMaterialConnectionPoint;
  114455. /**
  114456. * Set the source of this connection point to a well known value
  114457. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  114458. * @returns the current connection point
  114459. */
  114460. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): NodeMaterialConnectionPoint;
  114461. /**
  114462. * Gets a boolean indicating that the current connection point is a well known value
  114463. */
  114464. readonly isWellKnownValue: boolean;
  114465. /**
  114466. * Gets or sets the current well known value or null if not defined as well know value
  114467. */
  114468. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  114469. private _getTypeLength;
  114470. /**
  114471. * Connect this point to another connection point
  114472. * @param connectionPoint defines the other connection point
  114473. * @returns the current connection point
  114474. */
  114475. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  114476. /**
  114477. * Disconnect this point from one of his endpoint
  114478. * @param endpoint defines the other connection point
  114479. * @returns the current connection point
  114480. */
  114481. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  114482. /**
  114483. * When connection point is an uniform, this function will send its value to the effect
  114484. * @param effect defines the effect to transmit value to
  114485. * @param world defines the world matrix
  114486. * @param worldView defines the worldxview matrix
  114487. * @param worldViewProjection defines the worldxviewxprojection matrix
  114488. */
  114489. transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  114490. /**
  114491. * When connection point is an uniform, this function will send its value to the effect
  114492. * @param effect defines the effect to transmit value to
  114493. * @param scene defines the hosting scene
  114494. */
  114495. transmit(effect: Effect, scene: Scene): void;
  114496. }
  114497. }
  114498. declare module BABYLON {
  114499. /**
  114500. * Block used to add support for vertex skinning (bones)
  114501. */
  114502. export class BonesBlock extends NodeMaterialBlock {
  114503. /**
  114504. * Creates a new BonesBlock
  114505. * @param name defines the block name
  114506. */
  114507. constructor(name: string);
  114508. /**
  114509. * Initialize the block and prepare the context for build
  114510. * @param state defines the state that will be used for the build
  114511. */
  114512. initialize(state: NodeMaterialBuildState): void;
  114513. /**
  114514. * Gets the current class name
  114515. * @returns the class name
  114516. */
  114517. getClassName(): string;
  114518. /**
  114519. * Gets the matrix indices input component
  114520. */
  114521. readonly matricesIndices: NodeMaterialConnectionPoint;
  114522. /**
  114523. * Gets the matrix weights input component
  114524. */
  114525. readonly matricesWeights: NodeMaterialConnectionPoint;
  114526. /**
  114527. * Gets the extra matrix indices input component
  114528. */
  114529. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  114530. /**
  114531. * Gets the extra matrix weights input component
  114532. */
  114533. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  114534. /**
  114535. * Gets the world input component
  114536. */
  114537. readonly world: NodeMaterialConnectionPoint;
  114538. /**
  114539. * Gets the output component
  114540. */
  114541. readonly output: NodeMaterialConnectionPoint;
  114542. autoConfigure(): void;
  114543. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  114544. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  114545. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  114546. protected _buildBlock(state: NodeMaterialBuildState): this;
  114547. }
  114548. }
  114549. declare module BABYLON {
  114550. /**
  114551. * Block used to add support for instances
  114552. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  114553. */
  114554. export class InstancesBlock extends NodeMaterialBlock {
  114555. /**
  114556. * Creates a new InstancesBlock
  114557. * @param name defines the block name
  114558. */
  114559. constructor(name: string);
  114560. /**
  114561. * Gets the current class name
  114562. * @returns the class name
  114563. */
  114564. getClassName(): string;
  114565. /**
  114566. * Gets the first world row input component
  114567. */
  114568. readonly world0: NodeMaterialConnectionPoint;
  114569. /**
  114570. * Gets the second world row input component
  114571. */
  114572. readonly world1: NodeMaterialConnectionPoint;
  114573. /**
  114574. * Gets the third world row input component
  114575. */
  114576. readonly world2: NodeMaterialConnectionPoint;
  114577. /**
  114578. * Gets the forth world row input component
  114579. */
  114580. readonly world3: NodeMaterialConnectionPoint;
  114581. /**
  114582. * Gets the world input component
  114583. */
  114584. readonly world: NodeMaterialConnectionPoint;
  114585. /**
  114586. * Gets the output component
  114587. */
  114588. readonly output: NodeMaterialConnectionPoint;
  114589. autoConfigure(): void;
  114590. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  114591. protected _buildBlock(state: NodeMaterialBuildState): this;
  114592. }
  114593. }
  114594. declare module BABYLON {
  114595. /**
  114596. * Block used to add morph targets support to vertex shader
  114597. */
  114598. export class MorphTargetsBlock extends NodeMaterialBlock {
  114599. private _repeatableContentAnchor;
  114600. private _repeatebleContentGenerated;
  114601. /**
  114602. * Create a new MorphTargetsBlock
  114603. * @param name defines the block name
  114604. */
  114605. constructor(name: string);
  114606. /**
  114607. * Gets the current class name
  114608. * @returns the class name
  114609. */
  114610. getClassName(): string;
  114611. /**
  114612. * Gets the position input component
  114613. */
  114614. readonly position: NodeMaterialConnectionPoint;
  114615. /**
  114616. * Gets the normal input component
  114617. */
  114618. readonly normal: NodeMaterialConnectionPoint;
  114619. /**
  114620. * Gets the tangent input component
  114621. */
  114622. readonly tangent: NodeMaterialConnectionPoint;
  114623. /**
  114624. * Gets the tangent input component
  114625. */
  114626. readonly uv: NodeMaterialConnectionPoint;
  114627. /**
  114628. * Gets the position output component
  114629. */
  114630. readonly positionOutput: NodeMaterialConnectionPoint;
  114631. /**
  114632. * Gets the normal output component
  114633. */
  114634. readonly normalOutput: NodeMaterialConnectionPoint;
  114635. /**
  114636. * Gets the tangent output component
  114637. */
  114638. readonly tangentOutput: NodeMaterialConnectionPoint;
  114639. /**
  114640. * Gets the tangent output component
  114641. */
  114642. readonly uvOutput: NodeMaterialConnectionPoint;
  114643. initialize(state: NodeMaterialBuildState): void;
  114644. autoConfigure(): void;
  114645. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  114646. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  114647. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  114648. protected _buildBlock(state: NodeMaterialBuildState): this;
  114649. }
  114650. }
  114651. declare module BABYLON {
  114652. /**
  114653. * Block used to add an alpha test in the fragment shader
  114654. */
  114655. export class AlphaTestBlock extends NodeMaterialBlock {
  114656. /**
  114657. * Gets or sets the alpha value where alpha testing happens
  114658. */
  114659. alphaCutOff: number;
  114660. /**
  114661. * Create a new AlphaTestBlock
  114662. * @param name defines the block name
  114663. */
  114664. constructor(name: string);
  114665. /**
  114666. * Gets the current class name
  114667. * @returns the class name
  114668. */
  114669. getClassName(): string;
  114670. /**
  114671. * Gets the color input component
  114672. */
  114673. readonly color: NodeMaterialConnectionPoint;
  114674. protected _buildBlock(state: NodeMaterialBuildState): this;
  114675. }
  114676. }
  114677. declare module BABYLON {
  114678. /**
  114679. * Block used to create a Color4 out of 4 inputs (one for each component)
  114680. */
  114681. export class RGBAMergerBlock extends NodeMaterialBlock {
  114682. /**
  114683. * Create a new RGBAMergerBlock
  114684. * @param name defines the block name
  114685. */
  114686. constructor(name: string);
  114687. /**
  114688. * Gets the current class name
  114689. * @returns the class name
  114690. */
  114691. getClassName(): string;
  114692. /**
  114693. * Gets the R input component
  114694. */
  114695. readonly r: NodeMaterialConnectionPoint;
  114696. /**
  114697. * Gets the G input component
  114698. */
  114699. readonly g: NodeMaterialConnectionPoint;
  114700. /**
  114701. * Gets the B input component
  114702. */
  114703. readonly b: NodeMaterialConnectionPoint;
  114704. /**
  114705. * Gets the RGB input component
  114706. */
  114707. readonly rgb: NodeMaterialConnectionPoint;
  114708. /**
  114709. * Gets the R input component
  114710. */
  114711. readonly a: NodeMaterialConnectionPoint;
  114712. /**
  114713. * Gets the output component
  114714. */
  114715. readonly output: NodeMaterialConnectionPoint;
  114716. protected _buildBlock(state: NodeMaterialBuildState): this;
  114717. }
  114718. }
  114719. declare module BABYLON {
  114720. /**
  114721. * Block used to create a Color3 out of 3 inputs (one for each component)
  114722. */
  114723. export class RGBMergerBlock extends NodeMaterialBlock {
  114724. /**
  114725. * Create a new RGBMergerBlock
  114726. * @param name defines the block name
  114727. */
  114728. constructor(name: string);
  114729. /**
  114730. * Gets the current class name
  114731. * @returns the class name
  114732. */
  114733. getClassName(): string;
  114734. /**
  114735. * Gets the R component input
  114736. */
  114737. readonly r: NodeMaterialConnectionPoint;
  114738. /**
  114739. * Gets the G component input
  114740. */
  114741. readonly g: NodeMaterialConnectionPoint;
  114742. /**
  114743. * Gets the B component input
  114744. */
  114745. readonly b: NodeMaterialConnectionPoint;
  114746. /**
  114747. * Gets the output component
  114748. */
  114749. readonly output: NodeMaterialConnectionPoint;
  114750. protected _buildBlock(state: NodeMaterialBuildState): this;
  114751. }
  114752. }
  114753. declare module BABYLON {
  114754. /**
  114755. * Block used to expand a Color4 or a Vector4 into 4 outputs (one for each component)
  114756. */
  114757. export class RGBASplitterBlock extends NodeMaterialBlock {
  114758. /**
  114759. * Create a new RGBASplitterBlock
  114760. * @param name defines the block name
  114761. */
  114762. constructor(name: string);
  114763. /**
  114764. * Gets the current class name
  114765. * @returns the class name
  114766. */
  114767. getClassName(): string;
  114768. /**
  114769. * Gets the input component
  114770. */
  114771. readonly input: NodeMaterialConnectionPoint;
  114772. protected _buildBlock(state: NodeMaterialBuildState): this;
  114773. }
  114774. }
  114775. declare module BABYLON {
  114776. /**
  114777. * Block used to expand a Color3 or a Vector3 into 3 outputs (one for each component)
  114778. */
  114779. export class RGBSplitterBlock extends NodeMaterialBlock {
  114780. /**
  114781. * Create a new RGBSplitterBlock
  114782. * @param name defines the block name
  114783. */
  114784. constructor(name: string);
  114785. /**
  114786. * Gets the current class name
  114787. * @returns the class name
  114788. */
  114789. getClassName(): string;
  114790. /**
  114791. * Gets the input component
  114792. */
  114793. readonly input: NodeMaterialConnectionPoint;
  114794. protected _buildBlock(state: NodeMaterialBuildState): this;
  114795. }
  114796. }
  114797. declare module BABYLON {
  114798. /**
  114799. * Block used to read a texture from a sampler
  114800. */
  114801. export class TextureBlock extends NodeMaterialBlock {
  114802. private _defineName;
  114803. /**
  114804. * Gets or sets a boolean indicating that the block can automatically fetch the texture matrix
  114805. */
  114806. autoConnectTextureMatrix: boolean;
  114807. /**
  114808. * Gets or sets a boolean indicating that the block can automatically select the uv channel based on texture
  114809. */
  114810. autoSelectUV: boolean;
  114811. /**
  114812. * Create a new TextureBlock
  114813. * @param name defines the block name
  114814. */
  114815. constructor(name: string);
  114816. /**
  114817. * Gets the current class name
  114818. * @returns the class name
  114819. */
  114820. getClassName(): string;
  114821. /**
  114822. * Gets the uv input component
  114823. */
  114824. readonly uv: NodeMaterialConnectionPoint;
  114825. /**
  114826. * Gets the texture information input component
  114827. */
  114828. readonly textureInfo: NodeMaterialConnectionPoint;
  114829. /**
  114830. * Gets the transformed uv input component
  114831. */
  114832. readonly transformedUV: NodeMaterialConnectionPoint;
  114833. /**
  114834. * Gets the texture input component
  114835. */
  114836. readonly texture: NodeMaterialConnectionPoint;
  114837. /**
  114838. * Gets the texture transform input component
  114839. */
  114840. readonly textureTransform: NodeMaterialConnectionPoint;
  114841. /**
  114842. * Gets the output component
  114843. */
  114844. readonly output: NodeMaterialConnectionPoint;
  114845. autoConfigure(): void;
  114846. initialize(state: NodeMaterialBuildState): void;
  114847. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  114848. isReady(): boolean;
  114849. private _injectVertexCode;
  114850. protected _buildBlock(state: NodeMaterialBuildState): this;
  114851. }
  114852. }
  114853. declare module BABYLON {
  114854. /**
  114855. * Block used to add image processing support to fragment shader
  114856. */
  114857. export class ImageProcessingBlock extends NodeMaterialBlock {
  114858. /**
  114859. * Create a new ImageProcessingBlock
  114860. * @param name defines the block name
  114861. */
  114862. constructor(name: string);
  114863. /**
  114864. * Gets the current class name
  114865. * @returns the class name
  114866. */
  114867. getClassName(): string;
  114868. /**
  114869. * Gets the color input component
  114870. */
  114871. readonly color: NodeMaterialConnectionPoint;
  114872. /**
  114873. * Gets the output component
  114874. */
  114875. readonly output: NodeMaterialConnectionPoint;
  114876. /**
  114877. * Initialize the block and prepare the context for build
  114878. * @param state defines the state that will be used for the build
  114879. */
  114880. initialize(state: NodeMaterialBuildState): void;
  114881. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  114882. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  114883. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  114884. protected _buildBlock(state: NodeMaterialBuildState): this;
  114885. }
  114886. }
  114887. declare module BABYLON {
  114888. /**
  114889. * Block used to add support for scene fog
  114890. */
  114891. export class FogBlock extends NodeMaterialBlock {
  114892. /**
  114893. * Create a new FogBlock
  114894. * @param name defines the block name
  114895. */
  114896. constructor(name: string);
  114897. /**
  114898. * Gets the current class name
  114899. * @returns the class name
  114900. */
  114901. getClassName(): string;
  114902. /**
  114903. * Gets the world position input component
  114904. */
  114905. readonly worldPosition: NodeMaterialConnectionPoint;
  114906. /**
  114907. * Gets the view input component
  114908. */
  114909. readonly view: NodeMaterialConnectionPoint;
  114910. /**
  114911. * Gets the color input component
  114912. */
  114913. readonly color: NodeMaterialConnectionPoint;
  114914. /**
  114915. * Gets the fog color input component
  114916. */
  114917. readonly fogColor: NodeMaterialConnectionPoint;
  114918. /**
  114919. * Gets the for parameter input component
  114920. */
  114921. readonly fogParameters: NodeMaterialConnectionPoint;
  114922. /**
  114923. * Gets the output component
  114924. */
  114925. readonly output: NodeMaterialConnectionPoint;
  114926. autoConfigure(): void;
  114927. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  114928. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  114929. protected _buildBlock(state: NodeMaterialBuildState): this;
  114930. }
  114931. }
  114932. declare module BABYLON {
  114933. /**
  114934. * Block used to add light in the fragment shader
  114935. */
  114936. export class LightBlock extends NodeMaterialBlock {
  114937. private _lightId;
  114938. /**
  114939. * Create a new LightBlock
  114940. * @param name defines the block name
  114941. */
  114942. constructor(name: string);
  114943. /**
  114944. * Gets the current class name
  114945. * @returns the class name
  114946. */
  114947. getClassName(): string;
  114948. /**
  114949. * Gets the world position input component
  114950. */
  114951. readonly worldPosition: NodeMaterialConnectionPoint;
  114952. /**
  114953. * Gets the world normal input component
  114954. */
  114955. readonly worldNormal: NodeMaterialConnectionPoint;
  114956. /**
  114957. * Gets the light input component
  114958. */
  114959. readonly light: NodeMaterialConnectionPoint;
  114960. /**
  114961. * Gets the camera (or eye) position component
  114962. */
  114963. readonly cameraPosition: NodeMaterialConnectionPoint;
  114964. /**
  114965. * Gets the diffuse output component
  114966. */
  114967. readonly diffuseOutput: NodeMaterialConnectionPoint;
  114968. /**
  114969. * Gets the specular output component
  114970. */
  114971. readonly specularOutput: NodeMaterialConnectionPoint;
  114972. autoConfigure(): void;
  114973. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  114974. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  114975. private _injectVertexCode;
  114976. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  114977. }
  114978. }
  114979. declare module BABYLON {
  114980. /**
  114981. * Block used to multiply 2 vector4
  114982. */
  114983. export class MultiplyBlock extends NodeMaterialBlock {
  114984. /**
  114985. * Creates a new MultiplyBlock
  114986. * @param name defines the block name
  114987. */
  114988. constructor(name: string);
  114989. /**
  114990. * Gets the current class name
  114991. * @returns the class name
  114992. */
  114993. getClassName(): string;
  114994. /**
  114995. * Gets the left operand input component
  114996. */
  114997. readonly left: NodeMaterialConnectionPoint;
  114998. /**
  114999. * Gets the right operand input component
  115000. */
  115001. readonly right: NodeMaterialConnectionPoint;
  115002. /**
  115003. * Gets the output component
  115004. */
  115005. readonly output: NodeMaterialConnectionPoint;
  115006. protected _buildBlock(state: NodeMaterialBuildState): this;
  115007. }
  115008. }
  115009. declare module BABYLON {
  115010. /**
  115011. * Block used to add 2 vector4
  115012. */
  115013. export class AddBlock extends NodeMaterialBlock {
  115014. /**
  115015. * Creates a new AddBlock
  115016. * @param name defines the block name
  115017. */
  115018. constructor(name: string);
  115019. /**
  115020. * Gets the current class name
  115021. * @returns the class name
  115022. */
  115023. getClassName(): string;
  115024. /**
  115025. * Gets the left operand input component
  115026. */
  115027. readonly left: NodeMaterialConnectionPoint;
  115028. /**
  115029. * Gets the right operand input component
  115030. */
  115031. readonly right: NodeMaterialConnectionPoint;
  115032. /**
  115033. * Gets the output component
  115034. */
  115035. readonly output: NodeMaterialConnectionPoint;
  115036. protected _buildBlock(state: NodeMaterialBuildState): this;
  115037. }
  115038. }
  115039. declare module BABYLON {
  115040. /**
  115041. * Block used to clamp a float
  115042. */
  115043. export class ClampBlock extends NodeMaterialBlock {
  115044. /** Gets or sets the minimum range */
  115045. minimum: number;
  115046. /** Gets or sets the maximum range */
  115047. maximum: number;
  115048. /**
  115049. * Creates a new ClampBlock
  115050. * @param name defines the block name
  115051. */
  115052. constructor(name: string);
  115053. /**
  115054. * Gets the current class name
  115055. * @returns the class name
  115056. */
  115057. getClassName(): string;
  115058. /**
  115059. * Gets the value input component
  115060. */
  115061. readonly value: NodeMaterialConnectionPoint;
  115062. /**
  115063. * Gets the output component
  115064. */
  115065. readonly output: NodeMaterialConnectionPoint;
  115066. protected _buildBlock(state: NodeMaterialBuildState): this;
  115067. }
  115068. }
  115069. declare module BABYLON {
  115070. /**
  115071. * Block used to scale a value
  115072. */
  115073. export class ScaleBlock extends NodeMaterialBlock {
  115074. /**
  115075. * Creates a new ScaleBlock
  115076. * @param name defines the block name
  115077. */
  115078. constructor(name: string);
  115079. /**
  115080. * Gets the current class name
  115081. * @returns the class name
  115082. */
  115083. getClassName(): string;
  115084. /**
  115085. * Gets the value operand input component
  115086. */
  115087. readonly value: NodeMaterialConnectionPoint;
  115088. /**
  115089. * Gets the scale operand input component
  115090. */
  115091. readonly scale: NodeMaterialConnectionPoint;
  115092. /**
  115093. * Gets the output component
  115094. */
  115095. readonly output: NodeMaterialConnectionPoint;
  115096. protected _buildBlock(state: NodeMaterialBuildState): this;
  115097. }
  115098. }
  115099. declare module BABYLON {
  115100. /**
  115101. * Block used to transform a vector2 with a matrix
  115102. */
  115103. export class Vector2TransformBlock extends NodeMaterialBlock {
  115104. /**
  115105. * Defines the value to use to complement Vector2 to transform it to a Vector4
  115106. */
  115107. complementZ: number;
  115108. /**
  115109. * Defines the value to use to complement Vector2 to transform it to a Vector4
  115110. */
  115111. complementW: number;
  115112. /**
  115113. * Creates a new Vector2TransformBlock
  115114. * @param name defines the block name
  115115. */
  115116. constructor(name: string);
  115117. /**
  115118. * Gets the vector input
  115119. */
  115120. readonly vector: NodeMaterialConnectionPoint;
  115121. /**
  115122. * Gets the matrix transform input
  115123. */
  115124. readonly transform: NodeMaterialConnectionPoint;
  115125. /**
  115126. * Gets the output component
  115127. */
  115128. readonly output: NodeMaterialConnectionPoint;
  115129. /**
  115130. * Gets the current class name
  115131. * @returns the class name
  115132. */
  115133. getClassName(): string;
  115134. protected _buildBlock(state: NodeMaterialBuildState): this;
  115135. }
  115136. }
  115137. declare module BABYLON {
  115138. /**
  115139. * Block used to transform a vector3 with a matrix
  115140. */
  115141. export class Vector3TransformBlock extends NodeMaterialBlock {
  115142. /**
  115143. * Defines the value to use to complement Vector3 to transform it to a Vector4
  115144. */
  115145. complement: number;
  115146. /**
  115147. * Creates a new Vector3TransformBlock
  115148. * @param name defines the block name
  115149. */
  115150. constructor(name: string);
  115151. /**
  115152. * Gets the vector input
  115153. */
  115154. readonly vector: NodeMaterialConnectionPoint;
  115155. /**
  115156. * Gets the matrix transform input
  115157. */
  115158. readonly transform: NodeMaterialConnectionPoint;
  115159. /**
  115160. * Gets the output component
  115161. */
  115162. readonly output: NodeMaterialConnectionPoint;
  115163. /**
  115164. * Gets the current class name
  115165. * @returns the class name
  115166. */
  115167. getClassName(): string;
  115168. protected _buildBlock(state: NodeMaterialBuildState): this;
  115169. }
  115170. }
  115171. declare module BABYLON {
  115172. /**
  115173. * Block used to multiply two matrices
  115174. */
  115175. export class MatrixMultiplicationBlock extends NodeMaterialBlock {
  115176. /**
  115177. * Creates a new MatrixMultiplicationBlock
  115178. * @param name defines the block name
  115179. */
  115180. constructor(name: string);
  115181. /**
  115182. * Gets the left operand
  115183. */
  115184. readonly left: NodeMaterialConnectionPoint;
  115185. /**
  115186. * Gets the right operand
  115187. */
  115188. readonly right: NodeMaterialConnectionPoint;
  115189. /**
  115190. * Gets the output component
  115191. */
  115192. readonly output: NodeMaterialConnectionPoint;
  115193. /**
  115194. * Gets the current class name
  115195. * @returns the class name
  115196. */
  115197. getClassName(): string;
  115198. protected _buildBlock(state: NodeMaterialBuildState): this;
  115199. }
  115200. }
  115201. declare module BABYLON {
  115202. /**
  115203. * Helper class to push actions to a pool of workers.
  115204. */
  115205. export class WorkerPool implements IDisposable {
  115206. private _workerInfos;
  115207. private _pendingActions;
  115208. /**
  115209. * Constructor
  115210. * @param workers Array of workers to use for actions
  115211. */
  115212. constructor(workers: Array<Worker>);
  115213. /**
  115214. * Terminates all workers and clears any pending actions.
  115215. */
  115216. dispose(): void;
  115217. /**
  115218. * Pushes an action to the worker pool. If all the workers are active, the action will be
  115219. * pended until a worker has completed its action.
  115220. * @param action The action to perform. Call onComplete when the action is complete.
  115221. */
  115222. push(action: (worker: Worker, onComplete: () => void) => void): void;
  115223. private _execute;
  115224. }
  115225. }
  115226. declare module BABYLON {
  115227. /**
  115228. * Configuration for Draco compression
  115229. */
  115230. export interface IDracoCompressionConfiguration {
  115231. /**
  115232. * Configuration for the decoder.
  115233. */
  115234. decoder: {
  115235. /**
  115236. * The url to the WebAssembly module.
  115237. */
  115238. wasmUrl?: string;
  115239. /**
  115240. * The url to the WebAssembly binary.
  115241. */
  115242. wasmBinaryUrl?: string;
  115243. /**
  115244. * The url to the fallback JavaScript module.
  115245. */
  115246. fallbackUrl?: string;
  115247. };
  115248. }
  115249. /**
  115250. * Draco compression (https://google.github.io/draco/)
  115251. *
  115252. * This class wraps the Draco module.
  115253. *
  115254. * **Encoder**
  115255. *
  115256. * The encoder is not currently implemented.
  115257. *
  115258. * **Decoder**
  115259. *
  115260. * 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.
  115261. *
  115262. * To update the configuration, use the following code:
  115263. * ```javascript
  115264. * DracoCompression.Configuration = {
  115265. * decoder: {
  115266. * wasmUrl: "<url to the WebAssembly library>",
  115267. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  115268. * fallbackUrl: "<url to the fallback JavaScript library>",
  115269. * }
  115270. * };
  115271. * ```
  115272. *
  115273. * 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.
  115274. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  115275. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  115276. *
  115277. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  115278. * ```javascript
  115279. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  115280. * ```
  115281. *
  115282. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  115283. */
  115284. export class DracoCompression implements IDisposable {
  115285. private _workerPoolPromise?;
  115286. private _decoderModulePromise?;
  115287. /**
  115288. * The configuration. Defaults to the following urls:
  115289. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  115290. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  115291. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  115292. */
  115293. static Configuration: IDracoCompressionConfiguration;
  115294. /**
  115295. * Returns true if the decoder configuration is available.
  115296. */
  115297. static readonly DecoderAvailable: boolean;
  115298. /**
  115299. * Default number of workers to create when creating the draco compression object.
  115300. */
  115301. static DefaultNumWorkers: number;
  115302. private static GetDefaultNumWorkers;
  115303. private static _Default;
  115304. /**
  115305. * Default instance for the draco compression object.
  115306. */
  115307. static readonly Default: DracoCompression;
  115308. /**
  115309. * Constructor
  115310. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  115311. */
  115312. constructor(numWorkers?: number);
  115313. /**
  115314. * Stop all async operations and release resources.
  115315. */
  115316. dispose(): void;
  115317. /**
  115318. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  115319. * @returns a promise that resolves when ready
  115320. */
  115321. whenReadyAsync(): Promise<void>;
  115322. /**
  115323. * Decode Draco compressed mesh data to vertex data.
  115324. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  115325. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  115326. * @returns A promise that resolves with the decoded vertex data
  115327. */
  115328. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  115329. [kind: string]: number;
  115330. }): Promise<VertexData>;
  115331. }
  115332. }
  115333. declare module BABYLON {
  115334. /**
  115335. * Class for building Constructive Solid Geometry
  115336. */
  115337. export class CSG {
  115338. private polygons;
  115339. /**
  115340. * The world matrix
  115341. */
  115342. matrix: Matrix;
  115343. /**
  115344. * Stores the position
  115345. */
  115346. position: Vector3;
  115347. /**
  115348. * Stores the rotation
  115349. */
  115350. rotation: Vector3;
  115351. /**
  115352. * Stores the rotation quaternion
  115353. */
  115354. rotationQuaternion: Nullable<Quaternion>;
  115355. /**
  115356. * Stores the scaling vector
  115357. */
  115358. scaling: Vector3;
  115359. /**
  115360. * Convert the Mesh to CSG
  115361. * @param mesh The Mesh to convert to CSG
  115362. * @returns A new CSG from the Mesh
  115363. */
  115364. static FromMesh(mesh: Mesh): CSG;
  115365. /**
  115366. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  115367. * @param polygons Polygons used to construct a CSG solid
  115368. */
  115369. private static FromPolygons;
  115370. /**
  115371. * Clones, or makes a deep copy, of the CSG
  115372. * @returns A new CSG
  115373. */
  115374. clone(): CSG;
  115375. /**
  115376. * Unions this CSG with another CSG
  115377. * @param csg The CSG to union against this CSG
  115378. * @returns The unioned CSG
  115379. */
  115380. union(csg: CSG): CSG;
  115381. /**
  115382. * Unions this CSG with another CSG in place
  115383. * @param csg The CSG to union against this CSG
  115384. */
  115385. unionInPlace(csg: CSG): void;
  115386. /**
  115387. * Subtracts this CSG with another CSG
  115388. * @param csg The CSG to subtract against this CSG
  115389. * @returns A new CSG
  115390. */
  115391. subtract(csg: CSG): CSG;
  115392. /**
  115393. * Subtracts this CSG with another CSG in place
  115394. * @param csg The CSG to subtact against this CSG
  115395. */
  115396. subtractInPlace(csg: CSG): void;
  115397. /**
  115398. * Intersect this CSG with another CSG
  115399. * @param csg The CSG to intersect against this CSG
  115400. * @returns A new CSG
  115401. */
  115402. intersect(csg: CSG): CSG;
  115403. /**
  115404. * Intersects this CSG with another CSG in place
  115405. * @param csg The CSG to intersect against this CSG
  115406. */
  115407. intersectInPlace(csg: CSG): void;
  115408. /**
  115409. * Return a new CSG solid with solid and empty space switched. This solid is
  115410. * not modified.
  115411. * @returns A new CSG solid with solid and empty space switched
  115412. */
  115413. inverse(): CSG;
  115414. /**
  115415. * Inverses the CSG in place
  115416. */
  115417. inverseInPlace(): void;
  115418. /**
  115419. * This is used to keep meshes transformations so they can be restored
  115420. * when we build back a Babylon Mesh
  115421. * NB : All CSG operations are performed in world coordinates
  115422. * @param csg The CSG to copy the transform attributes from
  115423. * @returns This CSG
  115424. */
  115425. copyTransformAttributes(csg: CSG): CSG;
  115426. /**
  115427. * Build Raw mesh from CSG
  115428. * Coordinates here are in world space
  115429. * @param name The name of the mesh geometry
  115430. * @param scene The Scene
  115431. * @param keepSubMeshes Specifies if the submeshes should be kept
  115432. * @returns A new Mesh
  115433. */
  115434. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  115435. /**
  115436. * Build Mesh from CSG taking material and transforms into account
  115437. * @param name The name of the Mesh
  115438. * @param material The material of the Mesh
  115439. * @param scene The Scene
  115440. * @param keepSubMeshes Specifies if submeshes should be kept
  115441. * @returns The new Mesh
  115442. */
  115443. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  115444. }
  115445. }
  115446. declare module BABYLON {
  115447. /**
  115448. * Class used to create a trail following a mesh
  115449. */
  115450. export class TrailMesh extends Mesh {
  115451. private _generator;
  115452. private _autoStart;
  115453. private _running;
  115454. private _diameter;
  115455. private _length;
  115456. private _sectionPolygonPointsCount;
  115457. private _sectionVectors;
  115458. private _sectionNormalVectors;
  115459. private _beforeRenderObserver;
  115460. /**
  115461. * @constructor
  115462. * @param name The value used by scene.getMeshByName() to do a lookup.
  115463. * @param generator The mesh to generate a trail.
  115464. * @param scene The scene to add this mesh to.
  115465. * @param diameter Diameter of trailing mesh. Default is 1.
  115466. * @param length Length of trailing mesh. Default is 60.
  115467. * @param autoStart Automatically start trailing mesh. Default true.
  115468. */
  115469. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  115470. /**
  115471. * "TrailMesh"
  115472. * @returns "TrailMesh"
  115473. */
  115474. getClassName(): string;
  115475. private _createMesh;
  115476. /**
  115477. * Start trailing mesh.
  115478. */
  115479. start(): void;
  115480. /**
  115481. * Stop trailing mesh.
  115482. */
  115483. stop(): void;
  115484. /**
  115485. * Update trailing mesh geometry.
  115486. */
  115487. update(): void;
  115488. /**
  115489. * Returns a new TrailMesh object.
  115490. * @param name is a string, the name given to the new mesh
  115491. * @param newGenerator use new generator object for cloned trail mesh
  115492. * @returns a new mesh
  115493. */
  115494. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  115495. /**
  115496. * Serializes this trail mesh
  115497. * @param serializationObject object to write serialization to
  115498. */
  115499. serialize(serializationObject: any): void;
  115500. /**
  115501. * Parses a serialized trail mesh
  115502. * @param parsedMesh the serialized mesh
  115503. * @param scene the scene to create the trail mesh in
  115504. * @returns the created trail mesh
  115505. */
  115506. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  115507. }
  115508. }
  115509. declare module BABYLON {
  115510. /**
  115511. * Class containing static functions to help procedurally build meshes
  115512. */
  115513. export class TiledBoxBuilder {
  115514. /**
  115515. * Creates a box mesh
  115516. * 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)
  115517. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  115518. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115519. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115520. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115521. * @param name defines the name of the mesh
  115522. * @param options defines the options used to create the mesh
  115523. * @param scene defines the hosting scene
  115524. * @returns the box mesh
  115525. */
  115526. static CreateTiledBox(name: string, options: {
  115527. pattern?: number;
  115528. width?: number;
  115529. height?: number;
  115530. depth?: number;
  115531. tileSize?: number;
  115532. tileWidth?: number;
  115533. tileHeight?: number;
  115534. alignHorizontal?: number;
  115535. alignVertical?: number;
  115536. faceUV?: Vector4[];
  115537. faceColors?: Color4[];
  115538. sideOrientation?: number;
  115539. updatable?: boolean;
  115540. }, scene?: Nullable<Scene>): Mesh;
  115541. }
  115542. }
  115543. declare module BABYLON {
  115544. /**
  115545. * Class containing static functions to help procedurally build meshes
  115546. */
  115547. export class TorusKnotBuilder {
  115548. /**
  115549. * Creates a torus knot mesh
  115550. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  115551. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  115552. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  115553. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  115554. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115555. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115556. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115557. * @param name defines the name of the mesh
  115558. * @param options defines the options used to create the mesh
  115559. * @param scene defines the hosting scene
  115560. * @returns the torus knot mesh
  115561. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  115562. */
  115563. static CreateTorusKnot(name: string, options: {
  115564. radius?: number;
  115565. tube?: number;
  115566. radialSegments?: number;
  115567. tubularSegments?: number;
  115568. p?: number;
  115569. q?: number;
  115570. updatable?: boolean;
  115571. sideOrientation?: number;
  115572. frontUVs?: Vector4;
  115573. backUVs?: Vector4;
  115574. }, scene: any): Mesh;
  115575. }
  115576. }
  115577. declare module BABYLON {
  115578. /**
  115579. * Polygon
  115580. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  115581. */
  115582. export class Polygon {
  115583. /**
  115584. * Creates a rectangle
  115585. * @param xmin bottom X coord
  115586. * @param ymin bottom Y coord
  115587. * @param xmax top X coord
  115588. * @param ymax top Y coord
  115589. * @returns points that make the resulting rectation
  115590. */
  115591. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  115592. /**
  115593. * Creates a circle
  115594. * @param radius radius of circle
  115595. * @param cx scale in x
  115596. * @param cy scale in y
  115597. * @param numberOfSides number of sides that make up the circle
  115598. * @returns points that make the resulting circle
  115599. */
  115600. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  115601. /**
  115602. * Creates a polygon from input string
  115603. * @param input Input polygon data
  115604. * @returns the parsed points
  115605. */
  115606. static Parse(input: string): Vector2[];
  115607. /**
  115608. * Starts building a polygon from x and y coordinates
  115609. * @param x x coordinate
  115610. * @param y y coordinate
  115611. * @returns the started path2
  115612. */
  115613. static StartingAt(x: number, y: number): Path2;
  115614. }
  115615. /**
  115616. * Builds a polygon
  115617. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  115618. */
  115619. export class PolygonMeshBuilder {
  115620. private _points;
  115621. private _outlinepoints;
  115622. private _holes;
  115623. private _name;
  115624. private _scene;
  115625. private _epoints;
  115626. private _eholes;
  115627. private _addToepoint;
  115628. /**
  115629. * Babylon reference to the earcut plugin.
  115630. */
  115631. bjsEarcut: any;
  115632. /**
  115633. * Creates a PolygonMeshBuilder
  115634. * @param name name of the builder
  115635. * @param contours Path of the polygon
  115636. * @param scene scene to add to when creating the mesh
  115637. * @param earcutInjection can be used to inject your own earcut reference
  115638. */
  115639. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  115640. /**
  115641. * Adds a whole within the polygon
  115642. * @param hole Array of points defining the hole
  115643. * @returns this
  115644. */
  115645. addHole(hole: Vector2[]): PolygonMeshBuilder;
  115646. /**
  115647. * Creates the polygon
  115648. * @param updatable If the mesh should be updatable
  115649. * @param depth The depth of the mesh created
  115650. * @returns the created mesh
  115651. */
  115652. build(updatable?: boolean, depth?: number): Mesh;
  115653. /**
  115654. * Creates the polygon
  115655. * @param depth The depth of the mesh created
  115656. * @returns the created VertexData
  115657. */
  115658. buildVertexData(depth?: number): VertexData;
  115659. /**
  115660. * Adds a side to the polygon
  115661. * @param positions points that make the polygon
  115662. * @param normals normals of the polygon
  115663. * @param uvs uvs of the polygon
  115664. * @param indices indices of the polygon
  115665. * @param bounds bounds of the polygon
  115666. * @param points points of the polygon
  115667. * @param depth depth of the polygon
  115668. * @param flip flip of the polygon
  115669. */
  115670. private addSide;
  115671. }
  115672. }
  115673. declare module BABYLON {
  115674. /**
  115675. * Class containing static functions to help procedurally build meshes
  115676. */
  115677. export class PolygonBuilder {
  115678. /**
  115679. * Creates a polygon mesh
  115680. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  115681. * * 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
  115682. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115683. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115684. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  115685. * * Remember you can only change the shape positions, not their number when updating a polygon
  115686. * @param name defines the name of the mesh
  115687. * @param options defines the options used to create the mesh
  115688. * @param scene defines the hosting scene
  115689. * @param earcutInjection can be used to inject your own earcut reference
  115690. * @returns the polygon mesh
  115691. */
  115692. static CreatePolygon(name: string, options: {
  115693. shape: Vector3[];
  115694. holes?: Vector3[][];
  115695. depth?: number;
  115696. faceUV?: Vector4[];
  115697. faceColors?: Color4[];
  115698. updatable?: boolean;
  115699. sideOrientation?: number;
  115700. frontUVs?: Vector4;
  115701. backUVs?: Vector4;
  115702. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  115703. /**
  115704. * Creates an extruded polygon mesh, with depth in the Y direction.
  115705. * * 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)
  115706. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  115707. * @param name defines the name of the mesh
  115708. * @param options defines the options used to create the mesh
  115709. * @param scene defines the hosting scene
  115710. * @param earcutInjection can be used to inject your own earcut reference
  115711. * @returns the polygon mesh
  115712. */
  115713. static ExtrudePolygon(name: string, options: {
  115714. shape: Vector3[];
  115715. holes?: Vector3[][];
  115716. depth?: number;
  115717. faceUV?: Vector4[];
  115718. faceColors?: Color4[];
  115719. updatable?: boolean;
  115720. sideOrientation?: number;
  115721. frontUVs?: Vector4;
  115722. backUVs?: Vector4;
  115723. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  115724. }
  115725. }
  115726. declare module BABYLON {
  115727. /**
  115728. * Class containing static functions to help procedurally build meshes
  115729. */
  115730. export class LatheBuilder {
  115731. /**
  115732. * Creates lathe mesh.
  115733. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  115734. * * 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
  115735. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  115736. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  115737. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  115738. * * 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
  115739. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  115740. * * 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
  115741. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115742. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115743. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  115744. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115745. * @param name defines the name of the mesh
  115746. * @param options defines the options used to create the mesh
  115747. * @param scene defines the hosting scene
  115748. * @returns the lathe mesh
  115749. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  115750. */
  115751. static CreateLathe(name: string, options: {
  115752. shape: Vector3[];
  115753. radius?: number;
  115754. tessellation?: number;
  115755. clip?: number;
  115756. arc?: number;
  115757. closed?: boolean;
  115758. updatable?: boolean;
  115759. sideOrientation?: number;
  115760. frontUVs?: Vector4;
  115761. backUVs?: Vector4;
  115762. cap?: number;
  115763. invertUV?: boolean;
  115764. }, scene?: Nullable<Scene>): Mesh;
  115765. }
  115766. }
  115767. declare module BABYLON {
  115768. /**
  115769. * Class containing static functions to help procedurally build meshes
  115770. */
  115771. export class TiledPlaneBuilder {
  115772. /**
  115773. * Creates a tiled plane mesh
  115774. * * The parameter `pattern` will, depending on value, do nothing or
  115775. * * * flip (reflect about central vertical) alternate tiles across and up
  115776. * * * flip every tile on alternate rows
  115777. * * * rotate (180 degs) alternate tiles across and up
  115778. * * * rotate every tile on alternate rows
  115779. * * * flip and rotate alternate tiles across and up
  115780. * * * flip and rotate every tile on alternate rows
  115781. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  115782. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  115783. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115784. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115785. * * 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)
  115786. * * 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)
  115787. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  115788. * @param name defines the name of the mesh
  115789. * @param options defines the options used to create the mesh
  115790. * @param scene defines the hosting scene
  115791. * @returns the box mesh
  115792. */
  115793. static CreateTiledPlane(name: string, options: {
  115794. pattern?: number;
  115795. tileSize?: number;
  115796. tileWidth?: number;
  115797. tileHeight?: number;
  115798. size?: number;
  115799. width?: number;
  115800. height?: number;
  115801. alignHorizontal?: number;
  115802. alignVertical?: number;
  115803. sideOrientation?: number;
  115804. frontUVs?: Vector4;
  115805. backUVs?: Vector4;
  115806. updatable?: boolean;
  115807. }, scene?: Nullable<Scene>): Mesh;
  115808. }
  115809. }
  115810. declare module BABYLON {
  115811. /**
  115812. * Class containing static functions to help procedurally build meshes
  115813. */
  115814. export class TubeBuilder {
  115815. /**
  115816. * Creates a tube mesh.
  115817. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  115818. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  115819. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  115820. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  115821. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  115822. * * 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)
  115823. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  115824. * * 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
  115825. * * 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
  115826. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115827. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115828. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  115829. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115830. * @param name defines the name of the mesh
  115831. * @param options defines the options used to create the mesh
  115832. * @param scene defines the hosting scene
  115833. * @returns the tube mesh
  115834. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  115835. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  115836. */
  115837. static CreateTube(name: string, options: {
  115838. path: Vector3[];
  115839. radius?: number;
  115840. tessellation?: number;
  115841. radiusFunction?: {
  115842. (i: number, distance: number): number;
  115843. };
  115844. cap?: number;
  115845. arc?: number;
  115846. updatable?: boolean;
  115847. sideOrientation?: number;
  115848. frontUVs?: Vector4;
  115849. backUVs?: Vector4;
  115850. instance?: Mesh;
  115851. invertUV?: boolean;
  115852. }, scene?: Nullable<Scene>): Mesh;
  115853. }
  115854. }
  115855. declare module BABYLON {
  115856. /**
  115857. * Class containing static functions to help procedurally build meshes
  115858. */
  115859. export class IcoSphereBuilder {
  115860. /**
  115861. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  115862. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  115863. * * 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`)
  115864. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  115865. * * 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
  115866. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115867. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115868. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115869. * @param name defines the name of the mesh
  115870. * @param options defines the options used to create the mesh
  115871. * @param scene defines the hosting scene
  115872. * @returns the icosahedron mesh
  115873. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  115874. */
  115875. static CreateIcoSphere(name: string, options: {
  115876. radius?: number;
  115877. radiusX?: number;
  115878. radiusY?: number;
  115879. radiusZ?: number;
  115880. flat?: boolean;
  115881. subdivisions?: number;
  115882. sideOrientation?: number;
  115883. frontUVs?: Vector4;
  115884. backUVs?: Vector4;
  115885. updatable?: boolean;
  115886. }, scene?: Nullable<Scene>): Mesh;
  115887. }
  115888. }
  115889. declare module BABYLON {
  115890. /**
  115891. * Class containing static functions to help procedurally build meshes
  115892. */
  115893. export class DecalBuilder {
  115894. /**
  115895. * Creates a decal mesh.
  115896. * 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
  115897. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  115898. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  115899. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  115900. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  115901. * @param name defines the name of the mesh
  115902. * @param sourceMesh defines the mesh where the decal must be applied
  115903. * @param options defines the options used to create the mesh
  115904. * @param scene defines the hosting scene
  115905. * @returns the decal mesh
  115906. * @see https://doc.babylonjs.com/how_to/decals
  115907. */
  115908. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  115909. position?: Vector3;
  115910. normal?: Vector3;
  115911. size?: Vector3;
  115912. angle?: number;
  115913. }): Mesh;
  115914. }
  115915. }
  115916. declare module BABYLON {
  115917. /**
  115918. * Class containing static functions to help procedurally build meshes
  115919. */
  115920. export class MeshBuilder {
  115921. /**
  115922. * Creates a box mesh
  115923. * * The parameter `size` sets the size (float) of each box side (default 1)
  115924. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  115925. * * 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)
  115926. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  115927. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115928. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115929. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115930. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  115931. * @param name defines the name of the mesh
  115932. * @param options defines the options used to create the mesh
  115933. * @param scene defines the hosting scene
  115934. * @returns the box mesh
  115935. */
  115936. static CreateBox(name: string, options: {
  115937. size?: number;
  115938. width?: number;
  115939. height?: number;
  115940. depth?: number;
  115941. faceUV?: Vector4[];
  115942. faceColors?: Color4[];
  115943. sideOrientation?: number;
  115944. frontUVs?: Vector4;
  115945. backUVs?: Vector4;
  115946. updatable?: boolean;
  115947. }, scene?: Nullable<Scene>): Mesh;
  115948. /**
  115949. * Creates a tiled box mesh
  115950. * * faceTiles sets the pattern, tile size and number of tiles for a face
  115951. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115952. * @param name defines the name of the mesh
  115953. * @param options defines the options used to create the mesh
  115954. * @param scene defines the hosting scene
  115955. * @returns the tiled box mesh
  115956. */
  115957. static CreateTiledBox(name: string, options: {
  115958. pattern?: number;
  115959. size?: number;
  115960. width?: number;
  115961. height?: number;
  115962. depth: number;
  115963. tileSize?: number;
  115964. tileWidth?: number;
  115965. tileHeight?: number;
  115966. faceUV?: Vector4[];
  115967. faceColors?: Color4[];
  115968. alignHorizontal?: number;
  115969. alignVertical?: number;
  115970. sideOrientation?: number;
  115971. updatable?: boolean;
  115972. }, scene?: Nullable<Scene>): Mesh;
  115973. /**
  115974. * Creates a sphere mesh
  115975. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  115976. * * 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`)
  115977. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  115978. * * 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
  115979. * * 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)
  115980. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115981. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115982. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115983. * @param name defines the name of the mesh
  115984. * @param options defines the options used to create the mesh
  115985. * @param scene defines the hosting scene
  115986. * @returns the sphere mesh
  115987. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  115988. */
  115989. static CreateSphere(name: string, options: {
  115990. segments?: number;
  115991. diameter?: number;
  115992. diameterX?: number;
  115993. diameterY?: number;
  115994. diameterZ?: number;
  115995. arc?: number;
  115996. slice?: number;
  115997. sideOrientation?: number;
  115998. frontUVs?: Vector4;
  115999. backUVs?: Vector4;
  116000. updatable?: boolean;
  116001. }, scene?: Nullable<Scene>): Mesh;
  116002. /**
  116003. * Creates a plane polygonal mesh. By default, this is a disc
  116004. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  116005. * * 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
  116006. * * 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
  116007. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116008. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116009. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116010. * @param name defines the name of the mesh
  116011. * @param options defines the options used to create the mesh
  116012. * @param scene defines the hosting scene
  116013. * @returns the plane polygonal mesh
  116014. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  116015. */
  116016. static CreateDisc(name: string, options: {
  116017. radius?: number;
  116018. tessellation?: number;
  116019. arc?: number;
  116020. updatable?: boolean;
  116021. sideOrientation?: number;
  116022. frontUVs?: Vector4;
  116023. backUVs?: Vector4;
  116024. }, scene?: Nullable<Scene>): Mesh;
  116025. /**
  116026. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  116027. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  116028. * * 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`)
  116029. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  116030. * * 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
  116031. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116032. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116033. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116034. * @param name defines the name of the mesh
  116035. * @param options defines the options used to create the mesh
  116036. * @param scene defines the hosting scene
  116037. * @returns the icosahedron mesh
  116038. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  116039. */
  116040. static CreateIcoSphere(name: string, options: {
  116041. radius?: number;
  116042. radiusX?: number;
  116043. radiusY?: number;
  116044. radiusZ?: number;
  116045. flat?: boolean;
  116046. subdivisions?: number;
  116047. sideOrientation?: number;
  116048. frontUVs?: Vector4;
  116049. backUVs?: Vector4;
  116050. updatable?: boolean;
  116051. }, scene?: Nullable<Scene>): Mesh;
  116052. /**
  116053. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  116054. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  116055. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  116056. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  116057. * * 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
  116058. * * 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
  116059. * * 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
  116060. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116061. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116062. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  116063. * * 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
  116064. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  116065. * * 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
  116066. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  116067. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116068. * @param name defines the name of the mesh
  116069. * @param options defines the options used to create the mesh
  116070. * @param scene defines the hosting scene
  116071. * @returns the ribbon mesh
  116072. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  116073. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  116074. */
  116075. static CreateRibbon(name: string, options: {
  116076. pathArray: Vector3[][];
  116077. closeArray?: boolean;
  116078. closePath?: boolean;
  116079. offset?: number;
  116080. updatable?: boolean;
  116081. sideOrientation?: number;
  116082. frontUVs?: Vector4;
  116083. backUVs?: Vector4;
  116084. instance?: Mesh;
  116085. invertUV?: boolean;
  116086. uvs?: Vector2[];
  116087. colors?: Color4[];
  116088. }, scene?: Nullable<Scene>): Mesh;
  116089. /**
  116090. * Creates a cylinder or a cone mesh
  116091. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  116092. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  116093. * * 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.
  116094. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  116095. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  116096. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  116097. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  116098. * * 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).
  116099. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  116100. * * 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).
  116101. * * 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
  116102. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  116103. * * 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
  116104. * * 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.
  116105. * * If `enclose` is false, a ring surface is one element.
  116106. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  116107. * * 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
  116108. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116109. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116110. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  116111. * @param name defines the name of the mesh
  116112. * @param options defines the options used to create the mesh
  116113. * @param scene defines the hosting scene
  116114. * @returns the cylinder mesh
  116115. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  116116. */
  116117. static CreateCylinder(name: string, options: {
  116118. height?: number;
  116119. diameterTop?: number;
  116120. diameterBottom?: number;
  116121. diameter?: number;
  116122. tessellation?: number;
  116123. subdivisions?: number;
  116124. arc?: number;
  116125. faceColors?: Color4[];
  116126. faceUV?: Vector4[];
  116127. updatable?: boolean;
  116128. hasRings?: boolean;
  116129. enclose?: boolean;
  116130. cap?: number;
  116131. sideOrientation?: number;
  116132. frontUVs?: Vector4;
  116133. backUVs?: Vector4;
  116134. }, scene?: Nullable<Scene>): Mesh;
  116135. /**
  116136. * Creates a torus mesh
  116137. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  116138. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  116139. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  116140. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116141. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116142. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  116143. * @param name defines the name of the mesh
  116144. * @param options defines the options used to create the mesh
  116145. * @param scene defines the hosting scene
  116146. * @returns the torus mesh
  116147. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  116148. */
  116149. static CreateTorus(name: string, options: {
  116150. diameter?: number;
  116151. thickness?: number;
  116152. tessellation?: number;
  116153. updatable?: boolean;
  116154. sideOrientation?: number;
  116155. frontUVs?: Vector4;
  116156. backUVs?: Vector4;
  116157. }, scene?: Nullable<Scene>): Mesh;
  116158. /**
  116159. * Creates a torus knot mesh
  116160. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  116161. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  116162. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  116163. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  116164. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116165. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116166. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  116167. * @param name defines the name of the mesh
  116168. * @param options defines the options used to create the mesh
  116169. * @param scene defines the hosting scene
  116170. * @returns the torus knot mesh
  116171. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  116172. */
  116173. static CreateTorusKnot(name: string, options: {
  116174. radius?: number;
  116175. tube?: number;
  116176. radialSegments?: number;
  116177. tubularSegments?: number;
  116178. p?: number;
  116179. q?: number;
  116180. updatable?: boolean;
  116181. sideOrientation?: number;
  116182. frontUVs?: Vector4;
  116183. backUVs?: Vector4;
  116184. }, scene?: Nullable<Scene>): Mesh;
  116185. /**
  116186. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  116187. * * 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
  116188. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  116189. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  116190. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  116191. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  116192. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  116193. * * 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
  116194. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  116195. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116196. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  116197. * @param name defines the name of the new line system
  116198. * @param options defines the options used to create the line system
  116199. * @param scene defines the hosting scene
  116200. * @returns a new line system mesh
  116201. */
  116202. static CreateLineSystem(name: string, options: {
  116203. lines: Vector3[][];
  116204. updatable?: boolean;
  116205. instance?: Nullable<LinesMesh>;
  116206. colors?: Nullable<Color4[][]>;
  116207. useVertexAlpha?: boolean;
  116208. }, scene: Nullable<Scene>): LinesMesh;
  116209. /**
  116210. * Creates a line mesh
  116211. * 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
  116212. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  116213. * * The parameter `points` is an array successive Vector3
  116214. * * 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
  116215. * * The optional parameter `colors` is an array of successive Color4, one per line point
  116216. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  116217. * * When updating an instance, remember that only point positions can change, not the number of points
  116218. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116219. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  116220. * @param name defines the name of the new line system
  116221. * @param options defines the options used to create the line system
  116222. * @param scene defines the hosting scene
  116223. * @returns a new line mesh
  116224. */
  116225. static CreateLines(name: string, options: {
  116226. points: Vector3[];
  116227. updatable?: boolean;
  116228. instance?: Nullable<LinesMesh>;
  116229. colors?: Color4[];
  116230. useVertexAlpha?: boolean;
  116231. }, scene?: Nullable<Scene>): LinesMesh;
  116232. /**
  116233. * Creates a dashed line mesh
  116234. * * 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
  116235. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  116236. * * The parameter `points` is an array successive Vector3
  116237. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  116238. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  116239. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  116240. * * 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
  116241. * * When updating an instance, remember that only point positions can change, not the number of points
  116242. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116243. * @param name defines the name of the mesh
  116244. * @param options defines the options used to create the mesh
  116245. * @param scene defines the hosting scene
  116246. * @returns the dashed line mesh
  116247. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  116248. */
  116249. static CreateDashedLines(name: string, options: {
  116250. points: Vector3[];
  116251. dashSize?: number;
  116252. gapSize?: number;
  116253. dashNb?: number;
  116254. updatable?: boolean;
  116255. instance?: LinesMesh;
  116256. }, scene?: Nullable<Scene>): LinesMesh;
  116257. /**
  116258. * 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.
  116259. * * 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.
  116260. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  116261. * * 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.
  116262. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  116263. * * 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
  116264. * * 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
  116265. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  116266. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116267. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116268. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  116269. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  116270. * @param name defines the name of the mesh
  116271. * @param options defines the options used to create the mesh
  116272. * @param scene defines the hosting scene
  116273. * @returns the extruded shape mesh
  116274. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  116275. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  116276. */
  116277. static ExtrudeShape(name: string, options: {
  116278. shape: Vector3[];
  116279. path: Vector3[];
  116280. scale?: number;
  116281. rotation?: number;
  116282. cap?: number;
  116283. updatable?: boolean;
  116284. sideOrientation?: number;
  116285. frontUVs?: Vector4;
  116286. backUVs?: Vector4;
  116287. instance?: Mesh;
  116288. invertUV?: boolean;
  116289. }, scene?: Nullable<Scene>): Mesh;
  116290. /**
  116291. * Creates an custom extruded shape mesh.
  116292. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  116293. * * 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.
  116294. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  116295. * * 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
  116296. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  116297. * * 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
  116298. * * It must returns a float value that will be the scale value applied to the shape on each path point
  116299. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  116300. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  116301. * * 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
  116302. * * 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
  116303. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  116304. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116305. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116306. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  116307. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116308. * @param name defines the name of the mesh
  116309. * @param options defines the options used to create the mesh
  116310. * @param scene defines the hosting scene
  116311. * @returns the custom extruded shape mesh
  116312. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  116313. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  116314. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  116315. */
  116316. static ExtrudeShapeCustom(name: string, options: {
  116317. shape: Vector3[];
  116318. path: Vector3[];
  116319. scaleFunction?: any;
  116320. rotationFunction?: any;
  116321. ribbonCloseArray?: boolean;
  116322. ribbonClosePath?: boolean;
  116323. cap?: number;
  116324. updatable?: boolean;
  116325. sideOrientation?: number;
  116326. frontUVs?: Vector4;
  116327. backUVs?: Vector4;
  116328. instance?: Mesh;
  116329. invertUV?: boolean;
  116330. }, scene?: Nullable<Scene>): Mesh;
  116331. /**
  116332. * Creates lathe mesh.
  116333. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  116334. * * 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
  116335. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  116336. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  116337. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  116338. * * 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
  116339. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  116340. * * 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
  116341. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116342. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116343. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  116344. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116345. * @param name defines the name of the mesh
  116346. * @param options defines the options used to create the mesh
  116347. * @param scene defines the hosting scene
  116348. * @returns the lathe mesh
  116349. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  116350. */
  116351. static CreateLathe(name: string, options: {
  116352. shape: Vector3[];
  116353. radius?: number;
  116354. tessellation?: number;
  116355. clip?: number;
  116356. arc?: number;
  116357. closed?: boolean;
  116358. updatable?: boolean;
  116359. sideOrientation?: number;
  116360. frontUVs?: Vector4;
  116361. backUVs?: Vector4;
  116362. cap?: number;
  116363. invertUV?: boolean;
  116364. }, scene?: Nullable<Scene>): Mesh;
  116365. /**
  116366. * Creates a tiled plane mesh
  116367. * * You can set a limited pattern arrangement with the tiles
  116368. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116369. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116370. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116371. * @param name defines the name of the mesh
  116372. * @param options defines the options used to create the mesh
  116373. * @param scene defines the hosting scene
  116374. * @returns the plane mesh
  116375. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  116376. */
  116377. static CreateTiledPlane(name: string, options: {
  116378. pattern?: number;
  116379. tileSize?: number;
  116380. tileWidth?: number;
  116381. tileHeight?: number;
  116382. size?: number;
  116383. width?: number;
  116384. height?: number;
  116385. alignHorizontal?: number;
  116386. alignVertical?: number;
  116387. sideOrientation?: number;
  116388. frontUVs?: Vector4;
  116389. backUVs?: Vector4;
  116390. updatable?: boolean;
  116391. }, scene?: Nullable<Scene>): Mesh;
  116392. /**
  116393. * Creates a plane mesh
  116394. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  116395. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  116396. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  116397. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116398. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116399. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116400. * @param name defines the name of the mesh
  116401. * @param options defines the options used to create the mesh
  116402. * @param scene defines the hosting scene
  116403. * @returns the plane mesh
  116404. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  116405. */
  116406. static CreatePlane(name: string, options: {
  116407. size?: number;
  116408. width?: number;
  116409. height?: number;
  116410. sideOrientation?: number;
  116411. frontUVs?: Vector4;
  116412. backUVs?: Vector4;
  116413. updatable?: boolean;
  116414. sourcePlane?: Plane;
  116415. }, scene?: Nullable<Scene>): Mesh;
  116416. /**
  116417. * Creates a ground mesh
  116418. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  116419. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  116420. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116421. * @param name defines the name of the mesh
  116422. * @param options defines the options used to create the mesh
  116423. * @param scene defines the hosting scene
  116424. * @returns the ground mesh
  116425. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  116426. */
  116427. static CreateGround(name: string, options: {
  116428. width?: number;
  116429. height?: number;
  116430. subdivisions?: number;
  116431. subdivisionsX?: number;
  116432. subdivisionsY?: number;
  116433. updatable?: boolean;
  116434. }, scene?: Nullable<Scene>): Mesh;
  116435. /**
  116436. * Creates a tiled ground mesh
  116437. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  116438. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  116439. * * 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
  116440. * * 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
  116441. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  116442. * @param name defines the name of the mesh
  116443. * @param options defines the options used to create the mesh
  116444. * @param scene defines the hosting scene
  116445. * @returns the tiled ground mesh
  116446. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  116447. */
  116448. static CreateTiledGround(name: string, options: {
  116449. xmin: number;
  116450. zmin: number;
  116451. xmax: number;
  116452. zmax: number;
  116453. subdivisions?: {
  116454. w: number;
  116455. h: number;
  116456. };
  116457. precision?: {
  116458. w: number;
  116459. h: number;
  116460. };
  116461. updatable?: boolean;
  116462. }, scene?: Nullable<Scene>): Mesh;
  116463. /**
  116464. * Creates a ground mesh from a height map
  116465. * * The parameter `url` sets the URL of the height map image resource.
  116466. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  116467. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  116468. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  116469. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  116470. * * 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.
  116471. * * 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).
  116472. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  116473. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  116474. * @param name defines the name of the mesh
  116475. * @param url defines the url to the height map
  116476. * @param options defines the options used to create the mesh
  116477. * @param scene defines the hosting scene
  116478. * @returns the ground mesh
  116479. * @see https://doc.babylonjs.com/babylon101/height_map
  116480. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  116481. */
  116482. static CreateGroundFromHeightMap(name: string, url: string, options: {
  116483. width?: number;
  116484. height?: number;
  116485. subdivisions?: number;
  116486. minHeight?: number;
  116487. maxHeight?: number;
  116488. colorFilter?: Color3;
  116489. alphaFilter?: number;
  116490. updatable?: boolean;
  116491. onReady?: (mesh: GroundMesh) => void;
  116492. }, scene?: Nullable<Scene>): GroundMesh;
  116493. /**
  116494. * Creates a polygon mesh
  116495. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  116496. * * 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
  116497. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  116498. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116499. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  116500. * * Remember you can only change the shape positions, not their number when updating a polygon
  116501. * @param name defines the name of the mesh
  116502. * @param options defines the options used to create the mesh
  116503. * @param scene defines the hosting scene
  116504. * @param earcutInjection can be used to inject your own earcut reference
  116505. * @returns the polygon mesh
  116506. */
  116507. static CreatePolygon(name: string, options: {
  116508. shape: Vector3[];
  116509. holes?: Vector3[][];
  116510. depth?: number;
  116511. faceUV?: Vector4[];
  116512. faceColors?: Color4[];
  116513. updatable?: boolean;
  116514. sideOrientation?: number;
  116515. frontUVs?: Vector4;
  116516. backUVs?: Vector4;
  116517. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  116518. /**
  116519. * Creates an extruded polygon mesh, with depth in the Y direction.
  116520. * * 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)
  116521. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  116522. * @param name defines the name of the mesh
  116523. * @param options defines the options used to create the mesh
  116524. * @param scene defines the hosting scene
  116525. * @param earcutInjection can be used to inject your own earcut reference
  116526. * @returns the polygon mesh
  116527. */
  116528. static ExtrudePolygon(name: string, options: {
  116529. shape: Vector3[];
  116530. holes?: Vector3[][];
  116531. depth?: number;
  116532. faceUV?: Vector4[];
  116533. faceColors?: Color4[];
  116534. updatable?: boolean;
  116535. sideOrientation?: number;
  116536. frontUVs?: Vector4;
  116537. backUVs?: Vector4;
  116538. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  116539. /**
  116540. * Creates a tube mesh.
  116541. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  116542. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  116543. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  116544. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  116545. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  116546. * * 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)
  116547. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  116548. * * 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
  116549. * * 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
  116550. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116551. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116552. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  116553. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116554. * @param name defines the name of the mesh
  116555. * @param options defines the options used to create the mesh
  116556. * @param scene defines the hosting scene
  116557. * @returns the tube mesh
  116558. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  116559. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  116560. */
  116561. static CreateTube(name: string, options: {
  116562. path: Vector3[];
  116563. radius?: number;
  116564. tessellation?: number;
  116565. radiusFunction?: {
  116566. (i: number, distance: number): number;
  116567. };
  116568. cap?: number;
  116569. arc?: number;
  116570. updatable?: boolean;
  116571. sideOrientation?: number;
  116572. frontUVs?: Vector4;
  116573. backUVs?: Vector4;
  116574. instance?: Mesh;
  116575. invertUV?: boolean;
  116576. }, scene?: Nullable<Scene>): Mesh;
  116577. /**
  116578. * Creates a polyhedron mesh
  116579. * * 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
  116580. * * The parameter `size` (positive float, default 1) sets the polygon size
  116581. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  116582. * * 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`
  116583. * * 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
  116584. * * 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)`)
  116585. * * 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
  116586. * * 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
  116587. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116588. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116589. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116590. * @param name defines the name of the mesh
  116591. * @param options defines the options used to create the mesh
  116592. * @param scene defines the hosting scene
  116593. * @returns the polyhedron mesh
  116594. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  116595. */
  116596. static CreatePolyhedron(name: string, options: {
  116597. type?: number;
  116598. size?: number;
  116599. sizeX?: number;
  116600. sizeY?: number;
  116601. sizeZ?: number;
  116602. custom?: any;
  116603. faceUV?: Vector4[];
  116604. faceColors?: Color4[];
  116605. flat?: boolean;
  116606. updatable?: boolean;
  116607. sideOrientation?: number;
  116608. frontUVs?: Vector4;
  116609. backUVs?: Vector4;
  116610. }, scene?: Nullable<Scene>): Mesh;
  116611. /**
  116612. * Creates a decal mesh.
  116613. * 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
  116614. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  116615. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  116616. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  116617. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  116618. * @param name defines the name of the mesh
  116619. * @param sourceMesh defines the mesh where the decal must be applied
  116620. * @param options defines the options used to create the mesh
  116621. * @param scene defines the hosting scene
  116622. * @returns the decal mesh
  116623. * @see https://doc.babylonjs.com/how_to/decals
  116624. */
  116625. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  116626. position?: Vector3;
  116627. normal?: Vector3;
  116628. size?: Vector3;
  116629. angle?: number;
  116630. }): Mesh;
  116631. }
  116632. }
  116633. declare module BABYLON {
  116634. /**
  116635. * A simplifier interface for future simplification implementations
  116636. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  116637. */
  116638. export interface ISimplifier {
  116639. /**
  116640. * Simplification of a given mesh according to the given settings.
  116641. * Since this requires computation, it is assumed that the function runs async.
  116642. * @param settings The settings of the simplification, including quality and distance
  116643. * @param successCallback A callback that will be called after the mesh was simplified.
  116644. * @param errorCallback in case of an error, this callback will be called. optional.
  116645. */
  116646. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  116647. }
  116648. /**
  116649. * Expected simplification settings.
  116650. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  116651. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  116652. */
  116653. export interface ISimplificationSettings {
  116654. /**
  116655. * Gets or sets the expected quality
  116656. */
  116657. quality: number;
  116658. /**
  116659. * Gets or sets the distance when this optimized version should be used
  116660. */
  116661. distance: number;
  116662. /**
  116663. * Gets an already optimized mesh
  116664. */
  116665. optimizeMesh?: boolean;
  116666. }
  116667. /**
  116668. * Class used to specify simplification options
  116669. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  116670. */
  116671. export class SimplificationSettings implements ISimplificationSettings {
  116672. /** expected quality */
  116673. quality: number;
  116674. /** distance when this optimized version should be used */
  116675. distance: number;
  116676. /** already optimized mesh */
  116677. optimizeMesh?: boolean | undefined;
  116678. /**
  116679. * Creates a SimplificationSettings
  116680. * @param quality expected quality
  116681. * @param distance distance when this optimized version should be used
  116682. * @param optimizeMesh already optimized mesh
  116683. */
  116684. constructor(
  116685. /** expected quality */
  116686. quality: number,
  116687. /** distance when this optimized version should be used */
  116688. distance: number,
  116689. /** already optimized mesh */
  116690. optimizeMesh?: boolean | undefined);
  116691. }
  116692. /**
  116693. * Interface used to define a simplification task
  116694. */
  116695. export interface ISimplificationTask {
  116696. /**
  116697. * Array of settings
  116698. */
  116699. settings: Array<ISimplificationSettings>;
  116700. /**
  116701. * Simplification type
  116702. */
  116703. simplificationType: SimplificationType;
  116704. /**
  116705. * Mesh to simplify
  116706. */
  116707. mesh: Mesh;
  116708. /**
  116709. * Callback called on success
  116710. */
  116711. successCallback?: () => void;
  116712. /**
  116713. * Defines if parallel processing can be used
  116714. */
  116715. parallelProcessing: boolean;
  116716. }
  116717. /**
  116718. * Queue used to order the simplification tasks
  116719. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  116720. */
  116721. export class SimplificationQueue {
  116722. private _simplificationArray;
  116723. /**
  116724. * Gets a boolean indicating that the process is still running
  116725. */
  116726. running: boolean;
  116727. /**
  116728. * Creates a new queue
  116729. */
  116730. constructor();
  116731. /**
  116732. * Adds a new simplification task
  116733. * @param task defines a task to add
  116734. */
  116735. addTask(task: ISimplificationTask): void;
  116736. /**
  116737. * Execute next task
  116738. */
  116739. executeNext(): void;
  116740. /**
  116741. * Execute a simplification task
  116742. * @param task defines the task to run
  116743. */
  116744. runSimplification(task: ISimplificationTask): void;
  116745. private getSimplifier;
  116746. }
  116747. /**
  116748. * The implemented types of simplification
  116749. * At the moment only Quadratic Error Decimation is implemented
  116750. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  116751. */
  116752. export enum SimplificationType {
  116753. /** Quadratic error decimation */
  116754. QUADRATIC = 0
  116755. }
  116756. }
  116757. declare module BABYLON {
  116758. interface Scene {
  116759. /** @hidden (Backing field) */
  116760. _simplificationQueue: SimplificationQueue;
  116761. /**
  116762. * Gets or sets the simplification queue attached to the scene
  116763. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  116764. */
  116765. simplificationQueue: SimplificationQueue;
  116766. }
  116767. interface Mesh {
  116768. /**
  116769. * Simplify the mesh according to the given array of settings.
  116770. * Function will return immediately and will simplify async
  116771. * @param settings a collection of simplification settings
  116772. * @param parallelProcessing should all levels calculate parallel or one after the other
  116773. * @param simplificationType the type of simplification to run
  116774. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  116775. * @returns the current mesh
  116776. */
  116777. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  116778. }
  116779. /**
  116780. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  116781. * created in a scene
  116782. */
  116783. export class SimplicationQueueSceneComponent implements ISceneComponent {
  116784. /**
  116785. * The component name helpfull to identify the component in the list of scene components.
  116786. */
  116787. readonly name: string;
  116788. /**
  116789. * The scene the component belongs to.
  116790. */
  116791. scene: Scene;
  116792. /**
  116793. * Creates a new instance of the component for the given scene
  116794. * @param scene Defines the scene to register the component in
  116795. */
  116796. constructor(scene: Scene);
  116797. /**
  116798. * Registers the component in a given scene
  116799. */
  116800. register(): void;
  116801. /**
  116802. * Rebuilds the elements related to this component in case of
  116803. * context lost for instance.
  116804. */
  116805. rebuild(): void;
  116806. /**
  116807. * Disposes the component and the associated ressources
  116808. */
  116809. dispose(): void;
  116810. private _beforeCameraUpdate;
  116811. }
  116812. }
  116813. declare module BABYLON {
  116814. /**
  116815. * Class used to enable access to IndexedDB
  116816. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  116817. */
  116818. export class Database implements IOfflineProvider {
  116819. private _callbackManifestChecked;
  116820. private _currentSceneUrl;
  116821. private _db;
  116822. private _enableSceneOffline;
  116823. private _enableTexturesOffline;
  116824. private _manifestVersionFound;
  116825. private _mustUpdateRessources;
  116826. private _hasReachedQuota;
  116827. private _isSupported;
  116828. private _idbFactory;
  116829. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  116830. private static IsUASupportingBlobStorage;
  116831. /**
  116832. * Gets a boolean indicating if Database storate is enabled (off by default)
  116833. */
  116834. static IDBStorageEnabled: boolean;
  116835. /**
  116836. * Gets a boolean indicating if scene must be saved in the database
  116837. */
  116838. readonly enableSceneOffline: boolean;
  116839. /**
  116840. * Gets a boolean indicating if textures must be saved in the database
  116841. */
  116842. readonly enableTexturesOffline: boolean;
  116843. /**
  116844. * Creates a new Database
  116845. * @param urlToScene defines the url to load the scene
  116846. * @param callbackManifestChecked defines the callback to use when manifest is checked
  116847. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  116848. */
  116849. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  116850. private static _ParseURL;
  116851. private static _ReturnFullUrlLocation;
  116852. private _checkManifestFile;
  116853. /**
  116854. * Open the database and make it available
  116855. * @param successCallback defines the callback to call on success
  116856. * @param errorCallback defines the callback to call on error
  116857. */
  116858. open(successCallback: () => void, errorCallback: () => void): void;
  116859. /**
  116860. * Loads an image from the database
  116861. * @param url defines the url to load from
  116862. * @param image defines the target DOM image
  116863. */
  116864. loadImage(url: string, image: HTMLImageElement): void;
  116865. private _loadImageFromDBAsync;
  116866. private _saveImageIntoDBAsync;
  116867. private _checkVersionFromDB;
  116868. private _loadVersionFromDBAsync;
  116869. private _saveVersionIntoDBAsync;
  116870. /**
  116871. * Loads a file from database
  116872. * @param url defines the URL to load from
  116873. * @param sceneLoaded defines a callback to call on success
  116874. * @param progressCallBack defines a callback to call when progress changed
  116875. * @param errorCallback defines a callback to call on error
  116876. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  116877. */
  116878. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  116879. private _loadFileAsync;
  116880. private _saveFileAsync;
  116881. /**
  116882. * Validates if xhr data is correct
  116883. * @param xhr defines the request to validate
  116884. * @param dataType defines the expected data type
  116885. * @returns true if data is correct
  116886. */
  116887. private static _ValidateXHRData;
  116888. }
  116889. }
  116890. declare module BABYLON {
  116891. /** @hidden */
  116892. export var gpuUpdateParticlesPixelShader: {
  116893. name: string;
  116894. shader: string;
  116895. };
  116896. }
  116897. declare module BABYLON {
  116898. /** @hidden */
  116899. export var gpuUpdateParticlesVertexShader: {
  116900. name: string;
  116901. shader: string;
  116902. };
  116903. }
  116904. declare module BABYLON {
  116905. /** @hidden */
  116906. export var clipPlaneFragmentDeclaration2: {
  116907. name: string;
  116908. shader: string;
  116909. };
  116910. }
  116911. declare module BABYLON {
  116912. /** @hidden */
  116913. export var gpuRenderParticlesPixelShader: {
  116914. name: string;
  116915. shader: string;
  116916. };
  116917. }
  116918. declare module BABYLON {
  116919. /** @hidden */
  116920. export var clipPlaneVertexDeclaration2: {
  116921. name: string;
  116922. shader: string;
  116923. };
  116924. }
  116925. declare module BABYLON {
  116926. /** @hidden */
  116927. export var gpuRenderParticlesVertexShader: {
  116928. name: string;
  116929. shader: string;
  116930. };
  116931. }
  116932. declare module BABYLON {
  116933. /**
  116934. * This represents a GPU particle system in Babylon
  116935. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  116936. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  116937. */
  116938. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  116939. /**
  116940. * The layer mask we are rendering the particles through.
  116941. */
  116942. layerMask: number;
  116943. private _capacity;
  116944. private _activeCount;
  116945. private _currentActiveCount;
  116946. private _accumulatedCount;
  116947. private _renderEffect;
  116948. private _updateEffect;
  116949. private _buffer0;
  116950. private _buffer1;
  116951. private _spriteBuffer;
  116952. private _updateVAO;
  116953. private _renderVAO;
  116954. private _targetIndex;
  116955. private _sourceBuffer;
  116956. private _targetBuffer;
  116957. private _engine;
  116958. private _currentRenderId;
  116959. private _started;
  116960. private _stopped;
  116961. private _timeDelta;
  116962. private _randomTexture;
  116963. private _randomTexture2;
  116964. private _attributesStrideSize;
  116965. private _updateEffectOptions;
  116966. private _randomTextureSize;
  116967. private _actualFrame;
  116968. private readonly _rawTextureWidth;
  116969. /**
  116970. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  116971. */
  116972. static readonly IsSupported: boolean;
  116973. /**
  116974. * An event triggered when the system is disposed.
  116975. */
  116976. onDisposeObservable: Observable<GPUParticleSystem>;
  116977. /**
  116978. * Gets the maximum number of particles active at the same time.
  116979. * @returns The max number of active particles.
  116980. */
  116981. getCapacity(): number;
  116982. /**
  116983. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  116984. * to override the particles.
  116985. */
  116986. forceDepthWrite: boolean;
  116987. /**
  116988. * Gets or set the number of active particles
  116989. */
  116990. activeParticleCount: number;
  116991. private _preWarmDone;
  116992. /**
  116993. * Is this system ready to be used/rendered
  116994. * @return true if the system is ready
  116995. */
  116996. isReady(): boolean;
  116997. /**
  116998. * Gets if the system has been started. (Note: this will still be true after stop is called)
  116999. * @returns True if it has been started, otherwise false.
  117000. */
  117001. isStarted(): boolean;
  117002. /**
  117003. * Starts the particle system and begins to emit
  117004. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  117005. */
  117006. start(delay?: number): void;
  117007. /**
  117008. * Stops the particle system.
  117009. */
  117010. stop(): void;
  117011. /**
  117012. * Remove all active particles
  117013. */
  117014. reset(): void;
  117015. /**
  117016. * Returns the string "GPUParticleSystem"
  117017. * @returns a string containing the class name
  117018. */
  117019. getClassName(): string;
  117020. private _colorGradientsTexture;
  117021. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  117022. /**
  117023. * Adds a new color gradient
  117024. * @param gradient defines the gradient to use (between 0 and 1)
  117025. * @param color1 defines the color to affect to the specified gradient
  117026. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  117027. * @returns the current particle system
  117028. */
  117029. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  117030. /**
  117031. * Remove a specific color gradient
  117032. * @param gradient defines the gradient to remove
  117033. * @returns the current particle system
  117034. */
  117035. removeColorGradient(gradient: number): GPUParticleSystem;
  117036. private _angularSpeedGradientsTexture;
  117037. private _sizeGradientsTexture;
  117038. private _velocityGradientsTexture;
  117039. private _limitVelocityGradientsTexture;
  117040. private _dragGradientsTexture;
  117041. private _addFactorGradient;
  117042. /**
  117043. * Adds a new size gradient
  117044. * @param gradient defines the gradient to use (between 0 and 1)
  117045. * @param factor defines the size factor to affect to the specified gradient
  117046. * @returns the current particle system
  117047. */
  117048. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  117049. /**
  117050. * Remove a specific size gradient
  117051. * @param gradient defines the gradient to remove
  117052. * @returns the current particle system
  117053. */
  117054. removeSizeGradient(gradient: number): GPUParticleSystem;
  117055. /**
  117056. * Adds a new angular speed gradient
  117057. * @param gradient defines the gradient to use (between 0 and 1)
  117058. * @param factor defines the angular speed to affect to the specified gradient
  117059. * @returns the current particle system
  117060. */
  117061. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  117062. /**
  117063. * Remove a specific angular speed gradient
  117064. * @param gradient defines the gradient to remove
  117065. * @returns the current particle system
  117066. */
  117067. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  117068. /**
  117069. * Adds a new velocity gradient
  117070. * @param gradient defines the gradient to use (between 0 and 1)
  117071. * @param factor defines the velocity to affect to the specified gradient
  117072. * @returns the current particle system
  117073. */
  117074. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  117075. /**
  117076. * Remove a specific velocity gradient
  117077. * @param gradient defines the gradient to remove
  117078. * @returns the current particle system
  117079. */
  117080. removeVelocityGradient(gradient: number): GPUParticleSystem;
  117081. /**
  117082. * Adds a new limit velocity gradient
  117083. * @param gradient defines the gradient to use (between 0 and 1)
  117084. * @param factor defines the limit velocity value to affect to the specified gradient
  117085. * @returns the current particle system
  117086. */
  117087. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  117088. /**
  117089. * Remove a specific limit velocity gradient
  117090. * @param gradient defines the gradient to remove
  117091. * @returns the current particle system
  117092. */
  117093. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  117094. /**
  117095. * Adds a new drag gradient
  117096. * @param gradient defines the gradient to use (between 0 and 1)
  117097. * @param factor defines the drag value to affect to the specified gradient
  117098. * @returns the current particle system
  117099. */
  117100. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  117101. /**
  117102. * Remove a specific drag gradient
  117103. * @param gradient defines the gradient to remove
  117104. * @returns the current particle system
  117105. */
  117106. removeDragGradient(gradient: number): GPUParticleSystem;
  117107. /**
  117108. * Not supported by GPUParticleSystem
  117109. * @param gradient defines the gradient to use (between 0 and 1)
  117110. * @param factor defines the emit rate value to affect to the specified gradient
  117111. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  117112. * @returns the current particle system
  117113. */
  117114. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  117115. /**
  117116. * Not supported by GPUParticleSystem
  117117. * @param gradient defines the gradient to remove
  117118. * @returns the current particle system
  117119. */
  117120. removeEmitRateGradient(gradient: number): IParticleSystem;
  117121. /**
  117122. * Not supported by GPUParticleSystem
  117123. * @param gradient defines the gradient to use (between 0 and 1)
  117124. * @param factor defines the start size value to affect to the specified gradient
  117125. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  117126. * @returns the current particle system
  117127. */
  117128. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  117129. /**
  117130. * Not supported by GPUParticleSystem
  117131. * @param gradient defines the gradient to remove
  117132. * @returns the current particle system
  117133. */
  117134. removeStartSizeGradient(gradient: number): IParticleSystem;
  117135. /**
  117136. * Not supported by GPUParticleSystem
  117137. * @param gradient defines the gradient to use (between 0 and 1)
  117138. * @param min defines the color remap minimal range
  117139. * @param max defines the color remap maximal range
  117140. * @returns the current particle system
  117141. */
  117142. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  117143. /**
  117144. * Not supported by GPUParticleSystem
  117145. * @param gradient defines the gradient to remove
  117146. * @returns the current particle system
  117147. */
  117148. removeColorRemapGradient(): IParticleSystem;
  117149. /**
  117150. * Not supported by GPUParticleSystem
  117151. * @param gradient defines the gradient to use (between 0 and 1)
  117152. * @param min defines the alpha remap minimal range
  117153. * @param max defines the alpha remap maximal range
  117154. * @returns the current particle system
  117155. */
  117156. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  117157. /**
  117158. * Not supported by GPUParticleSystem
  117159. * @param gradient defines the gradient to remove
  117160. * @returns the current particle system
  117161. */
  117162. removeAlphaRemapGradient(): IParticleSystem;
  117163. /**
  117164. * Not supported by GPUParticleSystem
  117165. * @param gradient defines the gradient to use (between 0 and 1)
  117166. * @param color defines the color to affect to the specified gradient
  117167. * @returns the current particle system
  117168. */
  117169. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  117170. /**
  117171. * Not supported by GPUParticleSystem
  117172. * @param gradient defines the gradient to remove
  117173. * @returns the current particle system
  117174. */
  117175. removeRampGradient(): IParticleSystem;
  117176. /**
  117177. * Not supported by GPUParticleSystem
  117178. * @returns the list of ramp gradients
  117179. */
  117180. getRampGradients(): Nullable<Array<Color3Gradient>>;
  117181. /**
  117182. * Not supported by GPUParticleSystem
  117183. * Gets or sets a boolean indicating that ramp gradients must be used
  117184. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  117185. */
  117186. useRampGradients: boolean;
  117187. /**
  117188. * Not supported by GPUParticleSystem
  117189. * @param gradient defines the gradient to use (between 0 and 1)
  117190. * @param factor defines the life time factor to affect to the specified gradient
  117191. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  117192. * @returns the current particle system
  117193. */
  117194. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  117195. /**
  117196. * Not supported by GPUParticleSystem
  117197. * @param gradient defines the gradient to remove
  117198. * @returns the current particle system
  117199. */
  117200. removeLifeTimeGradient(gradient: number): IParticleSystem;
  117201. /**
  117202. * Instantiates a GPU particle system.
  117203. * 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.
  117204. * @param name The name of the particle system
  117205. * @param options The options used to create the system
  117206. * @param scene The scene the particle system belongs to
  117207. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  117208. */
  117209. constructor(name: string, options: Partial<{
  117210. capacity: number;
  117211. randomTextureSize: number;
  117212. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  117213. protected _reset(): void;
  117214. private _createUpdateVAO;
  117215. private _createRenderVAO;
  117216. private _initialize;
  117217. /** @hidden */
  117218. _recreateUpdateEffect(): void;
  117219. /** @hidden */
  117220. _recreateRenderEffect(): void;
  117221. /**
  117222. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  117223. * @param preWarm defines if we are in the pre-warmimg phase
  117224. */
  117225. animate(preWarm?: boolean): void;
  117226. private _createFactorGradientTexture;
  117227. private _createSizeGradientTexture;
  117228. private _createAngularSpeedGradientTexture;
  117229. private _createVelocityGradientTexture;
  117230. private _createLimitVelocityGradientTexture;
  117231. private _createDragGradientTexture;
  117232. private _createColorGradientTexture;
  117233. /**
  117234. * Renders the particle system in its current state
  117235. * @param preWarm defines if the system should only update the particles but not render them
  117236. * @returns the current number of particles
  117237. */
  117238. render(preWarm?: boolean): number;
  117239. /**
  117240. * Rebuilds the particle system
  117241. */
  117242. rebuild(): void;
  117243. private _releaseBuffers;
  117244. private _releaseVAOs;
  117245. /**
  117246. * Disposes the particle system and free the associated resources
  117247. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  117248. */
  117249. dispose(disposeTexture?: boolean): void;
  117250. /**
  117251. * Clones the particle system.
  117252. * @param name The name of the cloned object
  117253. * @param newEmitter The new emitter to use
  117254. * @returns the cloned particle system
  117255. */
  117256. clone(name: string, newEmitter: any): GPUParticleSystem;
  117257. /**
  117258. * Serializes the particle system to a JSON object.
  117259. * @returns the JSON object
  117260. */
  117261. serialize(): any;
  117262. /**
  117263. * Parses a JSON object to create a GPU particle system.
  117264. * @param parsedParticleSystem The JSON object to parse
  117265. * @param scene The scene to create the particle system in
  117266. * @param rootUrl The root url to use to load external dependencies like texture
  117267. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  117268. * @returns the parsed GPU particle system
  117269. */
  117270. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  117271. }
  117272. }
  117273. declare module BABYLON {
  117274. /**
  117275. * Represents a set of particle systems working together to create a specific effect
  117276. */
  117277. export class ParticleSystemSet implements IDisposable {
  117278. private _emitterCreationOptions;
  117279. private _emitterNode;
  117280. /**
  117281. * Gets the particle system list
  117282. */
  117283. systems: IParticleSystem[];
  117284. /**
  117285. * Gets the emitter node used with this set
  117286. */
  117287. readonly emitterNode: Nullable<TransformNode>;
  117288. /**
  117289. * Creates a new emitter mesh as a sphere
  117290. * @param options defines the options used to create the sphere
  117291. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  117292. * @param scene defines the hosting scene
  117293. */
  117294. setEmitterAsSphere(options: {
  117295. diameter: number;
  117296. segments: number;
  117297. color: Color3;
  117298. }, renderingGroupId: number, scene: Scene): void;
  117299. /**
  117300. * Starts all particle systems of the set
  117301. * @param emitter defines an optional mesh to use as emitter for the particle systems
  117302. */
  117303. start(emitter?: AbstractMesh): void;
  117304. /**
  117305. * Release all associated resources
  117306. */
  117307. dispose(): void;
  117308. /**
  117309. * Serialize the set into a JSON compatible object
  117310. * @returns a JSON compatible representation of the set
  117311. */
  117312. serialize(): any;
  117313. /**
  117314. * Parse a new ParticleSystemSet from a serialized source
  117315. * @param data defines a JSON compatible representation of the set
  117316. * @param scene defines the hosting scene
  117317. * @param gpu defines if we want GPU particles or CPU particles
  117318. * @returns a new ParticleSystemSet
  117319. */
  117320. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  117321. }
  117322. }
  117323. declare module BABYLON {
  117324. /**
  117325. * This class is made for on one-liner static method to help creating particle system set.
  117326. */
  117327. export class ParticleHelper {
  117328. /**
  117329. * Gets or sets base Assets URL
  117330. */
  117331. static BaseAssetsUrl: string;
  117332. /**
  117333. * Create a default particle system that you can tweak
  117334. * @param emitter defines the emitter to use
  117335. * @param capacity defines the system capacity (default is 500 particles)
  117336. * @param scene defines the hosting scene
  117337. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  117338. * @returns the new Particle system
  117339. */
  117340. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  117341. /**
  117342. * This is the main static method (one-liner) of this helper to create different particle systems
  117343. * @param type This string represents the type to the particle system to create
  117344. * @param scene The scene where the particle system should live
  117345. * @param gpu If the system will use gpu
  117346. * @returns the ParticleSystemSet created
  117347. */
  117348. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  117349. /**
  117350. * Static function used to export a particle system to a ParticleSystemSet variable.
  117351. * Please note that the emitter shape is not exported
  117352. * @param systems defines the particle systems to export
  117353. * @returns the created particle system set
  117354. */
  117355. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  117356. }
  117357. }
  117358. declare module BABYLON {
  117359. interface Engine {
  117360. /**
  117361. * Create an effect to use with particle systems.
  117362. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  117363. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  117364. * @param uniformsNames defines a list of attribute names
  117365. * @param samplers defines an array of string used to represent textures
  117366. * @param defines defines the string containing the defines to use to compile the shaders
  117367. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  117368. * @param onCompiled defines a function to call when the effect creation is successful
  117369. * @param onError defines a function to call when the effect creation has failed
  117370. * @returns the new Effect
  117371. */
  117372. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  117373. }
  117374. interface Mesh {
  117375. /**
  117376. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  117377. * @returns an array of IParticleSystem
  117378. */
  117379. getEmittedParticleSystems(): IParticleSystem[];
  117380. /**
  117381. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  117382. * @returns an array of IParticleSystem
  117383. */
  117384. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  117385. }
  117386. /**
  117387. * @hidden
  117388. */
  117389. export var _IDoNeedToBeInTheBuild: number;
  117390. }
  117391. declare module BABYLON {
  117392. interface Scene {
  117393. /** @hidden (Backing field) */
  117394. _physicsEngine: Nullable<IPhysicsEngine>;
  117395. /**
  117396. * Gets the current physics engine
  117397. * @returns a IPhysicsEngine or null if none attached
  117398. */
  117399. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  117400. /**
  117401. * Enables physics to the current scene
  117402. * @param gravity defines the scene's gravity for the physics engine
  117403. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  117404. * @return a boolean indicating if the physics engine was initialized
  117405. */
  117406. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  117407. /**
  117408. * Disables and disposes the physics engine associated with the scene
  117409. */
  117410. disablePhysicsEngine(): void;
  117411. /**
  117412. * Gets a boolean indicating if there is an active physics engine
  117413. * @returns a boolean indicating if there is an active physics engine
  117414. */
  117415. isPhysicsEnabled(): boolean;
  117416. /**
  117417. * Deletes a physics compound impostor
  117418. * @param compound defines the compound to delete
  117419. */
  117420. deleteCompoundImpostor(compound: any): void;
  117421. /**
  117422. * An event triggered when physic simulation is about to be run
  117423. */
  117424. onBeforePhysicsObservable: Observable<Scene>;
  117425. /**
  117426. * An event triggered when physic simulation has been done
  117427. */
  117428. onAfterPhysicsObservable: Observable<Scene>;
  117429. }
  117430. interface AbstractMesh {
  117431. /** @hidden */
  117432. _physicsImpostor: Nullable<PhysicsImpostor>;
  117433. /**
  117434. * Gets or sets impostor used for physic simulation
  117435. * @see http://doc.babylonjs.com/features/physics_engine
  117436. */
  117437. physicsImpostor: Nullable<PhysicsImpostor>;
  117438. /**
  117439. * Gets the current physics impostor
  117440. * @see http://doc.babylonjs.com/features/physics_engine
  117441. * @returns a physics impostor or null
  117442. */
  117443. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  117444. /** Apply a physic impulse to the mesh
  117445. * @param force defines the force to apply
  117446. * @param contactPoint defines where to apply the force
  117447. * @returns the current mesh
  117448. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  117449. */
  117450. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  117451. /**
  117452. * Creates a physic joint between two meshes
  117453. * @param otherMesh defines the other mesh to use
  117454. * @param pivot1 defines the pivot to use on this mesh
  117455. * @param pivot2 defines the pivot to use on the other mesh
  117456. * @param options defines additional options (can be plugin dependent)
  117457. * @returns the current mesh
  117458. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  117459. */
  117460. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  117461. /** @hidden */
  117462. _disposePhysicsObserver: Nullable<Observer<Node>>;
  117463. }
  117464. /**
  117465. * Defines the physics engine scene component responsible to manage a physics engine
  117466. */
  117467. export class PhysicsEngineSceneComponent implements ISceneComponent {
  117468. /**
  117469. * The component name helpful to identify the component in the list of scene components.
  117470. */
  117471. readonly name: string;
  117472. /**
  117473. * The scene the component belongs to.
  117474. */
  117475. scene: Scene;
  117476. /**
  117477. * Creates a new instance of the component for the given scene
  117478. * @param scene Defines the scene to register the component in
  117479. */
  117480. constructor(scene: Scene);
  117481. /**
  117482. * Registers the component in a given scene
  117483. */
  117484. register(): void;
  117485. /**
  117486. * Rebuilds the elements related to this component in case of
  117487. * context lost for instance.
  117488. */
  117489. rebuild(): void;
  117490. /**
  117491. * Disposes the component and the associated ressources
  117492. */
  117493. dispose(): void;
  117494. }
  117495. }
  117496. declare module BABYLON {
  117497. /**
  117498. * A helper for physics simulations
  117499. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117500. */
  117501. export class PhysicsHelper {
  117502. private _scene;
  117503. private _physicsEngine;
  117504. /**
  117505. * Initializes the Physics helper
  117506. * @param scene Babylon.js scene
  117507. */
  117508. constructor(scene: Scene);
  117509. /**
  117510. * Applies a radial explosion impulse
  117511. * @param origin the origin of the explosion
  117512. * @param radiusOrEventOptions the radius or the options of radial explosion
  117513. * @param strength the explosion strength
  117514. * @param falloff possible options: Constant & Linear. Defaults to Constant
  117515. * @returns A physics radial explosion event, or null
  117516. */
  117517. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  117518. /**
  117519. * Applies a radial explosion force
  117520. * @param origin the origin of the explosion
  117521. * @param radiusOrEventOptions the radius or the options of radial explosion
  117522. * @param strength the explosion strength
  117523. * @param falloff possible options: Constant & Linear. Defaults to Constant
  117524. * @returns A physics radial explosion event, or null
  117525. */
  117526. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  117527. /**
  117528. * Creates a gravitational field
  117529. * @param origin the origin of the explosion
  117530. * @param radiusOrEventOptions the radius or the options of radial explosion
  117531. * @param strength the explosion strength
  117532. * @param falloff possible options: Constant & Linear. Defaults to Constant
  117533. * @returns A physics gravitational field event, or null
  117534. */
  117535. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  117536. /**
  117537. * Creates a physics updraft event
  117538. * @param origin the origin of the updraft
  117539. * @param radiusOrEventOptions the radius or the options of the updraft
  117540. * @param strength the strength of the updraft
  117541. * @param height the height of the updraft
  117542. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  117543. * @returns A physics updraft event, or null
  117544. */
  117545. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  117546. /**
  117547. * Creates a physics vortex event
  117548. * @param origin the of the vortex
  117549. * @param radiusOrEventOptions the radius or the options of the vortex
  117550. * @param strength the strength of the vortex
  117551. * @param height the height of the vortex
  117552. * @returns a Physics vortex event, or null
  117553. * A physics vortex event or null
  117554. */
  117555. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  117556. }
  117557. /**
  117558. * Represents a physics radial explosion event
  117559. */
  117560. class PhysicsRadialExplosionEvent {
  117561. private _scene;
  117562. private _options;
  117563. private _sphere;
  117564. private _dataFetched;
  117565. /**
  117566. * Initializes a radial explosioin event
  117567. * @param _scene BabylonJS scene
  117568. * @param _options The options for the vortex event
  117569. */
  117570. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  117571. /**
  117572. * Returns the data related to the radial explosion event (sphere).
  117573. * @returns The radial explosion event data
  117574. */
  117575. getData(): PhysicsRadialExplosionEventData;
  117576. /**
  117577. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  117578. * @param impostor A physics imposter
  117579. * @param origin the origin of the explosion
  117580. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  117581. */
  117582. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  117583. /**
  117584. * Triggers affecterd impostors callbacks
  117585. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  117586. */
  117587. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  117588. /**
  117589. * Disposes the sphere.
  117590. * @param force Specifies if the sphere should be disposed by force
  117591. */
  117592. dispose(force?: boolean): void;
  117593. /*** Helpers ***/
  117594. private _prepareSphere;
  117595. private _intersectsWithSphere;
  117596. }
  117597. /**
  117598. * Represents a gravitational field event
  117599. */
  117600. class PhysicsGravitationalFieldEvent {
  117601. private _physicsHelper;
  117602. private _scene;
  117603. private _origin;
  117604. private _options;
  117605. private _tickCallback;
  117606. private _sphere;
  117607. private _dataFetched;
  117608. /**
  117609. * Initializes the physics gravitational field event
  117610. * @param _physicsHelper A physics helper
  117611. * @param _scene BabylonJS scene
  117612. * @param _origin The origin position of the gravitational field event
  117613. * @param _options The options for the vortex event
  117614. */
  117615. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  117616. /**
  117617. * Returns the data related to the gravitational field event (sphere).
  117618. * @returns A gravitational field event
  117619. */
  117620. getData(): PhysicsGravitationalFieldEventData;
  117621. /**
  117622. * Enables the gravitational field.
  117623. */
  117624. enable(): void;
  117625. /**
  117626. * Disables the gravitational field.
  117627. */
  117628. disable(): void;
  117629. /**
  117630. * Disposes the sphere.
  117631. * @param force The force to dispose from the gravitational field event
  117632. */
  117633. dispose(force?: boolean): void;
  117634. private _tick;
  117635. }
  117636. /**
  117637. * Represents a physics updraft event
  117638. */
  117639. class PhysicsUpdraftEvent {
  117640. private _scene;
  117641. private _origin;
  117642. private _options;
  117643. private _physicsEngine;
  117644. private _originTop;
  117645. private _originDirection;
  117646. private _tickCallback;
  117647. private _cylinder;
  117648. private _cylinderPosition;
  117649. private _dataFetched;
  117650. /**
  117651. * Initializes the physics updraft event
  117652. * @param _scene BabylonJS scene
  117653. * @param _origin The origin position of the updraft
  117654. * @param _options The options for the updraft event
  117655. */
  117656. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  117657. /**
  117658. * Returns the data related to the updraft event (cylinder).
  117659. * @returns A physics updraft event
  117660. */
  117661. getData(): PhysicsUpdraftEventData;
  117662. /**
  117663. * Enables the updraft.
  117664. */
  117665. enable(): void;
  117666. /**
  117667. * Disables the updraft.
  117668. */
  117669. disable(): void;
  117670. /**
  117671. * Disposes the cylinder.
  117672. * @param force Specifies if the updraft should be disposed by force
  117673. */
  117674. dispose(force?: boolean): void;
  117675. private getImpostorHitData;
  117676. private _tick;
  117677. /*** Helpers ***/
  117678. private _prepareCylinder;
  117679. private _intersectsWithCylinder;
  117680. }
  117681. /**
  117682. * Represents a physics vortex event
  117683. */
  117684. class PhysicsVortexEvent {
  117685. private _scene;
  117686. private _origin;
  117687. private _options;
  117688. private _physicsEngine;
  117689. private _originTop;
  117690. private _tickCallback;
  117691. private _cylinder;
  117692. private _cylinderPosition;
  117693. private _dataFetched;
  117694. /**
  117695. * Initializes the physics vortex event
  117696. * @param _scene The BabylonJS scene
  117697. * @param _origin The origin position of the vortex
  117698. * @param _options The options for the vortex event
  117699. */
  117700. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  117701. /**
  117702. * Returns the data related to the vortex event (cylinder).
  117703. * @returns The physics vortex event data
  117704. */
  117705. getData(): PhysicsVortexEventData;
  117706. /**
  117707. * Enables the vortex.
  117708. */
  117709. enable(): void;
  117710. /**
  117711. * Disables the cortex.
  117712. */
  117713. disable(): void;
  117714. /**
  117715. * Disposes the sphere.
  117716. * @param force
  117717. */
  117718. dispose(force?: boolean): void;
  117719. private getImpostorHitData;
  117720. private _tick;
  117721. /*** Helpers ***/
  117722. private _prepareCylinder;
  117723. private _intersectsWithCylinder;
  117724. }
  117725. /**
  117726. * Options fot the radial explosion event
  117727. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117728. */
  117729. export class PhysicsRadialExplosionEventOptions {
  117730. /**
  117731. * The radius of the sphere for the radial explosion.
  117732. */
  117733. radius: number;
  117734. /**
  117735. * The strenth of the explosion.
  117736. */
  117737. strength: number;
  117738. /**
  117739. * The strenght of the force in correspondence to the distance of the affected object
  117740. */
  117741. falloff: PhysicsRadialImpulseFalloff;
  117742. /**
  117743. * Sphere options for the radial explosion.
  117744. */
  117745. sphere: {
  117746. segments: number;
  117747. diameter: number;
  117748. };
  117749. /**
  117750. * Sphere options for the radial explosion.
  117751. */
  117752. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  117753. }
  117754. /**
  117755. * Options fot the updraft event
  117756. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117757. */
  117758. export class PhysicsUpdraftEventOptions {
  117759. /**
  117760. * The radius of the cylinder for the vortex
  117761. */
  117762. radius: number;
  117763. /**
  117764. * The strenth of the updraft.
  117765. */
  117766. strength: number;
  117767. /**
  117768. * The height of the cylinder for the updraft.
  117769. */
  117770. height: number;
  117771. /**
  117772. * The mode for the the updraft.
  117773. */
  117774. updraftMode: PhysicsUpdraftMode;
  117775. }
  117776. /**
  117777. * Options fot the vortex event
  117778. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117779. */
  117780. export class PhysicsVortexEventOptions {
  117781. /**
  117782. * The radius of the cylinder for the vortex
  117783. */
  117784. radius: number;
  117785. /**
  117786. * The strenth of the vortex.
  117787. */
  117788. strength: number;
  117789. /**
  117790. * The height of the cylinder for the vortex.
  117791. */
  117792. height: number;
  117793. /**
  117794. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  117795. */
  117796. centripetalForceThreshold: number;
  117797. /**
  117798. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  117799. */
  117800. centripetalForceMultiplier: number;
  117801. /**
  117802. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  117803. */
  117804. centrifugalForceMultiplier: number;
  117805. /**
  117806. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  117807. */
  117808. updraftForceMultiplier: number;
  117809. }
  117810. /**
  117811. * The strenght of the force in correspondence to the distance of the affected object
  117812. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117813. */
  117814. export enum PhysicsRadialImpulseFalloff {
  117815. /** Defines that impulse is constant in strength across it's whole radius */
  117816. Constant = 0,
  117817. /** Defines that impulse gets weaker if it's further from the origin */
  117818. Linear = 1
  117819. }
  117820. /**
  117821. * The strength of the force in correspondence to the distance of the affected object
  117822. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117823. */
  117824. export enum PhysicsUpdraftMode {
  117825. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  117826. Center = 0,
  117827. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  117828. Perpendicular = 1
  117829. }
  117830. /**
  117831. * Interface for a physics hit data
  117832. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117833. */
  117834. export interface PhysicsHitData {
  117835. /**
  117836. * The force applied at the contact point
  117837. */
  117838. force: Vector3;
  117839. /**
  117840. * The contact point
  117841. */
  117842. contactPoint: Vector3;
  117843. /**
  117844. * The distance from the origin to the contact point
  117845. */
  117846. distanceFromOrigin: number;
  117847. }
  117848. /**
  117849. * Interface for radial explosion event data
  117850. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117851. */
  117852. export interface PhysicsRadialExplosionEventData {
  117853. /**
  117854. * A sphere used for the radial explosion event
  117855. */
  117856. sphere: Mesh;
  117857. }
  117858. /**
  117859. * Interface for gravitational field event data
  117860. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117861. */
  117862. export interface PhysicsGravitationalFieldEventData {
  117863. /**
  117864. * A sphere mesh used for the gravitational field event
  117865. */
  117866. sphere: Mesh;
  117867. }
  117868. /**
  117869. * Interface for updraft event data
  117870. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117871. */
  117872. export interface PhysicsUpdraftEventData {
  117873. /**
  117874. * A cylinder used for the updraft event
  117875. */
  117876. cylinder: Mesh;
  117877. }
  117878. /**
  117879. * Interface for vortex event data
  117880. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117881. */
  117882. export interface PhysicsVortexEventData {
  117883. /**
  117884. * A cylinder used for the vortex event
  117885. */
  117886. cylinder: Mesh;
  117887. }
  117888. /**
  117889. * Interface for an affected physics impostor
  117890. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117891. */
  117892. export interface PhysicsAffectedImpostorWithData {
  117893. /**
  117894. * The impostor affected by the effect
  117895. */
  117896. impostor: PhysicsImpostor;
  117897. /**
  117898. * The data about the hit/horce from the explosion
  117899. */
  117900. hitData: PhysicsHitData;
  117901. }
  117902. }
  117903. declare module BABYLON {
  117904. /** @hidden */
  117905. export var blackAndWhitePixelShader: {
  117906. name: string;
  117907. shader: string;
  117908. };
  117909. }
  117910. declare module BABYLON {
  117911. /**
  117912. * Post process used to render in black and white
  117913. */
  117914. export class BlackAndWhitePostProcess extends PostProcess {
  117915. /**
  117916. * Linear about to convert he result to black and white (default: 1)
  117917. */
  117918. degree: number;
  117919. /**
  117920. * Creates a black and white post process
  117921. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  117922. * @param name The name of the effect.
  117923. * @param options The required width/height ratio to downsize to before computing the render pass.
  117924. * @param camera The camera to apply the render pass to.
  117925. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117926. * @param engine The engine which the post process will be applied. (default: current engine)
  117927. * @param reusable If the post process can be reused on the same frame. (default: false)
  117928. */
  117929. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  117930. }
  117931. }
  117932. declare module BABYLON {
  117933. /**
  117934. * This represents a set of one or more post processes in Babylon.
  117935. * A post process can be used to apply a shader to a texture after it is rendered.
  117936. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  117937. */
  117938. export class PostProcessRenderEffect {
  117939. private _postProcesses;
  117940. private _getPostProcesses;
  117941. private _singleInstance;
  117942. private _cameras;
  117943. private _indicesForCamera;
  117944. /**
  117945. * Name of the effect
  117946. * @hidden
  117947. */
  117948. _name: string;
  117949. /**
  117950. * Instantiates a post process render effect.
  117951. * A post process can be used to apply a shader to a texture after it is rendered.
  117952. * @param engine The engine the effect is tied to
  117953. * @param name The name of the effect
  117954. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  117955. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  117956. */
  117957. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  117958. /**
  117959. * Checks if all the post processes in the effect are supported.
  117960. */
  117961. readonly isSupported: boolean;
  117962. /**
  117963. * Updates the current state of the effect
  117964. * @hidden
  117965. */
  117966. _update(): void;
  117967. /**
  117968. * Attaches the effect on cameras
  117969. * @param cameras The camera to attach to.
  117970. * @hidden
  117971. */
  117972. _attachCameras(cameras: Camera): void;
  117973. /**
  117974. * Attaches the effect on cameras
  117975. * @param cameras The camera to attach to.
  117976. * @hidden
  117977. */
  117978. _attachCameras(cameras: Camera[]): void;
  117979. /**
  117980. * Detaches the effect on cameras
  117981. * @param cameras The camera to detatch from.
  117982. * @hidden
  117983. */
  117984. _detachCameras(cameras: Camera): void;
  117985. /**
  117986. * Detatches the effect on cameras
  117987. * @param cameras The camera to detatch from.
  117988. * @hidden
  117989. */
  117990. _detachCameras(cameras: Camera[]): void;
  117991. /**
  117992. * Enables the effect on given cameras
  117993. * @param cameras The camera to enable.
  117994. * @hidden
  117995. */
  117996. _enable(cameras: Camera): void;
  117997. /**
  117998. * Enables the effect on given cameras
  117999. * @param cameras The camera to enable.
  118000. * @hidden
  118001. */
  118002. _enable(cameras: Nullable<Camera[]>): void;
  118003. /**
  118004. * Disables the effect on the given cameras
  118005. * @param cameras The camera to disable.
  118006. * @hidden
  118007. */
  118008. _disable(cameras: Camera): void;
  118009. /**
  118010. * Disables the effect on the given cameras
  118011. * @param cameras The camera to disable.
  118012. * @hidden
  118013. */
  118014. _disable(cameras: Nullable<Camera[]>): void;
  118015. /**
  118016. * Gets a list of the post processes contained in the effect.
  118017. * @param camera The camera to get the post processes on.
  118018. * @returns The list of the post processes in the effect.
  118019. */
  118020. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  118021. }
  118022. }
  118023. declare module BABYLON {
  118024. /** @hidden */
  118025. export var extractHighlightsPixelShader: {
  118026. name: string;
  118027. shader: string;
  118028. };
  118029. }
  118030. declare module BABYLON {
  118031. /**
  118032. * 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.
  118033. */
  118034. export class ExtractHighlightsPostProcess extends PostProcess {
  118035. /**
  118036. * The luminance threshold, pixels below this value will be set to black.
  118037. */
  118038. threshold: number;
  118039. /** @hidden */
  118040. _exposure: number;
  118041. /**
  118042. * Post process which has the input texture to be used when performing highlight extraction
  118043. * @hidden
  118044. */
  118045. _inputPostProcess: Nullable<PostProcess>;
  118046. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  118047. }
  118048. }
  118049. declare module BABYLON {
  118050. /** @hidden */
  118051. export var bloomMergePixelShader: {
  118052. name: string;
  118053. shader: string;
  118054. };
  118055. }
  118056. declare module BABYLON {
  118057. /**
  118058. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  118059. */
  118060. export class BloomMergePostProcess extends PostProcess {
  118061. /** Weight of the bloom to be added to the original input. */
  118062. weight: number;
  118063. /**
  118064. * Creates a new instance of @see BloomMergePostProcess
  118065. * @param name The name of the effect.
  118066. * @param originalFromInput Post process which's input will be used for the merge.
  118067. * @param blurred Blurred highlights post process which's output will be used.
  118068. * @param weight Weight of the bloom to be added to the original input.
  118069. * @param options The required width/height ratio to downsize to before computing the render pass.
  118070. * @param camera The camera to apply the render pass to.
  118071. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118072. * @param engine The engine which the post process will be applied. (default: current engine)
  118073. * @param reusable If the post process can be reused on the same frame. (default: false)
  118074. * @param textureType Type of textures used when performing the post process. (default: 0)
  118075. * @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)
  118076. */
  118077. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  118078. /** Weight of the bloom to be added to the original input. */
  118079. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  118080. }
  118081. }
  118082. declare module BABYLON {
  118083. /**
  118084. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  118085. */
  118086. export class BloomEffect extends PostProcessRenderEffect {
  118087. private bloomScale;
  118088. /**
  118089. * @hidden Internal
  118090. */
  118091. _effects: Array<PostProcess>;
  118092. /**
  118093. * @hidden Internal
  118094. */
  118095. _downscale: ExtractHighlightsPostProcess;
  118096. private _blurX;
  118097. private _blurY;
  118098. private _merge;
  118099. /**
  118100. * The luminance threshold to find bright areas of the image to bloom.
  118101. */
  118102. threshold: number;
  118103. /**
  118104. * The strength of the bloom.
  118105. */
  118106. weight: number;
  118107. /**
  118108. * Specifies the size of the bloom blur kernel, relative to the final output size
  118109. */
  118110. kernel: number;
  118111. /**
  118112. * Creates a new instance of @see BloomEffect
  118113. * @param scene The scene the effect belongs to.
  118114. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  118115. * @param bloomKernel The size of the kernel to be used when applying the blur.
  118116. * @param bloomWeight The the strength of bloom.
  118117. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  118118. * @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)
  118119. */
  118120. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  118121. /**
  118122. * Disposes each of the internal effects for a given camera.
  118123. * @param camera The camera to dispose the effect on.
  118124. */
  118125. disposeEffects(camera: Camera): void;
  118126. /**
  118127. * @hidden Internal
  118128. */
  118129. _updateEffects(): void;
  118130. /**
  118131. * Internal
  118132. * @returns if all the contained post processes are ready.
  118133. * @hidden
  118134. */
  118135. _isReady(): boolean;
  118136. }
  118137. }
  118138. declare module BABYLON {
  118139. /** @hidden */
  118140. export var chromaticAberrationPixelShader: {
  118141. name: string;
  118142. shader: string;
  118143. };
  118144. }
  118145. declare module BABYLON {
  118146. /**
  118147. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  118148. */
  118149. export class ChromaticAberrationPostProcess extends PostProcess {
  118150. /**
  118151. * The amount of seperation of rgb channels (default: 30)
  118152. */
  118153. aberrationAmount: number;
  118154. /**
  118155. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  118156. */
  118157. radialIntensity: number;
  118158. /**
  118159. * 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))
  118160. */
  118161. direction: Vector2;
  118162. /**
  118163. * 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))
  118164. */
  118165. centerPosition: Vector2;
  118166. /**
  118167. * Creates a new instance ChromaticAberrationPostProcess
  118168. * @param name The name of the effect.
  118169. * @param screenWidth The width of the screen to apply the effect on.
  118170. * @param screenHeight The height of the screen to apply the effect on.
  118171. * @param options The required width/height ratio to downsize to before computing the render pass.
  118172. * @param camera The camera to apply the render pass to.
  118173. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118174. * @param engine The engine which the post process will be applied. (default: current engine)
  118175. * @param reusable If the post process can be reused on the same frame. (default: false)
  118176. * @param textureType Type of textures used when performing the post process. (default: 0)
  118177. * @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)
  118178. */
  118179. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  118180. }
  118181. }
  118182. declare module BABYLON {
  118183. /** @hidden */
  118184. export var circleOfConfusionPixelShader: {
  118185. name: string;
  118186. shader: string;
  118187. };
  118188. }
  118189. declare module BABYLON {
  118190. /**
  118191. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  118192. */
  118193. export class CircleOfConfusionPostProcess extends PostProcess {
  118194. /**
  118195. * 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.
  118196. */
  118197. lensSize: number;
  118198. /**
  118199. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  118200. */
  118201. fStop: number;
  118202. /**
  118203. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  118204. */
  118205. focusDistance: number;
  118206. /**
  118207. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  118208. */
  118209. focalLength: number;
  118210. private _depthTexture;
  118211. /**
  118212. * Creates a new instance CircleOfConfusionPostProcess
  118213. * @param name The name of the effect.
  118214. * @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.
  118215. * @param options The required width/height ratio to downsize to before computing the render pass.
  118216. * @param camera The camera to apply the render pass to.
  118217. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118218. * @param engine The engine which the post process will be applied. (default: current engine)
  118219. * @param reusable If the post process can be reused on the same frame. (default: false)
  118220. * @param textureType Type of textures used when performing the post process. (default: 0)
  118221. * @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)
  118222. */
  118223. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  118224. /**
  118225. * 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.
  118226. */
  118227. depthTexture: RenderTargetTexture;
  118228. }
  118229. }
  118230. declare module BABYLON {
  118231. /** @hidden */
  118232. export var colorCorrectionPixelShader: {
  118233. name: string;
  118234. shader: string;
  118235. };
  118236. }
  118237. declare module BABYLON {
  118238. /**
  118239. *
  118240. * This post-process allows the modification of rendered colors by using
  118241. * a 'look-up table' (LUT). This effect is also called Color Grading.
  118242. *
  118243. * The object needs to be provided an url to a texture containing the color
  118244. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  118245. * Use an image editing software to tweak the LUT to match your needs.
  118246. *
  118247. * For an example of a color LUT, see here:
  118248. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  118249. * For explanations on color grading, see here:
  118250. * @see http://udn.epicgames.com/Three/ColorGrading.html
  118251. *
  118252. */
  118253. export class ColorCorrectionPostProcess extends PostProcess {
  118254. private _colorTableTexture;
  118255. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  118256. }
  118257. }
  118258. declare module BABYLON {
  118259. /** @hidden */
  118260. export var convolutionPixelShader: {
  118261. name: string;
  118262. shader: string;
  118263. };
  118264. }
  118265. declare module BABYLON {
  118266. /**
  118267. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  118268. * input texture to perform effects such as edge detection or sharpening
  118269. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  118270. */
  118271. export class ConvolutionPostProcess extends PostProcess {
  118272. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  118273. kernel: number[];
  118274. /**
  118275. * Creates a new instance ConvolutionPostProcess
  118276. * @param name The name of the effect.
  118277. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  118278. * @param options The required width/height ratio to downsize to before computing the render pass.
  118279. * @param camera The camera to apply the render pass to.
  118280. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118281. * @param engine The engine which the post process will be applied. (default: current engine)
  118282. * @param reusable If the post process can be reused on the same frame. (default: false)
  118283. * @param textureType Type of textures used when performing the post process. (default: 0)
  118284. */
  118285. constructor(name: string,
  118286. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  118287. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  118288. /**
  118289. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  118290. */
  118291. static EdgeDetect0Kernel: number[];
  118292. /**
  118293. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  118294. */
  118295. static EdgeDetect1Kernel: number[];
  118296. /**
  118297. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  118298. */
  118299. static EdgeDetect2Kernel: number[];
  118300. /**
  118301. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  118302. */
  118303. static SharpenKernel: number[];
  118304. /**
  118305. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  118306. */
  118307. static EmbossKernel: number[];
  118308. /**
  118309. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  118310. */
  118311. static GaussianKernel: number[];
  118312. }
  118313. }
  118314. declare module BABYLON {
  118315. /**
  118316. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  118317. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  118318. * based on samples that have a large difference in distance than the center pixel.
  118319. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  118320. */
  118321. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  118322. direction: Vector2;
  118323. /**
  118324. * Creates a new instance CircleOfConfusionPostProcess
  118325. * @param name The name of the effect.
  118326. * @param scene The scene the effect belongs to.
  118327. * @param direction The direction the blur should be applied.
  118328. * @param kernel The size of the kernel used to blur.
  118329. * @param options The required width/height ratio to downsize to before computing the render pass.
  118330. * @param camera The camera to apply the render pass to.
  118331. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  118332. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  118333. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118334. * @param engine The engine which the post process will be applied. (default: current engine)
  118335. * @param reusable If the post process can be reused on the same frame. (default: false)
  118336. * @param textureType Type of textures used when performing the post process. (default: 0)
  118337. * @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)
  118338. */
  118339. 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);
  118340. }
  118341. }
  118342. declare module BABYLON {
  118343. /** @hidden */
  118344. export var depthOfFieldMergePixelShader: {
  118345. name: string;
  118346. shader: string;
  118347. };
  118348. }
  118349. declare module BABYLON {
  118350. /**
  118351. * Options to be set when merging outputs from the default pipeline.
  118352. */
  118353. export class DepthOfFieldMergePostProcessOptions {
  118354. /**
  118355. * The original image to merge on top of
  118356. */
  118357. originalFromInput: PostProcess;
  118358. /**
  118359. * Parameters to perform the merge of the depth of field effect
  118360. */
  118361. depthOfField?: {
  118362. circleOfConfusion: PostProcess;
  118363. blurSteps: Array<PostProcess>;
  118364. };
  118365. /**
  118366. * Parameters to perform the merge of bloom effect
  118367. */
  118368. bloom?: {
  118369. blurred: PostProcess;
  118370. weight: number;
  118371. };
  118372. }
  118373. /**
  118374. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  118375. */
  118376. export class DepthOfFieldMergePostProcess extends PostProcess {
  118377. private blurSteps;
  118378. /**
  118379. * Creates a new instance of DepthOfFieldMergePostProcess
  118380. * @param name The name of the effect.
  118381. * @param originalFromInput Post process which's input will be used for the merge.
  118382. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  118383. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  118384. * @param options The required width/height ratio to downsize to before computing the render pass.
  118385. * @param camera The camera to apply the render pass to.
  118386. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118387. * @param engine The engine which the post process will be applied. (default: current engine)
  118388. * @param reusable If the post process can be reused on the same frame. (default: false)
  118389. * @param textureType Type of textures used when performing the post process. (default: 0)
  118390. * @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)
  118391. */
  118392. 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);
  118393. /**
  118394. * Updates the effect with the current post process compile time values and recompiles the shader.
  118395. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  118396. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  118397. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  118398. * @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
  118399. * @param onCompiled Called when the shader has been compiled.
  118400. * @param onError Called if there is an error when compiling a shader.
  118401. */
  118402. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  118403. }
  118404. }
  118405. declare module BABYLON {
  118406. /**
  118407. * Specifies the level of max blur that should be applied when using the depth of field effect
  118408. */
  118409. export enum DepthOfFieldEffectBlurLevel {
  118410. /**
  118411. * Subtle blur
  118412. */
  118413. Low = 0,
  118414. /**
  118415. * Medium blur
  118416. */
  118417. Medium = 1,
  118418. /**
  118419. * Large blur
  118420. */
  118421. High = 2
  118422. }
  118423. /**
  118424. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  118425. */
  118426. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  118427. private _circleOfConfusion;
  118428. /**
  118429. * @hidden Internal, blurs from high to low
  118430. */
  118431. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  118432. private _depthOfFieldBlurY;
  118433. private _dofMerge;
  118434. /**
  118435. * @hidden Internal post processes in depth of field effect
  118436. */
  118437. _effects: Array<PostProcess>;
  118438. /**
  118439. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  118440. */
  118441. focalLength: number;
  118442. /**
  118443. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  118444. */
  118445. fStop: number;
  118446. /**
  118447. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  118448. */
  118449. focusDistance: number;
  118450. /**
  118451. * 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.
  118452. */
  118453. lensSize: number;
  118454. /**
  118455. * Creates a new instance DepthOfFieldEffect
  118456. * @param scene The scene the effect belongs to.
  118457. * @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.
  118458. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  118459. * @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)
  118460. */
  118461. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  118462. /**
  118463. * Get the current class name of the current effet
  118464. * @returns "DepthOfFieldEffect"
  118465. */
  118466. getClassName(): string;
  118467. /**
  118468. * 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.
  118469. */
  118470. depthTexture: RenderTargetTexture;
  118471. /**
  118472. * Disposes each of the internal effects for a given camera.
  118473. * @param camera The camera to dispose the effect on.
  118474. */
  118475. disposeEffects(camera: Camera): void;
  118476. /**
  118477. * @hidden Internal
  118478. */
  118479. _updateEffects(): void;
  118480. /**
  118481. * Internal
  118482. * @returns if all the contained post processes are ready.
  118483. * @hidden
  118484. */
  118485. _isReady(): boolean;
  118486. }
  118487. }
  118488. declare module BABYLON {
  118489. /** @hidden */
  118490. export var displayPassPixelShader: {
  118491. name: string;
  118492. shader: string;
  118493. };
  118494. }
  118495. declare module BABYLON {
  118496. /**
  118497. * DisplayPassPostProcess which produces an output the same as it's input
  118498. */
  118499. export class DisplayPassPostProcess extends PostProcess {
  118500. /**
  118501. * Creates the DisplayPassPostProcess
  118502. * @param name The name of the effect.
  118503. * @param options The required width/height ratio to downsize to before computing the render pass.
  118504. * @param camera The camera to apply the render pass to.
  118505. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118506. * @param engine The engine which the post process will be applied. (default: current engine)
  118507. * @param reusable If the post process can be reused on the same frame. (default: false)
  118508. */
  118509. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  118510. }
  118511. }
  118512. declare module BABYLON {
  118513. /** @hidden */
  118514. export var filterPixelShader: {
  118515. name: string;
  118516. shader: string;
  118517. };
  118518. }
  118519. declare module BABYLON {
  118520. /**
  118521. * Applies a kernel filter to the image
  118522. */
  118523. export class FilterPostProcess extends PostProcess {
  118524. /** The matrix to be applied to the image */
  118525. kernelMatrix: Matrix;
  118526. /**
  118527. *
  118528. * @param name The name of the effect.
  118529. * @param kernelMatrix The matrix to be applied to the image
  118530. * @param options The required width/height ratio to downsize to before computing the render pass.
  118531. * @param camera The camera to apply the render pass to.
  118532. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118533. * @param engine The engine which the post process will be applied. (default: current engine)
  118534. * @param reusable If the post process can be reused on the same frame. (default: false)
  118535. */
  118536. constructor(name: string,
  118537. /** The matrix to be applied to the image */
  118538. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  118539. }
  118540. }
  118541. declare module BABYLON {
  118542. /** @hidden */
  118543. export var fxaaPixelShader: {
  118544. name: string;
  118545. shader: string;
  118546. };
  118547. }
  118548. declare module BABYLON {
  118549. /** @hidden */
  118550. export var fxaaVertexShader: {
  118551. name: string;
  118552. shader: string;
  118553. };
  118554. }
  118555. declare module BABYLON {
  118556. /**
  118557. * Fxaa post process
  118558. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  118559. */
  118560. export class FxaaPostProcess extends PostProcess {
  118561. /** @hidden */
  118562. texelWidth: number;
  118563. /** @hidden */
  118564. texelHeight: number;
  118565. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  118566. private _getDefines;
  118567. }
  118568. }
  118569. declare module BABYLON {
  118570. /** @hidden */
  118571. export var grainPixelShader: {
  118572. name: string;
  118573. shader: string;
  118574. };
  118575. }
  118576. declare module BABYLON {
  118577. /**
  118578. * The GrainPostProcess adds noise to the image at mid luminance levels
  118579. */
  118580. export class GrainPostProcess extends PostProcess {
  118581. /**
  118582. * The intensity of the grain added (default: 30)
  118583. */
  118584. intensity: number;
  118585. /**
  118586. * If the grain should be randomized on every frame
  118587. */
  118588. animated: boolean;
  118589. /**
  118590. * Creates a new instance of @see GrainPostProcess
  118591. * @param name The name of the effect.
  118592. * @param options The required width/height ratio to downsize to before computing the render pass.
  118593. * @param camera The camera to apply the render pass to.
  118594. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118595. * @param engine The engine which the post process will be applied. (default: current engine)
  118596. * @param reusable If the post process can be reused on the same frame. (default: false)
  118597. * @param textureType Type of textures used when performing the post process. (default: 0)
  118598. * @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)
  118599. */
  118600. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  118601. }
  118602. }
  118603. declare module BABYLON {
  118604. /** @hidden */
  118605. export var highlightsPixelShader: {
  118606. name: string;
  118607. shader: string;
  118608. };
  118609. }
  118610. declare module BABYLON {
  118611. /**
  118612. * Extracts highlights from the image
  118613. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  118614. */
  118615. export class HighlightsPostProcess extends PostProcess {
  118616. /**
  118617. * Extracts highlights from the image
  118618. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  118619. * @param name The name of the effect.
  118620. * @param options The required width/height ratio to downsize to before computing the render pass.
  118621. * @param camera The camera to apply the render pass to.
  118622. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118623. * @param engine The engine which the post process will be applied. (default: current engine)
  118624. * @param reusable If the post process can be reused on the same frame. (default: false)
  118625. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  118626. */
  118627. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  118628. }
  118629. }
  118630. declare module BABYLON {
  118631. /** @hidden */
  118632. export var mrtFragmentDeclaration: {
  118633. name: string;
  118634. shader: string;
  118635. };
  118636. }
  118637. declare module BABYLON {
  118638. /** @hidden */
  118639. export var geometryPixelShader: {
  118640. name: string;
  118641. shader: string;
  118642. };
  118643. }
  118644. declare module BABYLON {
  118645. /** @hidden */
  118646. export var geometryVertexShader: {
  118647. name: string;
  118648. shader: string;
  118649. };
  118650. }
  118651. declare module BABYLON {
  118652. /** @hidden */
  118653. interface ISavedTransformationMatrix {
  118654. world: Matrix;
  118655. viewProjection: Matrix;
  118656. }
  118657. /**
  118658. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  118659. */
  118660. export class GeometryBufferRenderer {
  118661. /**
  118662. * Constant used to retrieve the position texture index in the G-Buffer textures array
  118663. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  118664. */
  118665. static readonly POSITION_TEXTURE_TYPE: number;
  118666. /**
  118667. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  118668. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  118669. */
  118670. static readonly VELOCITY_TEXTURE_TYPE: number;
  118671. /**
  118672. * Dictionary used to store the previous transformation matrices of each rendered mesh
  118673. * in order to compute objects velocities when enableVelocity is set to "true"
  118674. * @hidden
  118675. */
  118676. _previousTransformationMatrices: {
  118677. [index: number]: ISavedTransformationMatrix;
  118678. };
  118679. /**
  118680. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  118681. * in order to compute objects velocities when enableVelocity is set to "true"
  118682. * @hidden
  118683. */
  118684. _previousBonesTransformationMatrices: {
  118685. [index: number]: Float32Array;
  118686. };
  118687. /**
  118688. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  118689. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  118690. */
  118691. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  118692. private _scene;
  118693. private _multiRenderTarget;
  118694. private _ratio;
  118695. private _enablePosition;
  118696. private _enableVelocity;
  118697. private _positionIndex;
  118698. private _velocityIndex;
  118699. protected _effect: Effect;
  118700. protected _cachedDefines: string;
  118701. /**
  118702. * Set the render list (meshes to be rendered) used in the G buffer.
  118703. */
  118704. renderList: Mesh[];
  118705. /**
  118706. * Gets wether or not G buffer are supported by the running hardware.
  118707. * This requires draw buffer supports
  118708. */
  118709. readonly isSupported: boolean;
  118710. /**
  118711. * Returns the index of the given texture type in the G-Buffer textures array
  118712. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  118713. * @returns the index of the given texture type in the G-Buffer textures array
  118714. */
  118715. getTextureIndex(textureType: number): number;
  118716. /**
  118717. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  118718. */
  118719. /**
  118720. * Sets whether or not objects positions are enabled for the G buffer.
  118721. */
  118722. enablePosition: boolean;
  118723. /**
  118724. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  118725. */
  118726. /**
  118727. * Sets wether or not objects velocities are enabled for the G buffer.
  118728. */
  118729. enableVelocity: boolean;
  118730. /**
  118731. * Gets the scene associated with the buffer.
  118732. */
  118733. readonly scene: Scene;
  118734. /**
  118735. * Gets the ratio used by the buffer during its creation.
  118736. * How big is the buffer related to the main canvas.
  118737. */
  118738. readonly ratio: number;
  118739. /** @hidden */
  118740. static _SceneComponentInitialization: (scene: Scene) => void;
  118741. /**
  118742. * Creates a new G Buffer for the scene
  118743. * @param scene The scene the buffer belongs to
  118744. * @param ratio How big is the buffer related to the main canvas.
  118745. */
  118746. constructor(scene: Scene, ratio?: number);
  118747. /**
  118748. * Checks wether everything is ready to render a submesh to the G buffer.
  118749. * @param subMesh the submesh to check readiness for
  118750. * @param useInstances is the mesh drawn using instance or not
  118751. * @returns true if ready otherwise false
  118752. */
  118753. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  118754. /**
  118755. * Gets the current underlying G Buffer.
  118756. * @returns the buffer
  118757. */
  118758. getGBuffer(): MultiRenderTarget;
  118759. /**
  118760. * Gets the number of samples used to render the buffer (anti aliasing).
  118761. */
  118762. /**
  118763. * Sets the number of samples used to render the buffer (anti aliasing).
  118764. */
  118765. samples: number;
  118766. /**
  118767. * Disposes the renderer and frees up associated resources.
  118768. */
  118769. dispose(): void;
  118770. protected _createRenderTargets(): void;
  118771. private _copyBonesTransformationMatrices;
  118772. }
  118773. }
  118774. declare module BABYLON {
  118775. interface Scene {
  118776. /** @hidden (Backing field) */
  118777. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  118778. /**
  118779. * Gets or Sets the current geometry buffer associated to the scene.
  118780. */
  118781. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  118782. /**
  118783. * Enables a GeometryBufferRender and associates it with the scene
  118784. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  118785. * @returns the GeometryBufferRenderer
  118786. */
  118787. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  118788. /**
  118789. * Disables the GeometryBufferRender associated with the scene
  118790. */
  118791. disableGeometryBufferRenderer(): void;
  118792. }
  118793. /**
  118794. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  118795. * in several rendering techniques.
  118796. */
  118797. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  118798. /**
  118799. * The component name helpful to identify the component in the list of scene components.
  118800. */
  118801. readonly name: string;
  118802. /**
  118803. * The scene the component belongs to.
  118804. */
  118805. scene: Scene;
  118806. /**
  118807. * Creates a new instance of the component for the given scene
  118808. * @param scene Defines the scene to register the component in
  118809. */
  118810. constructor(scene: Scene);
  118811. /**
  118812. * Registers the component in a given scene
  118813. */
  118814. register(): void;
  118815. /**
  118816. * Rebuilds the elements related to this component in case of
  118817. * context lost for instance.
  118818. */
  118819. rebuild(): void;
  118820. /**
  118821. * Disposes the component and the associated ressources
  118822. */
  118823. dispose(): void;
  118824. private _gatherRenderTargets;
  118825. }
  118826. }
  118827. declare module BABYLON {
  118828. /** @hidden */
  118829. export var motionBlurPixelShader: {
  118830. name: string;
  118831. shader: string;
  118832. };
  118833. }
  118834. declare module BABYLON {
  118835. /**
  118836. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  118837. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  118838. * As an example, all you have to do is to create the post-process:
  118839. * var mb = new BABYLON.MotionBlurPostProcess(
  118840. * 'mb', // The name of the effect.
  118841. * scene, // The scene containing the objects to blur according to their velocity.
  118842. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  118843. * camera // The camera to apply the render pass to.
  118844. * );
  118845. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  118846. */
  118847. export class MotionBlurPostProcess extends PostProcess {
  118848. /**
  118849. * Defines how much the image is blurred by the movement. Default value is equal to 1
  118850. */
  118851. motionStrength: number;
  118852. /**
  118853. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  118854. */
  118855. /**
  118856. * Sets the number of iterations to be used for motion blur quality
  118857. */
  118858. motionBlurSamples: number;
  118859. private _motionBlurSamples;
  118860. private _geometryBufferRenderer;
  118861. /**
  118862. * Creates a new instance MotionBlurPostProcess
  118863. * @param name The name of the effect.
  118864. * @param scene The scene containing the objects to blur according to their velocity.
  118865. * @param options The required width/height ratio to downsize to before computing the render pass.
  118866. * @param camera The camera to apply the render pass to.
  118867. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118868. * @param engine The engine which the post process will be applied. (default: current engine)
  118869. * @param reusable If the post process can be reused on the same frame. (default: false)
  118870. * @param textureType Type of textures used when performing the post process. (default: 0)
  118871. * @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)
  118872. */
  118873. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  118874. /**
  118875. * Excludes the given skinned mesh from computing bones velocities.
  118876. * 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.
  118877. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  118878. */
  118879. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  118880. /**
  118881. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  118882. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  118883. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  118884. */
  118885. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  118886. /**
  118887. * Disposes the post process.
  118888. * @param camera The camera to dispose the post process on.
  118889. */
  118890. dispose(camera?: Camera): void;
  118891. }
  118892. }
  118893. declare module BABYLON {
  118894. /** @hidden */
  118895. export var refractionPixelShader: {
  118896. name: string;
  118897. shader: string;
  118898. };
  118899. }
  118900. declare module BABYLON {
  118901. /**
  118902. * Post process which applies a refractin texture
  118903. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  118904. */
  118905. export class RefractionPostProcess extends PostProcess {
  118906. /** the base color of the refraction (used to taint the rendering) */
  118907. color: Color3;
  118908. /** simulated refraction depth */
  118909. depth: number;
  118910. /** the coefficient of the base color (0 to remove base color tainting) */
  118911. colorLevel: number;
  118912. private _refTexture;
  118913. private _ownRefractionTexture;
  118914. /**
  118915. * Gets or sets the refraction texture
  118916. * Please note that you are responsible for disposing the texture if you set it manually
  118917. */
  118918. refractionTexture: Texture;
  118919. /**
  118920. * Initializes the RefractionPostProcess
  118921. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  118922. * @param name The name of the effect.
  118923. * @param refractionTextureUrl Url of the refraction texture to use
  118924. * @param color the base color of the refraction (used to taint the rendering)
  118925. * @param depth simulated refraction depth
  118926. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  118927. * @param camera The camera to apply the render pass to.
  118928. * @param options The required width/height ratio to downsize to before computing the render pass.
  118929. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118930. * @param engine The engine which the post process will be applied. (default: current engine)
  118931. * @param reusable If the post process can be reused on the same frame. (default: false)
  118932. */
  118933. constructor(name: string, refractionTextureUrl: string,
  118934. /** the base color of the refraction (used to taint the rendering) */
  118935. color: Color3,
  118936. /** simulated refraction depth */
  118937. depth: number,
  118938. /** the coefficient of the base color (0 to remove base color tainting) */
  118939. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  118940. /**
  118941. * Disposes of the post process
  118942. * @param camera Camera to dispose post process on
  118943. */
  118944. dispose(camera: Camera): void;
  118945. }
  118946. }
  118947. declare module BABYLON {
  118948. /** @hidden */
  118949. export var sharpenPixelShader: {
  118950. name: string;
  118951. shader: string;
  118952. };
  118953. }
  118954. declare module BABYLON {
  118955. /**
  118956. * The SharpenPostProcess applies a sharpen kernel to every pixel
  118957. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  118958. */
  118959. export class SharpenPostProcess extends PostProcess {
  118960. /**
  118961. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  118962. */
  118963. colorAmount: number;
  118964. /**
  118965. * How much sharpness should be applied (default: 0.3)
  118966. */
  118967. edgeAmount: number;
  118968. /**
  118969. * Creates a new instance ConvolutionPostProcess
  118970. * @param name The name of the effect.
  118971. * @param options The required width/height ratio to downsize to before computing the render pass.
  118972. * @param camera The camera to apply the render pass to.
  118973. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118974. * @param engine The engine which the post process will be applied. (default: current engine)
  118975. * @param reusable If the post process can be reused on the same frame. (default: false)
  118976. * @param textureType Type of textures used when performing the post process. (default: 0)
  118977. * @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)
  118978. */
  118979. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  118980. }
  118981. }
  118982. declare module BABYLON {
  118983. /**
  118984. * PostProcessRenderPipeline
  118985. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  118986. */
  118987. export class PostProcessRenderPipeline {
  118988. private engine;
  118989. private _renderEffects;
  118990. private _renderEffectsForIsolatedPass;
  118991. /**
  118992. * List of inspectable custom properties (used by the Inspector)
  118993. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  118994. */
  118995. inspectableCustomProperties: IInspectable[];
  118996. /**
  118997. * @hidden
  118998. */
  118999. protected _cameras: Camera[];
  119000. /** @hidden */
  119001. _name: string;
  119002. /**
  119003. * Gets pipeline name
  119004. */
  119005. readonly name: string;
  119006. /**
  119007. * Initializes a PostProcessRenderPipeline
  119008. * @param engine engine to add the pipeline to
  119009. * @param name name of the pipeline
  119010. */
  119011. constructor(engine: Engine, name: string);
  119012. /**
  119013. * Gets the class name
  119014. * @returns "PostProcessRenderPipeline"
  119015. */
  119016. getClassName(): string;
  119017. /**
  119018. * If all the render effects in the pipeline are supported
  119019. */
  119020. readonly isSupported: boolean;
  119021. /**
  119022. * Adds an effect to the pipeline
  119023. * @param renderEffect the effect to add
  119024. */
  119025. addEffect(renderEffect: PostProcessRenderEffect): void;
  119026. /** @hidden */
  119027. _rebuild(): void;
  119028. /** @hidden */
  119029. _enableEffect(renderEffectName: string, cameras: Camera): void;
  119030. /** @hidden */
  119031. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  119032. /** @hidden */
  119033. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  119034. /** @hidden */
  119035. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  119036. /** @hidden */
  119037. _attachCameras(cameras: Camera, unique: boolean): void;
  119038. /** @hidden */
  119039. _attachCameras(cameras: Camera[], unique: boolean): void;
  119040. /** @hidden */
  119041. _detachCameras(cameras: Camera): void;
  119042. /** @hidden */
  119043. _detachCameras(cameras: Nullable<Camera[]>): void;
  119044. /** @hidden */
  119045. _update(): void;
  119046. /** @hidden */
  119047. _reset(): void;
  119048. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  119049. /**
  119050. * Disposes of the pipeline
  119051. */
  119052. dispose(): void;
  119053. }
  119054. }
  119055. declare module BABYLON {
  119056. /**
  119057. * PostProcessRenderPipelineManager class
  119058. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  119059. */
  119060. export class PostProcessRenderPipelineManager {
  119061. private _renderPipelines;
  119062. /**
  119063. * Initializes a PostProcessRenderPipelineManager
  119064. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  119065. */
  119066. constructor();
  119067. /**
  119068. * Gets the list of supported render pipelines
  119069. */
  119070. readonly supportedPipelines: PostProcessRenderPipeline[];
  119071. /**
  119072. * Adds a pipeline to the manager
  119073. * @param renderPipeline The pipeline to add
  119074. */
  119075. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  119076. /**
  119077. * Attaches a camera to the pipeline
  119078. * @param renderPipelineName The name of the pipeline to attach to
  119079. * @param cameras the camera to attach
  119080. * @param unique if the camera can be attached multiple times to the pipeline
  119081. */
  119082. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  119083. /**
  119084. * Detaches a camera from the pipeline
  119085. * @param renderPipelineName The name of the pipeline to detach from
  119086. * @param cameras the camera to detach
  119087. */
  119088. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  119089. /**
  119090. * Enables an effect by name on a pipeline
  119091. * @param renderPipelineName the name of the pipeline to enable the effect in
  119092. * @param renderEffectName the name of the effect to enable
  119093. * @param cameras the cameras that the effect should be enabled on
  119094. */
  119095. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  119096. /**
  119097. * Disables an effect by name on a pipeline
  119098. * @param renderPipelineName the name of the pipeline to disable the effect in
  119099. * @param renderEffectName the name of the effect to disable
  119100. * @param cameras the cameras that the effect should be disabled on
  119101. */
  119102. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  119103. /**
  119104. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  119105. */
  119106. update(): void;
  119107. /** @hidden */
  119108. _rebuild(): void;
  119109. /**
  119110. * Disposes of the manager and pipelines
  119111. */
  119112. dispose(): void;
  119113. }
  119114. }
  119115. declare module BABYLON {
  119116. interface Scene {
  119117. /** @hidden (Backing field) */
  119118. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  119119. /**
  119120. * Gets the postprocess render pipeline manager
  119121. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  119122. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  119123. */
  119124. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  119125. }
  119126. /**
  119127. * Defines the Render Pipeline scene component responsible to rendering pipelines
  119128. */
  119129. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  119130. /**
  119131. * The component name helpfull to identify the component in the list of scene components.
  119132. */
  119133. readonly name: string;
  119134. /**
  119135. * The scene the component belongs to.
  119136. */
  119137. scene: Scene;
  119138. /**
  119139. * Creates a new instance of the component for the given scene
  119140. * @param scene Defines the scene to register the component in
  119141. */
  119142. constructor(scene: Scene);
  119143. /**
  119144. * Registers the component in a given scene
  119145. */
  119146. register(): void;
  119147. /**
  119148. * Rebuilds the elements related to this component in case of
  119149. * context lost for instance.
  119150. */
  119151. rebuild(): void;
  119152. /**
  119153. * Disposes the component and the associated ressources
  119154. */
  119155. dispose(): void;
  119156. private _gatherRenderTargets;
  119157. }
  119158. }
  119159. declare module BABYLON {
  119160. /**
  119161. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  119162. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  119163. */
  119164. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  119165. private _scene;
  119166. private _camerasToBeAttached;
  119167. /**
  119168. * ID of the sharpen post process,
  119169. */
  119170. private readonly SharpenPostProcessId;
  119171. /**
  119172. * @ignore
  119173. * ID of the image processing post process;
  119174. */
  119175. readonly ImageProcessingPostProcessId: string;
  119176. /**
  119177. * @ignore
  119178. * ID of the Fast Approximate Anti-Aliasing post process;
  119179. */
  119180. readonly FxaaPostProcessId: string;
  119181. /**
  119182. * ID of the chromatic aberration post process,
  119183. */
  119184. private readonly ChromaticAberrationPostProcessId;
  119185. /**
  119186. * ID of the grain post process
  119187. */
  119188. private readonly GrainPostProcessId;
  119189. /**
  119190. * Sharpen post process which will apply a sharpen convolution to enhance edges
  119191. */
  119192. sharpen: SharpenPostProcess;
  119193. private _sharpenEffect;
  119194. private bloom;
  119195. /**
  119196. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  119197. */
  119198. depthOfField: DepthOfFieldEffect;
  119199. /**
  119200. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  119201. */
  119202. fxaa: FxaaPostProcess;
  119203. /**
  119204. * Image post processing pass used to perform operations such as tone mapping or color grading.
  119205. */
  119206. imageProcessing: ImageProcessingPostProcess;
  119207. /**
  119208. * Chromatic aberration post process which will shift rgb colors in the image
  119209. */
  119210. chromaticAberration: ChromaticAberrationPostProcess;
  119211. private _chromaticAberrationEffect;
  119212. /**
  119213. * Grain post process which add noise to the image
  119214. */
  119215. grain: GrainPostProcess;
  119216. private _grainEffect;
  119217. /**
  119218. * Glow post process which adds a glow to emissive areas of the image
  119219. */
  119220. private _glowLayer;
  119221. /**
  119222. * Animations which can be used to tweak settings over a period of time
  119223. */
  119224. animations: Animation[];
  119225. private _imageProcessingConfigurationObserver;
  119226. private _sharpenEnabled;
  119227. private _bloomEnabled;
  119228. private _depthOfFieldEnabled;
  119229. private _depthOfFieldBlurLevel;
  119230. private _fxaaEnabled;
  119231. private _imageProcessingEnabled;
  119232. private _defaultPipelineTextureType;
  119233. private _bloomScale;
  119234. private _chromaticAberrationEnabled;
  119235. private _grainEnabled;
  119236. private _buildAllowed;
  119237. /**
  119238. * Gets active scene
  119239. */
  119240. readonly scene: Scene;
  119241. /**
  119242. * Enable or disable the sharpen process from the pipeline
  119243. */
  119244. sharpenEnabled: boolean;
  119245. private _resizeObserver;
  119246. private _hardwareScaleLevel;
  119247. private _bloomKernel;
  119248. /**
  119249. * Specifies the size of the bloom blur kernel, relative to the final output size
  119250. */
  119251. bloomKernel: number;
  119252. /**
  119253. * Specifies the weight of the bloom in the final rendering
  119254. */
  119255. private _bloomWeight;
  119256. /**
  119257. * Specifies the luma threshold for the area that will be blurred by the bloom
  119258. */
  119259. private _bloomThreshold;
  119260. private _hdr;
  119261. /**
  119262. * The strength of the bloom.
  119263. */
  119264. bloomWeight: number;
  119265. /**
  119266. * The strength of the bloom.
  119267. */
  119268. bloomThreshold: number;
  119269. /**
  119270. * The scale of the bloom, lower value will provide better performance.
  119271. */
  119272. bloomScale: number;
  119273. /**
  119274. * Enable or disable the bloom from the pipeline
  119275. */
  119276. bloomEnabled: boolean;
  119277. private _rebuildBloom;
  119278. /**
  119279. * If the depth of field is enabled.
  119280. */
  119281. depthOfFieldEnabled: boolean;
  119282. /**
  119283. * Blur level of the depth of field effect. (Higher blur will effect performance)
  119284. */
  119285. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  119286. /**
  119287. * If the anti aliasing is enabled.
  119288. */
  119289. fxaaEnabled: boolean;
  119290. private _samples;
  119291. /**
  119292. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  119293. */
  119294. samples: number;
  119295. /**
  119296. * If image processing is enabled.
  119297. */
  119298. imageProcessingEnabled: boolean;
  119299. /**
  119300. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  119301. */
  119302. glowLayerEnabled: boolean;
  119303. /**
  119304. * Gets the glow layer (or null if not defined)
  119305. */
  119306. readonly glowLayer: Nullable<GlowLayer>;
  119307. /**
  119308. * Enable or disable the chromaticAberration process from the pipeline
  119309. */
  119310. chromaticAberrationEnabled: boolean;
  119311. /**
  119312. * Enable or disable the grain process from the pipeline
  119313. */
  119314. grainEnabled: boolean;
  119315. /**
  119316. * @constructor
  119317. * @param name - The rendering pipeline name (default: "")
  119318. * @param hdr - If high dynamic range textures should be used (default: true)
  119319. * @param scene - The scene linked to this pipeline (default: the last created scene)
  119320. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  119321. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  119322. */
  119323. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  119324. /**
  119325. * Get the class name
  119326. * @returns "DefaultRenderingPipeline"
  119327. */
  119328. getClassName(): string;
  119329. /**
  119330. * Force the compilation of the entire pipeline.
  119331. */
  119332. prepare(): void;
  119333. private _hasCleared;
  119334. private _prevPostProcess;
  119335. private _prevPrevPostProcess;
  119336. private _setAutoClearAndTextureSharing;
  119337. private _depthOfFieldSceneObserver;
  119338. private _buildPipeline;
  119339. private _disposePostProcesses;
  119340. /**
  119341. * Adds a camera to the pipeline
  119342. * @param camera the camera to be added
  119343. */
  119344. addCamera(camera: Camera): void;
  119345. /**
  119346. * Removes a camera from the pipeline
  119347. * @param camera the camera to remove
  119348. */
  119349. removeCamera(camera: Camera): void;
  119350. /**
  119351. * Dispose of the pipeline and stop all post processes
  119352. */
  119353. dispose(): void;
  119354. /**
  119355. * Serialize the rendering pipeline (Used when exporting)
  119356. * @returns the serialized object
  119357. */
  119358. serialize(): any;
  119359. /**
  119360. * Parse the serialized pipeline
  119361. * @param source Source pipeline.
  119362. * @param scene The scene to load the pipeline to.
  119363. * @param rootUrl The URL of the serialized pipeline.
  119364. * @returns An instantiated pipeline from the serialized object.
  119365. */
  119366. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  119367. }
  119368. }
  119369. declare module BABYLON {
  119370. /** @hidden */
  119371. export var lensHighlightsPixelShader: {
  119372. name: string;
  119373. shader: string;
  119374. };
  119375. }
  119376. declare module BABYLON {
  119377. /** @hidden */
  119378. export var depthOfFieldPixelShader: {
  119379. name: string;
  119380. shader: string;
  119381. };
  119382. }
  119383. declare module BABYLON {
  119384. /**
  119385. * BABYLON.JS Chromatic Aberration GLSL Shader
  119386. * Author: Olivier Guyot
  119387. * Separates very slightly R, G and B colors on the edges of the screen
  119388. * Inspired by Francois Tarlier & Martins Upitis
  119389. */
  119390. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  119391. /**
  119392. * @ignore
  119393. * The chromatic aberration PostProcess id in the pipeline
  119394. */
  119395. LensChromaticAberrationEffect: string;
  119396. /**
  119397. * @ignore
  119398. * The highlights enhancing PostProcess id in the pipeline
  119399. */
  119400. HighlightsEnhancingEffect: string;
  119401. /**
  119402. * @ignore
  119403. * The depth-of-field PostProcess id in the pipeline
  119404. */
  119405. LensDepthOfFieldEffect: string;
  119406. private _scene;
  119407. private _depthTexture;
  119408. private _grainTexture;
  119409. private _chromaticAberrationPostProcess;
  119410. private _highlightsPostProcess;
  119411. private _depthOfFieldPostProcess;
  119412. private _edgeBlur;
  119413. private _grainAmount;
  119414. private _chromaticAberration;
  119415. private _distortion;
  119416. private _highlightsGain;
  119417. private _highlightsThreshold;
  119418. private _dofDistance;
  119419. private _dofAperture;
  119420. private _dofDarken;
  119421. private _dofPentagon;
  119422. private _blurNoise;
  119423. /**
  119424. * @constructor
  119425. *
  119426. * Effect parameters are as follow:
  119427. * {
  119428. * chromatic_aberration: number; // from 0 to x (1 for realism)
  119429. * edge_blur: number; // from 0 to x (1 for realism)
  119430. * distortion: number; // from 0 to x (1 for realism)
  119431. * grain_amount: number; // from 0 to 1
  119432. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  119433. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  119434. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  119435. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  119436. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  119437. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  119438. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  119439. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  119440. * }
  119441. * Note: if an effect parameter is unset, effect is disabled
  119442. *
  119443. * @param name The rendering pipeline name
  119444. * @param parameters - An object containing all parameters (see above)
  119445. * @param scene The scene linked to this pipeline
  119446. * @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)
  119447. * @param cameras The array of cameras that the rendering pipeline will be attached to
  119448. */
  119449. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  119450. /**
  119451. * Get the class name
  119452. * @returns "LensRenderingPipeline"
  119453. */
  119454. getClassName(): string;
  119455. /**
  119456. * Gets associated scene
  119457. */
  119458. readonly scene: Scene;
  119459. /**
  119460. * Gets or sets the edge blur
  119461. */
  119462. edgeBlur: number;
  119463. /**
  119464. * Gets or sets the grain amount
  119465. */
  119466. grainAmount: number;
  119467. /**
  119468. * Gets or sets the chromatic aberration amount
  119469. */
  119470. chromaticAberration: number;
  119471. /**
  119472. * Gets or sets the depth of field aperture
  119473. */
  119474. dofAperture: number;
  119475. /**
  119476. * Gets or sets the edge distortion
  119477. */
  119478. edgeDistortion: number;
  119479. /**
  119480. * Gets or sets the depth of field distortion
  119481. */
  119482. dofDistortion: number;
  119483. /**
  119484. * Gets or sets the darken out of focus amount
  119485. */
  119486. darkenOutOfFocus: number;
  119487. /**
  119488. * Gets or sets a boolean indicating if blur noise is enabled
  119489. */
  119490. blurNoise: boolean;
  119491. /**
  119492. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  119493. */
  119494. pentagonBokeh: boolean;
  119495. /**
  119496. * Gets or sets the highlight grain amount
  119497. */
  119498. highlightsGain: number;
  119499. /**
  119500. * Gets or sets the highlight threshold
  119501. */
  119502. highlightsThreshold: number;
  119503. /**
  119504. * Sets the amount of blur at the edges
  119505. * @param amount blur amount
  119506. */
  119507. setEdgeBlur(amount: number): void;
  119508. /**
  119509. * Sets edge blur to 0
  119510. */
  119511. disableEdgeBlur(): void;
  119512. /**
  119513. * Sets the amout of grain
  119514. * @param amount Amount of grain
  119515. */
  119516. setGrainAmount(amount: number): void;
  119517. /**
  119518. * Set grain amount to 0
  119519. */
  119520. disableGrain(): void;
  119521. /**
  119522. * Sets the chromatic aberration amount
  119523. * @param amount amount of chromatic aberration
  119524. */
  119525. setChromaticAberration(amount: number): void;
  119526. /**
  119527. * Sets chromatic aberration amount to 0
  119528. */
  119529. disableChromaticAberration(): void;
  119530. /**
  119531. * Sets the EdgeDistortion amount
  119532. * @param amount amount of EdgeDistortion
  119533. */
  119534. setEdgeDistortion(amount: number): void;
  119535. /**
  119536. * Sets edge distortion to 0
  119537. */
  119538. disableEdgeDistortion(): void;
  119539. /**
  119540. * Sets the FocusDistance amount
  119541. * @param amount amount of FocusDistance
  119542. */
  119543. setFocusDistance(amount: number): void;
  119544. /**
  119545. * Disables depth of field
  119546. */
  119547. disableDepthOfField(): void;
  119548. /**
  119549. * Sets the Aperture amount
  119550. * @param amount amount of Aperture
  119551. */
  119552. setAperture(amount: number): void;
  119553. /**
  119554. * Sets the DarkenOutOfFocus amount
  119555. * @param amount amount of DarkenOutOfFocus
  119556. */
  119557. setDarkenOutOfFocus(amount: number): void;
  119558. private _pentagonBokehIsEnabled;
  119559. /**
  119560. * Creates a pentagon bokeh effect
  119561. */
  119562. enablePentagonBokeh(): void;
  119563. /**
  119564. * Disables the pentagon bokeh effect
  119565. */
  119566. disablePentagonBokeh(): void;
  119567. /**
  119568. * Enables noise blur
  119569. */
  119570. enableNoiseBlur(): void;
  119571. /**
  119572. * Disables noise blur
  119573. */
  119574. disableNoiseBlur(): void;
  119575. /**
  119576. * Sets the HighlightsGain amount
  119577. * @param amount amount of HighlightsGain
  119578. */
  119579. setHighlightsGain(amount: number): void;
  119580. /**
  119581. * Sets the HighlightsThreshold amount
  119582. * @param amount amount of HighlightsThreshold
  119583. */
  119584. setHighlightsThreshold(amount: number): void;
  119585. /**
  119586. * Disables highlights
  119587. */
  119588. disableHighlights(): void;
  119589. /**
  119590. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  119591. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  119592. */
  119593. dispose(disableDepthRender?: boolean): void;
  119594. private _createChromaticAberrationPostProcess;
  119595. private _createHighlightsPostProcess;
  119596. private _createDepthOfFieldPostProcess;
  119597. private _createGrainTexture;
  119598. }
  119599. }
  119600. declare module BABYLON {
  119601. /** @hidden */
  119602. export var ssao2PixelShader: {
  119603. name: string;
  119604. shader: string;
  119605. };
  119606. }
  119607. declare module BABYLON {
  119608. /** @hidden */
  119609. export var ssaoCombinePixelShader: {
  119610. name: string;
  119611. shader: string;
  119612. };
  119613. }
  119614. declare module BABYLON {
  119615. /**
  119616. * Render pipeline to produce ssao effect
  119617. */
  119618. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  119619. /**
  119620. * @ignore
  119621. * The PassPostProcess id in the pipeline that contains the original scene color
  119622. */
  119623. SSAOOriginalSceneColorEffect: string;
  119624. /**
  119625. * @ignore
  119626. * The SSAO PostProcess id in the pipeline
  119627. */
  119628. SSAORenderEffect: string;
  119629. /**
  119630. * @ignore
  119631. * The horizontal blur PostProcess id in the pipeline
  119632. */
  119633. SSAOBlurHRenderEffect: string;
  119634. /**
  119635. * @ignore
  119636. * The vertical blur PostProcess id in the pipeline
  119637. */
  119638. SSAOBlurVRenderEffect: string;
  119639. /**
  119640. * @ignore
  119641. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  119642. */
  119643. SSAOCombineRenderEffect: string;
  119644. /**
  119645. * The output strength of the SSAO post-process. Default value is 1.0.
  119646. */
  119647. totalStrength: number;
  119648. /**
  119649. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  119650. */
  119651. maxZ: number;
  119652. /**
  119653. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  119654. */
  119655. minZAspect: number;
  119656. private _samples;
  119657. /**
  119658. * Number of samples used for the SSAO calculations. Default value is 8
  119659. */
  119660. samples: number;
  119661. private _textureSamples;
  119662. /**
  119663. * Number of samples to use for antialiasing
  119664. */
  119665. textureSamples: number;
  119666. /**
  119667. * Ratio object used for SSAO ratio and blur ratio
  119668. */
  119669. private _ratio;
  119670. /**
  119671. * Dynamically generated sphere sampler.
  119672. */
  119673. private _sampleSphere;
  119674. /**
  119675. * Blur filter offsets
  119676. */
  119677. private _samplerOffsets;
  119678. private _expensiveBlur;
  119679. /**
  119680. * If bilateral blur should be used
  119681. */
  119682. expensiveBlur: boolean;
  119683. /**
  119684. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  119685. */
  119686. radius: number;
  119687. /**
  119688. * The base color of the SSAO post-process
  119689. * The final result is "base + ssao" between [0, 1]
  119690. */
  119691. base: number;
  119692. /**
  119693. * Support test.
  119694. */
  119695. static readonly IsSupported: boolean;
  119696. private _scene;
  119697. private _depthTexture;
  119698. private _normalTexture;
  119699. private _randomTexture;
  119700. private _originalColorPostProcess;
  119701. private _ssaoPostProcess;
  119702. private _blurHPostProcess;
  119703. private _blurVPostProcess;
  119704. private _ssaoCombinePostProcess;
  119705. private _firstUpdate;
  119706. /**
  119707. * Gets active scene
  119708. */
  119709. readonly scene: Scene;
  119710. /**
  119711. * @constructor
  119712. * @param name The rendering pipeline name
  119713. * @param scene The scene linked to this pipeline
  119714. * @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 }
  119715. * @param cameras The array of cameras that the rendering pipeline will be attached to
  119716. */
  119717. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  119718. /**
  119719. * Get the class name
  119720. * @returns "SSAO2RenderingPipeline"
  119721. */
  119722. getClassName(): string;
  119723. /**
  119724. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  119725. */
  119726. dispose(disableGeometryBufferRenderer?: boolean): void;
  119727. private _createBlurPostProcess;
  119728. /** @hidden */
  119729. _rebuild(): void;
  119730. private _bits;
  119731. private _radicalInverse_VdC;
  119732. private _hammersley;
  119733. private _hemisphereSample_uniform;
  119734. private _generateHemisphere;
  119735. private _createSSAOPostProcess;
  119736. private _createSSAOCombinePostProcess;
  119737. private _createRandomTexture;
  119738. /**
  119739. * Serialize the rendering pipeline (Used when exporting)
  119740. * @returns the serialized object
  119741. */
  119742. serialize(): any;
  119743. /**
  119744. * Parse the serialized pipeline
  119745. * @param source Source pipeline.
  119746. * @param scene The scene to load the pipeline to.
  119747. * @param rootUrl The URL of the serialized pipeline.
  119748. * @returns An instantiated pipeline from the serialized object.
  119749. */
  119750. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  119751. }
  119752. }
  119753. declare module BABYLON {
  119754. /** @hidden */
  119755. export var ssaoPixelShader: {
  119756. name: string;
  119757. shader: string;
  119758. };
  119759. }
  119760. declare module BABYLON {
  119761. /**
  119762. * Render pipeline to produce ssao effect
  119763. */
  119764. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  119765. /**
  119766. * @ignore
  119767. * The PassPostProcess id in the pipeline that contains the original scene color
  119768. */
  119769. SSAOOriginalSceneColorEffect: string;
  119770. /**
  119771. * @ignore
  119772. * The SSAO PostProcess id in the pipeline
  119773. */
  119774. SSAORenderEffect: string;
  119775. /**
  119776. * @ignore
  119777. * The horizontal blur PostProcess id in the pipeline
  119778. */
  119779. SSAOBlurHRenderEffect: string;
  119780. /**
  119781. * @ignore
  119782. * The vertical blur PostProcess id in the pipeline
  119783. */
  119784. SSAOBlurVRenderEffect: string;
  119785. /**
  119786. * @ignore
  119787. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  119788. */
  119789. SSAOCombineRenderEffect: string;
  119790. /**
  119791. * The output strength of the SSAO post-process. Default value is 1.0.
  119792. */
  119793. totalStrength: number;
  119794. /**
  119795. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  119796. */
  119797. radius: number;
  119798. /**
  119799. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  119800. * Must not be equal to fallOff and superior to fallOff.
  119801. * Default value is 0.0075
  119802. */
  119803. area: number;
  119804. /**
  119805. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  119806. * Must not be equal to area and inferior to area.
  119807. * Default value is 0.000001
  119808. */
  119809. fallOff: number;
  119810. /**
  119811. * The base color of the SSAO post-process
  119812. * The final result is "base + ssao" between [0, 1]
  119813. */
  119814. base: number;
  119815. private _scene;
  119816. private _depthTexture;
  119817. private _randomTexture;
  119818. private _originalColorPostProcess;
  119819. private _ssaoPostProcess;
  119820. private _blurHPostProcess;
  119821. private _blurVPostProcess;
  119822. private _ssaoCombinePostProcess;
  119823. private _firstUpdate;
  119824. /**
  119825. * Gets active scene
  119826. */
  119827. readonly scene: Scene;
  119828. /**
  119829. * @constructor
  119830. * @param name - The rendering pipeline name
  119831. * @param scene - The scene linked to this pipeline
  119832. * @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 }
  119833. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  119834. */
  119835. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  119836. /**
  119837. * Get the class name
  119838. * @returns "SSAORenderingPipeline"
  119839. */
  119840. getClassName(): string;
  119841. /**
  119842. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  119843. */
  119844. dispose(disableDepthRender?: boolean): void;
  119845. private _createBlurPostProcess;
  119846. /** @hidden */
  119847. _rebuild(): void;
  119848. private _createSSAOPostProcess;
  119849. private _createSSAOCombinePostProcess;
  119850. private _createRandomTexture;
  119851. }
  119852. }
  119853. declare module BABYLON {
  119854. /** @hidden */
  119855. export var standardPixelShader: {
  119856. name: string;
  119857. shader: string;
  119858. };
  119859. }
  119860. declare module BABYLON {
  119861. /**
  119862. * Standard rendering pipeline
  119863. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  119864. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  119865. */
  119866. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  119867. /**
  119868. * Public members
  119869. */
  119870. /**
  119871. * Post-process which contains the original scene color before the pipeline applies all the effects
  119872. */
  119873. originalPostProcess: Nullable<PostProcess>;
  119874. /**
  119875. * Post-process used to down scale an image x4
  119876. */
  119877. downSampleX4PostProcess: Nullable<PostProcess>;
  119878. /**
  119879. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  119880. */
  119881. brightPassPostProcess: Nullable<PostProcess>;
  119882. /**
  119883. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  119884. */
  119885. blurHPostProcesses: PostProcess[];
  119886. /**
  119887. * Post-process array storing all the vertical blur post-processes used by the pipeline
  119888. */
  119889. blurVPostProcesses: PostProcess[];
  119890. /**
  119891. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  119892. */
  119893. textureAdderPostProcess: Nullable<PostProcess>;
  119894. /**
  119895. * Post-process used to create volumetric lighting effect
  119896. */
  119897. volumetricLightPostProcess: Nullable<PostProcess>;
  119898. /**
  119899. * Post-process used to smooth the previous volumetric light post-process on the X axis
  119900. */
  119901. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  119902. /**
  119903. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  119904. */
  119905. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  119906. /**
  119907. * Post-process used to merge the volumetric light effect and the real scene color
  119908. */
  119909. volumetricLightMergePostProces: Nullable<PostProcess>;
  119910. /**
  119911. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  119912. */
  119913. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  119914. /**
  119915. * Base post-process used to calculate the average luminance of the final image for HDR
  119916. */
  119917. luminancePostProcess: Nullable<PostProcess>;
  119918. /**
  119919. * Post-processes used to create down sample post-processes in order to get
  119920. * the average luminance of the final image for HDR
  119921. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  119922. */
  119923. luminanceDownSamplePostProcesses: PostProcess[];
  119924. /**
  119925. * Post-process used to create a HDR effect (light adaptation)
  119926. */
  119927. hdrPostProcess: Nullable<PostProcess>;
  119928. /**
  119929. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  119930. */
  119931. textureAdderFinalPostProcess: Nullable<PostProcess>;
  119932. /**
  119933. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  119934. */
  119935. lensFlareFinalPostProcess: Nullable<PostProcess>;
  119936. /**
  119937. * Post-process used to merge the final HDR post-process and the real scene color
  119938. */
  119939. hdrFinalPostProcess: Nullable<PostProcess>;
  119940. /**
  119941. * Post-process used to create a lens flare effect
  119942. */
  119943. lensFlarePostProcess: Nullable<PostProcess>;
  119944. /**
  119945. * Post-process that merges the result of the lens flare post-process and the real scene color
  119946. */
  119947. lensFlareComposePostProcess: Nullable<PostProcess>;
  119948. /**
  119949. * Post-process used to create a motion blur effect
  119950. */
  119951. motionBlurPostProcess: Nullable<PostProcess>;
  119952. /**
  119953. * Post-process used to create a depth of field effect
  119954. */
  119955. depthOfFieldPostProcess: Nullable<PostProcess>;
  119956. /**
  119957. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  119958. */
  119959. fxaaPostProcess: Nullable<FxaaPostProcess>;
  119960. /**
  119961. * Represents the brightness threshold in order to configure the illuminated surfaces
  119962. */
  119963. brightThreshold: number;
  119964. /**
  119965. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  119966. */
  119967. blurWidth: number;
  119968. /**
  119969. * Sets if the blur for highlighted surfaces must be only horizontal
  119970. */
  119971. horizontalBlur: boolean;
  119972. /**
  119973. * Gets the overall exposure used by the pipeline
  119974. */
  119975. /**
  119976. * Sets the overall exposure used by the pipeline
  119977. */
  119978. exposure: number;
  119979. /**
  119980. * Texture used typically to simulate "dirty" on camera lens
  119981. */
  119982. lensTexture: Nullable<Texture>;
  119983. /**
  119984. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  119985. */
  119986. volumetricLightCoefficient: number;
  119987. /**
  119988. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  119989. */
  119990. volumetricLightPower: number;
  119991. /**
  119992. * Used the set the blur intensity to smooth the volumetric lights
  119993. */
  119994. volumetricLightBlurScale: number;
  119995. /**
  119996. * Light (spot or directional) used to generate the volumetric lights rays
  119997. * The source light must have a shadow generate so the pipeline can get its
  119998. * depth map
  119999. */
  120000. sourceLight: Nullable<SpotLight | DirectionalLight>;
  120001. /**
  120002. * For eye adaptation, represents the minimum luminance the eye can see
  120003. */
  120004. hdrMinimumLuminance: number;
  120005. /**
  120006. * For eye adaptation, represents the decrease luminance speed
  120007. */
  120008. hdrDecreaseRate: number;
  120009. /**
  120010. * For eye adaptation, represents the increase luminance speed
  120011. */
  120012. hdrIncreaseRate: number;
  120013. /**
  120014. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  120015. */
  120016. /**
  120017. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  120018. */
  120019. hdrAutoExposure: boolean;
  120020. /**
  120021. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  120022. */
  120023. lensColorTexture: Nullable<Texture>;
  120024. /**
  120025. * The overall strengh for the lens flare effect
  120026. */
  120027. lensFlareStrength: number;
  120028. /**
  120029. * Dispersion coefficient for lens flare ghosts
  120030. */
  120031. lensFlareGhostDispersal: number;
  120032. /**
  120033. * Main lens flare halo width
  120034. */
  120035. lensFlareHaloWidth: number;
  120036. /**
  120037. * Based on the lens distortion effect, defines how much the lens flare result
  120038. * is distorted
  120039. */
  120040. lensFlareDistortionStrength: number;
  120041. /**
  120042. * Lens star texture must be used to simulate rays on the flares and is available
  120043. * in the documentation
  120044. */
  120045. lensStarTexture: Nullable<Texture>;
  120046. /**
  120047. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  120048. * flare effect by taking account of the dirt texture
  120049. */
  120050. lensFlareDirtTexture: Nullable<Texture>;
  120051. /**
  120052. * Represents the focal length for the depth of field effect
  120053. */
  120054. depthOfFieldDistance: number;
  120055. /**
  120056. * Represents the blur intensity for the blurred part of the depth of field effect
  120057. */
  120058. depthOfFieldBlurWidth: number;
  120059. /**
  120060. * Gets how much the image is blurred by the movement while using the motion blur post-process
  120061. */
  120062. /**
  120063. * Sets how much the image is blurred by the movement while using the motion blur post-process
  120064. */
  120065. motionStrength: number;
  120066. /**
  120067. * Gets wether or not the motion blur post-process is object based or screen based.
  120068. */
  120069. /**
  120070. * Sets wether or not the motion blur post-process should be object based or screen based
  120071. */
  120072. objectBasedMotionBlur: boolean;
  120073. /**
  120074. * List of animations for the pipeline (IAnimatable implementation)
  120075. */
  120076. animations: Animation[];
  120077. /**
  120078. * Private members
  120079. */
  120080. private _scene;
  120081. private _currentDepthOfFieldSource;
  120082. private _basePostProcess;
  120083. private _fixedExposure;
  120084. private _currentExposure;
  120085. private _hdrAutoExposure;
  120086. private _hdrCurrentLuminance;
  120087. private _motionStrength;
  120088. private _isObjectBasedMotionBlur;
  120089. private _floatTextureType;
  120090. private _ratio;
  120091. private _bloomEnabled;
  120092. private _depthOfFieldEnabled;
  120093. private _vlsEnabled;
  120094. private _lensFlareEnabled;
  120095. private _hdrEnabled;
  120096. private _motionBlurEnabled;
  120097. private _fxaaEnabled;
  120098. private _motionBlurSamples;
  120099. private _volumetricLightStepsCount;
  120100. private _samples;
  120101. /**
  120102. * @ignore
  120103. * Specifies if the bloom pipeline is enabled
  120104. */
  120105. BloomEnabled: boolean;
  120106. /**
  120107. * @ignore
  120108. * Specifies if the depth of field pipeline is enabed
  120109. */
  120110. DepthOfFieldEnabled: boolean;
  120111. /**
  120112. * @ignore
  120113. * Specifies if the lens flare pipeline is enabed
  120114. */
  120115. LensFlareEnabled: boolean;
  120116. /**
  120117. * @ignore
  120118. * Specifies if the HDR pipeline is enabled
  120119. */
  120120. HDREnabled: boolean;
  120121. /**
  120122. * @ignore
  120123. * Specifies if the volumetric lights scattering effect is enabled
  120124. */
  120125. VLSEnabled: boolean;
  120126. /**
  120127. * @ignore
  120128. * Specifies if the motion blur effect is enabled
  120129. */
  120130. MotionBlurEnabled: boolean;
  120131. /**
  120132. * Specifies if anti-aliasing is enabled
  120133. */
  120134. fxaaEnabled: boolean;
  120135. /**
  120136. * Specifies the number of steps used to calculate the volumetric lights
  120137. * Typically in interval [50, 200]
  120138. */
  120139. volumetricLightStepsCount: number;
  120140. /**
  120141. * Specifies the number of samples used for the motion blur effect
  120142. * Typically in interval [16, 64]
  120143. */
  120144. motionBlurSamples: number;
  120145. /**
  120146. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  120147. */
  120148. samples: number;
  120149. /**
  120150. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  120151. * @constructor
  120152. * @param name The rendering pipeline name
  120153. * @param scene The scene linked to this pipeline
  120154. * @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)
  120155. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  120156. * @param cameras The array of cameras that the rendering pipeline will be attached to
  120157. */
  120158. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  120159. private _buildPipeline;
  120160. private _createDownSampleX4PostProcess;
  120161. private _createBrightPassPostProcess;
  120162. private _createBlurPostProcesses;
  120163. private _createTextureAdderPostProcess;
  120164. private _createVolumetricLightPostProcess;
  120165. private _createLuminancePostProcesses;
  120166. private _createHdrPostProcess;
  120167. private _createLensFlarePostProcess;
  120168. private _createDepthOfFieldPostProcess;
  120169. private _createMotionBlurPostProcess;
  120170. private _getDepthTexture;
  120171. private _disposePostProcesses;
  120172. /**
  120173. * Dispose of the pipeline and stop all post processes
  120174. */
  120175. dispose(): void;
  120176. /**
  120177. * Serialize the rendering pipeline (Used when exporting)
  120178. * @returns the serialized object
  120179. */
  120180. serialize(): any;
  120181. /**
  120182. * Parse the serialized pipeline
  120183. * @param source Source pipeline.
  120184. * @param scene The scene to load the pipeline to.
  120185. * @param rootUrl The URL of the serialized pipeline.
  120186. * @returns An instantiated pipeline from the serialized object.
  120187. */
  120188. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  120189. /**
  120190. * Luminance steps
  120191. */
  120192. static LuminanceSteps: number;
  120193. }
  120194. }
  120195. declare module BABYLON {
  120196. /** @hidden */
  120197. export var tonemapPixelShader: {
  120198. name: string;
  120199. shader: string;
  120200. };
  120201. }
  120202. declare module BABYLON {
  120203. /** Defines operator used for tonemapping */
  120204. export enum TonemappingOperator {
  120205. /** Hable */
  120206. Hable = 0,
  120207. /** Reinhard */
  120208. Reinhard = 1,
  120209. /** HejiDawson */
  120210. HejiDawson = 2,
  120211. /** Photographic */
  120212. Photographic = 3
  120213. }
  120214. /**
  120215. * Defines a post process to apply tone mapping
  120216. */
  120217. export class TonemapPostProcess extends PostProcess {
  120218. private _operator;
  120219. /** Defines the required exposure adjustement */
  120220. exposureAdjustment: number;
  120221. /**
  120222. * Creates a new TonemapPostProcess
  120223. * @param name defines the name of the postprocess
  120224. * @param _operator defines the operator to use
  120225. * @param exposureAdjustment defines the required exposure adjustement
  120226. * @param camera defines the camera to use (can be null)
  120227. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  120228. * @param engine defines the hosting engine (can be ignore if camera is set)
  120229. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  120230. */
  120231. constructor(name: string, _operator: TonemappingOperator,
  120232. /** Defines the required exposure adjustement */
  120233. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  120234. }
  120235. }
  120236. declare module BABYLON {
  120237. /** @hidden */
  120238. export var depthVertexShader: {
  120239. name: string;
  120240. shader: string;
  120241. };
  120242. }
  120243. declare module BABYLON {
  120244. /** @hidden */
  120245. export var volumetricLightScatteringPixelShader: {
  120246. name: string;
  120247. shader: string;
  120248. };
  120249. }
  120250. declare module BABYLON {
  120251. /** @hidden */
  120252. export var volumetricLightScatteringPassPixelShader: {
  120253. name: string;
  120254. shader: string;
  120255. };
  120256. }
  120257. declare module BABYLON {
  120258. /**
  120259. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  120260. */
  120261. export class VolumetricLightScatteringPostProcess extends PostProcess {
  120262. private _volumetricLightScatteringPass;
  120263. private _volumetricLightScatteringRTT;
  120264. private _viewPort;
  120265. private _screenCoordinates;
  120266. private _cachedDefines;
  120267. /**
  120268. * If not undefined, the mesh position is computed from the attached node position
  120269. */
  120270. attachedNode: {
  120271. position: Vector3;
  120272. };
  120273. /**
  120274. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  120275. */
  120276. customMeshPosition: Vector3;
  120277. /**
  120278. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  120279. */
  120280. useCustomMeshPosition: boolean;
  120281. /**
  120282. * If the post-process should inverse the light scattering direction
  120283. */
  120284. invert: boolean;
  120285. /**
  120286. * The internal mesh used by the post-process
  120287. */
  120288. mesh: Mesh;
  120289. /**
  120290. * @hidden
  120291. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  120292. */
  120293. useDiffuseColor: boolean;
  120294. /**
  120295. * Array containing the excluded meshes not rendered in the internal pass
  120296. */
  120297. excludedMeshes: AbstractMesh[];
  120298. /**
  120299. * Controls the overall intensity of the post-process
  120300. */
  120301. exposure: number;
  120302. /**
  120303. * Dissipates each sample's contribution in range [0, 1]
  120304. */
  120305. decay: number;
  120306. /**
  120307. * Controls the overall intensity of each sample
  120308. */
  120309. weight: number;
  120310. /**
  120311. * Controls the density of each sample
  120312. */
  120313. density: number;
  120314. /**
  120315. * @constructor
  120316. * @param name The post-process name
  120317. * @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)
  120318. * @param camera The camera that the post-process will be attached to
  120319. * @param mesh The mesh used to create the light scattering
  120320. * @param samples The post-process quality, default 100
  120321. * @param samplingModeThe post-process filtering mode
  120322. * @param engine The babylon engine
  120323. * @param reusable If the post-process is reusable
  120324. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  120325. */
  120326. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  120327. /**
  120328. * Returns the string "VolumetricLightScatteringPostProcess"
  120329. * @returns "VolumetricLightScatteringPostProcess"
  120330. */
  120331. getClassName(): string;
  120332. private _isReady;
  120333. /**
  120334. * Sets the new light position for light scattering effect
  120335. * @param position The new custom light position
  120336. */
  120337. setCustomMeshPosition(position: Vector3): void;
  120338. /**
  120339. * Returns the light position for light scattering effect
  120340. * @return Vector3 The custom light position
  120341. */
  120342. getCustomMeshPosition(): Vector3;
  120343. /**
  120344. * Disposes the internal assets and detaches the post-process from the camera
  120345. */
  120346. dispose(camera: Camera): void;
  120347. /**
  120348. * Returns the render target texture used by the post-process
  120349. * @return the render target texture used by the post-process
  120350. */
  120351. getPass(): RenderTargetTexture;
  120352. private _meshExcluded;
  120353. private _createPass;
  120354. private _updateMeshScreenCoordinates;
  120355. /**
  120356. * Creates a default mesh for the Volumeric Light Scattering post-process
  120357. * @param name The mesh name
  120358. * @param scene The scene where to create the mesh
  120359. * @return the default mesh
  120360. */
  120361. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  120362. }
  120363. }
  120364. declare module BABYLON {
  120365. interface Scene {
  120366. /** @hidden (Backing field) */
  120367. _boundingBoxRenderer: BoundingBoxRenderer;
  120368. /** @hidden (Backing field) */
  120369. _forceShowBoundingBoxes: boolean;
  120370. /**
  120371. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  120372. */
  120373. forceShowBoundingBoxes: boolean;
  120374. /**
  120375. * Gets the bounding box renderer associated with the scene
  120376. * @returns a BoundingBoxRenderer
  120377. */
  120378. getBoundingBoxRenderer(): BoundingBoxRenderer;
  120379. }
  120380. interface AbstractMesh {
  120381. /** @hidden (Backing field) */
  120382. _showBoundingBox: boolean;
  120383. /**
  120384. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  120385. */
  120386. showBoundingBox: boolean;
  120387. }
  120388. /**
  120389. * Component responsible of rendering the bounding box of the meshes in a scene.
  120390. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  120391. */
  120392. export class BoundingBoxRenderer implements ISceneComponent {
  120393. /**
  120394. * The component name helpfull to identify the component in the list of scene components.
  120395. */
  120396. readonly name: string;
  120397. /**
  120398. * The scene the component belongs to.
  120399. */
  120400. scene: Scene;
  120401. /**
  120402. * Color of the bounding box lines placed in front of an object
  120403. */
  120404. frontColor: Color3;
  120405. /**
  120406. * Color of the bounding box lines placed behind an object
  120407. */
  120408. backColor: Color3;
  120409. /**
  120410. * Defines if the renderer should show the back lines or not
  120411. */
  120412. showBackLines: boolean;
  120413. /**
  120414. * @hidden
  120415. */
  120416. renderList: SmartArray<BoundingBox>;
  120417. private _colorShader;
  120418. private _vertexBuffers;
  120419. private _indexBuffer;
  120420. private _fillIndexBuffer;
  120421. private _fillIndexData;
  120422. /**
  120423. * Instantiates a new bounding box renderer in a scene.
  120424. * @param scene the scene the renderer renders in
  120425. */
  120426. constructor(scene: Scene);
  120427. /**
  120428. * Registers the component in a given scene
  120429. */
  120430. register(): void;
  120431. private _evaluateSubMesh;
  120432. private _activeMesh;
  120433. private _prepareRessources;
  120434. private _createIndexBuffer;
  120435. /**
  120436. * Rebuilds the elements related to this component in case of
  120437. * context lost for instance.
  120438. */
  120439. rebuild(): void;
  120440. /**
  120441. * @hidden
  120442. */
  120443. reset(): void;
  120444. /**
  120445. * Render the bounding boxes of a specific rendering group
  120446. * @param renderingGroupId defines the rendering group to render
  120447. */
  120448. render(renderingGroupId: number): void;
  120449. /**
  120450. * In case of occlusion queries, we can render the occlusion bounding box through this method
  120451. * @param mesh Define the mesh to render the occlusion bounding box for
  120452. */
  120453. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  120454. /**
  120455. * Dispose and release the resources attached to this renderer.
  120456. */
  120457. dispose(): void;
  120458. }
  120459. }
  120460. declare module BABYLON {
  120461. /** @hidden */
  120462. export var depthPixelShader: {
  120463. name: string;
  120464. shader: string;
  120465. };
  120466. }
  120467. declare module BABYLON {
  120468. /**
  120469. * This represents a depth renderer in Babylon.
  120470. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  120471. */
  120472. export class DepthRenderer {
  120473. private _scene;
  120474. private _depthMap;
  120475. private _effect;
  120476. private _cachedDefines;
  120477. private _camera;
  120478. /**
  120479. * Specifiess that the depth renderer will only be used within
  120480. * the camera it is created for.
  120481. * This can help forcing its rendering during the camera processing.
  120482. */
  120483. useOnlyInActiveCamera: boolean;
  120484. /** @hidden */
  120485. static _SceneComponentInitialization: (scene: Scene) => void;
  120486. /**
  120487. * Instantiates a depth renderer
  120488. * @param scene The scene the renderer belongs to
  120489. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  120490. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  120491. */
  120492. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  120493. /**
  120494. * Creates the depth rendering effect and checks if the effect is ready.
  120495. * @param subMesh The submesh to be used to render the depth map of
  120496. * @param useInstances If multiple world instances should be used
  120497. * @returns if the depth renderer is ready to render the depth map
  120498. */
  120499. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  120500. /**
  120501. * Gets the texture which the depth map will be written to.
  120502. * @returns The depth map texture
  120503. */
  120504. getDepthMap(): RenderTargetTexture;
  120505. /**
  120506. * Disposes of the depth renderer.
  120507. */
  120508. dispose(): void;
  120509. }
  120510. }
  120511. declare module BABYLON {
  120512. interface Scene {
  120513. /** @hidden (Backing field) */
  120514. _depthRenderer: {
  120515. [id: string]: DepthRenderer;
  120516. };
  120517. /**
  120518. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  120519. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  120520. * @returns the created depth renderer
  120521. */
  120522. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  120523. /**
  120524. * Disables a depth renderer for a given camera
  120525. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  120526. */
  120527. disableDepthRenderer(camera?: Nullable<Camera>): void;
  120528. }
  120529. /**
  120530. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  120531. * in several rendering techniques.
  120532. */
  120533. export class DepthRendererSceneComponent implements ISceneComponent {
  120534. /**
  120535. * The component name helpfull to identify the component in the list of scene components.
  120536. */
  120537. readonly name: string;
  120538. /**
  120539. * The scene the component belongs to.
  120540. */
  120541. scene: Scene;
  120542. /**
  120543. * Creates a new instance of the component for the given scene
  120544. * @param scene Defines the scene to register the component in
  120545. */
  120546. constructor(scene: Scene);
  120547. /**
  120548. * Registers the component in a given scene
  120549. */
  120550. register(): void;
  120551. /**
  120552. * Rebuilds the elements related to this component in case of
  120553. * context lost for instance.
  120554. */
  120555. rebuild(): void;
  120556. /**
  120557. * Disposes the component and the associated ressources
  120558. */
  120559. dispose(): void;
  120560. private _gatherRenderTargets;
  120561. private _gatherActiveCameraRenderTargets;
  120562. }
  120563. }
  120564. declare module BABYLON {
  120565. /** @hidden */
  120566. export var outlinePixelShader: {
  120567. name: string;
  120568. shader: string;
  120569. };
  120570. }
  120571. declare module BABYLON {
  120572. /** @hidden */
  120573. export var outlineVertexShader: {
  120574. name: string;
  120575. shader: string;
  120576. };
  120577. }
  120578. declare module BABYLON {
  120579. interface Scene {
  120580. /** @hidden */
  120581. _outlineRenderer: OutlineRenderer;
  120582. /**
  120583. * Gets the outline renderer associated with the scene
  120584. * @returns a OutlineRenderer
  120585. */
  120586. getOutlineRenderer(): OutlineRenderer;
  120587. }
  120588. interface AbstractMesh {
  120589. /** @hidden (Backing field) */
  120590. _renderOutline: boolean;
  120591. /**
  120592. * Gets or sets a boolean indicating if the outline must be rendered as well
  120593. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  120594. */
  120595. renderOutline: boolean;
  120596. /** @hidden (Backing field) */
  120597. _renderOverlay: boolean;
  120598. /**
  120599. * Gets or sets a boolean indicating if the overlay must be rendered as well
  120600. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  120601. */
  120602. renderOverlay: boolean;
  120603. }
  120604. /**
  120605. * This class is responsible to draw bothe outline/overlay of meshes.
  120606. * It should not be used directly but through the available method on mesh.
  120607. */
  120608. export class OutlineRenderer implements ISceneComponent {
  120609. /**
  120610. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  120611. */
  120612. private static _StencilReference;
  120613. /**
  120614. * The name of the component. Each component must have a unique name.
  120615. */
  120616. name: string;
  120617. /**
  120618. * The scene the component belongs to.
  120619. */
  120620. scene: Scene;
  120621. /**
  120622. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  120623. */
  120624. zOffset: number;
  120625. private _engine;
  120626. private _effect;
  120627. private _cachedDefines;
  120628. private _savedDepthWrite;
  120629. /**
  120630. * Instantiates a new outline renderer. (There could be only one per scene).
  120631. * @param scene Defines the scene it belongs to
  120632. */
  120633. constructor(scene: Scene);
  120634. /**
  120635. * Register the component to one instance of a scene.
  120636. */
  120637. register(): void;
  120638. /**
  120639. * Rebuilds the elements related to this component in case of
  120640. * context lost for instance.
  120641. */
  120642. rebuild(): void;
  120643. /**
  120644. * Disposes the component and the associated ressources.
  120645. */
  120646. dispose(): void;
  120647. /**
  120648. * Renders the outline in the canvas.
  120649. * @param subMesh Defines the sumesh to render
  120650. * @param batch Defines the batch of meshes in case of instances
  120651. * @param useOverlay Defines if the rendering is for the overlay or the outline
  120652. */
  120653. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  120654. /**
  120655. * Returns whether or not the outline renderer is ready for a given submesh.
  120656. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  120657. * @param subMesh Defines the submesh to check readyness for
  120658. * @param useInstances Defines wheter wee are trying to render instances or not
  120659. * @returns true if ready otherwise false
  120660. */
  120661. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  120662. private _beforeRenderingMesh;
  120663. private _afterRenderingMesh;
  120664. }
  120665. }
  120666. declare module BABYLON {
  120667. /**
  120668. * Defines the list of states available for a task inside a AssetsManager
  120669. */
  120670. export enum AssetTaskState {
  120671. /**
  120672. * Initialization
  120673. */
  120674. INIT = 0,
  120675. /**
  120676. * Running
  120677. */
  120678. RUNNING = 1,
  120679. /**
  120680. * Done
  120681. */
  120682. DONE = 2,
  120683. /**
  120684. * Error
  120685. */
  120686. ERROR = 3
  120687. }
  120688. /**
  120689. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  120690. */
  120691. export abstract class AbstractAssetTask {
  120692. /**
  120693. * Task name
  120694. */ name: string;
  120695. /**
  120696. * Callback called when the task is successful
  120697. */
  120698. onSuccess: (task: any) => void;
  120699. /**
  120700. * Callback called when the task is not successful
  120701. */
  120702. onError: (task: any, message?: string, exception?: any) => void;
  120703. /**
  120704. * Creates a new AssetsManager
  120705. * @param name defines the name of the task
  120706. */
  120707. constructor(
  120708. /**
  120709. * Task name
  120710. */ name: string);
  120711. private _isCompleted;
  120712. private _taskState;
  120713. private _errorObject;
  120714. /**
  120715. * Get if the task is completed
  120716. */
  120717. readonly isCompleted: boolean;
  120718. /**
  120719. * Gets the current state of the task
  120720. */
  120721. readonly taskState: AssetTaskState;
  120722. /**
  120723. * Gets the current error object (if task is in error)
  120724. */
  120725. readonly errorObject: {
  120726. message?: string;
  120727. exception?: any;
  120728. };
  120729. /**
  120730. * Internal only
  120731. * @hidden
  120732. */
  120733. _setErrorObject(message?: string, exception?: any): void;
  120734. /**
  120735. * Execute the current task
  120736. * @param scene defines the scene where you want your assets to be loaded
  120737. * @param onSuccess is a callback called when the task is successfully executed
  120738. * @param onError is a callback called if an error occurs
  120739. */
  120740. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120741. /**
  120742. * Execute the current task
  120743. * @param scene defines the scene where you want your assets to be loaded
  120744. * @param onSuccess is a callback called when the task is successfully executed
  120745. * @param onError is a callback called if an error occurs
  120746. */
  120747. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120748. /**
  120749. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  120750. * This can be used with failed tasks that have the reason for failure fixed.
  120751. */
  120752. reset(): void;
  120753. private onErrorCallback;
  120754. private onDoneCallback;
  120755. }
  120756. /**
  120757. * Define the interface used by progress events raised during assets loading
  120758. */
  120759. export interface IAssetsProgressEvent {
  120760. /**
  120761. * Defines the number of remaining tasks to process
  120762. */
  120763. remainingCount: number;
  120764. /**
  120765. * Defines the total number of tasks
  120766. */
  120767. totalCount: number;
  120768. /**
  120769. * Defines the task that was just processed
  120770. */
  120771. task: AbstractAssetTask;
  120772. }
  120773. /**
  120774. * Class used to share progress information about assets loading
  120775. */
  120776. export class AssetsProgressEvent implements IAssetsProgressEvent {
  120777. /**
  120778. * Defines the number of remaining tasks to process
  120779. */
  120780. remainingCount: number;
  120781. /**
  120782. * Defines the total number of tasks
  120783. */
  120784. totalCount: number;
  120785. /**
  120786. * Defines the task that was just processed
  120787. */
  120788. task: AbstractAssetTask;
  120789. /**
  120790. * Creates a AssetsProgressEvent
  120791. * @param remainingCount defines the number of remaining tasks to process
  120792. * @param totalCount defines the total number of tasks
  120793. * @param task defines the task that was just processed
  120794. */
  120795. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  120796. }
  120797. /**
  120798. * Define a task used by AssetsManager to load meshes
  120799. */
  120800. export class MeshAssetTask extends AbstractAssetTask {
  120801. /**
  120802. * Defines the name of the task
  120803. */
  120804. name: string;
  120805. /**
  120806. * Defines the list of mesh's names you want to load
  120807. */
  120808. meshesNames: any;
  120809. /**
  120810. * Defines the root url to use as a base to load your meshes and associated resources
  120811. */
  120812. rootUrl: string;
  120813. /**
  120814. * Defines the filename of the scene to load from
  120815. */
  120816. sceneFilename: string;
  120817. /**
  120818. * Gets the list of loaded meshes
  120819. */
  120820. loadedMeshes: Array<AbstractMesh>;
  120821. /**
  120822. * Gets the list of loaded particle systems
  120823. */
  120824. loadedParticleSystems: Array<IParticleSystem>;
  120825. /**
  120826. * Gets the list of loaded skeletons
  120827. */
  120828. loadedSkeletons: Array<Skeleton>;
  120829. /**
  120830. * Gets the list of loaded animation groups
  120831. */
  120832. loadedAnimationGroups: Array<AnimationGroup>;
  120833. /**
  120834. * Callback called when the task is successful
  120835. */
  120836. onSuccess: (task: MeshAssetTask) => void;
  120837. /**
  120838. * Callback called when the task is successful
  120839. */
  120840. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  120841. /**
  120842. * Creates a new MeshAssetTask
  120843. * @param name defines the name of the task
  120844. * @param meshesNames defines the list of mesh's names you want to load
  120845. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  120846. * @param sceneFilename defines the filename of the scene to load from
  120847. */
  120848. constructor(
  120849. /**
  120850. * Defines the name of the task
  120851. */
  120852. name: string,
  120853. /**
  120854. * Defines the list of mesh's names you want to load
  120855. */
  120856. meshesNames: any,
  120857. /**
  120858. * Defines the root url to use as a base to load your meshes and associated resources
  120859. */
  120860. rootUrl: string,
  120861. /**
  120862. * Defines the filename of the scene to load from
  120863. */
  120864. sceneFilename: string);
  120865. /**
  120866. * Execute the current task
  120867. * @param scene defines the scene where you want your assets to be loaded
  120868. * @param onSuccess is a callback called when the task is successfully executed
  120869. * @param onError is a callback called if an error occurs
  120870. */
  120871. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120872. }
  120873. /**
  120874. * Define a task used by AssetsManager to load text content
  120875. */
  120876. export class TextFileAssetTask extends AbstractAssetTask {
  120877. /**
  120878. * Defines the name of the task
  120879. */
  120880. name: string;
  120881. /**
  120882. * Defines the location of the file to load
  120883. */
  120884. url: string;
  120885. /**
  120886. * Gets the loaded text string
  120887. */
  120888. text: string;
  120889. /**
  120890. * Callback called when the task is successful
  120891. */
  120892. onSuccess: (task: TextFileAssetTask) => void;
  120893. /**
  120894. * Callback called when the task is successful
  120895. */
  120896. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  120897. /**
  120898. * Creates a new TextFileAssetTask object
  120899. * @param name defines the name of the task
  120900. * @param url defines the location of the file to load
  120901. */
  120902. constructor(
  120903. /**
  120904. * Defines the name of the task
  120905. */
  120906. name: string,
  120907. /**
  120908. * Defines the location of the file to load
  120909. */
  120910. url: string);
  120911. /**
  120912. * Execute the current task
  120913. * @param scene defines the scene where you want your assets to be loaded
  120914. * @param onSuccess is a callback called when the task is successfully executed
  120915. * @param onError is a callback called if an error occurs
  120916. */
  120917. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120918. }
  120919. /**
  120920. * Define a task used by AssetsManager to load binary data
  120921. */
  120922. export class BinaryFileAssetTask extends AbstractAssetTask {
  120923. /**
  120924. * Defines the name of the task
  120925. */
  120926. name: string;
  120927. /**
  120928. * Defines the location of the file to load
  120929. */
  120930. url: string;
  120931. /**
  120932. * Gets the lodaded data (as an array buffer)
  120933. */
  120934. data: ArrayBuffer;
  120935. /**
  120936. * Callback called when the task is successful
  120937. */
  120938. onSuccess: (task: BinaryFileAssetTask) => void;
  120939. /**
  120940. * Callback called when the task is successful
  120941. */
  120942. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  120943. /**
  120944. * Creates a new BinaryFileAssetTask object
  120945. * @param name defines the name of the new task
  120946. * @param url defines the location of the file to load
  120947. */
  120948. constructor(
  120949. /**
  120950. * Defines the name of the task
  120951. */
  120952. name: string,
  120953. /**
  120954. * Defines the location of the file to load
  120955. */
  120956. url: string);
  120957. /**
  120958. * Execute the current task
  120959. * @param scene defines the scene where you want your assets to be loaded
  120960. * @param onSuccess is a callback called when the task is successfully executed
  120961. * @param onError is a callback called if an error occurs
  120962. */
  120963. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120964. }
  120965. /**
  120966. * Define a task used by AssetsManager to load images
  120967. */
  120968. export class ImageAssetTask extends AbstractAssetTask {
  120969. /**
  120970. * Defines the name of the task
  120971. */
  120972. name: string;
  120973. /**
  120974. * Defines the location of the image to load
  120975. */
  120976. url: string;
  120977. /**
  120978. * Gets the loaded images
  120979. */
  120980. image: HTMLImageElement;
  120981. /**
  120982. * Callback called when the task is successful
  120983. */
  120984. onSuccess: (task: ImageAssetTask) => void;
  120985. /**
  120986. * Callback called when the task is successful
  120987. */
  120988. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  120989. /**
  120990. * Creates a new ImageAssetTask
  120991. * @param name defines the name of the task
  120992. * @param url defines the location of the image to load
  120993. */
  120994. constructor(
  120995. /**
  120996. * Defines the name of the task
  120997. */
  120998. name: string,
  120999. /**
  121000. * Defines the location of the image to load
  121001. */
  121002. url: string);
  121003. /**
  121004. * Execute the current task
  121005. * @param scene defines the scene where you want your assets to be loaded
  121006. * @param onSuccess is a callback called when the task is successfully executed
  121007. * @param onError is a callback called if an error occurs
  121008. */
  121009. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  121010. }
  121011. /**
  121012. * Defines the interface used by texture loading tasks
  121013. */
  121014. export interface ITextureAssetTask<TEX extends BaseTexture> {
  121015. /**
  121016. * Gets the loaded texture
  121017. */
  121018. texture: TEX;
  121019. }
  121020. /**
  121021. * Define a task used by AssetsManager to load 2D textures
  121022. */
  121023. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  121024. /**
  121025. * Defines the name of the task
  121026. */
  121027. name: string;
  121028. /**
  121029. * Defines the location of the file to load
  121030. */
  121031. url: string;
  121032. /**
  121033. * Defines if mipmap should not be generated (default is false)
  121034. */
  121035. noMipmap?: boolean | undefined;
  121036. /**
  121037. * Defines if texture must be inverted on Y axis (default is false)
  121038. */
  121039. invertY?: boolean | undefined;
  121040. /**
  121041. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  121042. */
  121043. samplingMode: number;
  121044. /**
  121045. * Gets the loaded texture
  121046. */
  121047. texture: Texture;
  121048. /**
  121049. * Callback called when the task is successful
  121050. */
  121051. onSuccess: (task: TextureAssetTask) => void;
  121052. /**
  121053. * Callback called when the task is successful
  121054. */
  121055. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  121056. /**
  121057. * Creates a new TextureAssetTask object
  121058. * @param name defines the name of the task
  121059. * @param url defines the location of the file to load
  121060. * @param noMipmap defines if mipmap should not be generated (default is false)
  121061. * @param invertY defines if texture must be inverted on Y axis (default is false)
  121062. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  121063. */
  121064. constructor(
  121065. /**
  121066. * Defines the name of the task
  121067. */
  121068. name: string,
  121069. /**
  121070. * Defines the location of the file to load
  121071. */
  121072. url: string,
  121073. /**
  121074. * Defines if mipmap should not be generated (default is false)
  121075. */
  121076. noMipmap?: boolean | undefined,
  121077. /**
  121078. * Defines if texture must be inverted on Y axis (default is false)
  121079. */
  121080. invertY?: boolean | undefined,
  121081. /**
  121082. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  121083. */
  121084. samplingMode?: number);
  121085. /**
  121086. * Execute the current task
  121087. * @param scene defines the scene where you want your assets to be loaded
  121088. * @param onSuccess is a callback called when the task is successfully executed
  121089. * @param onError is a callback called if an error occurs
  121090. */
  121091. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  121092. }
  121093. /**
  121094. * Define a task used by AssetsManager to load cube textures
  121095. */
  121096. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  121097. /**
  121098. * Defines the name of the task
  121099. */
  121100. name: string;
  121101. /**
  121102. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  121103. */
  121104. url: string;
  121105. /**
  121106. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  121107. */
  121108. extensions?: string[] | undefined;
  121109. /**
  121110. * Defines if mipmaps should not be generated (default is false)
  121111. */
  121112. noMipmap?: boolean | undefined;
  121113. /**
  121114. * Defines the explicit list of files (undefined by default)
  121115. */
  121116. files?: string[] | undefined;
  121117. /**
  121118. * Gets the loaded texture
  121119. */
  121120. texture: CubeTexture;
  121121. /**
  121122. * Callback called when the task is successful
  121123. */
  121124. onSuccess: (task: CubeTextureAssetTask) => void;
  121125. /**
  121126. * Callback called when the task is successful
  121127. */
  121128. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  121129. /**
  121130. * Creates a new CubeTextureAssetTask
  121131. * @param name defines the name of the task
  121132. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  121133. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  121134. * @param noMipmap defines if mipmaps should not be generated (default is false)
  121135. * @param files defines the explicit list of files (undefined by default)
  121136. */
  121137. constructor(
  121138. /**
  121139. * Defines the name of the task
  121140. */
  121141. name: string,
  121142. /**
  121143. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  121144. */
  121145. url: string,
  121146. /**
  121147. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  121148. */
  121149. extensions?: string[] | undefined,
  121150. /**
  121151. * Defines if mipmaps should not be generated (default is false)
  121152. */
  121153. noMipmap?: boolean | undefined,
  121154. /**
  121155. * Defines the explicit list of files (undefined by default)
  121156. */
  121157. files?: string[] | undefined);
  121158. /**
  121159. * Execute the current task
  121160. * @param scene defines the scene where you want your assets to be loaded
  121161. * @param onSuccess is a callback called when the task is successfully executed
  121162. * @param onError is a callback called if an error occurs
  121163. */
  121164. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  121165. }
  121166. /**
  121167. * Define a task used by AssetsManager to load HDR cube textures
  121168. */
  121169. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  121170. /**
  121171. * Defines the name of the task
  121172. */
  121173. name: string;
  121174. /**
  121175. * Defines the location of the file to load
  121176. */
  121177. url: string;
  121178. /**
  121179. * Defines the desired size (the more it increases the longer the generation will be)
  121180. */
  121181. size: number;
  121182. /**
  121183. * Defines if mipmaps should not be generated (default is false)
  121184. */
  121185. noMipmap: boolean;
  121186. /**
  121187. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  121188. */
  121189. generateHarmonics: boolean;
  121190. /**
  121191. * 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)
  121192. */
  121193. gammaSpace: boolean;
  121194. /**
  121195. * Internal Use Only
  121196. */
  121197. reserved: boolean;
  121198. /**
  121199. * Gets the loaded texture
  121200. */
  121201. texture: HDRCubeTexture;
  121202. /**
  121203. * Callback called when the task is successful
  121204. */
  121205. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  121206. /**
  121207. * Callback called when the task is successful
  121208. */
  121209. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  121210. /**
  121211. * Creates a new HDRCubeTextureAssetTask object
  121212. * @param name defines the name of the task
  121213. * @param url defines the location of the file to load
  121214. * @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.
  121215. * @param noMipmap defines if mipmaps should not be generated (default is false)
  121216. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  121217. * @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)
  121218. * @param reserved Internal use only
  121219. */
  121220. constructor(
  121221. /**
  121222. * Defines the name of the task
  121223. */
  121224. name: string,
  121225. /**
  121226. * Defines the location of the file to load
  121227. */
  121228. url: string,
  121229. /**
  121230. * Defines the desired size (the more it increases the longer the generation will be)
  121231. */
  121232. size: number,
  121233. /**
  121234. * Defines if mipmaps should not be generated (default is false)
  121235. */
  121236. noMipmap?: boolean,
  121237. /**
  121238. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  121239. */
  121240. generateHarmonics?: boolean,
  121241. /**
  121242. * 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)
  121243. */
  121244. gammaSpace?: boolean,
  121245. /**
  121246. * Internal Use Only
  121247. */
  121248. reserved?: boolean);
  121249. /**
  121250. * Execute the current task
  121251. * @param scene defines the scene where you want your assets to be loaded
  121252. * @param onSuccess is a callback called when the task is successfully executed
  121253. * @param onError is a callback called if an error occurs
  121254. */
  121255. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  121256. }
  121257. /**
  121258. * Define a task used by AssetsManager to load Equirectangular cube textures
  121259. */
  121260. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  121261. /**
  121262. * Defines the name of the task
  121263. */
  121264. name: string;
  121265. /**
  121266. * Defines the location of the file to load
  121267. */
  121268. url: string;
  121269. /**
  121270. * Defines the desired size (the more it increases the longer the generation will be)
  121271. */
  121272. size: number;
  121273. /**
  121274. * Defines if mipmaps should not be generated (default is false)
  121275. */
  121276. noMipmap: boolean;
  121277. /**
  121278. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  121279. * but the standard material would require them in Gamma space) (default is true)
  121280. */
  121281. gammaSpace: boolean;
  121282. /**
  121283. * Gets the loaded texture
  121284. */
  121285. texture: EquiRectangularCubeTexture;
  121286. /**
  121287. * Callback called when the task is successful
  121288. */
  121289. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  121290. /**
  121291. * Callback called when the task is successful
  121292. */
  121293. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  121294. /**
  121295. * Creates a new EquiRectangularCubeTextureAssetTask object
  121296. * @param name defines the name of the task
  121297. * @param url defines the location of the file to load
  121298. * @param size defines the desired size (the more it increases the longer the generation will be)
  121299. * If the size is omitted this implies you are using a preprocessed cubemap.
  121300. * @param noMipmap defines if mipmaps should not be generated (default is false)
  121301. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  121302. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  121303. * (default is true)
  121304. */
  121305. constructor(
  121306. /**
  121307. * Defines the name of the task
  121308. */
  121309. name: string,
  121310. /**
  121311. * Defines the location of the file to load
  121312. */
  121313. url: string,
  121314. /**
  121315. * Defines the desired size (the more it increases the longer the generation will be)
  121316. */
  121317. size: number,
  121318. /**
  121319. * Defines if mipmaps should not be generated (default is false)
  121320. */
  121321. noMipmap?: boolean,
  121322. /**
  121323. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  121324. * but the standard material would require them in Gamma space) (default is true)
  121325. */
  121326. gammaSpace?: boolean);
  121327. /**
  121328. * Execute the current task
  121329. * @param scene defines the scene where you want your assets to be loaded
  121330. * @param onSuccess is a callback called when the task is successfully executed
  121331. * @param onError is a callback called if an error occurs
  121332. */
  121333. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  121334. }
  121335. /**
  121336. * This class can be used to easily import assets into a scene
  121337. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  121338. */
  121339. export class AssetsManager {
  121340. private _scene;
  121341. private _isLoading;
  121342. protected _tasks: AbstractAssetTask[];
  121343. protected _waitingTasksCount: number;
  121344. protected _totalTasksCount: number;
  121345. /**
  121346. * Callback called when all tasks are processed
  121347. */
  121348. onFinish: (tasks: AbstractAssetTask[]) => void;
  121349. /**
  121350. * Callback called when a task is successful
  121351. */
  121352. onTaskSuccess: (task: AbstractAssetTask) => void;
  121353. /**
  121354. * Callback called when a task had an error
  121355. */
  121356. onTaskError: (task: AbstractAssetTask) => void;
  121357. /**
  121358. * Callback called when a task is done (whatever the result is)
  121359. */
  121360. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  121361. /**
  121362. * Observable called when all tasks are processed
  121363. */
  121364. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  121365. /**
  121366. * Observable called when a task had an error
  121367. */
  121368. onTaskErrorObservable: Observable<AbstractAssetTask>;
  121369. /**
  121370. * Observable called when all tasks were executed
  121371. */
  121372. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  121373. /**
  121374. * Observable called when a task is done (whatever the result is)
  121375. */
  121376. onProgressObservable: Observable<IAssetsProgressEvent>;
  121377. /**
  121378. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  121379. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  121380. */
  121381. useDefaultLoadingScreen: boolean;
  121382. /**
  121383. * Creates a new AssetsManager
  121384. * @param scene defines the scene to work on
  121385. */
  121386. constructor(scene: Scene);
  121387. /**
  121388. * Add a MeshAssetTask to the list of active tasks
  121389. * @param taskName defines the name of the new task
  121390. * @param meshesNames defines the name of meshes to load
  121391. * @param rootUrl defines the root url to use to locate files
  121392. * @param sceneFilename defines the filename of the scene file
  121393. * @returns a new MeshAssetTask object
  121394. */
  121395. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  121396. /**
  121397. * Add a TextFileAssetTask to the list of active tasks
  121398. * @param taskName defines the name of the new task
  121399. * @param url defines the url of the file to load
  121400. * @returns a new TextFileAssetTask object
  121401. */
  121402. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  121403. /**
  121404. * Add a BinaryFileAssetTask to the list of active tasks
  121405. * @param taskName defines the name of the new task
  121406. * @param url defines the url of the file to load
  121407. * @returns a new BinaryFileAssetTask object
  121408. */
  121409. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  121410. /**
  121411. * Add a ImageAssetTask to the list of active tasks
  121412. * @param taskName defines the name of the new task
  121413. * @param url defines the url of the file to load
  121414. * @returns a new ImageAssetTask object
  121415. */
  121416. addImageTask(taskName: string, url: string): ImageAssetTask;
  121417. /**
  121418. * Add a TextureAssetTask to the list of active tasks
  121419. * @param taskName defines the name of the new task
  121420. * @param url defines the url of the file to load
  121421. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  121422. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  121423. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  121424. * @returns a new TextureAssetTask object
  121425. */
  121426. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  121427. /**
  121428. * Add a CubeTextureAssetTask to the list of active tasks
  121429. * @param taskName defines the name of the new task
  121430. * @param url defines the url of the file to load
  121431. * @param extensions defines the extension to use to load the cube map (can be null)
  121432. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  121433. * @param files defines the list of files to load (can be null)
  121434. * @returns a new CubeTextureAssetTask object
  121435. */
  121436. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  121437. /**
  121438. *
  121439. * Add a HDRCubeTextureAssetTask to the list of active tasks
  121440. * @param taskName defines the name of the new task
  121441. * @param url defines the url of the file to load
  121442. * @param size defines the size you want for the cubemap (can be null)
  121443. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  121444. * @param generateHarmonics defines if you want to automatically generate (true by default)
  121445. * @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)
  121446. * @param reserved Internal use only
  121447. * @returns a new HDRCubeTextureAssetTask object
  121448. */
  121449. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  121450. /**
  121451. *
  121452. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  121453. * @param taskName defines the name of the new task
  121454. * @param url defines the url of the file to load
  121455. * @param size defines the size you want for the cubemap (can be null)
  121456. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  121457. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  121458. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  121459. * @returns a new EquiRectangularCubeTextureAssetTask object
  121460. */
  121461. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  121462. /**
  121463. * Remove a task from the assets manager.
  121464. * @param task the task to remove
  121465. */
  121466. removeTask(task: AbstractAssetTask): void;
  121467. private _decreaseWaitingTasksCount;
  121468. private _runTask;
  121469. /**
  121470. * Reset the AssetsManager and remove all tasks
  121471. * @return the current instance of the AssetsManager
  121472. */
  121473. reset(): AssetsManager;
  121474. /**
  121475. * Start the loading process
  121476. * @return the current instance of the AssetsManager
  121477. */
  121478. load(): AssetsManager;
  121479. /**
  121480. * Start the loading process as an async operation
  121481. * @return a promise returning the list of failed tasks
  121482. */
  121483. loadAsync(): Promise<void>;
  121484. }
  121485. }
  121486. declare module BABYLON {
  121487. /**
  121488. * Wrapper class for promise with external resolve and reject.
  121489. */
  121490. export class Deferred<T> {
  121491. /**
  121492. * The promise associated with this deferred object.
  121493. */
  121494. readonly promise: Promise<T>;
  121495. private _resolve;
  121496. private _reject;
  121497. /**
  121498. * The resolve method of the promise associated with this deferred object.
  121499. */
  121500. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  121501. /**
  121502. * The reject method of the promise associated with this deferred object.
  121503. */
  121504. readonly reject: (reason?: any) => void;
  121505. /**
  121506. * Constructor for this deferred object.
  121507. */
  121508. constructor();
  121509. }
  121510. }
  121511. declare module BABYLON {
  121512. /**
  121513. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  121514. */
  121515. export class MeshExploder {
  121516. private _centerMesh;
  121517. private _meshes;
  121518. private _meshesOrigins;
  121519. private _toCenterVectors;
  121520. private _scaledDirection;
  121521. private _newPosition;
  121522. private _centerPosition;
  121523. /**
  121524. * Explodes meshes from a center mesh.
  121525. * @param meshes The meshes to explode.
  121526. * @param centerMesh The mesh to be center of explosion.
  121527. */
  121528. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  121529. private _setCenterMesh;
  121530. /**
  121531. * Get class name
  121532. * @returns "MeshExploder"
  121533. */
  121534. getClassName(): string;
  121535. /**
  121536. * "Exploded meshes"
  121537. * @returns Array of meshes with the centerMesh at index 0.
  121538. */
  121539. getMeshes(): Array<Mesh>;
  121540. /**
  121541. * Explodes meshes giving a specific direction
  121542. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  121543. */
  121544. explode(direction?: number): void;
  121545. }
  121546. }
  121547. declare module BABYLON {
  121548. /**
  121549. * Class used to help managing file picking and drag'n'drop
  121550. */
  121551. export class FilesInput {
  121552. /**
  121553. * List of files ready to be loaded
  121554. */
  121555. static readonly FilesToLoad: {
  121556. [key: string]: File;
  121557. };
  121558. /**
  121559. * Callback called when a file is processed
  121560. */
  121561. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  121562. private _engine;
  121563. private _currentScene;
  121564. private _sceneLoadedCallback;
  121565. private _progressCallback;
  121566. private _additionalRenderLoopLogicCallback;
  121567. private _textureLoadingCallback;
  121568. private _startingProcessingFilesCallback;
  121569. private _onReloadCallback;
  121570. private _errorCallback;
  121571. private _elementToMonitor;
  121572. private _sceneFileToLoad;
  121573. private _filesToLoad;
  121574. /**
  121575. * Creates a new FilesInput
  121576. * @param engine defines the rendering engine
  121577. * @param scene defines the hosting scene
  121578. * @param sceneLoadedCallback callback called when scene is loaded
  121579. * @param progressCallback callback called to track progress
  121580. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  121581. * @param textureLoadingCallback callback called when a texture is loading
  121582. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  121583. * @param onReloadCallback callback called when a reload is requested
  121584. * @param errorCallback callback call if an error occurs
  121585. */
  121586. 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);
  121587. private _dragEnterHandler;
  121588. private _dragOverHandler;
  121589. private _dropHandler;
  121590. /**
  121591. * Calls this function to listen to drag'n'drop events on a specific DOM element
  121592. * @param elementToMonitor defines the DOM element to track
  121593. */
  121594. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  121595. /**
  121596. * Release all associated resources
  121597. */
  121598. dispose(): void;
  121599. private renderFunction;
  121600. private drag;
  121601. private drop;
  121602. private _traverseFolder;
  121603. private _processFiles;
  121604. /**
  121605. * Load files from a drop event
  121606. * @param event defines the drop event to use as source
  121607. */
  121608. loadFiles(event: any): void;
  121609. private _processReload;
  121610. /**
  121611. * Reload the current scene from the loaded files
  121612. */
  121613. reload(): void;
  121614. }
  121615. }
  121616. declare module BABYLON {
  121617. /**
  121618. * Defines the root class used to create scene optimization to use with SceneOptimizer
  121619. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121620. */
  121621. export class SceneOptimization {
  121622. /**
  121623. * Defines the priority of this optimization (0 by default which means first in the list)
  121624. */
  121625. priority: number;
  121626. /**
  121627. * Gets a string describing the action executed by the current optimization
  121628. * @returns description string
  121629. */
  121630. getDescription(): string;
  121631. /**
  121632. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121633. * @param scene defines the current scene where to apply this optimization
  121634. * @param optimizer defines the current optimizer
  121635. * @returns true if everything that can be done was applied
  121636. */
  121637. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121638. /**
  121639. * Creates the SceneOptimization object
  121640. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  121641. * @param desc defines the description associated with the optimization
  121642. */
  121643. constructor(
  121644. /**
  121645. * Defines the priority of this optimization (0 by default which means first in the list)
  121646. */
  121647. priority?: number);
  121648. }
  121649. /**
  121650. * Defines an optimization used to reduce the size of render target textures
  121651. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121652. */
  121653. export class TextureOptimization extends SceneOptimization {
  121654. /**
  121655. * Defines the priority of this optimization (0 by default which means first in the list)
  121656. */
  121657. priority: number;
  121658. /**
  121659. * 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
  121660. */
  121661. maximumSize: number;
  121662. /**
  121663. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  121664. */
  121665. step: number;
  121666. /**
  121667. * Gets a string describing the action executed by the current optimization
  121668. * @returns description string
  121669. */
  121670. getDescription(): string;
  121671. /**
  121672. * Creates the TextureOptimization object
  121673. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  121674. * @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
  121675. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  121676. */
  121677. constructor(
  121678. /**
  121679. * Defines the priority of this optimization (0 by default which means first in the list)
  121680. */
  121681. priority?: number,
  121682. /**
  121683. * 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
  121684. */
  121685. maximumSize?: number,
  121686. /**
  121687. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  121688. */
  121689. step?: number);
  121690. /**
  121691. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121692. * @param scene defines the current scene where to apply this optimization
  121693. * @param optimizer defines the current optimizer
  121694. * @returns true if everything that can be done was applied
  121695. */
  121696. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121697. }
  121698. /**
  121699. * Defines an optimization used to increase or decrease the rendering resolution
  121700. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121701. */
  121702. export class HardwareScalingOptimization extends SceneOptimization {
  121703. /**
  121704. * Defines the priority of this optimization (0 by default which means first in the list)
  121705. */
  121706. priority: number;
  121707. /**
  121708. * Defines the maximum scale to use (2 by default)
  121709. */
  121710. maximumScale: number;
  121711. /**
  121712. * Defines the step to use between two passes (0.5 by default)
  121713. */
  121714. step: number;
  121715. private _currentScale;
  121716. private _directionOffset;
  121717. /**
  121718. * Gets a string describing the action executed by the current optimization
  121719. * @return description string
  121720. */
  121721. getDescription(): string;
  121722. /**
  121723. * Creates the HardwareScalingOptimization object
  121724. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  121725. * @param maximumScale defines the maximum scale to use (2 by default)
  121726. * @param step defines the step to use between two passes (0.5 by default)
  121727. */
  121728. constructor(
  121729. /**
  121730. * Defines the priority of this optimization (0 by default which means first in the list)
  121731. */
  121732. priority?: number,
  121733. /**
  121734. * Defines the maximum scale to use (2 by default)
  121735. */
  121736. maximumScale?: number,
  121737. /**
  121738. * Defines the step to use between two passes (0.5 by default)
  121739. */
  121740. step?: number);
  121741. /**
  121742. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121743. * @param scene defines the current scene where to apply this optimization
  121744. * @param optimizer defines the current optimizer
  121745. * @returns true if everything that can be done was applied
  121746. */
  121747. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121748. }
  121749. /**
  121750. * Defines an optimization used to remove shadows
  121751. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121752. */
  121753. export class ShadowsOptimization extends SceneOptimization {
  121754. /**
  121755. * Gets a string describing the action executed by the current optimization
  121756. * @return description string
  121757. */
  121758. getDescription(): string;
  121759. /**
  121760. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121761. * @param scene defines the current scene where to apply this optimization
  121762. * @param optimizer defines the current optimizer
  121763. * @returns true if everything that can be done was applied
  121764. */
  121765. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121766. }
  121767. /**
  121768. * Defines an optimization used to turn post-processes off
  121769. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121770. */
  121771. export class PostProcessesOptimization extends SceneOptimization {
  121772. /**
  121773. * Gets a string describing the action executed by the current optimization
  121774. * @return description string
  121775. */
  121776. getDescription(): string;
  121777. /**
  121778. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121779. * @param scene defines the current scene where to apply this optimization
  121780. * @param optimizer defines the current optimizer
  121781. * @returns true if everything that can be done was applied
  121782. */
  121783. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121784. }
  121785. /**
  121786. * Defines an optimization used to turn lens flares off
  121787. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121788. */
  121789. export class LensFlaresOptimization extends SceneOptimization {
  121790. /**
  121791. * Gets a string describing the action executed by the current optimization
  121792. * @return description string
  121793. */
  121794. getDescription(): string;
  121795. /**
  121796. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121797. * @param scene defines the current scene where to apply this optimization
  121798. * @param optimizer defines the current optimizer
  121799. * @returns true if everything that can be done was applied
  121800. */
  121801. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121802. }
  121803. /**
  121804. * Defines an optimization based on user defined callback.
  121805. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121806. */
  121807. export class CustomOptimization extends SceneOptimization {
  121808. /**
  121809. * Callback called to apply the custom optimization.
  121810. */
  121811. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  121812. /**
  121813. * Callback called to get custom description
  121814. */
  121815. onGetDescription: () => string;
  121816. /**
  121817. * Gets a string describing the action executed by the current optimization
  121818. * @returns description string
  121819. */
  121820. getDescription(): string;
  121821. /**
  121822. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121823. * @param scene defines the current scene where to apply this optimization
  121824. * @param optimizer defines the current optimizer
  121825. * @returns true if everything that can be done was applied
  121826. */
  121827. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121828. }
  121829. /**
  121830. * Defines an optimization used to turn particles off
  121831. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121832. */
  121833. export class ParticlesOptimization extends SceneOptimization {
  121834. /**
  121835. * Gets a string describing the action executed by the current optimization
  121836. * @return description string
  121837. */
  121838. getDescription(): string;
  121839. /**
  121840. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121841. * @param scene defines the current scene where to apply this optimization
  121842. * @param optimizer defines the current optimizer
  121843. * @returns true if everything that can be done was applied
  121844. */
  121845. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121846. }
  121847. /**
  121848. * Defines an optimization used to turn render targets off
  121849. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121850. */
  121851. export class RenderTargetsOptimization extends SceneOptimization {
  121852. /**
  121853. * Gets a string describing the action executed by the current optimization
  121854. * @return description string
  121855. */
  121856. getDescription(): string;
  121857. /**
  121858. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121859. * @param scene defines the current scene where to apply this optimization
  121860. * @param optimizer defines the current optimizer
  121861. * @returns true if everything that can be done was applied
  121862. */
  121863. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121864. }
  121865. /**
  121866. * Defines an optimization used to merge meshes with compatible materials
  121867. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121868. */
  121869. export class MergeMeshesOptimization extends SceneOptimization {
  121870. private static _UpdateSelectionTree;
  121871. /**
  121872. * Gets or sets a boolean which defines if optimization octree has to be updated
  121873. */
  121874. /**
  121875. * Gets or sets a boolean which defines if optimization octree has to be updated
  121876. */
  121877. static UpdateSelectionTree: boolean;
  121878. /**
  121879. * Gets a string describing the action executed by the current optimization
  121880. * @return description string
  121881. */
  121882. getDescription(): string;
  121883. private _canBeMerged;
  121884. /**
  121885. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121886. * @param scene defines the current scene where to apply this optimization
  121887. * @param optimizer defines the current optimizer
  121888. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  121889. * @returns true if everything that can be done was applied
  121890. */
  121891. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  121892. }
  121893. /**
  121894. * Defines a list of options used by SceneOptimizer
  121895. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121896. */
  121897. export class SceneOptimizerOptions {
  121898. /**
  121899. * Defines the target frame rate to reach (60 by default)
  121900. */
  121901. targetFrameRate: number;
  121902. /**
  121903. * Defines the interval between two checkes (2000ms by default)
  121904. */
  121905. trackerDuration: number;
  121906. /**
  121907. * Gets the list of optimizations to apply
  121908. */
  121909. optimizations: SceneOptimization[];
  121910. /**
  121911. * Creates a new list of options used by SceneOptimizer
  121912. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  121913. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  121914. */
  121915. constructor(
  121916. /**
  121917. * Defines the target frame rate to reach (60 by default)
  121918. */
  121919. targetFrameRate?: number,
  121920. /**
  121921. * Defines the interval between two checkes (2000ms by default)
  121922. */
  121923. trackerDuration?: number);
  121924. /**
  121925. * Add a new optimization
  121926. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  121927. * @returns the current SceneOptimizerOptions
  121928. */
  121929. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  121930. /**
  121931. * Add a new custom optimization
  121932. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  121933. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  121934. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  121935. * @returns the current SceneOptimizerOptions
  121936. */
  121937. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  121938. /**
  121939. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  121940. * @param targetFrameRate defines the target frame rate (60 by default)
  121941. * @returns a SceneOptimizerOptions object
  121942. */
  121943. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  121944. /**
  121945. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  121946. * @param targetFrameRate defines the target frame rate (60 by default)
  121947. * @returns a SceneOptimizerOptions object
  121948. */
  121949. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  121950. /**
  121951. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  121952. * @param targetFrameRate defines the target frame rate (60 by default)
  121953. * @returns a SceneOptimizerOptions object
  121954. */
  121955. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  121956. }
  121957. /**
  121958. * Class used to run optimizations in order to reach a target frame rate
  121959. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121960. */
  121961. export class SceneOptimizer implements IDisposable {
  121962. private _isRunning;
  121963. private _options;
  121964. private _scene;
  121965. private _currentPriorityLevel;
  121966. private _targetFrameRate;
  121967. private _trackerDuration;
  121968. private _currentFrameRate;
  121969. private _sceneDisposeObserver;
  121970. private _improvementMode;
  121971. /**
  121972. * Defines an observable called when the optimizer reaches the target frame rate
  121973. */
  121974. onSuccessObservable: Observable<SceneOptimizer>;
  121975. /**
  121976. * Defines an observable called when the optimizer enables an optimization
  121977. */
  121978. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  121979. /**
  121980. * Defines an observable called when the optimizer is not able to reach the target frame rate
  121981. */
  121982. onFailureObservable: Observable<SceneOptimizer>;
  121983. /**
  121984. * Gets a boolean indicating if the optimizer is in improvement mode
  121985. */
  121986. readonly isInImprovementMode: boolean;
  121987. /**
  121988. * Gets the current priority level (0 at start)
  121989. */
  121990. readonly currentPriorityLevel: number;
  121991. /**
  121992. * Gets the current frame rate checked by the SceneOptimizer
  121993. */
  121994. readonly currentFrameRate: number;
  121995. /**
  121996. * Gets or sets the current target frame rate (60 by default)
  121997. */
  121998. /**
  121999. * Gets or sets the current target frame rate (60 by default)
  122000. */
  122001. targetFrameRate: number;
  122002. /**
  122003. * Gets or sets the current interval between two checks (every 2000ms by default)
  122004. */
  122005. /**
  122006. * Gets or sets the current interval between two checks (every 2000ms by default)
  122007. */
  122008. trackerDuration: number;
  122009. /**
  122010. * Gets the list of active optimizations
  122011. */
  122012. readonly optimizations: SceneOptimization[];
  122013. /**
  122014. * Creates a new SceneOptimizer
  122015. * @param scene defines the scene to work on
  122016. * @param options defines the options to use with the SceneOptimizer
  122017. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  122018. * @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)
  122019. */
  122020. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  122021. /**
  122022. * Stops the current optimizer
  122023. */
  122024. stop(): void;
  122025. /**
  122026. * Reset the optimizer to initial step (current priority level = 0)
  122027. */
  122028. reset(): void;
  122029. /**
  122030. * Start the optimizer. By default it will try to reach a specific framerate
  122031. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  122032. */
  122033. start(): void;
  122034. private _checkCurrentState;
  122035. /**
  122036. * Release all resources
  122037. */
  122038. dispose(): void;
  122039. /**
  122040. * Helper function to create a SceneOptimizer with one single line of code
  122041. * @param scene defines the scene to work on
  122042. * @param options defines the options to use with the SceneOptimizer
  122043. * @param onSuccess defines a callback to call on success
  122044. * @param onFailure defines a callback to call on failure
  122045. * @returns the new SceneOptimizer object
  122046. */
  122047. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  122048. }
  122049. }
  122050. declare module BABYLON {
  122051. /**
  122052. * Class used to serialize a scene into a string
  122053. */
  122054. export class SceneSerializer {
  122055. /**
  122056. * Clear cache used by a previous serialization
  122057. */
  122058. static ClearCache(): void;
  122059. /**
  122060. * Serialize a scene into a JSON compatible object
  122061. * @param scene defines the scene to serialize
  122062. * @returns a JSON compatible object
  122063. */
  122064. static Serialize(scene: Scene): any;
  122065. /**
  122066. * Serialize a mesh into a JSON compatible object
  122067. * @param toSerialize defines the mesh to serialize
  122068. * @param withParents defines if parents must be serialized as well
  122069. * @param withChildren defines if children must be serialized as well
  122070. * @returns a JSON compatible object
  122071. */
  122072. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  122073. }
  122074. }
  122075. declare module BABYLON {
  122076. /**
  122077. * Class used to host texture specific utilities
  122078. */
  122079. export class TextureTools {
  122080. /**
  122081. * Uses the GPU to create a copy texture rescaled at a given size
  122082. * @param texture Texture to copy from
  122083. * @param width defines the desired width
  122084. * @param height defines the desired height
  122085. * @param useBilinearMode defines if bilinear mode has to be used
  122086. * @return the generated texture
  122087. */
  122088. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  122089. }
  122090. }
  122091. declare module BABYLON {
  122092. /**
  122093. * This represents the different options available for the video capture.
  122094. */
  122095. export interface VideoRecorderOptions {
  122096. /** Defines the mime type of the video. */
  122097. mimeType: string;
  122098. /** Defines the FPS the video should be recorded at. */
  122099. fps: number;
  122100. /** Defines the chunk size for the recording data. */
  122101. recordChunckSize: number;
  122102. /** The audio tracks to attach to the recording. */
  122103. audioTracks?: MediaStreamTrack[];
  122104. }
  122105. /**
  122106. * This can help with recording videos from BabylonJS.
  122107. * This is based on the available WebRTC functionalities of the browser.
  122108. *
  122109. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  122110. */
  122111. export class VideoRecorder {
  122112. private static readonly _defaultOptions;
  122113. /**
  122114. * Returns whether or not the VideoRecorder is available in your browser.
  122115. * @param engine Defines the Babylon Engine.
  122116. * @returns true if supported otherwise false.
  122117. */
  122118. static IsSupported(engine: Engine): boolean;
  122119. private readonly _options;
  122120. private _canvas;
  122121. private _mediaRecorder;
  122122. private _recordedChunks;
  122123. private _fileName;
  122124. private _resolve;
  122125. private _reject;
  122126. /**
  122127. * True when a recording is already in progress.
  122128. */
  122129. readonly isRecording: boolean;
  122130. /**
  122131. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  122132. * @param engine Defines the BabylonJS Engine you wish to record.
  122133. * @param options Defines options that can be used to customize the capture.
  122134. */
  122135. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  122136. /**
  122137. * Stops the current recording before the default capture timeout passed in the startRecording function.
  122138. */
  122139. stopRecording(): void;
  122140. /**
  122141. * Starts recording the canvas for a max duration specified in parameters.
  122142. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  122143. * If null no automatic download will start and you can rely on the promise to get the data back.
  122144. * @param maxDuration Defines the maximum recording time in seconds.
  122145. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  122146. * @return A promise callback at the end of the recording with the video data in Blob.
  122147. */
  122148. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  122149. /**
  122150. * Releases internal resources used during the recording.
  122151. */
  122152. dispose(): void;
  122153. private _handleDataAvailable;
  122154. private _handleError;
  122155. private _handleStop;
  122156. }
  122157. }
  122158. declare module BABYLON {
  122159. /**
  122160. * Class containing a set of static utilities functions for screenshots
  122161. */
  122162. export class ScreenshotTools {
  122163. /**
  122164. * Captures a screenshot of the current rendering
  122165. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  122166. * @param engine defines the rendering engine
  122167. * @param camera defines the source camera
  122168. * @param size This parameter can be set to a single number or to an object with the
  122169. * following (optional) properties: precision, width, height. If a single number is passed,
  122170. * it will be used for both width and height. If an object is passed, the screenshot size
  122171. * will be derived from the parameters. The precision property is a multiplier allowing
  122172. * rendering at a higher or lower resolution
  122173. * @param successCallback defines the callback receives a single parameter which contains the
  122174. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  122175. * src parameter of an <img> to display it
  122176. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  122177. * Check your browser for supported MIME types
  122178. */
  122179. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  122180. /**
  122181. * Generates an image screenshot from the specified camera.
  122182. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  122183. * @param engine The engine to use for rendering
  122184. * @param camera The camera to use for rendering
  122185. * @param size This parameter can be set to a single number or to an object with the
  122186. * following (optional) properties: precision, width, height. If a single number is passed,
  122187. * it will be used for both width and height. If an object is passed, the screenshot size
  122188. * will be derived from the parameters. The precision property is a multiplier allowing
  122189. * rendering at a higher or lower resolution
  122190. * @param successCallback The callback receives a single parameter which contains the
  122191. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  122192. * src parameter of an <img> to display it
  122193. * @param mimeType The MIME type of the screenshot image (default: image/png).
  122194. * Check your browser for supported MIME types
  122195. * @param samples Texture samples (default: 1)
  122196. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  122197. * @param fileName A name for for the downloaded file.
  122198. */
  122199. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  122200. }
  122201. }
  122202. declare module BABYLON {
  122203. /**
  122204. * A cursor which tracks a point on a path
  122205. */
  122206. export class PathCursor {
  122207. private path;
  122208. /**
  122209. * Stores path cursor callbacks for when an onchange event is triggered
  122210. */
  122211. private _onchange;
  122212. /**
  122213. * The value of the path cursor
  122214. */
  122215. value: number;
  122216. /**
  122217. * The animation array of the path cursor
  122218. */
  122219. animations: Animation[];
  122220. /**
  122221. * Initializes the path cursor
  122222. * @param path The path to track
  122223. */
  122224. constructor(path: Path2);
  122225. /**
  122226. * Gets the cursor point on the path
  122227. * @returns A point on the path cursor at the cursor location
  122228. */
  122229. getPoint(): Vector3;
  122230. /**
  122231. * Moves the cursor ahead by the step amount
  122232. * @param step The amount to move the cursor forward
  122233. * @returns This path cursor
  122234. */
  122235. moveAhead(step?: number): PathCursor;
  122236. /**
  122237. * Moves the cursor behind by the step amount
  122238. * @param step The amount to move the cursor back
  122239. * @returns This path cursor
  122240. */
  122241. moveBack(step?: number): PathCursor;
  122242. /**
  122243. * Moves the cursor by the step amount
  122244. * If the step amount is greater than one, an exception is thrown
  122245. * @param step The amount to move the cursor
  122246. * @returns This path cursor
  122247. */
  122248. move(step: number): PathCursor;
  122249. /**
  122250. * Ensures that the value is limited between zero and one
  122251. * @returns This path cursor
  122252. */
  122253. private ensureLimits;
  122254. /**
  122255. * Runs onchange callbacks on change (used by the animation engine)
  122256. * @returns This path cursor
  122257. */
  122258. private raiseOnChange;
  122259. /**
  122260. * Executes a function on change
  122261. * @param f A path cursor onchange callback
  122262. * @returns This path cursor
  122263. */
  122264. onchange(f: (cursor: PathCursor) => void): PathCursor;
  122265. }
  122266. }
  122267. declare module BABYLON {
  122268. /** @hidden */
  122269. export var blurPixelShader: {
  122270. name: string;
  122271. shader: string;
  122272. };
  122273. }
  122274. declare module BABYLON {
  122275. /** @hidden */
  122276. export var pointCloudVertexDeclaration: {
  122277. name: string;
  122278. shader: string;
  122279. };
  122280. }
  122281. // Mixins
  122282. interface Window {
  122283. mozIndexedDB: IDBFactory;
  122284. webkitIndexedDB: IDBFactory;
  122285. msIndexedDB: IDBFactory;
  122286. webkitURL: typeof URL;
  122287. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  122288. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  122289. WebGLRenderingContext: WebGLRenderingContext;
  122290. MSGesture: MSGesture;
  122291. CANNON: any;
  122292. AudioContext: AudioContext;
  122293. webkitAudioContext: AudioContext;
  122294. PointerEvent: any;
  122295. Math: Math;
  122296. Uint8Array: Uint8ArrayConstructor;
  122297. Float32Array: Float32ArrayConstructor;
  122298. mozURL: typeof URL;
  122299. msURL: typeof URL;
  122300. VRFrameData: any; // WebVR, from specs 1.1
  122301. DracoDecoderModule: any;
  122302. setImmediate(handler: (...args: any[]) => void): number;
  122303. }
  122304. interface HTMLCanvasElement {
  122305. requestPointerLock(): void;
  122306. msRequestPointerLock?(): void;
  122307. mozRequestPointerLock?(): void;
  122308. webkitRequestPointerLock?(): void;
  122309. /** Track wether a record is in progress */
  122310. isRecording: boolean;
  122311. /** Capture Stream method defined by some browsers */
  122312. captureStream(fps?: number): MediaStream;
  122313. }
  122314. interface CanvasRenderingContext2D {
  122315. msImageSmoothingEnabled: boolean;
  122316. }
  122317. interface MouseEvent {
  122318. mozMovementX: number;
  122319. mozMovementY: number;
  122320. webkitMovementX: number;
  122321. webkitMovementY: number;
  122322. msMovementX: number;
  122323. msMovementY: number;
  122324. }
  122325. interface Navigator {
  122326. mozGetVRDevices: (any: any) => any;
  122327. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  122328. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  122329. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  122330. webkitGetGamepads(): Gamepad[];
  122331. msGetGamepads(): Gamepad[];
  122332. webkitGamepads(): Gamepad[];
  122333. }
  122334. interface HTMLVideoElement {
  122335. mozSrcObject: any;
  122336. }
  122337. interface Math {
  122338. fround(x: number): number;
  122339. imul(a: number, b: number): number;
  122340. }
  122341. interface WebGLRenderingContext {
  122342. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  122343. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  122344. vertexAttribDivisor(index: number, divisor: number): void;
  122345. createVertexArray(): any;
  122346. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  122347. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  122348. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  122349. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  122350. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  122351. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  122352. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  122353. // Queries
  122354. createQuery(): WebGLQuery;
  122355. deleteQuery(query: WebGLQuery): void;
  122356. beginQuery(target: number, query: WebGLQuery): void;
  122357. endQuery(target: number): void;
  122358. getQueryParameter(query: WebGLQuery, pname: number): any;
  122359. getQuery(target: number, pname: number): any;
  122360. MAX_SAMPLES: number;
  122361. RGBA8: number;
  122362. READ_FRAMEBUFFER: number;
  122363. DRAW_FRAMEBUFFER: number;
  122364. UNIFORM_BUFFER: number;
  122365. HALF_FLOAT_OES: number;
  122366. RGBA16F: number;
  122367. RGBA32F: number;
  122368. R32F: number;
  122369. RG32F: number;
  122370. RGB32F: number;
  122371. R16F: number;
  122372. RG16F: number;
  122373. RGB16F: number;
  122374. RED: number;
  122375. RG: number;
  122376. R8: number;
  122377. RG8: number;
  122378. UNSIGNED_INT_24_8: number;
  122379. DEPTH24_STENCIL8: number;
  122380. /* Multiple Render Targets */
  122381. drawBuffers(buffers: number[]): void;
  122382. readBuffer(src: number): void;
  122383. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  122384. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  122385. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  122386. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  122387. // Occlusion Query
  122388. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  122389. ANY_SAMPLES_PASSED: number;
  122390. QUERY_RESULT_AVAILABLE: number;
  122391. QUERY_RESULT: number;
  122392. }
  122393. interface WebGLProgram {
  122394. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  122395. }
  122396. interface EXT_disjoint_timer_query {
  122397. QUERY_COUNTER_BITS_EXT: number;
  122398. TIME_ELAPSED_EXT: number;
  122399. TIMESTAMP_EXT: number;
  122400. GPU_DISJOINT_EXT: number;
  122401. QUERY_RESULT_EXT: number;
  122402. QUERY_RESULT_AVAILABLE_EXT: number;
  122403. queryCounterEXT(query: WebGLQuery, target: number): void;
  122404. createQueryEXT(): WebGLQuery;
  122405. beginQueryEXT(target: number, query: WebGLQuery): void;
  122406. endQueryEXT(target: number): void;
  122407. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  122408. deleteQueryEXT(query: WebGLQuery): void;
  122409. }
  122410. interface WebGLUniformLocation {
  122411. _currentState: any;
  122412. }
  122413. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  122414. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  122415. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  122416. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  122417. interface WebGLRenderingContext {
  122418. readonly RASTERIZER_DISCARD: number;
  122419. readonly DEPTH_COMPONENT24: number;
  122420. readonly TEXTURE_3D: number;
  122421. readonly TEXTURE_2D_ARRAY: number;
  122422. readonly TEXTURE_COMPARE_FUNC: number;
  122423. readonly TEXTURE_COMPARE_MODE: number;
  122424. readonly COMPARE_REF_TO_TEXTURE: number;
  122425. readonly TEXTURE_WRAP_R: number;
  122426. readonly HALF_FLOAT: number;
  122427. readonly RGB8: number;
  122428. readonly RED_INTEGER: number;
  122429. readonly RG_INTEGER: number;
  122430. readonly RGB_INTEGER: number;
  122431. readonly RGBA_INTEGER: number;
  122432. readonly R8_SNORM: number;
  122433. readonly RG8_SNORM: number;
  122434. readonly RGB8_SNORM: number;
  122435. readonly RGBA8_SNORM: number;
  122436. readonly R8I: number;
  122437. readonly RG8I: number;
  122438. readonly RGB8I: number;
  122439. readonly RGBA8I: number;
  122440. readonly R8UI: number;
  122441. readonly RG8UI: number;
  122442. readonly RGB8UI: number;
  122443. readonly RGBA8UI: number;
  122444. readonly R16I: number;
  122445. readonly RG16I: number;
  122446. readonly RGB16I: number;
  122447. readonly RGBA16I: number;
  122448. readonly R16UI: number;
  122449. readonly RG16UI: number;
  122450. readonly RGB16UI: number;
  122451. readonly RGBA16UI: number;
  122452. readonly R32I: number;
  122453. readonly RG32I: number;
  122454. readonly RGB32I: number;
  122455. readonly RGBA32I: number;
  122456. readonly R32UI: number;
  122457. readonly RG32UI: number;
  122458. readonly RGB32UI: number;
  122459. readonly RGBA32UI: number;
  122460. readonly RGB10_A2UI: number;
  122461. readonly R11F_G11F_B10F: number;
  122462. readonly RGB9_E5: number;
  122463. readonly RGB10_A2: number;
  122464. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  122465. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  122466. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  122467. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  122468. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  122469. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  122470. 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;
  122471. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  122472. readonly TRANSFORM_FEEDBACK: number;
  122473. readonly INTERLEAVED_ATTRIBS: number;
  122474. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  122475. createTransformFeedback(): WebGLTransformFeedback;
  122476. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  122477. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  122478. beginTransformFeedback(primitiveMode: number): void;
  122479. endTransformFeedback(): void;
  122480. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  122481. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  122482. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  122483. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  122484. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  122485. }
  122486. interface ImageBitmap {
  122487. readonly width: number;
  122488. readonly height: number;
  122489. close(): void;
  122490. }
  122491. interface WebGLQuery extends WebGLObject {
  122492. }
  122493. declare var WebGLQuery: {
  122494. prototype: WebGLQuery;
  122495. new(): WebGLQuery;
  122496. };
  122497. interface WebGLSampler extends WebGLObject {
  122498. }
  122499. declare var WebGLSampler: {
  122500. prototype: WebGLSampler;
  122501. new(): WebGLSampler;
  122502. };
  122503. interface WebGLSync extends WebGLObject {
  122504. }
  122505. declare var WebGLSync: {
  122506. prototype: WebGLSync;
  122507. new(): WebGLSync;
  122508. };
  122509. interface WebGLTransformFeedback extends WebGLObject {
  122510. }
  122511. declare var WebGLTransformFeedback: {
  122512. prototype: WebGLTransformFeedback;
  122513. new(): WebGLTransformFeedback;
  122514. };
  122515. interface WebGLVertexArrayObject extends WebGLObject {
  122516. }
  122517. declare var WebGLVertexArrayObject: {
  122518. prototype: WebGLVertexArrayObject;
  122519. new(): WebGLVertexArrayObject;
  122520. };
  122521. // Type definitions for WebVR API
  122522. // Project: https://w3c.github.io/webvr/
  122523. // Definitions by: six a <https://github.com/lostfictions>
  122524. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  122525. interface VRDisplay extends EventTarget {
  122526. /**
  122527. * Dictionary of capabilities describing the VRDisplay.
  122528. */
  122529. readonly capabilities: VRDisplayCapabilities;
  122530. /**
  122531. * z-depth defining the far plane of the eye view frustum
  122532. * enables mapping of values in the render target depth
  122533. * attachment to scene coordinates. Initially set to 10000.0.
  122534. */
  122535. depthFar: number;
  122536. /**
  122537. * z-depth defining the near plane of the eye view frustum
  122538. * enables mapping of values in the render target depth
  122539. * attachment to scene coordinates. Initially set to 0.01.
  122540. */
  122541. depthNear: number;
  122542. /**
  122543. * An identifier for this distinct VRDisplay. Used as an
  122544. * association point in the Gamepad API.
  122545. */
  122546. readonly displayId: number;
  122547. /**
  122548. * A display name, a user-readable name identifying it.
  122549. */
  122550. readonly displayName: string;
  122551. readonly isConnected: boolean;
  122552. readonly isPresenting: boolean;
  122553. /**
  122554. * If this VRDisplay supports room-scale experiences, the optional
  122555. * stage attribute contains details on the room-scale parameters.
  122556. */
  122557. readonly stageParameters: VRStageParameters | null;
  122558. /**
  122559. * Passing the value returned by `requestAnimationFrame` to
  122560. * `cancelAnimationFrame` will unregister the callback.
  122561. * @param handle Define the hanle of the request to cancel
  122562. */
  122563. cancelAnimationFrame(handle: number): void;
  122564. /**
  122565. * Stops presenting to the VRDisplay.
  122566. * @returns a promise to know when it stopped
  122567. */
  122568. exitPresent(): Promise<void>;
  122569. /**
  122570. * Return the current VREyeParameters for the given eye.
  122571. * @param whichEye Define the eye we want the parameter for
  122572. * @returns the eye parameters
  122573. */
  122574. getEyeParameters(whichEye: string): VREyeParameters;
  122575. /**
  122576. * Populates the passed VRFrameData with the information required to render
  122577. * the current frame.
  122578. * @param frameData Define the data structure to populate
  122579. * @returns true if ok otherwise false
  122580. */
  122581. getFrameData(frameData: VRFrameData): boolean;
  122582. /**
  122583. * Get the layers currently being presented.
  122584. * @returns the list of VR layers
  122585. */
  122586. getLayers(): VRLayer[];
  122587. /**
  122588. * Return a VRPose containing the future predicted pose of the VRDisplay
  122589. * when the current frame will be presented. The value returned will not
  122590. * change until JavaScript has returned control to the browser.
  122591. *
  122592. * The VRPose will contain the position, orientation, velocity,
  122593. * and acceleration of each of these properties.
  122594. * @returns the pose object
  122595. */
  122596. getPose(): VRPose;
  122597. /**
  122598. * Return the current instantaneous pose of the VRDisplay, with no
  122599. * prediction applied.
  122600. * @returns the current instantaneous pose
  122601. */
  122602. getImmediatePose(): VRPose;
  122603. /**
  122604. * The callback passed to `requestAnimationFrame` will be called
  122605. * any time a new frame should be rendered. When the VRDisplay is
  122606. * presenting the callback will be called at the native refresh
  122607. * rate of the HMD. When not presenting this function acts
  122608. * identically to how window.requestAnimationFrame acts. Content should
  122609. * make no assumptions of frame rate or vsync behavior as the HMD runs
  122610. * asynchronously from other displays and at differing refresh rates.
  122611. * @param callback Define the eaction to run next frame
  122612. * @returns the request handle it
  122613. */
  122614. requestAnimationFrame(callback: FrameRequestCallback): number;
  122615. /**
  122616. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  122617. * Repeat calls while already presenting will update the VRLayers being displayed.
  122618. * @param layers Define the list of layer to present
  122619. * @returns a promise to know when the request has been fulfilled
  122620. */
  122621. requestPresent(layers: VRLayer[]): Promise<void>;
  122622. /**
  122623. * Reset the pose for this display, treating its current position and
  122624. * orientation as the "origin/zero" values. VRPose.position,
  122625. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  122626. * updated when calling resetPose(). This should be called in only
  122627. * sitting-space experiences.
  122628. */
  122629. resetPose(): void;
  122630. /**
  122631. * The VRLayer provided to the VRDisplay will be captured and presented
  122632. * in the HMD. Calling this function has the same effect on the source
  122633. * canvas as any other operation that uses its source image, and canvases
  122634. * created without preserveDrawingBuffer set to true will be cleared.
  122635. * @param pose Define the pose to submit
  122636. */
  122637. submitFrame(pose?: VRPose): void;
  122638. }
  122639. declare var VRDisplay: {
  122640. prototype: VRDisplay;
  122641. new(): VRDisplay;
  122642. };
  122643. interface VRLayer {
  122644. leftBounds?: number[] | Float32Array | null;
  122645. rightBounds?: number[] | Float32Array | null;
  122646. source?: HTMLCanvasElement | null;
  122647. }
  122648. interface VRDisplayCapabilities {
  122649. readonly canPresent: boolean;
  122650. readonly hasExternalDisplay: boolean;
  122651. readonly hasOrientation: boolean;
  122652. readonly hasPosition: boolean;
  122653. readonly maxLayers: number;
  122654. }
  122655. interface VREyeParameters {
  122656. /** @deprecated */
  122657. readonly fieldOfView: VRFieldOfView;
  122658. readonly offset: Float32Array;
  122659. readonly renderHeight: number;
  122660. readonly renderWidth: number;
  122661. }
  122662. interface VRFieldOfView {
  122663. readonly downDegrees: number;
  122664. readonly leftDegrees: number;
  122665. readonly rightDegrees: number;
  122666. readonly upDegrees: number;
  122667. }
  122668. interface VRFrameData {
  122669. readonly leftProjectionMatrix: Float32Array;
  122670. readonly leftViewMatrix: Float32Array;
  122671. readonly pose: VRPose;
  122672. readonly rightProjectionMatrix: Float32Array;
  122673. readonly rightViewMatrix: Float32Array;
  122674. readonly timestamp: number;
  122675. }
  122676. interface VRPose {
  122677. readonly angularAcceleration: Float32Array | null;
  122678. readonly angularVelocity: Float32Array | null;
  122679. readonly linearAcceleration: Float32Array | null;
  122680. readonly linearVelocity: Float32Array | null;
  122681. readonly orientation: Float32Array | null;
  122682. readonly position: Float32Array | null;
  122683. readonly timestamp: number;
  122684. }
  122685. interface VRStageParameters {
  122686. sittingToStandingTransform?: Float32Array;
  122687. sizeX?: number;
  122688. sizeY?: number;
  122689. }
  122690. interface Navigator {
  122691. getVRDisplays(): Promise<VRDisplay[]>;
  122692. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  122693. }
  122694. interface Window {
  122695. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  122696. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  122697. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  122698. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  122699. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  122700. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  122701. }
  122702. interface Gamepad {
  122703. readonly displayId: number;
  122704. }
  122705. interface XRDevice {
  122706. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  122707. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  122708. }
  122709. interface XRSession {
  122710. getInputSources(): Array<any>;
  122711. baseLayer: XRWebGLLayer;
  122712. requestFrameOfReference(type: string): Promise<void>;
  122713. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  122714. end(): Promise<void>;
  122715. requestAnimationFrame: Function;
  122716. addEventListener: Function;
  122717. }
  122718. interface XRSessionCreationOptions {
  122719. outputContext?: WebGLRenderingContext | null;
  122720. immersive?: boolean;
  122721. environmentIntegration?: boolean;
  122722. }
  122723. interface XRLayer {
  122724. getViewport: Function;
  122725. framebufferWidth: number;
  122726. framebufferHeight: number;
  122727. }
  122728. interface XRView {
  122729. projectionMatrix: Float32Array;
  122730. }
  122731. interface XRFrame {
  122732. getDevicePose: Function;
  122733. getInputPose: Function;
  122734. views: Array<XRView>;
  122735. baseLayer: XRLayer;
  122736. }
  122737. interface XRFrameOfReference {
  122738. }
  122739. interface XRWebGLLayer extends XRLayer {
  122740. framebuffer: WebGLFramebuffer;
  122741. }
  122742. declare var XRWebGLLayer: {
  122743. prototype: XRWebGLLayer;
  122744. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  122745. };